amiro-os / modules / LightRing_1-2 / module.c @ 908b6fb4
History | View | Annotate | Download (20.863 KB)
1 | 9ae7c4f3 | Thomas Schöpping | /*
|
---|---|---|---|
2 | AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
|
||
3 | Copyright (C) 2016..2019 Thomas Schöpping et al.
|
||
4 | |||
5 | This program is free software: you can redistribute it and/or modify
|
||
6 | it under the terms of the GNU General Public License as published by
|
||
7 | the Free Software Foundation, either version 3 of the License, or
|
||
8 | (at your option) any later version.
|
||
9 | |||
10 | This program is distributed in the hope that it will be useful,
|
||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | GNU General Public License for more details.
|
||
14 | |||
15 | You should have received a copy of the GNU General Public License
|
||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
17 | */
|
||
18 | |||
19 | /**
|
||
20 | * @file
|
||
21 | 034cb15a | Thomas Schöpping | * @brief Structures and constant for the LightRing v1.2 module.
|
22 | 9ae7c4f3 | Thomas Schöpping | *
|
23 | * @addtogroup lightring_module
|
||
24 | * @{
|
||
25 | */
|
||
26 | |||
27 | #include "module.h" |
||
28 | |||
29 | /*===========================================================================*/
|
||
30 | /**
|
||
31 | * @name Module specific functions
|
||
32 | * @{
|
||
33 | */
|
||
34 | /*===========================================================================*/
|
||
35 | |||
36 | /** @} */
|
||
37 | |||
38 | /*===========================================================================*/
|
||
39 | /**
|
||
40 | * @name ChibiOS/HAL configuration
|
||
41 | * @{
|
||
42 | */
|
||
43 | /*===========================================================================*/
|
||
44 | |||
45 | CANConfig moduleHalCanConfig = { |
||
46 | /* mcr */ CAN_MCR_ABOM | CAN_MCR_AWUM | CAN_MCR_TXFP,
|
||
47 | /* btr */ CAN_BTR_SJW(1) | CAN_BTR_TS2(2) | CAN_BTR_TS1(13) | CAN_BTR_BRP(1), |
||
48 | }; |
||
49 | |||
50 | ee884101 | Thomas Schöpping | I2CConfig moduleHalI2cEepromPwrmtrBreakoutConfig = { |
51 | 9ae7c4f3 | Thomas Schöpping | /* I²C mode */ OPMODE_I2C,
|
52 | /* frequency */ 400000, // TODO: replace with some macro (-> ChibiOS/HAL) |
||
53 | /* duty cycle */ FAST_DUTY_CYCLE_2,
|
||
54 | }; |
||
55 | |||
56 | SerialConfig moduleHalProgIfConfig = { |
||
57 | /* bit rate */ 115200, |
||
58 | /* CR1 */ 0, |
||
59 | /* CR1 */ 0, |
||
60 | /* CR1 */ 0, |
||
61 | }; |
||
62 | |||
63 | SPIConfig moduleHalSpiLightConfig = { |
||
64 | /* circular buffer mode */ false, |
||
65 | /* callback function pointer */ NULL, |
||
66 | 3106e8cc | Thomas Schöpping | /* chip select line port */ PAL_PORT(LINE_LIGHT_XLAT),
|
67 | /* chip select line pad number */ PAL_PAD(LINE_LIGHT_XLAT),
|
||
68 | 9ae7c4f3 | Thomas Schöpping | /* CR1 */ SPI_CR1_BR_0 | SPI_CR1_BR_1,
|
69 | /* CR2 */ SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN,
|
||
70 | }; |
||
71 | |||
72 | 88449987 | Cung Sang | #if defined(AMIROLLD_CFG_DW1000)
|
73 | |||
74 | /*! SPI (high speed) configuration for DW1000 */
|
||
75 | SPIConfig moduleHalSpiUwbHsConfig = { |
||
76 | /* circular buffer mode */ false, |
||
77 | /* callback function pointer */ NULL, |
||
78 | /* chip select line port */ PAL_PORT(LINE_SPI_SS_N),
|
||
79 | /* chip select line pad number */ PAL_PAD(LINE_SPI_SS_N),
|
||
80 | /* CR1 */ 0, // 36/2 Mbps |
||
81 | /* CR2 */ SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN, // 0 |
||
82 | }; |
||
83 | /*! SPI (low speed) configuration for DW1000 */
|
||
84 | SPIConfig moduleHalSpiUwbLsConfig = { |
||
85 | /* circular buffer mode */ false, |
||
86 | /* callback function pointer */ NULL, |
||
87 | /* chip select line port */ PAL_PORT(LINE_SPI_SS_N),
|
||
88 | /* chip select line pad number */ PAL_PAD(LINE_SPI_SS_N),
|
||
89 | /* CR1 */ SPI_CR1_BR_1 | SPI_CR1_BR_0, // 36/16 Mbps |
||
90 | /* CR2 */ SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN, // 0 |
||
91 | }; |
||
92 | |||
93 | #endif /* defined(AMIROLLD_CFG_DW1000) */ |
||
94 | |||
95 | 9ae7c4f3 | Thomas Schöpping | |
96 | /*===========================================================================*/
|
||
97 | /**
|
||
98 | * @name GPIO definitions
|
||
99 | * @{
|
||
100 | */
|
||
101 | /*===========================================================================*/
|
||
102 | |||
103 | /**
|
||
104 | * @brief LIGHT_BANK output signal GPIO.
|
||
105 | */
|
||
106 | static apalGpio_t _gpioLightBlank = {
|
||
107 | 3106e8cc | Thomas Schöpping | /* line */ LINE_LIGHT_BLANK,
|
108 | 9ae7c4f3 | Thomas Schöpping | }; |
109 | ROMCONST apalControlGpio_t moduleGpioLightBlank = { |
||
110 | /* GPIO */ &_gpioLightBlank,
|
||
111 | /* meta */ {
|
||
112 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
113 | /* active state */ TLC5947_LLD_BLANK_ACTIVE_STATE,
|
||
114 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
115 | }, |
||
116 | }; |
||
117 | |||
118 | /**
|
||
119 | * @brief RS232_R_EN_N output signal GPIO.
|
||
120 | */
|
||
121 | static apalGpio_t _gpioRs232En = {
|
||
122 | 3106e8cc | Thomas Schöpping | /* line */ LINE_RS232_R_EN_N,
|
123 | 9ae7c4f3 | Thomas Schöpping | }; |
124 | ROMCONST apalControlGpio_t moduleGpioRs232En = { |
||
125 | /* GPIO */ &_gpioRs232En,
|
||
126 | /* meta */ {
|
||
127 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
128 | /* active state */ APAL_GPIO_ACTIVE_LOW, //TODO |
||
129 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
130 | }, |
||
131 | }; |
||
132 | |||
133 | /**
|
||
134 | * @brief SW_V33_EN output signal GPIO.
|
||
135 | */
|
||
136 | static apalGpio_t _gpioSwV33En = {
|
||
137 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SW_V33_EN,
|
138 | 9ae7c4f3 | Thomas Schöpping | }; |
139 | ROMCONST apalControlGpio_t moduleGpioSwV33En = { |
||
140 | /* GPIO */ &_gpioSwV33En,
|
||
141 | /* meta */ {
|
||
142 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
143 | ee884101 | Thomas Schöpping | /* active state */ MIC9404x_LLD_EN_ACTIVE_STATE,
|
144 | 9ae7c4f3 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
145 | }, |
||
146 | }; |
||
147 | |||
148 | /**
|
||
149 | * @brief SW_V42_EN output signal GPIO.
|
||
150 | */
|
||
151 | static apalGpio_t _gpioSwV42En = {
|
||
152 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SW_V42_EN,
|
153 | 9ae7c4f3 | Thomas Schöpping | }; |
154 | ROMCONST apalControlGpio_t moduleGpioSwV42En = { |
||
155 | /* GPIO */ &_gpioSwV42En,
|
||
156 | /* meta */ {
|
||
157 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
158 | ee884101 | Thomas Schöpping | /* active state */ MIC9404x_LLD_EN_ACTIVE_STATE,
|
159 | 9ae7c4f3 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
160 | }, |
||
161 | }; |
||
162 | |||
163 | /**
|
||
164 | * @brief SW_V50_EN output signal GPIO.
|
||
165 | */
|
||
166 | static apalGpio_t _gpioSwV50En = {
|
||
167 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SW_V50_EN,
|
168 | 9ae7c4f3 | Thomas Schöpping | }; |
169 | ROMCONST apalControlGpio_t moduleGpioSwV50En = { |
||
170 | /* GPIO */ &_gpioSwV50En,
|
||
171 | /* meta */ {
|
||
172 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
173 | ee884101 | Thomas Schöpping | /* active state */ MIC9404x_LLD_EN_ACTIVE_STATE,
|
174 | 9ae7c4f3 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
175 | }, |
||
176 | }; |
||
177 | |||
178 | /**
|
||
179 | * @brief IO_3 breakout signal GPIO.
|
||
180 | */
|
||
181 | static apalGpio_t _gpioBreakoutIo3 = {
|
||
182 | 3106e8cc | Thomas Schöpping | /* line */ LINE_IO_3,
|
183 | 9ae7c4f3 | Thomas Schöpping | }; |
184 | apalControlGpio_t moduleGpioBreakoutIo3 = { |
||
185 | /* GPIO */ &_gpioBreakoutIo3,
|
||
186 | /* meta */ {
|
||
187 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
188 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
189 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
190 | }, |
||
191 | }; |
||
192 | |||
193 | /**
|
||
194 | * @brief IO_5 breakout signal GPIO.
|
||
195 | */
|
||
196 | static apalGpio_t _gpioBreakoutIo5 = {
|
||
197 | 3106e8cc | Thomas Schöpping | /* line */ LINE_IO_5,
|
198 | 9ae7c4f3 | Thomas Schöpping | }; |
199 | apalControlGpio_t moduleGpioBreakoutIo5 = { |
||
200 | /* GPIO */ &_gpioBreakoutIo5,
|
||
201 | /* meta */ {
|
||
202 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
203 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
204 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
205 | }, |
||
206 | }; |
||
207 | |||
208 | /**
|
||
209 | * @brief IO_6 breakout signal GPIO.
|
||
210 | */
|
||
211 | static apalGpio_t _gpioBreakoutIo6 = {
|
||
212 | 3106e8cc | Thomas Schöpping | /* line */ LINE_IO_6,
|
213 | 9ae7c4f3 | Thomas Schöpping | }; |
214 | apalControlGpio_t moduleGpioBreakoutIo6 = { |
||
215 | /* GPIO */ &_gpioBreakoutIo6,
|
||
216 | /* meta */ {
|
||
217 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
218 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
219 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
220 | }, |
||
221 | }; |
||
222 | |||
223 | /**
|
||
224 | * @brief SYS_UART_DN bidirectional signal GPIO.
|
||
225 | */
|
||
226 | static apalGpio_t _gpioSysUartDn = {
|
||
227 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SYS_UART_DN,
|
228 | 9ae7c4f3 | Thomas Schöpping | }; |
229 | ROMCONST apalControlGpio_t moduleGpioSysUartDn = { |
||
230 | /* GPIO */ &_gpioSysUartDn,
|
||
231 | /* meta */ {
|
||
232 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
233 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
234 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
235 | }, |
||
236 | }; |
||
237 | |||
238 | 88449987 | Cung Sang | #if defined (AMIROLLD_CFG_DW1000)
|
239 | 9ae7c4f3 | Thomas Schöpping | /**
|
240 | 88449987 | Cung Sang | * @brief DW1000 interrrupt input signal GPIO.
|
241 | 9ae7c4f3 | Thomas Schöpping | */
|
242 | 88449987 | Cung Sang | static apalGpio_t _gpioDw1000Irqn = {
|
243 | /* line */ LINE_IO_8, // (GPIOB, GPIOB_IO_8), |
||
244 | }; |
||
245 | ROMCONST apalControlGpio_t moduleGpioDw1000Irqn = { |
||
246 | /* GPIO */ &_gpioDw1000Irqn,
|
||
247 | /* meta */ {
|
||
248 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
249 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
250 | /* interrupt edge */ APAL_GPIO_EDGE_RISING,
|
||
251 | }, |
||
252 | }; |
||
253 | |||
254 | /**
|
||
255 | * @brief DW1000 reset output signal GPIO.
|
||
256 | */
|
||
257 | static apalGpio_t _gpioDw1000Reset = {
|
||
258 | 3106e8cc | Thomas Schöpping | /* line */ LINE_IO_7,
|
259 | 9ae7c4f3 | Thomas Schöpping | }; |
260 | 88449987 | Cung Sang | ROMCONST apalControlGpio_t moduleGpioDw1000Reset = { |
261 | /* GPIO */ &_gpioDw1000Reset,
|
||
262 | 9ae7c4f3 | Thomas Schöpping | /* meta */ {
|
263 | 88449987 | Cung Sang | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
264 | 9ae7c4f3 | Thomas Schöpping | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
265 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
266 | }, |
||
267 | }; |
||
268 | |||
269 | /**
|
||
270 | 88449987 | Cung Sang | * @brief IO_2 breakout signal GPIO.
|
271 | */
|
||
272 | static apalGpio_t _gpioDw1000WakeUp = {
|
||
273 | /* line */ LINE_IO_2,
|
||
274 | }; |
||
275 | ROMCONST apalControlGpio_t moduleGpioDw1000WakeUp = { |
||
276 | /* GPIO */ &_gpioDw1000WakeUp,
|
||
277 | /* meta */ {
|
||
278 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
279 | /* active state */ APAL_GPIO_ACTIVE_HIGH,
|
||
280 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
281 | }, |
||
282 | }; |
||
283 | |||
284 | /**
|
||
285 | * @brief DW1000 SPI chip select output signal GPIO.
|
||
286 | */
|
||
287 | static apalGpio_t _gpioSpiChipSelect = {
|
||
288 | /* line */ LINE_SPI_SS_N,
|
||
289 | }; |
||
290 | ROMCONST apalControlGpio_t moduleGpioSpiChipSelect = { |
||
291 | /* GPIO */ &_gpioSpiChipSelect,
|
||
292 | /* meta */ {
|
||
293 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
294 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
295 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
296 | }, |
||
297 | }; |
||
298 | #else
|
||
299 | /**
|
||
300 | 9ae7c4f3 | Thomas Schöpping | * @brief IO_8 breakout signal GPIO.
|
301 | */
|
||
302 | static apalGpio_t _gpioBreakoutIo8 = {
|
||
303 | 3106e8cc | Thomas Schöpping | /* line */ LINE_IO_8,
|
304 | 9ae7c4f3 | Thomas Schöpping | }; |
305 | apalControlGpio_t moduleGpioBreakoutIo8 = { |
||
306 | /* GPIO */ &_gpioBreakoutIo8,
|
||
307 | /* meta */ {
|
||
308 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
309 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
310 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
311 | }, |
||
312 | }; |
||
313 | |||
314 | /**
|
||
315 | 88449987 | Cung Sang | * @brief IO_7 breakout signal GPIO.
|
316 | 9ae7c4f3 | Thomas Schöpping | */
|
317 | 88449987 | Cung Sang | static apalGpio_t _gpioBreakoutIo7 = {
|
318 | /* line */ LINE_IO_7,
|
||
319 | 9ae7c4f3 | Thomas Schöpping | }; |
320 | 88449987 | Cung Sang | apalControlGpio_t moduleGpioBreakoutIo7 = { |
321 | /* GPIO */ &_gpioBreakoutIo7,
|
||
322 | 9ae7c4f3 | Thomas Schöpping | /* meta */ {
|
323 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
324 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
325 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
326 | }, |
||
327 | }; |
||
328 | |||
329 | /**
|
||
330 | 88449987 | Cung Sang | * @brief IO_2 breakout signal GPIO.
|
331 | 9ae7c4f3 | Thomas Schöpping | */
|
332 | 88449987 | Cung Sang | static apalGpio_t _gpioBreakoutIo2 = {
|
333 | /* line */ LINE_IO_2,
|
||
334 | 9ae7c4f3 | Thomas Schöpping | }; |
335 | 88449987 | Cung Sang | apalControlGpio_t moduleGpioBreakoutIo2 = { |
336 | /* GPIO */ &_gpioBreakoutIo2,
|
||
337 | 9ae7c4f3 | Thomas Schöpping | /* meta */ {
|
338 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
339 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
340 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
341 | }, |
||
342 | }; |
||
343 | 88449987 | Cung Sang | #endif /* defined (AMIROLLD_CFG_DW1000) */ |
344 | 9ae7c4f3 | Thomas Schöpping | |
345 | /**
|
||
346 | 88449987 | Cung Sang | * @brief IO_4 breakout signal GPIO.
|
347 | 9ae7c4f3 | Thomas Schöpping | */
|
348 | 88449987 | Cung Sang | static apalGpio_t _gpioBreakoutIo4 = {
|
349 | /* line */ LINE_IO_4,
|
||
350 | 9ae7c4f3 | Thomas Schöpping | }; |
351 | 88449987 | Cung Sang | apalControlGpio_t moduleGpioBreakoutIo4 = { |
352 | /* GPIO */ &_gpioBreakoutIo4,
|
||
353 | /* meta */ {
|
||
354 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
355 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
356 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
357 | }, |
||
358 | }; |
||
359 | |||
360 | /**
|
||
361 | * @brief IO_1 breakout signal GPIO.
|
||
362 | */
|
||
363 | static apalGpio_t _gpioBreakoutIo1 = {
|
||
364 | /* line */ LINE_IO_1,
|
||
365 | }; |
||
366 | apalControlGpio_t moduleGpioBreakoutIo1 = { |
||
367 | /* GPIO */ &_gpioBreakoutIo1,
|
||
368 | 9ae7c4f3 | Thomas Schöpping | /* meta */ {
|
369 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
370 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
371 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
372 | }, |
||
373 | }; |
||
374 | |||
375 | /**
|
||
376 | * @brief LED output signal GPIO.
|
||
377 | */
|
||
378 | static apalGpio_t _gpioLed = {
|
||
379 | 3106e8cc | Thomas Schöpping | /* line */ LINE_LED,
|
380 | 9ae7c4f3 | Thomas Schöpping | }; |
381 | ROMCONST apalControlGpio_t moduleGpioLed = { |
||
382 | /* GPIO */ &_gpioLed,
|
||
383 | /* meta */ {
|
||
384 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
385 | /* active state */ LED_LLD_GPIO_ACTIVE_STATE,
|
||
386 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
387 | }, |
||
388 | }; |
||
389 | |||
390 | /**
|
||
391 | * @brief SW_V18_EN output signal GPIO.
|
||
392 | */
|
||
393 | static apalGpio_t _gpioSwV18En = {
|
||
394 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SW_V18_EN,
|
395 | 9ae7c4f3 | Thomas Schöpping | }; |
396 | ROMCONST apalControlGpio_t moduleGpioSwV18En = { |
||
397 | /* GPIO */ &_gpioSwV18En,
|
||
398 | /* meta */ {
|
||
399 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
400 | ee884101 | Thomas Schöpping | /* active state */ MIC9404x_LLD_EN_ACTIVE_STATE,
|
401 | 9ae7c4f3 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
402 | }, |
||
403 | }; |
||
404 | |||
405 | /**
|
||
406 | * @brief SW_VSYS_EN output signal GPIO.
|
||
407 | */
|
||
408 | static apalGpio_t _gpioSwVsysEn = {
|
||
409 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SW_VSYS_EN,
|
410 | 9ae7c4f3 | Thomas Schöpping | }; |
411 | ROMCONST apalControlGpio_t moduleGpioSwVsysEn = { |
||
412 | /* GPIO */ &_gpioSwVsysEn,
|
||
413 | /* meta */ {
|
||
414 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
415 | ee884101 | Thomas Schöpping | /* active state */ APAL_GPIO_ACTIVE_HIGH,
|
416 | 9ae7c4f3 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
417 | }, |
||
418 | }; |
||
419 | |||
420 | /**
|
||
421 | * @brief SYS_UART_UP bidirectional signal GPIO.
|
||
422 | */
|
||
423 | static apalGpio_t _gpioSysUartUp = {
|
||
424 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SYS_UART_UP,
|
425 | 9ae7c4f3 | Thomas Schöpping | }; |
426 | ROMCONST apalControlGpio_t moduleGpioSysUartUp = { |
||
427 | /* GPIO */ &_gpioSysUartUp,
|
||
428 | /* meta */ {
|
||
429 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
430 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
431 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
432 | }, |
||
433 | }; |
||
434 | |||
435 | /**
|
||
436 | * @brief SYS_PD bidirectional signal GPIO.
|
||
437 | */
|
||
438 | static apalGpio_t _gpioSysPd = {
|
||
439 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SYS_PD_N,
|
440 | 9ae7c4f3 | Thomas Schöpping | }; |
441 | ROMCONST apalControlGpio_t moduleGpioSysPd = { |
||
442 | /* GPIO */ &_gpioSysPd,
|
||
443 | /* meta */ {
|
||
444 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
445 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
446 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
447 | }, |
||
448 | }; |
||
449 | |||
450 | /**
|
||
451 | * @brief SYS_SYNC bidirectional signal GPIO.
|
||
452 | */
|
||
453 | static apalGpio_t _gpioSysSync = {
|
||
454 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SYS_INT_N,
|
455 | 9ae7c4f3 | Thomas Schöpping | }; |
456 | ROMCONST apalControlGpio_t moduleGpioSysSync = { |
||
457 | /* GPIO */ &_gpioSysSync,
|
||
458 | /* meta */ {
|
||
459 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
460 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
461 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
462 | }, |
||
463 | }; |
||
464 | |||
465 | /** @} */
|
||
466 | |||
467 | /*===========================================================================*/
|
||
468 | /**
|
||
469 | * @name AMiRo-OS core configurations
|
||
470 | * @{
|
||
471 | */
|
||
472 | /*===========================================================================*/
|
||
473 | |||
474 | #if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
475 | ROMCONST char* moduleShellPrompt = "LightRing"; |
||
476 | #endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */ |
||
477 | |||
478 | /** @} */
|
||
479 | |||
480 | /*===========================================================================*/
|
||
481 | /**
|
||
482 | * @name Startup Shutdown Synchronization Protocol (SSSP)
|
||
483 | * @{
|
||
484 | */
|
||
485 | /*===========================================================================*/
|
||
486 | |||
487 | /** @} */
|
||
488 | |||
489 | /*===========================================================================*/
|
||
490 | /**
|
||
491 | * @name Low-level drivers
|
||
492 | * @{
|
||
493 | */
|
||
494 | /*===========================================================================*/
|
||
495 | |||
496 | AT24C01BDriver moduleLldEeprom = { |
||
497 | ee884101 | Thomas Schöpping | /* I2C driver */ &MODULE_HAL_I2C_EEPROM_PWRMTR_BREAKOUT,
|
498 | 9ae7c4f3 | Thomas Schöpping | /* I2C address */ 0x00u, |
499 | }; |
||
500 | |||
501 | ee884101 | Thomas Schöpping | INA219Driver moduleLldPowerMonitorVled = { |
502 | /* I2C Driver */ &MODULE_HAL_I2C_EEPROM_PWRMTR_BREAKOUT,
|
||
503 | /* I²C address */ INA219_LLD_I2C_ADDR_FIXED,
|
||
504 | /* current LSB (uA) */ 0x00u, |
||
505 | /* configuration */ NULL, |
||
506 | }; |
||
507 | |||
508 | LEDDriver moduleLldStatusLed = { |
||
509 | /* LED enable Gpio */ &moduleGpioLed,
|
||
510 | }; |
||
511 | |||
512 | MIC9404xDriver moduleLldPowerSwitchV18 = { |
||
513 | /* power enable GPIO */ &moduleGpioSwV18En,
|
||
514 | }; |
||
515 | |||
516 | MIC9404xDriver moduleLldPowerSwitchV33 = { |
||
517 | /* power enable GPIO */ &moduleGpioSwV33En,
|
||
518 | }; |
||
519 | |||
520 | MIC9404xDriver moduleLldPowerSwitchV42 = { |
||
521 | /* power enable GPIO */ &moduleGpioSwV42En,
|
||
522 | }; |
||
523 | |||
524 | MIC9404xDriver moduleLldPowerSwitchV50 = { |
||
525 | /* power enable GPIO */ &moduleGpioSwV50En,
|
||
526 | }; |
||
527 | |||
528 | MIC9404xDriver moduleLldPowerSwitchVsys = { |
||
529 | /* power enable GPIO */ &moduleGpioSwVsysEn,
|
||
530 | }; |
||
531 | |||
532 | 9ae7c4f3 | Thomas Schöpping | TLC5947Driver moduleLldLedPwm = { |
533 | /* SPI driver */ &MODULE_HAL_SPI_LIGHT,
|
||
534 | /* BLANK signal GPIO */ &moduleGpioLightBlank,
|
||
535 | 3106e8cc | Thomas Schöpping | /* XLAT signal GPIO */ NULL, |
536 | 9ae7c4f3 | Thomas Schöpping | }; |
537 | |||
538 | 88449987 | Cung Sang | #if defined(AMIROLLD_CFG_DW1000)
|
539 | DW1000Driver moduleLldDw1000 = { |
||
540 | /* SPI driver */ &MODULE_HAL_SPI_UWB,
|
||
541 | /* ext interrupt */ &moduleGpioDw1000Irqn,
|
||
542 | /* RESET DW1000 */ &moduleGpioDw1000Reset,
|
||
543 | }; |
||
544 | #endif /* defined(AMIROLLD_CFG_DW1000) */ |
||
545 | |||
546 | 9ae7c4f3 | Thomas Schöpping | /** @} */
|
547 | |||
548 | /*===========================================================================*/
|
||
549 | /**
|
||
550 | * @name Unit tests (UT)
|
||
551 | * @{
|
||
552 | */
|
||
553 | /*===========================================================================*/
|
||
554 | #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
555 | ee884101 | Thomas Schöpping | #include <string.h> |
556 | 9ae7c4f3 | Thomas Schöpping | |
557 | /*
|
||
558 | * EEPROM (AT24C01B)
|
||
559 | */
|
||
560 | static int _utShellCmdCb_AlldAt24c01b(BaseSequentialStream* stream, int argc, char* argv[]) |
||
561 | { |
||
562 | (void)argc;
|
||
563 | (void)argv;
|
||
564 | aosUtRun(stream, &moduleUtAlldAt24c01b, NULL);
|
||
565 | return AOS_OK;
|
||
566 | } |
||
567 | static ut_at24c01bdata_t _utAlldAt24c01bData = {
|
||
568 | /* driver */ &moduleLldEeprom,
|
||
569 | /* timeout */ MICROSECONDS_PER_SECOND,
|
||
570 | }; |
||
571 | aos_unittest_t moduleUtAlldAt24c01b = { |
||
572 | /* name */ "AT24C01B", |
||
573 | /* info */ "1kbit EEPROM", |
||
574 | /* test function */ utAlldAt24c01bFunc,
|
||
575 | /* shell command */ {
|
||
576 | /* name */ "unittest:EEPROM", |
||
577 | /* callback */ _utShellCmdCb_AlldAt24c01b,
|
||
578 | /* next */ NULL, |
||
579 | }, |
||
580 | /* data */ &_utAlldAt24c01bData,
|
||
581 | }; |
||
582 | |||
583 | /*
|
||
584 | ee884101 | Thomas Schöpping | * INA219 (power monitor)
|
585 | */
|
||
586 | static int _utShellCmdCb_AlldIna219(BaseSequentialStream* stream, int argc, char* argv[]) |
||
587 | { |
||
588 | (void)argc;
|
||
589 | (void)argv;
|
||
590 | aosUtRun(stream, &moduleUtAlldIna219, "VLED (4.2V)");
|
||
591 | return AOS_OK;
|
||
592 | } |
||
593 | static ut_ina219data_t _utIna219Data = {
|
||
594 | /* driver */ &moduleLldPowerMonitorVled,
|
||
595 | /* expected voltage */ 4.2f, |
||
596 | /* tolerance */ 0.2f, |
||
597 | /* timeout */ MICROSECONDS_PER_SECOND,
|
||
598 | }; |
||
599 | aos_unittest_t moduleUtAlldIna219 = { |
||
600 | /* name */ "INA219", |
||
601 | /* info */ "power monitor", |
||
602 | /* test function */ utAlldIna219Func,
|
||
603 | /* shell command */ {
|
||
604 | /* name */ "unittest:PowerMonitor", |
||
605 | /* callback */ _utShellCmdCb_AlldIna219,
|
||
606 | /* next */ NULL, |
||
607 | }, |
||
608 | /* data */ &_utIna219Data,
|
||
609 | }; |
||
610 | |||
611 | /*
|
||
612 | * Status LED
|
||
613 | */
|
||
614 | static int _utShellCmdCb_AlldLed(BaseSequentialStream* stream, int argc, char* argv[]) |
||
615 | { |
||
616 | (void)argc;
|
||
617 | (void)argv;
|
||
618 | aosUtRun(stream, &moduleUtAlldLed, NULL);
|
||
619 | return AOS_OK;
|
||
620 | } |
||
621 | aos_unittest_t moduleUtAlldLed = { |
||
622 | /* name */ "LED", |
||
623 | /* info */ NULL, |
||
624 | /* test function */ utAlldLedFunc,
|
||
625 | /* shell command */ {
|
||
626 | /* name */ "unittest:StatusLED", |
||
627 | /* callback */ _utShellCmdCb_AlldLed,
|
||
628 | /* next */ NULL, |
||
629 | }, |
||
630 | /* data */ &moduleLldStatusLed,
|
||
631 | }; |
||
632 | |||
633 | /*
|
||
634 | * Power switch driver (MIC9404x)
|
||
635 | */
|
||
636 | static int _utShellCmdCb_Mic9404x(BaseSequentialStream* stream, int argc, char* argv[]) |
||
637 | { |
||
638 | // evaluate arguments
|
||
639 | if (argc == 2) { |
||
640 | if (strcmp(argv[1], "1.8V") == 0) { |
||
641 | moduleUtAlldMic9404x.data = &moduleLldPowerSwitchV18; |
||
642 | aosUtRun(stream, &moduleUtAlldMic9404x, "1.8V");
|
||
643 | moduleUtAlldMic9404x.data = NULL;
|
||
644 | return AOS_OK;
|
||
645 | } |
||
646 | else if (strcmp(argv[1], "3.3V") == 0) { |
||
647 | moduleUtAlldMic9404x.data = &moduleLldPowerSwitchV33; |
||
648 | aosUtRun(stream, &moduleUtAlldMic9404x, "3.3V");
|
||
649 | moduleUtAlldMic9404x.data = NULL;
|
||
650 | return AOS_OK;
|
||
651 | } |
||
652 | else if (strcmp(argv[1], "4.2V") == 0) { |
||
653 | moduleUtAlldMic9404x.data = &moduleLldPowerSwitchV42; |
||
654 | aosUtRun(stream, &moduleUtAlldMic9404x, "4.2V");
|
||
655 | moduleUtAlldMic9404x.data = NULL;
|
||
656 | return AOS_OK;
|
||
657 | } |
||
658 | else if (strcmp(argv[1], "5.0V") == 0) { |
||
659 | moduleUtAlldMic9404x.data = &moduleLldPowerSwitchV50; |
||
660 | aosUtRun(stream, &moduleUtAlldMic9404x, "5.0V");
|
||
661 | moduleUtAlldMic9404x.data = NULL;
|
||
662 | return AOS_OK;
|
||
663 | } |
||
664 | else if (strcmp(argv[1], "VSYS") == 0) { |
||
665 | moduleUtAlldMic9404x.data = &moduleLldPowerSwitchVsys; |
||
666 | aosUtRun(stream, &moduleUtAlldMic9404x, "VSYS");
|
||
667 | moduleUtAlldMic9404x.data = NULL;
|
||
668 | return AOS_OK;
|
||
669 | } |
||
670 | } |
||
671 | // print help
|
||
672 | chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
||
673 | chprintf(stream, "Options:\n");
|
||
674 | chprintf(stream, " 1.8V\n");
|
||
675 | chprintf(stream, " Test power switch for 1.8V supply.\n");
|
||
676 | chprintf(stream, " 3.3V\n");
|
||
677 | chprintf(stream, " Test power switch for 3.3V supply.\n");
|
||
678 | chprintf(stream, " 4.2V\n");
|
||
679 | chprintf(stream, " Test power switch for 4.2V supply.\n");
|
||
680 | chprintf(stream, " 5.0V\n");
|
||
681 | chprintf(stream, " Test power switch for 5.0V supply.\n");
|
||
682 | chprintf(stream, " VSYS\n");
|
||
683 | chprintf(stream, " Test power switch for VSYS supply.\n");
|
||
684 | 916f8d28 | Thomas Schöpping | return AOS_INVALIDARGUMENTS;
|
685 | ee884101 | Thomas Schöpping | } |
686 | aos_unittest_t moduleUtAlldMic9404x = { |
||
687 | /* info */ "MIC9404x", |
||
688 | /* name */ "power swicth driver", |
||
689 | /* test function */ utAlldMic9404xFunc,
|
||
690 | /* shell command */ {
|
||
691 | /* name */ "unittest:PowerSwitch", |
||
692 | /* callback */ _utShellCmdCb_Mic9404x,
|
||
693 | /* next */ NULL, |
||
694 | }, |
||
695 | /* data */ NULL, |
||
696 | }; |
||
697 | |||
698 | /*
|
||
699 | 9ae7c4f3 | Thomas Schöpping | * LED PWM driver (TLC5947)
|
700 | */
|
||
701 | static int _utShellCmdCb_Tlc5947(BaseSequentialStream* stream, int argc, char* argv[]) |
||
702 | { |
||
703 | (void)argc;
|
||
704 | (void)argv;
|
||
705 | aosUtRun(stream, &moduleUtAlldTlc5947, NULL);
|
||
706 | return AOS_OK;
|
||
707 | } |
||
708 | aos_unittest_t moduleUtAlldTlc5947 = { |
||
709 | /* info */ "TLC5947", |
||
710 | /* name */ "LED PWM driver", |
||
711 | /* test function */ utAlldTlc5947Func,
|
||
712 | /* shell command */ {
|
||
713 | /* name */ "unittest:Lights", |
||
714 | /* callback */ _utShellCmdCb_Tlc5947,
|
||
715 | /* next */ NULL, |
||
716 | }, |
||
717 | /* data */ &moduleLldLedPwm,
|
||
718 | }; |
||
719 | |||
720 | 88449987 | Cung Sang | #if defined(AMIROLLD_CFG_DW1000)
|
721 | /*
|
||
722 | * UwB Driver (DW1000)
|
||
723 | */
|
||
724 | static int _utShellCmdCb_Dw1000(BaseSequentialStream* stream, int argc, char* argv[]) |
||
725 | { |
||
726 | (void)argc;
|
||
727 | (void)argv;
|
||
728 | |||
729 | // Set the 3.3 V supply for powering the DW1000 module
|
||
730 | ((ut_dw1000data_t*)moduleUtAlldDw1000.data)->mic9404xd = &moduleLldPowerSwitchV33; |
||
731 | ((ut_dw1000data_t*)moduleUtAlldDw1000.data)->dw1000d = NULL;
|
||
732 | aosUtRun(stream, &moduleUtAlldDw1000, NULL);
|
||
733 | ((ut_dw1000data_t*)moduleUtAlldDw1000.data)->mic9404xd = NULL;
|
||
734 | |||
735 | // Set the 1.8 V supply
|
||
736 | ((ut_dw1000data_t*)moduleUtAlldDw1000.data)->mic9404xd = &moduleLldPowerSwitchV18; |
||
737 | ((ut_dw1000data_t*)moduleUtAlldDw1000.data)->dw1000d = NULL;
|
||
738 | aosUtRun(stream, &moduleUtAlldDw1000, NULL);
|
||
739 | ((ut_dw1000data_t*)moduleUtAlldDw1000.data)->mic9404xd = NULL;
|
||
740 | |||
741 | // Run the DW1000 module
|
||
742 | ((ut_dw1000data_t*)moduleUtAlldDw1000.data)->dw1000d = &moduleLldDw1000; |
||
743 | ((ut_dw1000data_t*)moduleUtAlldDw1000.data)->mic9404xd = NULL;
|
||
744 | aosUtRun(stream, &moduleUtAlldDw1000, NULL);
|
||
745 | return AOS_OK;
|
||
746 | } |
||
747 | static ut_dw1000data_t _utAlldDw1000Data = {
|
||
748 | /* driver DW1000 */ NULL, |
||
749 | /* driver MIC9404x */ NULL, |
||
750 | }; |
||
751 | aos_unittest_t moduleUtAlldDw1000 = { |
||
752 | /* info */ "DW1000", |
||
753 | /* name */ "UWB System", |
||
754 | /* test function */ utAlldDw1000Func,
|
||
755 | /* shell command */ {
|
||
756 | /* name */ "unittest:Uwb", |
||
757 | /* callback */ _utShellCmdCb_Dw1000,
|
||
758 | /* next */ NULL, |
||
759 | }, |
||
760 | /* data */ &_utAlldDw1000Data,
|
||
761 | }; |
||
762 | #endif /* defined(AMIROLLD_CFG_DW1000) */ |
||
763 | |||
764 | 9ae7c4f3 | Thomas Schöpping | #endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
765 | |||
766 | /** @} */
|
||
767 | /** @} */ |