PicoWAN SDK Documentation
boards.h
Go to the documentation of this file.
1 
31 #ifndef _BOARDS_H_
32 #define _BOARDS_H_
33 
34 #include <gpio.h>
35 
36 #ifdef CFG_discovery_stm32l1_board
37 /* ***********************************************************************************
38  *
39  * STM32L152 Discovery Kit (32L152CDISCOVERY) + SX1276RF1JAS board from Semtech
40  *
41  *************************************************************************************/
42 
43 // RF characteristics
44 #define MAX_RF_POWER 20 // dBm
45 #define MIN_RF_POWER 2 // dBm
46 #define ANTENNA_GAIN -6 // dBi
47 #define LNA_GAIN 0 // dB
48 
49 // GPIOs
50 #define NSS_PORT GPIO_PORT_A // NSS: PA4, sx1276
51 #define NSS_PIN 4
52 
53 #define TX_PA_PORT GPIO_PORT_C // TX_PA: PC6
54 #define TX_PA_PIN 6
55 
56 #define RST_PORT GPIO_PORT_A // RST: PA11
57 #define RST_PIN 11
58 
59 #define DIO0_PORT GPIO_PORT_C // DIO0: PC1, sx1276 (line 1 irq handler)
60 #define DIO0_PIN 1
61 #define DIO0_TYPE GPIO_PUPD_NONE
62 #define DIO1_PORT GPIO_PORT_C // DIO1: PC2, sx1276 (line 2 irq handler)
63 #define DIO1_PIN 2
64 #define DIO1_TYPE GPIO_PUPD_NONE
65 #define DIO2_PORT GPIO_PORT_C // DIO2: PC3, sx1276 (line 3 irq handler)
66 #define DIO2_PIN 3
67 #define DIO2_TYPE GPIO_PUPD_NONE
68 
69 #define LED0_PORT GPIO_PORT_B // Blue LED: PB6
70 #define LED0_PIN 6
71 #define LED0_MODE LED_ACTIVE_HIGH
72 #define LED1_PORT GPIO_PORT_B // Green LED: PB7
73 #define LED1_PIN 7
74 #define LED1_MODE LED_ACTIVE_HIGH
75 
76 #define BUTTON0_PORT GPIO_PORT_A // PA0
77 #define BUTTON0_PIN 0
78 #define BUTTON0_TYPE GPIO_PUPD_NONE
79 #define BUTTON0_MODE BUTTON_ACTIVE_HIGH
80 
81 #define OUTPUT_PINS {{NSS_PORT, NSS_PIN}, {TX_PA_PORT, TX_PA_PIN}, {LED0_PORT, LED0_PIN}, {LED1_PORT, LED1_PIN}}
82 #define INPUT_PINS {{DIO0_PORT, DIO0_PIN, DIO0_TYPE}, {DIO1_PORT, DIO1_PIN, DIO1_TYPE}, {DIO2_PORT, DIO2_PIN, DIO2_TYPE}, {BUTTON0_PORT, BUTTON0_PIN, BUTTON0_TYPE}}
83 
84 // SPI
85 #define SCK_PORT GPIO_PORT_A // SCK: PA5
86 #define SCK_PIN 5
87 #define MISO_PORT GPIO_PORT_A // MISO: PA6
88 #define MISO_PIN 6
89 #define MOSI_PORT GPIO_PORT_A // MOSI: PA7
90 #define MOSI_PIN 7
91 
92 #define GPIO_AF_SPI1 0x05
93 
94 // Console USART
95 #define CONSOLE_USART USART_PORT_1
96 
97 #define CONSOLE_USART_TX_PORT GPIO_PORT_A
98 #define CONSOLE_USART_TX_PIN 9
99 #define CONSOLE_USART_RX_PORT GPIO_PORT_A
100 #define CONSOLE_USART_RX_PIN 10
101 
102 #define CONSOLE_USART_AF 0x07
103 
104 #define LOWPOWER_PINS {{NSS_PORT, NSS_PIN}, {TX_PA_PORT, TX_PA_PIN}, {RST_PORT, RST_PIN}, \
105  {DIO0_PORT, DIO0_PIN}, {DIO1_PORT, DIO1_PIN}, {DIO2_PORT, DIO2_PIN}, \
106  {LED0_PORT, LED0_PIN}, {LED1_PORT, LED1_PIN}, {BUTTON0_PORT, BUTTON0_PIN}, \
107  {SCK_PORT, SCK_PIN}, {MISO_PORT, MISO_PIN}, {MOSI_PORT, MOSI_PIN}}
108 #elif CFG_picotag_board
109 /* ***********************************************************************************
110  *
111  * Archos PicoSmartTAG
112  *
113  *************************************************************************************/
114 
115 #define HAS_TCXO
116 #define HAS_LIS2DE12_ACCELEROMETER
117 
118 // RF characteristics
119 #define MAX_RF_POWER 20 // dBm
120 #define MIN_RF_POWER 0 // dBm
121 #define ANTENNA_GAIN -6 // dBi
122 // QORVO LNA with nominal gain of 14dB
123 #define LNA_GAIN 14 // dB
124 
125 // GPIOs
126 #define NSS_PORT GPIO_PORT_B // NSS: PB0, sx1276
127 #define NSS_PIN 0
128 
129 #define RX_PORT GPIO_PORT_B // RX: PB6
130 #define RX_PIN 6
131 #define TX_RFO_PORT GPIO_PORT_B // TX_RFO: PB7
132 #define TX_RFO_PIN 7
133 #define TX_PA_PORT GPIO_PORT_A // TX_PA: PA4
134 #define TX_PA_PIN 4
135 #define TCXO_PORT GPIO_PORT_H // PH1
136 #define TCXO_PIN 1
137 
138 #define RST_PORT GPIO_PORT_B // RST: PB13
139 #define RST_PIN 13
140 
141 #define DIO0_PORT GPIO_PORT_A // DIO0: PA11, sx1276 (line 1 irq handler)
142 #define DIO0_PIN 11
143 #define DIO0_TYPE GPIO_PUPD_NONE
144 #define DIO1_PORT GPIO_PORT_B // DIO1: PB1, sx1276 (line 2 irq handler)
145 #define DIO1_PIN 1
146 #define DIO1_TYPE GPIO_PUPD_NONE
147 #define DIO2_PORT GPIO_PORT_A // DIO2: PA3, sx1276 (line 3 irq handler)
148 #define DIO2_PIN 3
149 #define DIO2_TYPE GPIO_PUPD_NONE
150 #define DIO3_PORT GPIO_PORT_H // DIO3: PH0, sx1276 (line 4 irq handler)
151 #define DIO3_PIN 0
152 #define DIO3_TYPE GPIO_PUPD_NONE
153 #define DIO4_PORT GPIO_PORT_C // DIO4: PC13, sx1276 (line 5 irq handler)
154 #define DIO4_PIN 13
155 #define DIO4_TYPE GPIO_PUPD_NONE
156 
157 #define LED0_PORT GPIO_PORT_B // Red LED: PB3
158 #define LED0_PIN 3
159 #define LED0_MODE LED_ACTIVE_HIGH
160 #define LED1_PORT GPIO_PORT_A // Blue LED: PA8
161 #define LED1_PIN 8
162 #define LED1_MODE LED_ACTIVE_HIGH
163 
164 #define BUTTON0_PORT GPIO_PORT_B // PB5
165 #define BUTTON0_PIN 5
166 #define BUTTON0_MODE BUTTON_ACTIVE_LOW
167 #define BUTTON0_TYPE GPIO_PUPD_UP
168 #define BUTTON1_PORT GPIO_PORT_B // PB4
169 #define BUTTON1_PIN 4
170 #define BUTTON1_MODE BUTTON_ACTIVE_LOW
171 #define BUTTON1_TYPE GPIO_PUPD_UP
172 
173 #define WIFI_GPIO0_PORT GPIO_PORT_A // PA0
174 #define WIFI_GPIO0_PIN 0
175 #define WIFI_GPIO0_TYPE GPIO_PUPD_NONE
176 #define WIFI_ENABLE_PORT GPIO_PORT_A // PA12
177 #define WIFI_ENABLE_PIN 12
178 
179 #define ACC1_PORT GPIO_PORT_B // PB14
180 #define ACC1_PIN 14
181 #define ACC1_TYPE GPIO_PUPD_NONE
182 #define ACC2_PORT GPIO_PORT_B // PB15
183 #define ACC2_PIN 15
184 #define ACC2_TYPE GPIO_PUPD_NONE
185 
186 #define BATT_ANA_PORT GPIO_PORT_A // PA2
187 #define BATT_ANA_PIN 2
188 #define BATT_ANA_CHAN ADC_Channel_2
189 #define BATT_MEAS_PORT GPIO_PORT_A // PA15
190 #define BATT_MEAS_PIN 15
191 #define BATT_CHRG_PORT GPIO_PORT_B // PB12
192 #define BATT_CHRG_PIN 12
193 #define BATT_CHRG_TYPE GPIO_PUPD_UP
194 #define BATT_SYNC_PORT GPIO_PORT_A // PA1
195 #define BATT_SYNC_PIN 1
196 
197 #define OUTPUT_PINS {{NSS_PORT, NSS_PIN}, {RX_PORT, RX_PIN}, {TX_RFO_PORT, TX_RFO_PIN}, \
198  {TX_PA_PORT, TX_PA_PIN}, {LED0_PORT, LED0_PIN}, {LED1_PORT, LED1_PIN}, \
199  {WIFI_ENABLE_PORT, WIFI_ENABLE_PIN}, \
200  {BATT_MEAS_PORT, BATT_MEAS_PIN}, {BATT_SYNC_PORT, BATT_SYNC_PIN}, \
201  {TCXO_PORT, TCXO_PIN}}
202 #define INPUT_PINS {{DIO0_PORT, DIO0_PIN, DIO0_TYPE}, {DIO1_PORT, DIO1_PIN, DIO1_TYPE}, {DIO2_PORT, DIO2_PIN, DIO2_TYPE}, \
203  {DIO3_PORT, DIO3_PIN, DIO3_TYPE}, {DIO4_PORT, DIO4_PIN, DIO4_TYPE}, \
204  {BUTTON0_PORT, BUTTON0_PIN, BUTTON0_TYPE}, {BUTTON1_PORT, BUTTON1_PIN, BUTTON1_TYPE}, \
205  {ACC1_PORT, ACC1_PIN, ACC1_TYPE}, {ACC2_PORT, ACC2_PIN, ACC2_TYPE}, \
206  {BATT_CHRG_PORT, BATT_CHRG_PIN, BATT_CHRG_TYPE}}
207 
208 // SPI
209 #define SCK_PORT GPIO_PORT_A // SCK: PA5
210 #define SCK_PIN 5
211 #define MISO_PORT GPIO_PORT_A // MISO: PA6
212 #define MISO_PIN 6
213 #define MOSI_PORT GPIO_PORT_A // MOSI: PA7
214 #define MOSI_PIN 7
215 
216 #define GPIO_AF_SPI1 0x05
217 
218 // I2C
219 #define SCL_PORT GPIO_PORT_B // SCL: PB8
220 #define SCL_PIN 8
221 #define SDA_PORT GPIO_PORT_B // SDA: PB9
222 #define SDA_PIN 9
223 
224 #define GPIO_AF_I2C1 0x04
225 
226 #define ACC_I2C_PORT I2C_PORT_1
227 
228 // Console USART
229 #define CONSOLE_USART USART_PORT_1
230 
231 #define CONSOLE_USART_TX_PORT GPIO_PORT_A
232 #define CONSOLE_USART_TX_PIN 9
233 #define CONSOLE_USART_RX_PORT GPIO_PORT_A
234 #define CONSOLE_USART_RX_PIN 10
235 
236 #define CONSOLE_USART_AF 0x07
237 
238 // Wifi USART
239 #define WIFI_USART USART_PORT_3
240 
241 #define WIFI_USART_TX_PORT GPIO_PORT_B
242 #define WIFI_USART_TX_PIN 10
243 #define WIFI_USART_RX_PORT GPIO_PORT_B
244 #define WIFI_USART_RX_PIN 11
245 
246 #define WIFI_USART_AF 0x07
247 
248 #define LOWPOWER_PINS {{NSS_PORT, NSS_PIN}, {TX_RFO_PORT, TX_RFO_PIN}, {RX_PORT, RX_PIN}, \
249  {TX_PA_PORT, TX_PA_PIN}, {RST_PORT, RST_PIN}, \
250  {DIO0_PORT, DIO0_PIN}, {DIO1_PORT, DIO1_PIN}, {DIO2_PORT, DIO2_PIN}, \
251  {DIO3_PORT, DIO3_PIN}, {DIO4_PORT, DIO4_PIN}, \
252  {SCK_PORT, SCK_PIN}, {MISO_PORT, MISO_PIN}, {MOSI_PORT, MOSI_PIN}, \
253  {LED0_PORT, LED0_PIN}, {LED1_PORT, LED1_PIN}, \
254  {BUTTON0_PORT, BUTTON0_PIN}, {BUTTON1_PORT, BUTTON1_PIN}, \
255  {SCL_PORT, SCL_PIN}, {SDA_PORT, SDA_PIN}, \
256  {ACC1_PORT, ACC1_PIN}, {ACC2_PORT, ACC2_PIN}, \
257  {WIFI_ENABLE_PORT, WIFI_ENABLE_PIN}, \
258  {WIFI_USART_TX_PORT, WIFI_USART_TX_PIN}, {WIFI_USART_RX_PORT, WIFI_USART_RX_PIN}, \
259  {BATT_MEAS_PORT, BATT_MEAS_PIN}, {BATT_CHRG_PORT, BATT_CHRG_PIN}, {BATT_SYNC_PORT, BATT_SYNC_PIN}, \
260  {TCXO_PORT, TCXO_PIN}}
261 #else
262 #error Missing board configuration !
263 #endif
264 
265 
266 #endif /* _BOARDS_H_ */
GPIO driver.