Skip to content

Commit 5689a7d

Browse files
Merge pull request #1997 from Troels51/samr21-transceiver-port
samr21: implemention of transceiver via spi
2 parents 2ec5f9d + 33ef43c commit 5689a7d

File tree

9 files changed

+596
-118
lines changed

9 files changed

+596
-118
lines changed

boards/samr21-xpro/Makefile.dep

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ifneq (,$(filter defaulttransceiver,$(USEMODULE)))
2+
USEMODULE += at86rf231
3+
ifeq (,$(filter netdev_base,$(USEMODULE)))
4+
USEMODULE += transceiver
5+
endif
6+
endif

boards/samr21-xpro/Makefile.features

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
FEATURES_PROVIDED += periph_gpio cpp periph_uart periph_timer periph_i2c
1+
FEATURES_PROVIDED += transceiver periph_gpio periph_spi cpp periph_timer periph_uart periph_i2c cpp

boards/samr21-xpro/Makefile.include

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,5 @@ export LINKFLAGS += -specs=nano.specs -lc -lnosys
4141
endif
4242

4343
# export board specific includes to the global includes-listing
44-
export INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include
44+
export INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include/
45+
include $(RIOTBOARD)/$(BOARD)/Makefile.dep

boards/samr21-xpro/include/board.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ extern "C" {
3737
*/
3838
#define HW_TIMER TIMER_0
3939

40+
/**
41+
* @name AT86RF231 config
42+
* @{
43+
*/
44+
#define AT86RF231_SPI SPI_0
45+
#define AT86RF231_CS GPIO_4
46+
#define AT86RF231_INT GPIO_5
47+
#define AT86RF231_RESET GPIO_6
48+
#define AT86RF231_SLEEP GPIO_7
49+
50+
#define AT86RF231_SPI_SPEED SPI_SPEED_1MHZ
51+
/** @}*/
4052
/**
4153
* @name Define UART device and baudrate for stdio
4254
* @{
@@ -51,7 +63,7 @@ extern "C" {
5163
* @{
5264
*/
5365
#define LED_PORT PORT->Group[0]
54-
#define LED_PIN PORT_PA19
66+
#define LED_PIN (19)
5567
/** @} */
5668

5769
/**
@@ -74,6 +86,11 @@ extern "C" {
7486
#define LED_RED_TOGGLE LED_TOGGLE
7587
/** @} */
7688

89+
/**
90+
* @brief Define the type for the radio packet length for the transceiver
91+
*/
92+
typedef uint8_t radio_packet_length_t;
93+
7794
/**
7895
* @brief Initialize board specific hardware, including clock, LEDs and std-IO
7996
*/

boards/samr21-xpro/include/periph_conf.h

Lines changed: 123 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ extern "C" {
6969
#define UART_0_ISR isr_sercom0
7070
/* UART 0 pin configuration */
7171
#define UART_0_PORT (PORT->Group[0])
72-
#define UART_0_TX_PIN PIN_PA04
73-
#define UART_0_RX_PIN PIN_PA05
72+
#define UART_0_TX_PIN (4)
73+
#define UART_0_RX_PIN (5)
7474
#define UART_0_PINS (PORT_PA04 | PORT_PA05)
7575
#define UART_0_REF_F (8000000UL)
7676

@@ -84,6 +84,48 @@ extern "C" {
8484
#define UART_1_PINS
8585
/** @} */
8686

87+
88+
/**
89+
* @name SPI configuration
90+
* @{
91+
*/
92+
#define SPI_NUMOF (2)
93+
#define SPI_0_EN 1
94+
#define SPI_1_EN 1
95+
96+
/* SPI0 */
97+
#define SPI_0_DEV SERCOM4->SPI
98+
#define SPI_IRQ_0 SERCOM4_IRQn
99+
#define SPI_0_DOPO (1)
100+
#define SPI_0_DIPO (0)
101+
#define SPI_0_F_REF (8000000UL)
102+
103+
#define SPI_0_SCLK_DEV PORT->Group[2]
104+
#define SPI_0_SCLK_PIN (18)
105+
106+
#define SPI_0_MISO_DEV PORT->Group[2]
107+
#define SPI_0_MISO_PIN (19)
108+
109+
#define SPI_0_MOSI_DEV PORT->Group[1]
110+
#define SPI_0_MOSI_PIN (30)
111+
112+
/* SPI1 */
113+
#define SPI_1_DEV SERCOM5->SPI
114+
#define SPI_IRQ_1 SERCOM5_IRQn
115+
#define SPI_1_DOPO (1)
116+
#define SPI_1_DIPO (2)
117+
#define SPI_1_F_REF (8000000UL)
118+
119+
#define SPI_1_SCLK_DEV PORT->Group[1]
120+
#define SPI_1_SCLK_PIN (23)
121+
122+
#define SPI_1_MISO_DEV PORT->Group[1]
123+
#define SPI_1_MISO_PIN (02)
124+
125+
#define SPI_1_MOSI_DEV PORT->Group[1]
126+
#define SPI_1_MOSI_PIN (22)
127+
/** @} */
128+
87129
/**
88130
* @name I2C configuration
89131
* @{
@@ -110,36 +152,96 @@ extern "C" {
110152
* @name Random Number Generator configuration
111153
* @{
112154
*/
113-
#define RANDOM_NUMOF (0U)
155+
#define RANDOM_NUMOF (0U)
114156
/** @} */
115157

116158
/**
117159
* @name GPIO configuration
118160
* @{
119161
*/
120-
#define GPIO_NUMOF (4U)
121-
#define GPIO_0_EN 1
122-
#define GPIO_1_EN 1
123-
#define GPIO_2_EN 1
124-
#define GPIO_3_EN 1
162+
#define GPIO_NUMOF (9U)
163+
#define GPIO_0_EN 1
164+
#define GPIO_1_EN 1
165+
#define GPIO_2_EN 1
166+
#define GPIO_3_EN 1
167+
/*4-7 -> internal */
168+
#define GPIO_4_EN 1
169+
#define GPIO_5_EN 1
170+
#define GPIO_6_EN 1
171+
#define GPIO_7_EN 1
172+
#define GPIO_8_EN 1
173+
#define GPIO_9_EN 0
174+
#define GPIO_10_EN 0
175+
#define GPIO_11_EN 0
176+
177+
#define GPIO_12_EN 0
178+
#define GPIO_13_EN 0
179+
#define GPIO_14_EN 0
180+
#define GPIO_15_EN 0
181+
182+
#define GPIO_NO_EXTINT (18)
125183

126184
/* GPIO channel 0 config */
127-
#define GPIO_0_DEV PORT->Group[0]
128-
#define GPIO_0_PIN PIN_PA13
129-
#define GPIO_0_EXTINT 13
185+
#define GPIO_0_DEV PORT->Group[0]
186+
#define GPIO_0_PIN (13)
187+
#define GPIO_0_EXTINT (13)
130188
/* GPIO channel 1 config */
131-
/* SW0 Button, configure w/ GPIO_PULLUP and GPIO_FALLING */
132-
#define GPIO_1_DEV PORT->Group[0]
133-
#define GPIO_1_PIN PIN_PA28
134-
#define GPIO_1_EXTINT 8
189+
#define GPIO_1_DEV PORT->Group[0]
190+
#define GPIO_1_PIN (28)
191+
#define GPIO_1_EXTINT (8)
135192
/* GPIO channel 2 config */
136-
#define GPIO_2_DEV PORT->Group[0]
137-
#define GPIO_2_PIN PIN_PA15
138-
#define GPIO_2_EXTINT 15
193+
#define GPIO_2_DEV PORT->Group[0]
194+
#define GPIO_2_PIN (15)
195+
#define GPIO_2_EXTINT (15)
139196
/* GPIO channel 3 config */
140-
#define GPIO_3_DEV PORT->Group[0]
141-
#define GPIO_3_PIN PIN_PA19
142-
#define GPIO_3_EXTINT 3
197+
#define GPIO_3_DEV PORT->Group[0]
198+
#define GPIO_3_PIN (19)
199+
#define GPIO_3_EXTINT (3)
200+
/* GPIO 4-7 Internal radio pins*/
201+
/* GPIO channel 4 config radio CS*/
202+
#define GPIO_4_DEV PORT->Group[1]
203+
#define GPIO_4_PIN (31)
204+
#define GPIO_4_EXTINT GPIO_NO_EXTINT
205+
/* GPIO channel 5 config radio IRQ0*/
206+
#define GPIO_5_DEV PORT->Group[1]
207+
#define GPIO_5_PIN (0)
208+
#define GPIO_5_EXTINT (0)
209+
/* GPIO channel 6 config radio reset*/
210+
#define GPIO_6_DEV PORT->Group[1]
211+
#define GPIO_6_PIN (15)
212+
#define GPIO_6_EXTINT GPIO_NO_EXTINT
213+
/* GPIO channel 7 config radio sleep*/
214+
#define GPIO_7_DEV PORT->Group[0]
215+
#define GPIO_7_PIN (20)
216+
#define GPIO_7_EXTINT GPIO_NO_EXTINT
217+
/* GPIO channel 8 config */
218+
#define GPIO_8_DEV PORT->Group[0]
219+
#define GPIO_8_PIN (27)
220+
#define GPIO_8_EXTINT GPIO_NO_EXTINT
221+
/* GPIO channel 9 config */
222+
#define GPIO_9_DEV
223+
#define GPIO_9_PIN
224+
#define GPIO_9_EXTINT
225+
/* GPIO channel 10 config */
226+
#define GPIO_10_DEV
227+
#define GPIO_10_PIN
228+
#define GPIO_10_EXTINT
229+
/* GPIO channel 11 config */
230+
#define GPIO_11_DEV
231+
#define GPIO_11_PIN
232+
#define GPIO_11_EXTINT
233+
/* GPIO channel 12 config */
234+
#define GPIO_12_PIN
235+
#define GPIO_12_EXTINT
236+
/* GPIO channel 13 config */
237+
#define GPIO_13_PIN
238+
#define GPIO_13_EXTINT
239+
/* GPIO channel 14 config */
240+
#define GPIO_14_PIN
241+
#define GPIO_14_EXTINT
242+
/* GPIO channel 15 config */
243+
#define GPIO_15_PIN
244+
#define GPIO_15_EXTINT
143245
/** @} */
144246

145247
#ifdef __cplusplus

cpu/samd21/include/cpu-conf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ extern "C" {
5050
#endif
5151
/** @} */
5252

53+
#define TRANSCEIVER_BUFFER_SIZE (3)
5354
#ifdef __cplusplus
5455
}
5556
#endif

0 commit comments

Comments
 (0)