1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-25 23:31:54 +02:00

atusb/fw2: further abstract board functions

- atusb.c (main), board.h (board_init), board.c (board_init): moved
  clock and I/O initialization to board file
- board.h (led), board.c (led), atusb.c (main): abstracted LED setting
  in function "led" instead of open-coding it
- spi.c (spi_init): set nSS to 1 before enabling the output, so that we
  don't generate what looks like an empty SPI transaction
This commit is contained in:
Werner Almesberger 2011-02-10 20:49:23 -03:00
parent 509542af73
commit f8fbb02bb0
4 changed files with 30 additions and 14 deletions

View File

@ -14,26 +14,15 @@
int main(void) int main(void)
{ {
/* We start with a 1 MHz/8 clock. Disable the prescaler. */ board_init();
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);
spi_init(); spi_init();
reset_rf(); reset_rf();
/* now we should be at 8 MHz */ /* now we should be at 8 MHz */
SET(LED); led(1);
_delay_ms(100); _delay_ms(100);
CLR(LED); led(0);
usb_init(); usb_init();
ep0_init(); ep0_init();

View File

@ -51,3 +51,27 @@ uint8_t read_irq(void)
{ {
return PIN(IRQ_RF); 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);
}

View File

@ -44,5 +44,7 @@
void reset_rf(void); void reset_rf(void);
uint8_t read_irq(void); uint8_t read_irq(void);
void led(int on);
void board_init(void);
#endif /* !BOARD_H */ #endif /* !BOARD_H */

View File

@ -30,6 +30,7 @@ void spi_end(void)
void spi_init(void) void spi_init(void)
{ {
SET(nSS);
OUT(SCLK); OUT(SCLK);
OUT(MOSI); OUT(MOSI);
OUT(nSS); OUT(nSS);