amiro-os / modules / LightRing_1-2 / module.c @ 47e89ebf
History | View | Annotate | Download (19.9 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 | f606f432 | Thomas Schöpping | #if (BOARD_BREAKOUT_MODULE == BOARD_BREAKOUT_UWBv10)
|
73 | 0b989911 | Cung Sang | |
74 | SPIConfig moduleHalSpiUwbHsConfig = { |
||
75 | /* circular buffer mode */ false, |
||
76 | /* callback function pointer */ NULL, |
||
77 | /* chip select line port */ PAL_PORT(LINE_SPI_SS_N),
|
||
78 | /* chip select line pad number */ PAL_PAD(LINE_SPI_SS_N),
|
||
79 | /* CR1 */ 0, // 36/2 Mbps |
||
80 | /* CR2 */ SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN, // 0 |
||
81 | }; |
||
82 | f606f432 | Thomas Schöpping | |
83 | 0b989911 | Cung Sang | SPIConfig moduleHalSpiUwbLsConfig = { |
84 | /* circular buffer mode */ false, |
||
85 | /* callback function pointer */ NULL, |
||
86 | /* chip select line port */ PAL_PORT(LINE_SPI_SS_N),
|
||
87 | /* chip select line pad number */ PAL_PAD(LINE_SPI_SS_N),
|
||
88 | /* CR1 */ SPI_CR1_BR_1 | SPI_CR1_BR_0, // 36/16 Mbps |
||
89 | /* CR2 */ SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN, // 0 |
||
90 | }; |
||
91 | |||
92 | f606f432 | Thomas Schöpping | #endif /* (BOARD_BREAKOUT_MODULE == BOARD_BREAKOUT_UWBv10) */ |
93 | 9ae7c4f3 | Thomas Schöpping | |
94 | /*===========================================================================*/
|
||
95 | /**
|
||
96 | * @name GPIO definitions
|
||
97 | * @{
|
||
98 | */
|
||
99 | /*===========================================================================*/
|
||
100 | |||
101 | /**
|
||
102 | * @brief LIGHT_BANK output signal GPIO.
|
||
103 | */
|
||
104 | static apalGpio_t _gpioLightBlank = {
|
||
105 | 3106e8cc | Thomas Schöpping | /* line */ LINE_LIGHT_BLANK,
|
106 | 9ae7c4f3 | Thomas Schöpping | }; |
107 | ROMCONST apalControlGpio_t moduleGpioLightBlank = { |
||
108 | /* GPIO */ &_gpioLightBlank,
|
||
109 | /* meta */ {
|
||
110 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
111 | /* active state */ TLC5947_LLD_BLANK_ACTIVE_STATE,
|
||
112 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
113 | }, |
||
114 | }; |
||
115 | |||
116 | /**
|
||
117 | * @brief RS232_R_EN_N output signal GPIO.
|
||
118 | */
|
||
119 | static apalGpio_t _gpioRs232En = {
|
||
120 | 3106e8cc | Thomas Schöpping | /* line */ LINE_RS232_R_EN_N,
|
121 | 9ae7c4f3 | Thomas Schöpping | }; |
122 | ROMCONST apalControlGpio_t moduleGpioRs232En = { |
||
123 | /* GPIO */ &_gpioRs232En,
|
||
124 | /* meta */ {
|
||
125 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
126 | /* active state */ APAL_GPIO_ACTIVE_LOW, //TODO |
||
127 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
128 | }, |
||
129 | }; |
||
130 | |||
131 | /**
|
||
132 | * @brief SW_V33_EN output signal GPIO.
|
||
133 | */
|
||
134 | static apalGpio_t _gpioSwV33En = {
|
||
135 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SW_V33_EN,
|
136 | 9ae7c4f3 | Thomas Schöpping | }; |
137 | ROMCONST apalControlGpio_t moduleGpioSwV33En = { |
||
138 | /* GPIO */ &_gpioSwV33En,
|
||
139 | /* meta */ {
|
||
140 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
141 | ee884101 | Thomas Schöpping | /* active state */ MIC9404x_LLD_EN_ACTIVE_STATE,
|
142 | 9ae7c4f3 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
143 | }, |
||
144 | }; |
||
145 | |||
146 | 9acb8326 | Thomas Schöpping | // The 4.2V switch is disabled due to a hardware bug.
|
147 | ///**
|
||
148 | // * @brief SW_V42_EN output signal GPIO.
|
||
149 | // */
|
||
150 | //static apalGpio_t _gpioSwV42En = {
|
||
151 | // /* line */ LINE_SW_V42_EN,
|
||
152 | //};
|
||
153 | //ROMCONST apalControlGpio_t moduleGpioSwV42En = {
|
||
154 | // /* GPIO */ &_gpioSwV42En,
|
||
155 | // /* meta */ {
|
||
156 | // /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
157 | // /* active state */ MIC9404x_LLD_EN_ACTIVE_STATE,
|
||
158 | // /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
159 | // },
|
||
160 | //};
|
||
161 | 9ae7c4f3 | Thomas Schöpping | |
162 | /**
|
||
163 | * @brief SW_V50_EN output signal GPIO.
|
||
164 | */
|
||
165 | static apalGpio_t _gpioSwV50En = {
|
||
166 | 3106e8cc | Thomas Schöpping | /* line */ LINE_SW_V50_EN,
|
167 | 9ae7c4f3 | Thomas Schöpping | }; |
168 | ROMCONST apalControlGpio_t moduleGpioSwV50En = { |
||
169 | /* GPIO */ &_gpioSwV50En,
|
||
170 | /* meta */ {
|
||
171 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
172 | ee884101 | Thomas Schöpping | /* active state */ MIC9404x_LLD_EN_ACTIVE_STATE,
|
173 | 9ae7c4f3 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
174 | }, |
||
175 | }; |
||
176 | |||
177 | /**
|
||
178 | f606f432 | Thomas Schöpping | * @brief SYS_UART_DN bidirectional signal GPIO.
|
179 | 9ae7c4f3 | Thomas Schöpping | */
|
180 | f606f432 | Thomas Schöpping | static apalGpio_t _gpioSysUartDn = {
|
181 | /* line */ LINE_SYS_UART_DN,
|
||
182 | 9ae7c4f3 | Thomas Schöpping | }; |
183 | f606f432 | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysUartDn = { |
184 | /* GPIO */ &_gpioSysUartDn,
|
||
185 | 9ae7c4f3 | Thomas Schöpping | /* meta */ {
|
186 | f606f432 | Thomas Schöpping | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
187 | 9ae7c4f3 | Thomas Schöpping | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
188 | f606f432 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
189 | 9ae7c4f3 | Thomas Schöpping | }, |
190 | }; |
||
191 | |||
192 | /**
|
||
193 | f606f432 | Thomas Schöpping | * @brief LED output signal GPIO.
|
194 | 9ae7c4f3 | Thomas Schöpping | */
|
195 | f606f432 | Thomas Schöpping | static apalGpio_t _gpioLed = {
|
196 | /* line */ LINE_LED,
|
||
197 | 9ae7c4f3 | Thomas Schöpping | }; |
198 | f606f432 | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioLed = { |
199 | /* GPIO */ &_gpioLed,
|
||
200 | 9ae7c4f3 | Thomas Schöpping | /* meta */ {
|
201 | f606f432 | Thomas Schöpping | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
202 | 9ae7c4f3 | Thomas Schöpping | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
203 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
204 | }, |
||
205 | }; |
||
206 | |||
207 | /**
|
||
208 | f606f432 | Thomas Schöpping | * @brief LIGHT_XLAT output signal GPIO.
|
209 | 9ae7c4f3 | Thomas Schöpping | */
|
210 | f606f432 | Thomas Schöpping | static apalGpio_t _gpioLightXlat = {
|
211 | /* line */ LINE_LIGHT_XLAT,
|
||
212 | 9ae7c4f3 | Thomas Schöpping | }; |
213 | f606f432 | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioLightXlat = { |
214 | /* GPIO */ &_gpioLightXlat,
|
||
215 | 9ae7c4f3 | Thomas Schöpping | /* meta */ {
|
216 | f606f432 | Thomas Schöpping | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
217 | /* active state */ (TLC5947_LLD_XLAT_UPDATE_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
||
218 | 9ae7c4f3 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
219 | }, |
||
220 | }; |
||
221 | |||
222 | /**
|
||
223 | f606f432 | Thomas Schöpping | * @brief SW_V18_EN output signal GPIO.
|
224 | 9ae7c4f3 | Thomas Schöpping | */
|
225 | f606f432 | Thomas Schöpping | static apalGpio_t _gpioSwV18En = {
|
226 | /* line */ LINE_SW_V18_EN,
|
||
227 | 9ae7c4f3 | Thomas Schöpping | }; |
228 | f606f432 | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSwV18En = { |
229 | /* GPIO */ &_gpioSwV18En,
|
||
230 | 9ae7c4f3 | Thomas Schöpping | /* meta */ {
|
231 | f606f432 | Thomas Schöpping | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
232 | /* active state */ MIC9404x_LLD_EN_ACTIVE_STATE,
|
||
233 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
234 | 9ae7c4f3 | Thomas Schöpping | }, |
235 | }; |
||
236 | |||
237 | /**
|
||
238 | f606f432 | Thomas Schöpping | * @brief SW_VSYS_EN output signal GPIO.
|
239 | 9ae7c4f3 | Thomas Schöpping | */
|
240 | f606f432 | Thomas Schöpping | static apalGpio_t _gpioSwVsysEn = {
|
241 | /* line */ LINE_SW_VSYS_EN,
|
||
242 | 0b989911 | Cung Sang | }; |
243 | f606f432 | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSwVsysEn = { |
244 | /* GPIO */ &_gpioSwVsysEn,
|
||
245 | 0b989911 | Cung Sang | /* meta */ {
|
246 | f606f432 | Thomas Schöpping | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
247 | /* active state */ APAL_GPIO_ACTIVE_HIGH,
|
||
248 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
249 | 0b989911 | Cung Sang | }, |
250 | }; |
||
251 | |||
252 | /**
|
||
253 | f606f432 | Thomas Schöpping | * @brief SYS_UART_UP bidirectional signal GPIO.
|
254 | 0b989911 | Cung Sang | */
|
255 | f606f432 | Thomas Schöpping | static apalGpio_t _gpioSysUartUp = {
|
256 | /* line */ LINE_SYS_UART_UP,
|
||
257 | 9ae7c4f3 | Thomas Schöpping | }; |
258 | f606f432 | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysUartUp = { |
259 | /* GPIO */ &_gpioSysUartUp,
|
||
260 | 9ae7c4f3 | Thomas Schöpping | /* meta */ {
|
261 | 0b989911 | Cung Sang | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
262 | 9ae7c4f3 | Thomas Schöpping | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
263 | f606f432 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
264 | 9ae7c4f3 | Thomas Schöpping | }, |
265 | }; |
||
266 | |||
267 | /**
|
||
268 | f606f432 | Thomas Schöpping | * @brief SYS_PD bidirectional signal GPIO.
|
269 | 0b989911 | Cung Sang | */
|
270 | f606f432 | Thomas Schöpping | static apalGpio_t _gpioSysPd = {
|
271 | /* line */ LINE_SYS_PD_N,
|
||
272 | 0b989911 | Cung Sang | }; |
273 | f606f432 | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysPd = { |
274 | /* GPIO */ &_gpioSysPd,
|
||
275 | 0b989911 | Cung Sang | /* meta */ {
|
276 | f606f432 | Thomas Schöpping | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
277 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
278 | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
||
279 | 0b989911 | Cung Sang | }, |
280 | }; |
||
281 | |||
282 | /**
|
||
283 | f606f432 | Thomas Schöpping | * @brief SYS_SYNC bidirectional signal GPIO.
|
284 | 0b989911 | Cung Sang | */
|
285 | f606f432 | Thomas Schöpping | static apalGpio_t _gpioSysSync = {
|
286 | /* line */ LINE_SYS_INT_N,
|
||
287 | 0b989911 | Cung Sang | }; |
288 | f606f432 | Thomas Schöpping | ROMCONST apalControlGpio_t moduleGpioSysSync = { |
289 | /* GPIO */ &_gpioSysSync,
|
||
290 | 0b989911 | Cung Sang | /* meta */ {
|
291 | f606f432 | Thomas Schöpping | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
292 | 0b989911 | Cung Sang | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
293 | f606f432 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
294 | 0b989911 | Cung Sang | }, |
295 | }; |
||
296 | f606f432 | Thomas Schöpping | |
297 | 0b989911 | Cung Sang | /**
|
298 | f606f432 | Thomas Schöpping | * @brief IO_1 breakout signal GPIO.
|
299 | 9ae7c4f3 | Thomas Schöpping | */
|
300 | f606f432 | Thomas Schöpping | static apalGpio_t _gpioBreakoutIo1 = {
|
301 | /* line */ LINE_IO_1,
|
||
302 | 9ae7c4f3 | Thomas Schöpping | }; |
303 | f606f432 | Thomas Schöpping | |
304 | /**
|
||
305 | * @brief IO_2 breakout signal GPIO.
|
||
306 | */
|
||
307 | static apalGpio_t _gpioBreakoutIo2 = {
|
||
308 | /* line */ LINE_IO_2,
|
||
309 | }; |
||
310 | |||
311 | /**
|
||
312 | * @brief IO_3 breakout signal GPIO.
|
||
313 | */
|
||
314 | static apalGpio_t _gpioBreakoutIo3 = {
|
||
315 | /* line */ LINE_IO_3,
|
||
316 | }; |
||
317 | |||
318 | /**
|
||
319 | * @brief IO_4 breakout signal GPIO.
|
||
320 | */
|
||
321 | static apalGpio_t _gpioBreakoutIo4 = {
|
||
322 | /* line */ LINE_IO_4,
|
||
323 | }; |
||
324 | |||
325 | /**
|
||
326 | * @brief IO_5 breakout signal GPIO.
|
||
327 | */
|
||
328 | static apalGpio_t _gpioBreakoutIo5 = {
|
||
329 | /* line */ LINE_IO_5,
|
||
330 | }; |
||
331 | |||
332 | /**
|
||
333 | * @brief IO_6 breakout signal GPIO.
|
||
334 | */
|
||
335 | static apalGpio_t _gpioBreakoutIo6 = {
|
||
336 | /* line */ LINE_IO_6,
|
||
337 | 9ae7c4f3 | Thomas Schöpping | }; |
338 | |||
339 | /**
|
||
340 | 0b989911 | Cung Sang | * @brief IO_7 breakout signal GPIO.
|
341 | */
|
||
342 | static apalGpio_t _gpioBreakoutIo7 = {
|
||
343 | /* line */ LINE_IO_7,
|
||
344 | }; |
||
345 | f606f432 | Thomas Schöpping | |
346 | /**
|
||
347 | * @brief IO_8 breakout signal GPIO.
|
||
348 | */
|
||
349 | static apalGpio_t _gpioBreakoutIo8 = {
|
||
350 | /* line */ LINE_IO_8,
|
||
351 | }; |
||
352 | |||
353 | #if (BOARD_BREAKOUT_MODULE == BOARD_BREAKOUT_NONE)
|
||
354 | |||
355 | apalControlGpio_t moduleGpioBreakoutIo1 = { |
||
356 | /* GPIO */ &_gpioBreakoutIo1,
|
||
357 | 0b989911 | Cung Sang | /* meta */ {
|
358 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
359 | f606f432 | Thomas Schöpping | /* active state */ APAL_GPIO_ACTIVE_NONE,
|
360 | 0b989911 | Cung Sang | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
361 | }, |
||
362 | }; |
||
363 | |||
364 | apalControlGpio_t moduleGpioBreakoutIo2 = { |
||
365 | /* GPIO */ &_gpioBreakoutIo2,
|
||
366 | /* meta */ {
|
||
367 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
368 | f606f432 | Thomas Schöpping | /* active state */ APAL_GPIO_ACTIVE_NONE,
|
369 | 0b989911 | Cung Sang | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
370 | }, |
||
371 | }; |
||
372 | |||
373 | f606f432 | Thomas Schöpping | apalControlGpio_t moduleGpioBreakoutIo3 = { |
374 | /* GPIO */ &_gpioBreakoutIo3,
|
||
375 | /* meta */ {
|
||
376 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
377 | /* active state */ APAL_GPIO_ACTIVE_NONE,
|
||
378 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
379 | }, |
||
380 | 9ae7c4f3 | Thomas Schöpping | }; |
381 | f606f432 | Thomas Schöpping | |
382 | 9ae7c4f3 | Thomas Schöpping | apalControlGpio_t moduleGpioBreakoutIo4 = { |
383 | /* GPIO */ &_gpioBreakoutIo4,
|
||
384 | /* meta */ {
|
||
385 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
386 | f606f432 | Thomas Schöpping | /* active state */ APAL_GPIO_ACTIVE_NONE,
|
387 | 9ae7c4f3 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
388 | }, |
||
389 | }; |
||
390 | |||
391 | f606f432 | Thomas Schöpping | apalControlGpio_t moduleGpioBreakoutIo5 = { |
392 | /* GPIO */ &_gpioBreakoutIo5,
|
||
393 | 9ae7c4f3 | Thomas Schöpping | /* meta */ {
|
394 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
395 | f606f432 | Thomas Schöpping | /* active state */ APAL_GPIO_ACTIVE_NONE,
|
396 | 9ae7c4f3 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
397 | }, |
||
398 | }; |
||
399 | |||
400 | f606f432 | Thomas Schöpping | apalControlGpio_t moduleGpioBreakoutIo6 = { |
401 | /* GPIO */ &_gpioBreakoutIo6,
|
||
402 | 9ae7c4f3 | Thomas Schöpping | /* meta */ {
|
403 | f606f432 | Thomas Schöpping | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
404 | /* active state */ APAL_GPIO_ACTIVE_NONE,
|
||
405 | 9ae7c4f3 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
406 | }, |
||
407 | }; |
||
408 | |||
409 | f606f432 | Thomas Schöpping | apalControlGpio_t moduleGpioBreakoutIo7 = { |
410 | /* GPIO */ &_gpioBreakoutIo7,
|
||
411 | c930aa01 | Thomas Schöpping | /* meta */ {
|
412 | f606f432 | Thomas Schöpping | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
413 | /* active state */ APAL_GPIO_ACTIVE_NONE,
|
||
414 | c930aa01 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
415 | }, |
||
416 | }; |
||
417 | |||
418 | f606f432 | Thomas Schöpping | apalControlGpio_t moduleGpioBreakoutIo8 = { |
419 | /* GPIO */ &_gpioBreakoutIo8,
|
||
420 | 9ae7c4f3 | Thomas Schöpping | /* meta */ {
|
421 | f606f432 | Thomas Schöpping | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
422 | /* active state */ APAL_GPIO_ACTIVE_NONE,
|
||
423 | 9ae7c4f3 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
424 | }, |
||
425 | }; |
||
426 | |||
427 | f606f432 | Thomas Schöpping | #elif (BOARD_BREAKOUT_MODULE == BOARD_BREAKOUT_UWBv10)
|
428 | |||
429 | apalControlGpio_t moduleGpioBreakoutIo1 = { |
||
430 | /* GPIO */ &_gpioBreakoutIo1,
|
||
431 | /* meta */ {
|
||
432 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
433 | /* active state */ APAL_GPIO_ACTIVE_NONE,
|
||
434 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
435 | }, |
||
436 | 9ae7c4f3 | Thomas Schöpping | }; |
437 | f606f432 | Thomas Schöpping | |
438 | apalControlGpio_t moduleGpioBreakoutIo2 = { |
||
439 | /* GPIO */ &_gpioBreakoutIo2,
|
||
440 | 9ae7c4f3 | Thomas Schöpping | /* meta */ {
|
441 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
442 | ee884101 | Thomas Schöpping | /* active state */ APAL_GPIO_ACTIVE_HIGH,
|
443 | 9ae7c4f3 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
444 | }, |
||
445 | }; |
||
446 | |||
447 | f606f432 | Thomas Schöpping | apalControlGpio_t moduleGpioBreakoutIo3 = { |
448 | /* GPIO */ &_gpioBreakoutIo3,
|
||
449 | /* meta */ {
|
||
450 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
451 | /* active state */ APAL_GPIO_ACTIVE_NONE,
|
||
452 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
453 | }, |
||
454 | 9ae7c4f3 | Thomas Schöpping | }; |
455 | f606f432 | Thomas Schöpping | |
456 | apalControlGpio_t moduleGpioBreakoutIo4 = { |
||
457 | /* GPIO */ &_gpioBreakoutIo4,
|
||
458 | 9ae7c4f3 | Thomas Schöpping | /* meta */ {
|
459 | f606f432 | Thomas Schöpping | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
460 | /* active state */ APAL_GPIO_ACTIVE_NONE,
|
||
461 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
462 | 9ae7c4f3 | Thomas Schöpping | }, |
463 | }; |
||
464 | |||
465 | f606f432 | Thomas Schöpping | apalControlGpio_t moduleGpioBreakoutIo5 = { |
466 | /* GPIO */ &_gpioBreakoutIo5,
|
||
467 | /* meta */ {
|
||
468 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
469 | /* active state */ APAL_GPIO_ACTIVE_NONE,
|
||
470 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
471 | }, |
||
472 | 9ae7c4f3 | Thomas Schöpping | }; |
473 | f606f432 | Thomas Schöpping | |
474 | apalControlGpio_t moduleGpioBreakoutIo6 = { |
||
475 | /* GPIO */ &_gpioBreakoutIo6,
|
||
476 | /* meta */ {
|
||
477 | /* direction */ APAL_GPIO_DIRECTION_UNDEFINED,
|
||
478 | /* active state */ APAL_GPIO_ACTIVE_NONE,
|
||
479 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
480 | }, |
||
481 | }; |
||
482 | |||
483 | apalControlGpio_t moduleGpioBreakoutIo7 = { |
||
484 | /* GPIO */ &_gpioBreakoutIo7,
|
||
485 | 9ae7c4f3 | Thomas Schöpping | /* meta */ {
|
486 | /* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
||
487 | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
||
488 | f606f432 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
489 | 9ae7c4f3 | Thomas Schöpping | }, |
490 | }; |
||
491 | |||
492 | f606f432 | Thomas Schöpping | apalControlGpio_t moduleGpioBreakoutIo8 = { |
493 | /* GPIO */ &_gpioBreakoutIo8,
|
||
494 | 9ae7c4f3 | Thomas Schöpping | /* meta */ {
|
495 | f606f432 | Thomas Schöpping | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
496 | 9ae7c4f3 | Thomas Schöpping | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
497 | f606f432 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_RISING,
|
498 | 9ae7c4f3 | Thomas Schöpping | }, |
499 | }; |
||
500 | |||
501 | f606f432 | Thomas Schöpping | #endif
|
502 | |||
503 | 9ae7c4f3 | Thomas Schöpping | /** @} */
|
504 | |||
505 | /*===========================================================================*/
|
||
506 | /**
|
||
507 | * @name AMiRo-OS core configurations
|
||
508 | * @{
|
||
509 | */
|
||
510 | /*===========================================================================*/
|
||
511 | |||
512 | 47e89ebf | Thomas Schöpping | #if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
513 | 9ae7c4f3 | Thomas Schöpping | ROMCONST char* moduleShellPrompt = "LightRing"; |
514 | 47e89ebf | Thomas Schöpping | #endif /* (AMIROOS_CFG_SHELL_ENABLE == true) */ |
515 | 9ae7c4f3 | Thomas Schöpping | |
516 | /** @} */
|
||
517 | |||
518 | /*===========================================================================*/
|
||
519 | /**
|
||
520 | * @name Startup Shutdown Synchronization Protocol (SSSP)
|
||
521 | * @{
|
||
522 | */
|
||
523 | /*===========================================================================*/
|
||
524 | |||
525 | /** @} */
|
||
526 | |||
527 | /*===========================================================================*/
|
||
528 | /**
|
||
529 | * @name Low-level drivers
|
||
530 | * @{
|
||
531 | */
|
||
532 | /*===========================================================================*/
|
||
533 | |||
534 | AT24C01BDriver moduleLldEeprom = { |
||
535 | ee884101 | Thomas Schöpping | /* I2C driver */ &MODULE_HAL_I2C_EEPROM_PWRMTR_BREAKOUT,
|
536 | 9ae7c4f3 | Thomas Schöpping | /* I2C address */ 0x00u, |
537 | }; |
||
538 | |||
539 | ee884101 | Thomas Schöpping | INA219Driver moduleLldPowerMonitorVled = { |
540 | /* I2C Driver */ &MODULE_HAL_I2C_EEPROM_PWRMTR_BREAKOUT,
|
||
541 | /* I²C address */ INA219_LLD_I2C_ADDR_FIXED,
|
||
542 | /* current LSB (uA) */ 0x00u, |
||
543 | /* configuration */ NULL, |
||
544 | }; |
||
545 | |||
546 | LEDDriver moduleLldStatusLed = { |
||
547 | /* LED enable Gpio */ &moduleGpioLed,
|
||
548 | }; |
||
549 | |||
550 | MIC9404xDriver moduleLldPowerSwitchV18 = { |
||
551 | /* power enable GPIO */ &moduleGpioSwV18En,
|
||
552 | }; |
||
553 | |||
554 | MIC9404xDriver moduleLldPowerSwitchV33 = { |
||
555 | /* power enable GPIO */ &moduleGpioSwV33En,
|
||
556 | }; |
||
557 | |||
558 | 9acb8326 | Thomas Schöpping | // The 4.2V switch is disabled due to a hardware bug.
|
559 | //MIC9404xDriver moduleLldPowerSwitchV42 = {
|
||
560 | // /* power enable GPIO */ &moduleGpioSwV42En,
|
||
561 | //};
|
||
562 | ee884101 | Thomas Schöpping | |
563 | MIC9404xDriver moduleLldPowerSwitchV50 = { |
||
564 | /* power enable GPIO */ &moduleGpioSwV50En,
|
||
565 | }; |
||
566 | |||
567 | MIC9404xDriver moduleLldPowerSwitchVsys = { |
||
568 | /* power enable GPIO */ &moduleGpioSwVsysEn,
|
||
569 | }; |
||
570 | |||
571 | 4c72a54c | Thomas Schöpping | // TODO: add SNx5C3221E
|
572 | |||
573 | 9ae7c4f3 | Thomas Schöpping | TLC5947Driver moduleLldLedPwm = { |
574 | /* SPI driver */ &MODULE_HAL_SPI_LIGHT,
|
||
575 | /* BLANK signal GPIO */ &moduleGpioLightBlank,
|
||
576 | c930aa01 | Thomas Schöpping | /* XLAT signal GPIO */ &moduleGpioLightXlat,
|
577 | 9ae7c4f3 | Thomas Schöpping | }; |
578 | |||
579 | f606f432 | Thomas Schöpping | #if (BOARD_BREAKOUT_MODULE == BOARD_BREAKOUT_UWBv10)
|
580 | |||
581 | 0b989911 | Cung Sang | DW1000Driver moduleLldDw1000 = { |
582 | f606f432 | Thomas Schöpping | /* SPI driver */ &MODULE_HAL_SPI_UWB,
|
583 | /* interrupt GPIO */ &moduleGpioBreakoutIo8,
|
||
584 | /* reset GPIO */ &moduleGpioBreakoutIo7,
|
||
585 | 0b989911 | Cung Sang | }; |
586 | |||
587 | f606f432 | Thomas Schöpping | #endif /* (BOARD_BREAKOUT_MODULE == BOARD_BREAKOUT_UWBv10) */ |
588 | 0b989911 | Cung Sang | |
589 | 9ae7c4f3 | Thomas Schöpping | /** @} */
|
590 | |||
591 | /*===========================================================================*/
|
||
592 | /**
|
||
593 | 4c72a54c | Thomas Schöpping | * @name Tests
|
594 | 9ae7c4f3 | Thomas Schöpping | * @{
|
595 | */
|
||
596 | /*===========================================================================*/
|
||
597 | #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
598 | |||
599 | /*
|
||
600 | 4c72a54c | Thomas Schöpping | * AT24C01BN-SH-B (EEPROM)
|
601 | 9ae7c4f3 | Thomas Schöpping | */
|
602 | 4c72a54c | Thomas Schöpping | #include <module_test_AT24C01B.h> |
603 | static int _testAt24co1bShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
604 | 9ae7c4f3 | Thomas Schöpping | { |
605 | 4c72a54c | Thomas Schöpping | return moduleTestAt24c01bShellCb(stream, argc, argv, NULL); |
606 | 9ae7c4f3 | Thomas Schöpping | } |
607 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestAt24c01bShellCmd, "test:EEPROM", _testAt24co1bShellCmdCb);
|
608 | 9ae7c4f3 | Thomas Schöpping | |
609 | /*
|
||
610 | ee884101 | Thomas Schöpping | * INA219 (power monitor)
|
611 | */
|
||
612 | 4c72a54c | Thomas Schöpping | #include <module_test_INA219.h> |
613 | static int _testIna219ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
614 | ee884101 | Thomas Schöpping | { |
615 | 4c72a54c | Thomas Schöpping | return moduleTestIna219ShellCb(stream, argc, argv, NULL); |
616 | ee884101 | Thomas Schöpping | } |
617 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestIna219ShellCmd, "test:PowerMonitor", _testIna219ShellCmdCb);
|
618 | ee884101 | Thomas Schöpping | |
619 | /*
|
||
620 | * Status LED
|
||
621 | */
|
||
622 | 4c72a54c | Thomas Schöpping | #include <module_test_LED.h> |
623 | static int _testLedShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
624 | ee884101 | Thomas Schöpping | { |
625 | 4c72a54c | Thomas Schöpping | return moduleTestLedShellCb(stream, argc, argv, NULL); |
626 | ee884101 | Thomas Schöpping | } |
627 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestLedShellCmd, "test:StatusLED", _testLedShellCmdCb);
|
628 | ee884101 | Thomas Schöpping | |
629 | /*
|
||
630 | 4c72a54c | Thomas Schöpping | * MIC9404x (power switch)
|
631 | ee884101 | Thomas Schöpping | */
|
632 | 4c72a54c | Thomas Schöpping | #include <module_test_MIC9404x.h> |
633 | static int _testMic9404xShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
634 | ee884101 | Thomas Schöpping | { |
635 | 4c72a54c | Thomas Schöpping | return moduleTestMic9404xShellCb(stream, argc, argv, NULL); |
636 | ee884101 | Thomas Schöpping | } |
637 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestMic9404xShellCmd, "test:PowerSwitch", _testMic9404xShellCmdCb);
|
638 | |||
639 | // TODO: add SNx5C3221E
|
||
640 | |||
641 | /*
|
||
642 | * TLC5947 (24 channel PWM LED driver)
|
||
643 | */
|
||
644 | #include <module_test_TLC5947.h> |
||
645 | static int _testTlc5947ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
646 | { |
||
647 | return moduleTestTlc5947ShellCb(stream, argc, argv, NULL); |
||
648 | } |
||
649 | AOS_SHELL_COMMAND(moduleTestTlc5947ShellCmd, "test:Lights", _testTlc5947ShellCmdCb);
|
||
650 | ee884101 | Thomas Schöpping | |
651 | f606f432 | Thomas Schöpping | #if (BOARD_BREAKOUT_MODULE == BOARD_BREAKOUT_UWBv10)
|
652 | |||
653 | 0b989911 | Cung Sang | /*
|
654 | * UwB Driver (DW1000)
|
||
655 | */
|
||
656 | #include <module_test_DW1000.h> |
||
657 | static int _testDw1000ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
658 | { |
||
659 | return moduleTestDw1000ShellCb(stream, argc, argv, NULL); |
||
660 | } |
||
661 | AOS_SHELL_COMMAND(moduleTestDw1000ShellCmd, "test:DW1000", _testDw1000ShellCmdCb);
|
||
662 | f606f432 | Thomas Schöpping | |
663 | #endif /* (BOARD_BREAKOUT_MODULE == BOARD_BREAKOUT_UWBv10) */ |
||
664 | 0b989911 | Cung Sang | |
665 | ee884101 | Thomas Schöpping | /*
|
666 | 4c72a54c | Thomas Schöpping | * entire module
|
667 | 9ae7c4f3 | Thomas Schöpping | */
|
668 | 4c72a54c | Thomas Schöpping | static int _testAllShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
669 | 9ae7c4f3 | Thomas Schöpping | { |
670 | (void)argc;
|
||
671 | (void)argv;
|
||
672 | 4c72a54c | Thomas Schöpping | |
673 | int status = AOS_OK;
|
||
674 | char* targv[AMIROOS_CFG_SHELL_MAXARGS] = {NULL}; |
||
675 | aos_testresult_t result_test = {0, 0}; |
||
676 | aos_testresult_t result_total = {0, 0}; |
||
677 | |||
678 | /* AT24C01B (EEPROM) */
|
||
679 | status |= moduleTestAt24c01bShellCb(stream, 0, targv, &result_test);
|
||
680 | result_total = aosTestResultAdd(result_total, result_test); |
||
681 | |||
682 | /* INA219 (power monitor) */
|
||
683 | status |= moduleTestIna219ShellCb(stream, 0, targv, &result_test);
|
||
684 | result_total = aosTestResultAdd(result_total, result_test); |
||
685 | |||
686 | /* Status LED */
|
||
687 | status |= moduleTestLedShellCb(stream, 0, targv, &result_test);
|
||
688 | result_total = aosTestResultAdd(result_total, result_test); |
||
689 | |||
690 | /* MIC9404x (power switch) */
|
||
691 | // 1.8V
|
||
692 | targv[1] = "1.8V"; |
||
693 | status |= moduleTestMic9404xShellCb(stream, 2, targv, &result_test);
|
||
694 | result_total = aosTestResultAdd(result_total, result_test); |
||
695 | // 3.3V
|
||
696 | targv[1] = "3.3V"; |
||
697 | status |= moduleTestMic9404xShellCb(stream, 2, targv, &result_test);
|
||
698 | result_total = aosTestResultAdd(result_total, result_test); |
||
699 | // The 4.2V switch is disabled due to a hardware bug.
|
||
700 | // // 4.2V
|
||
701 | // targv[1] = "4.2V";
|
||
702 | // status |= moduleTestMic9404xShellCb(stream, 2, targv, &result_test);
|
||
703 | // result_total = aosTestResultAdd(result_total, result_test);
|
||
704 | // 5.0V
|
||
705 | targv[1] = "5.0V"; |
||
706 | status |= moduleTestMic9404xShellCb(stream, 2, targv, &result_test);
|
||
707 | result_total = aosTestResultAdd(result_total, result_test); |
||
708 | //VSYS
|
||
709 | targv[1] = "VSYS"; |
||
710 | status |= moduleTestMic9404xShellCb(stream, 2, targv, &result_test);
|
||
711 | result_total = aosTestResultAdd(result_total, result_test); |
||
712 | targv[1] = ""; |
||
713 | |||
714 | // TODO: add SNx5C3221E
|
||
715 | |||
716 | /* TLC5947 (24 channel PWM LED driver) */
|
||
717 | status |= moduleTestTlc5947ShellCb(stream, 0, targv, &result_test);
|
||
718 | result_total = aosTestResultAdd(result_total, result_test); |
||
719 | |||
720 | f606f432 | Thomas Schöpping | #if (BOARD_BREAKOUT_MODULE == BOARD_BREAKOUT_UWBv10)
|
721 | /* DW1000 (UWB transceiver) */
|
||
722 | status |= moduleTestDw1000ShellCb(stream, 0, targv, &result_test);
|
||
723 | result_total = aosTestResultAdd(result_total, result_test); |
||
724 | #endif /* (BOARD_BREAKOUT_MODULE == BOARD_BREAKOUT_UWBv10) */ |
||
725 | |||
726 | 4c72a54c | Thomas Schöpping | // print total result
|
727 | chprintf(stream, "\n");
|
||
728 | aosTestResultPrintSummary(stream, &result_total, "entire module");
|
||
729 | |||
730 | return status;
|
||
731 | 9ae7c4f3 | Thomas Schöpping | } |
732 | 4c72a54c | Thomas Schöpping | AOS_SHELL_COMMAND(moduleTestAllShellCmd, "test:all", _testAllShellCmdCb);
|
733 | |||
734 | 9ae7c4f3 | Thomas Schöpping | #endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
735 | |||
736 | /** @} */
|
||
737 | /** @} */ |