*/
#![no_std]
-#![crate_type="staticlib"]
+#![no_main]
#[link(name="libcommon.rlib")]
extern crate common;
use common::systick;
use common::port;
use common::gpio;
+use common::nvic;
+use common::i2c;
use common::usb_serial;
+use common::display;
extern {
fn enable_interrupts();
}
#[no_mangle]
-pub unsafe extern fn main() {
+pub unsafe extern "C" fn _start() -> ! {
clock::configure();
systick::init();
port::init();
+ // Configure pins for I2C0.
+ port::set_af(port::PORTC, 8, 2);
+ port::set_af(port::PORTC, 9, 2);
+
+ i2c::configure(i2c::I2C0);
+
+ nvic::disable_irq(8); // I2C0
+
+ // Configure pin for the display's reset line.
+ gpio::set_direction(gpio::GPIOB, 1 << 16, gpio::Direction::Output);
+ port::set_af(port::PORTB, 16, 1);
+
// Configure upper right push button.
gpio::set_direction(gpio::GPIOA, 1 << 12, gpio::Direction::Input);
port::set_af(port::PORTA, 12, 1);
cdc_tx_buf.write(b"\n");
cdc_tx_buf.flush();
+ let mut display = display::Display::new(gpio::GPIOB, 1 << 16, 0x3c);
+
+ display.init();
+ display.clear();
+
loop {
systick::delay_ms(1000);
cdc_tx_buf.write(b".\n");
cdc_tx_buf.flush();
+
+ if (gpio::get(gpio::GPIOA) & (1 << 12)) == 0 {
+ nvic::system_reset();
+ }
}
}