Skip to content

samr21: implemention of transceiver via spi #1997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions boards/samr21-xpro/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ifneq (,$(filter defaulttransceiver,$(USEMODULE)))
USEMODULE += at86rf231
ifeq (,$(filter netdev_base,$(USEMODULE)))
USEMODULE += transceiver
endif
endif
2 changes: 1 addition & 1 deletion boards/samr21-xpro/Makefile.features
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FEATURES_PROVIDED += periph_gpio cpp periph_uart periph_timer periph_i2c
FEATURES_PROVIDED += transceiver periph_gpio periph_spi cpp periph_timer periph_uart periph_i2c cpp
3 changes: 2 additions & 1 deletion boards/samr21-xpro/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ export LINKFLAGS += -specs=nano.specs -lc -lnosys
endif

# export board specific includes to the global includes-listing
export INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include
export INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include/
include $(RIOTBOARD)/$(BOARD)/Makefile.dep
19 changes: 18 additions & 1 deletion boards/samr21-xpro/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ extern "C" {
*/
#define HW_TIMER TIMER_0

/**
* @name AT86RF231 config
* @{
*/
#define AT86RF231_SPI SPI_0
#define AT86RF231_CS GPIO_4
#define AT86RF231_INT GPIO_5
#define AT86RF231_RESET GPIO_6
#define AT86RF231_SLEEP GPIO_7

#define AT86RF231_SPI_SPEED SPI_SPEED_1MHZ
/** @}*/
/**
* @name Define UART device and baudrate for stdio
* @{
Expand All @@ -51,7 +63,7 @@ extern "C" {
* @{
*/
#define LED_PORT PORT->Group[0]
#define LED_PIN PORT_PA19
#define LED_PIN (19)
/** @} */

/**
Expand All @@ -74,6 +86,11 @@ extern "C" {
#define LED_RED_TOGGLE LED_TOGGLE
/** @} */

/**
* @brief Define the type for the radio packet length for the transceiver
*/
typedef uint8_t radio_packet_length_t;

/**
* @brief Initialize board specific hardware, including clock, LEDs and std-IO
*/
Expand Down
144 changes: 123 additions & 21 deletions boards/samr21-xpro/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ extern "C" {
#define UART_0_ISR isr_sercom0
/* UART 0 pin configuration */
#define UART_0_PORT (PORT->Group[0])
#define UART_0_TX_PIN PIN_PA04
#define UART_0_RX_PIN PIN_PA05
#define UART_0_TX_PIN (4)
#define UART_0_RX_PIN (5)
#define UART_0_PINS (PORT_PA04 | PORT_PA05)
#define UART_0_REF_F (8000000UL)

Expand All @@ -84,6 +84,48 @@ extern "C" {
#define UART_1_PINS
/** @} */


/**
* @name SPI configuration
* @{
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put the SPI defines in a block using * @{ and /** @} */

#define SPI_NUMOF (2)
#define SPI_0_EN 1
#define SPI_1_EN 1

/* SPI0 */
#define SPI_0_DEV SERCOM4->SPI
#define SPI_IRQ_0 SERCOM4_IRQn
#define SPI_0_DOPO (1)
#define SPI_0_DIPO (0)
#define SPI_0_F_REF (8000000UL)

#define SPI_0_SCLK_DEV PORT->Group[2]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls put parentheses around the right part (and for all following occurrences)

#define SPI_0_SCLK_PIN (18)

#define SPI_0_MISO_DEV PORT->Group[2]
#define SPI_0_MISO_PIN (19)

#define SPI_0_MOSI_DEV PORT->Group[1]
#define SPI_0_MOSI_PIN (30)

/* SPI1 */
#define SPI_1_DEV SERCOM5->SPI
#define SPI_IRQ_1 SERCOM5_IRQn
#define SPI_1_DOPO (1)
#define SPI_1_DIPO (2)
#define SPI_1_F_REF (8000000UL)

#define SPI_1_SCLK_DEV PORT->Group[1]
#define SPI_1_SCLK_PIN (23)

#define SPI_1_MISO_DEV PORT->Group[1]
#define SPI_1_MISO_PIN (02)

#define SPI_1_MOSI_DEV PORT->Group[1]
#define SPI_1_MOSI_PIN (22)
/** @} */

/**
* @name I2C configuration
* @{
Expand All @@ -110,36 +152,96 @@ extern "C" {
* @name Random Number Generator configuration
* @{
*/
#define RANDOM_NUMOF (0U)
#define RANDOM_NUMOF (0U)
/** @} */

/**
* @name GPIO configuration
* @{
*/
#define GPIO_NUMOF (4U)
#define GPIO_0_EN 1
#define GPIO_1_EN 1
#define GPIO_2_EN 1
#define GPIO_3_EN 1
#define GPIO_NUMOF (9U)
#define GPIO_0_EN 1
#define GPIO_1_EN 1
#define GPIO_2_EN 1
#define GPIO_3_EN 1
/*4-7 -> internal */
#define GPIO_4_EN 1
#define GPIO_5_EN 1
#define GPIO_6_EN 1
#define GPIO_7_EN 1
#define GPIO_8_EN 1
#define GPIO_9_EN 0
#define GPIO_10_EN 0
#define GPIO_11_EN 0

#define GPIO_12_EN 0
#define GPIO_13_EN 0
#define GPIO_14_EN 0
#define GPIO_15_EN 0

#define GPIO_NO_EXTINT (18)

/* GPIO channel 0 config */
#define GPIO_0_DEV PORT->Group[0]
#define GPIO_0_PIN PIN_PA13
#define GPIO_0_EXTINT 13
#define GPIO_0_DEV PORT->Group[0]
#define GPIO_0_PIN (13)
#define GPIO_0_EXTINT (13)
/* GPIO channel 1 config */
/* SW0 Button, configure w/ GPIO_PULLUP and GPIO_FALLING */
#define GPIO_1_DEV PORT->Group[0]
#define GPIO_1_PIN PIN_PA28
#define GPIO_1_EXTINT 8
#define GPIO_1_DEV PORT->Group[0]
#define GPIO_1_PIN (28)
#define GPIO_1_EXTINT (8)
/* GPIO channel 2 config */
#define GPIO_2_DEV PORT->Group[0]
#define GPIO_2_PIN PIN_PA15
#define GPIO_2_EXTINT 15
#define GPIO_2_DEV PORT->Group[0]
#define GPIO_2_PIN (15)
#define GPIO_2_EXTINT (15)
/* GPIO channel 3 config */
#define GPIO_3_DEV PORT->Group[0]
#define GPIO_3_PIN PIN_PA19
#define GPIO_3_EXTINT 3
#define GPIO_3_DEV PORT->Group[0]
#define GPIO_3_PIN (19)
#define GPIO_3_EXTINT (3)
/* GPIO 4-7 Internal radio pins*/
/* GPIO channel 4 config radio CS*/
#define GPIO_4_DEV PORT->Group[1]
#define GPIO_4_PIN (31)
#define GPIO_4_EXTINT GPIO_NO_EXTINT
/* GPIO channel 5 config radio IRQ0*/
#define GPIO_5_DEV PORT->Group[1]
#define GPIO_5_PIN (0)
#define GPIO_5_EXTINT (0)
/* GPIO channel 6 config radio reset*/
#define GPIO_6_DEV PORT->Group[1]
#define GPIO_6_PIN (15)
#define GPIO_6_EXTINT GPIO_NO_EXTINT
/* GPIO channel 7 config radio sleep*/
#define GPIO_7_DEV PORT->Group[0]
#define GPIO_7_PIN (20)
#define GPIO_7_EXTINT GPIO_NO_EXTINT
/* GPIO channel 8 config */
#define GPIO_8_DEV PORT->Group[0]
#define GPIO_8_PIN (27)
#define GPIO_8_EXTINT GPIO_NO_EXTINT
/* GPIO channel 9 config */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it should be possible to use the GPIOs > 3 just as GPIOs and independent from SPI, it could be clearer to define them like the others and don't refert to the SPI values.

#define GPIO_9_DEV
#define GPIO_9_PIN
#define GPIO_9_EXTINT
/* GPIO channel 10 config */
#define GPIO_10_DEV
#define GPIO_10_PIN
#define GPIO_10_EXTINT
/* GPIO channel 11 config */
#define GPIO_11_DEV
#define GPIO_11_PIN
#define GPIO_11_EXTINT
/* GPIO channel 12 config */
#define GPIO_12_PIN
#define GPIO_12_EXTINT
/* GPIO channel 13 config */
#define GPIO_13_PIN
#define GPIO_13_EXTINT
/* GPIO channel 14 config */
#define GPIO_14_PIN
#define GPIO_14_EXTINT
/* GPIO channel 15 config */
#define GPIO_15_PIN
#define GPIO_15_EXTINT
/** @} */

#ifdef __cplusplus
Expand Down
1 change: 1 addition & 0 deletions cpu/samd21/include/cpu-conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ extern "C" {
#endif
/** @} */

#define TRANSCEIVER_BUFFER_SIZE (3)
#ifdef __cplusplus
}
#endif
Expand Down
Loading