diff --git a/atusb/fw2/atusb.c b/atusb/fw2/atusb.c index 019b8b0..19f8625 100644 --- a/atusb/fw2/atusb.c +++ b/atusb/fw2/atusb.c @@ -14,26 +14,15 @@ int main(void) { - /* We start with a 1 MHz/8 clock. Disable the prescaler. */ - - CLKPR = 1 << CLKPCE; - CLKPR = 0; - - /* set up all the outputs; default port value is 0 */ - - OUT(LED); - OUT(nRST_RF); /* resets the transceiver */ - OUT(SLP_TR); - + board_init(); spi_init(); - reset_rf(); /* now we should be at 8 MHz */ - SET(LED); + led(1); _delay_ms(100); - CLR(LED); + led(0); usb_init(); ep0_init(); diff --git a/atusb/fw2/board.c b/atusb/fw2/board.c index f2496a7..1cbe0d1 100644 --- a/atusb/fw2/board.c +++ b/atusb/fw2/board.c @@ -51,3 +51,27 @@ uint8_t read_irq(void) { return PIN(IRQ_RF); } + + +void led(int on) +{ + if (on) + SET(LED); + else + CLR(LED); +} + + +void board_init(void) +{ + /* We start with a 1 MHz/8 clock. Disable the prescaler. */ + + CLKPR = 1 << CLKPCE; + CLKPR = 0; + + /* set up all the outputs; default port value is 0 */ + + OUT(LED); + OUT(nRST_RF); /* resets the transceiver */ + OUT(SLP_TR); +} diff --git a/atusb/fw2/board.h b/atusb/fw2/board.h index 76bcdfb..eef892e 100644 --- a/atusb/fw2/board.h +++ b/atusb/fw2/board.h @@ -44,5 +44,7 @@ void reset_rf(void); uint8_t read_irq(void); +void led(int on); +void board_init(void); #endif /* !BOARD_H */ diff --git a/atusb/fw2/spi.c b/atusb/fw2/spi.c index 44e08c9..585c360 100644 --- a/atusb/fw2/spi.c +++ b/atusb/fw2/spi.c @@ -30,6 +30,7 @@ void spi_end(void) void spi_init(void) { + SET(nSS); OUT(SCLK); OUT(MOSI); OUT(nSS);