board.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
21 #ifndef BOARD_H
22 #define BOARD_H
23 
24 #include "cpu.h"
25 #include "periph_conf.h"
26 #include "periph_cpu.h"
27 
28 #include "edbg_eui.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
38 #define XTIMER_DEV TIMER_DEV(1)
39 #define XTIMER_CHAN (0)
40 
46 #define CONFIG_ZTIMER_USEC_TYPE ZTIMER_TYPE_PERIPH_TIMER
47 #define CONFIG_ZTIMER_USEC_DEV TIMER_DEV(1)
48 /* timer_set() may underflow for values smaller than 9, set 10 as margin */
49 #define CONFIG_ZTIMER_USEC_MIN (10)
50 
57 #define AT86RF2XX_PARAM_CS GPIO_PIN(PB, 31)
58 #define AT86RF2XX_PARAM_INT GPIO_PIN(PB, 0)
59 #define AT86RF2XX_PARAM_SLEEP GPIO_PIN(PA, 20)
60 #define AT86RF2XX_PARAM_RESET GPIO_PIN(PB, 15)
61 
65 static inline int _edbg_get_eui64(const void *arg, eui64_t *addr)
66 {
67  (void) arg;
68 
69  /* EDBG can take a while to respond on cold boot */
70  unsigned tries = 10000;
71  while (--tries && edbg_get_eui64(addr)) {}
72  return tries ? 0 : -1;
73 }
74 
80 #define EUI64_PROVIDER_FUNC _edbg_get_eui64
81 #define EUI64_PROVIDER_TYPE NETDEV_AT86RF2XX
82 #define EUI64_PROVIDER_INDEX 0
83 
90 #define LED0_PIN GPIO_PIN(0, 19)
91 
92 #define LED_PORT PORT->Group[0]
93 #define LED0_MASK (1 << 19)
94 
95 #define LED0_ON (LED_PORT.OUTCLR.reg = LED0_MASK)
96 #define LED0_OFF (LED_PORT.OUTSET.reg = LED0_MASK)
97 #define LED0_TOGGLE (LED_PORT.OUTTGL.reg = LED0_MASK)
98 
104 #define BTN0_PORT PORT->Group[0]
105 #define BTN0_PIN GPIO_PIN(0, 28)
106 #define BTN0_MODE GPIO_IN_PU
107 
113 #define RFCTL1_PIN GPIO_PIN(0, 9)
114 #define RFCTL2_PIN GPIO_PIN(0, 12)
115 
120 enum {
121  RFCTL_ANTENNA_BOARD,
122  RFCTL_ANTENNA_EXT,
123 };
124 
129 #ifndef RFCTL_ANTENNA_DEFAULT
130 #define RFCTL_ANTENNA_DEFAULT RFCTL_ANTENNA_BOARD
131 #endif
132 
137 void board_init(void);
138 
142 void board_antenna_config(uint8_t antenna);
143 #ifdef __cplusplus
144 }
145 #endif
146 
147 #endif /* BOARD_H */
148 
_edbg_get_eui64
static int _edbg_get_eui64(const void *arg, eui64_t *addr)
EDBG provides a EUI-64, the same that is printed on the board.
Definition: board.h:65
edbg_get_eui64
int edbg_get_eui64(eui64_t *addr)
Get the unique EUI64 address from a Atmel EDBG debugger.
board_antenna_config
void board_antenna_config(uint8_t antenna)
Set antenna switch.
eui64_t
Data type to represent an EUI-64.
Definition: eui64.h:55
periph_conf.h
Configuration of CPU peripherals for the Atmel SAM R21 Xplained Pro board.
edbg_eui.h
board_init
void board_init(void)
Board level initialization.