Date:2011-02-10 11:19:55 (8 years 7 months ago)
Author:Werner Almesberger
Commit:4f0af39d4d6df2d68d603d6e340340d948df958a
Message:atusb/fw2/: move board-specific items to board-specific file

- io.h: renamed to board.h
- Makefile (OBJS): added board.o
- atusb.c (reset_rf): moved to board.c
- board.h (reset_rf): give reset_rf a proper declaration
- atusb.c, ep.c, spi.c: include board.h instead of io.h
Files: atusb/fw2/Makefile (1 diff)
atusb/fw2/atusb.c (1 diff)
atusb/fw2/board.c (1 diff)
atusb/fw2/board.h (1 diff)
atusb/fw2/ep0.c (2 diffs)
atusb/fw2/io.h (1 diff)
atusb/fw2/spi.c (1 diff)

Change Details

atusb/fw2/Makefile
1616  $(FreakUSB)/usb/usb_buf.o \
1717  $(FreakUSB)/hw/at90usbxx2/ep.o $(FreakUSB)/hw/at90usbxx2/hw.o \
1818  $(FreakUSB)/hw/at90usbxx2/isr.o
19OBJS = atusb.o spi.o descr.o ep0.o $(USB_OBJS)
19OBJS = atusb.o board.o spi.o descr.o ep0.o $(USB_OBJS)
2020
2121CFLAGS += -I../fw/include \
2222      -I$(FreakUSB)/usb -I$(FreakUSB)/hw/at90usbxx2 \
atusb/fw2/atusb.c
88#include "freakusb.h"
99
1010#include "at86rf230.h"
11#include "io.h"
11#include "board.h"
1212#include "spi.h"
1313
1414
15void reset_rf(void);
1615void ep0_init(void);
1716
1817
19void reset_rf(void)
20{
21    /* AT86RF231 data sheet, 12.4.13, reset pulse width: 625 ns (min) */
22
23    CLR(nRST_RF);
24    _delay_us(1);
25    SET(nRST_RF);
26
27    /* 12.4.14: SPI access latency after reset: 625 ns (min) */
28
29    _delay_us(1);
30}
31
32
3318int main(void)
3419{
3520    /* We start with a 1 MHz/8 clock. Disable the prescaler. */
atusb/fw2/board.c
1#include <avr/io.h>
2
3#define F_CPU 8000000UL
4#include <util/delay.h>
5
6#include "board.h"
7
8
9void reset_rf(void)
10{
11    /* AT86RF231 data sheet, 12.4.13, reset pulse width: 625 ns (min) */
12
13    CLR(nRST_RF);
14    _delay_us(1);
15    SET(nRST_RF);
16
17    /* 12.4.14: SPI access latency after reset: 625 ns (min) */
18
19    _delay_us(1);
20}
atusb/fw2/board.h
1#ifndef BOARD_H
2#define BOARD_H
3
4#define LED_PORT B
5#define LED_BIT 6
6#define nRST_RF_PORT C
7#define nRST_RF_BIT 7
8#define SLP_TR_PORT B
9#define SLP_TR_BIT 4
10
11#define SCLK_PORT D
12#define SCLK_BIT 5
13#define MOSI_PORT D
14#define MOSI_BIT 3
15
16#define MISO_PORT D
17#define MISO_BIT 2
18#define nSS_PORT D
19#define nSS_BIT 1
20#define IRQ_RF_PORT D
21#define IRQ_RF_BIT 0
22
23
24#define SET_2(p, b) PORT##p |= 1 << (b)
25#define CLR_2(p, b) PORT##p &= ~(1 << (b))
26#define IN_2(p, b) DDR##p &= ~(1 << (b))
27#define OUT_2(p, b) DDR##p |= 1 << (b)
28
29#define SET_1(p, b) SET_2(p, b)
30#define CLR_1(p, b) CLR_2(p, b)
31#define IN_1(p, b) IN_2(p, b)
32#define OUT_1(p, b) OUT_2(p, b)
33
34#define SET(n) SET_1(n##_PORT, n##_BIT)
35#define CLR(n) CLR_1(n##_PORT, n##_BIT)
36#define IN(n) IN_1(n##_PORT, n##_BIT)
37#define OUT(n) OUT_1(n##_PORT, n##_BIT)
38
39
40void reset_rf(void);
41
42#endif /* !BOARD_H */
atusb/fw2/ep0.c
2727#include "at86rf230.h"
2828#include "atusb/ep0.h"
2929//#include "version.h"
30#include "io.h"
30#include "board.h"
3131#include "spi.h"
3232
3333
...... 
3535static const char *build_date = "today";
3636static unsigned build_number = 42;
3737
38extern void reset_rf(void);
39
40
4138#define debug(...)
4239#define error(...)
4340
atusb/fw2/io.h
1#ifndef IO_H
2#define IO_H
3
4#define LED_PORT B
5#define LED_BIT 6
6#define nRST_RF_PORT C
7#define nRST_RF_BIT 7
8#define SLP_TR_PORT B
9#define SLP_TR_BIT 4
10
11#define SCLK_PORT D
12#define SCLK_BIT 5
13#define MOSI_PORT D
14#define MOSI_BIT 3
15
16#define MISO_PORT D
17#define MISO_BIT 2
18#define nSS_PORT D
19#define nSS_BIT 1
20#define IRQ_RF_PORT D
21#define IRQ_RF_BIT 0
22
23
24#define SET_2(p, b) PORT##p |= 1 << (b)
25#define CLR_2(p, b) PORT##p &= ~(1 << (b))
26#define IN_2(p, b) DDR##p &= ~(1 << (b))
27#define OUT_2(p, b) DDR##p |= 1 << (b)
28
29#define SET_1(p, b) SET_2(p, b)
30#define CLR_1(p, b) CLR_2(p, b)
31#define IN_1(p, b) IN_2(p, b)
32#define OUT_1(p, b) OUT_2(p, b)
33
34#define SET(n) SET_1(n##_PORT, n##_BIT)
35#define CLR(n) CLR_1(n##_PORT, n##_BIT)
36#define IN(n) IN_1(n##_PORT, n##_BIT)
37#define OUT(n) OUT_1(n##_PORT, n##_BIT)
38
39#endif /* !IO_H */
atusb/fw2/spi.c
22
33#include <avr/io.h>
44
5#include "io.h"
5#include "board.h"
66#include "spi.h"
77
88

Archive Download the corresponding diff file



interactive