Date:2011-02-11 00:49:23 (8 years 7 months ago)
Author:Werner Almesberger
Commit:f8fbb02bb026e41f3655b9d9e204db9a66d53c9d
Message: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
Files: atusb/fw2/atusb.c (1 diff)
atusb/fw2/board.c (1 diff)
atusb/fw2/board.h (1 diff)
atusb/fw2/spi.c (1 diff)

Change Details

atusb/fw2/atusb.c
1414
1515int main(void)
1616{
17    /* We start with a 1 MHz/8 clock. Disable the prescaler. */
18
19    CLKPR = 1 << CLKPCE;
20    CLKPR = 0;
21
22    /* set up all the outputs; default port value is 0 */
23
24    OUT(LED);
25    OUT(nRST_RF); /* resets the transceiver */
26    OUT(SLP_TR);
27
17    board_init();
2818    spi_init();
29
3019    reset_rf();
3120
3221    /* now we should be at 8 MHz */
3322
34    SET(LED);
23    led(1);
3524    _delay_ms(100);
36    CLR(LED);
25    led(0);
3726
3827    usb_init();
3928    ep0_init();
atusb/fw2/board.c
5151{
5252    return PIN(IRQ_RF);
5353}
54
55
56void led(int on)
57{
58    if (on)
59        SET(LED);
60    else
61        CLR(LED);
62}
63
64
65void board_init(void)
66{
67    /* We start with a 1 MHz/8 clock. Disable the prescaler. */
68
69    CLKPR = 1 << CLKPCE;
70    CLKPR = 0;
71
72    /* set up all the outputs; default port value is 0 */
73
74    OUT(LED);
75    OUT(nRST_RF); /* resets the transceiver */
76    OUT(SLP_TR);
77}
atusb/fw2/board.h
4444
4545void reset_rf(void);
4646uint8_t read_irq(void);
47void led(int on);
48void board_init(void);
4749
4850#endif /* !BOARD_H */
atusb/fw2/spi.c
3030
3131void spi_init(void)
3232{
33    SET(nSS);
3334    OUT(SCLK);
3435    OUT(MOSI);
3536    OUT(nSS);

Archive Download the corresponding diff file



interactive