Revision 8d4d058e modules/NUCLEO-F103RB/module.c
modules/NUCLEO-F103RB/module.c | ||
---|---|---|
50 | 50 |
}; |
51 | 51 |
|
52 | 52 |
#if (BOARD_DW1000_CONNECTED == true) |
53 |
|
|
54 | 53 |
/*! SPI (high and low speed) configuration for DW1000 */ |
55 | 54 |
SPIConfig moduleHalSpiUwbHsConfig = { |
56 | 55 |
/* circular buffer mode */ false, |
... | ... | |
69 | 68 |
/* CR1 */ SPI_CR1_BR_1 | SPI_CR1_BR_0, |
70 | 69 |
/* CR2 */ 0, |
71 | 70 |
}; |
72 |
|
|
73 | 71 |
#endif /* (BOARD_DW1000_CONNECTED == true) */ |
74 | 72 |
|
75 | 73 |
/** @} */ |
... | ... | |
97 | 95 |
}; |
98 | 96 |
|
99 | 97 |
#if (BOARD_DW1000_CONNECTED == true) |
100 |
|
|
101 | 98 |
/** |
102 | 99 |
* @brief DW1000 reset output signal GPIO. |
103 | 100 |
*/ |
104 | 101 |
static apalGpio_t _gpioDw1000Reset = { |
105 |
/* line */ PAL_LINE(GPIOA, GPIOA_ARD_A0),
|
|
102 |
/* line */ LINE_ARD_D15, //PAL_LINE(GPIOA, GPIOA_ARD_A0)
|
|
106 | 103 |
}; |
107 | 104 |
ROMCONST apalControlGpio_t moduleGpioDw1000Reset = { |
108 | 105 |
/* GPIO */ &_gpioDw1000Reset, |
... | ... | |
118 | 115 |
* @brief DW1000 interrrupt input signal GPIO. |
119 | 116 |
*/ |
120 | 117 |
static apalGpio_t _gpioDw1000Irqn = { |
121 |
/* line */ PAL_LINE(GPIOB, GPIOB_ARD_D6),
|
|
118 |
/* line */ LINE_ARD_D14, // PAL_LINE(GPIOB, GPIOB_ARD_D6)
|
|
122 | 119 |
}; |
123 | 120 |
ROMCONST apalControlGpio_t moduleGpioDw1000Irqn = { |
124 | 121 |
/* GPIO */ &_gpioDw1000Irqn, |
... | ... | |
144 | 141 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE, |
145 | 142 |
}, |
146 | 143 |
}; |
147 |
|
|
148 | 144 |
#endif /* (BOARD_DW1000_CONNECTED == true) */ |
149 | 145 |
|
150 | 146 |
/** |
... | ... | |
194 | 190 |
/*===========================================================================*/ |
195 | 191 |
|
196 | 192 |
#if (BOARD_DW1000_CONNECTED == true) |
197 |
|
|
198 | 193 |
/*! @brief TODO: Manual implementation of SPI configuration. Somehow, it is necessary in NUCLEO-F103RB */ |
199 | 194 |
void dw1000_spi_init(void){ |
200 | 195 |
palSetPadMode(GPIOB, GPIOB_PIN13, PAL_MODE_STM32_ALTERNATE_PUSHPULL); |
... | ... | |
204 | 199 |
apalGpioWrite(moduleGpioSpiChipSelect.gpio, APAL_GPIO_LOW); |
205 | 200 |
} |
206 | 201 |
|
202 |
/*! @brief entry point to the IRQn event in DW1000 module |
|
203 |
* |
|
204 |
* */ |
|
205 |
void process_deca_irq(void){ |
|
206 |
do{ |
|
207 |
dwt_isr(); |
|
208 |
//while IRS line active (ARM can only do edge sensitive interrupts) |
|
209 |
}while(port_CheckEXT_IRQ() == 1); |
|
210 |
} |
|
211 |
|
|
212 |
/*! @brief Check the current value of GPIO pin and return the value */ |
|
213 |
apalGpioState_t port_CheckEXT_IRQ(void) { |
|
214 |
apalGpioState_t val; |
|
215 |
apalGpioRead(moduleGpioDw1000Irqn.gpio, &val); |
|
216 |
return val; |
|
217 |
} |
|
218 |
|
|
219 |
/*! @brief Manually set the chip select pin of the SPI */ |
|
220 |
void set_SPI_chip_select(void){ |
|
221 |
apalGpioWrite(moduleGpioSpiChipSelect.gpio, APAL_GPIO_HIGH); |
|
222 |
} |
|
223 |
|
|
224 |
/*! @brief Manually reset the chip select pin of the SPI */ |
|
225 |
void clear_SPI_chip_select(void){ |
|
226 |
apalGpioWrite(moduleGpioSpiChipSelect.gpio, APAL_GPIO_LOW); |
|
227 |
} |
|
228 |
|
|
229 |
/*! @brief Change the SPI speed configuration on the fly */ |
|
230 |
void setHighSpeed_SPI(bool speedValue, DW1000Driver* drv){ |
|
231 |
|
|
232 |
spiStop(drv->spid); |
|
233 |
|
|
234 |
if (speedValue == FALSE){ |
|
235 |
spiStart(drv->spid, &moduleHalSpiUwbLsConfig); // low speed spi configuration |
|
236 |
} |
|
237 |
else{ |
|
238 |
spiStart(drv->spid, &moduleHalSpiUwbHsConfig); // high speed spi configuration |
|
239 |
} |
|
240 |
} |
|
207 | 241 |
#endif /* (BOARD_DW1000_CONNECTED == true) */ |
208 | 242 |
/** @} */ |
209 | 243 |
|
... | ... | |
223 | 257 |
}; |
224 | 258 |
|
225 | 259 |
#if (BOARD_DW1000_CONNECTED == true) |
226 |
|
|
227 | 260 |
DW1000Driver moduleLldDw1000 = { |
228 | 261 |
/* SPI driver */ &MODULE_HAL_SPI_UWB, |
229 | 262 |
/* ext interrupt */ &moduleGpioDw1000Irqn, |
230 | 263 |
/* RESET DW1000 */ &moduleGpioDw1000Reset, |
231 | 264 |
}; |
232 |
|
|
233 | 265 |
#endif /* (BOARD_DW1000_CONNECTED == true) */ |
234 | 266 |
|
235 | 267 |
/** @} */ |
... | ... | |
263 | 295 |
AOS_SHELL_COMMAND(moduleTestButtonShellCmd, "test:button", _testButtonShellCmdCb); |
264 | 296 |
|
265 | 297 |
#if (BOARD_DW1000_CONNECTED == true) || defined(__DOXYGEN__) |
266 |
|
|
267 | 298 |
/* |
268 | 299 |
* UwB Driver (DW1000) |
269 | 300 |
*/ |
270 |
static int _utShellCmdCb_Dw1000(BaseSequentialStream* stream, int argc, char* argv[]) |
|
301 |
#include <module_test_DW1000.h> |
|
302 |
static int _testDw1000ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
|
271 | 303 |
{ |
272 |
(void)argc; |
|
273 |
(void)argv; |
|
274 |
aosUtRun(stream, &moduleUtAlldDw1000, NULL); |
|
275 |
return AOS_OK; |
|
304 |
return moduleTestDw1000ShellCb(stream, argc, argv, NULL); |
|
276 | 305 |
} |
277 |
aos_unittest_t moduleUtAlldDw1000 = { |
|
278 |
/* info */ "DW1000", |
|
279 |
/* name */ "UWB System", |
|
280 |
/* test function */ utAlldDw1000Func, |
|
281 |
/* shell command */ { |
|
282 |
/* name */ "unittest:Uwb", |
|
283 |
/* callback */ _utShellCmdCb_Dw1000, |
|
284 |
/* next */ NULL, |
|
285 |
}, |
|
286 |
/* data */ &moduleLldDw1000, |
|
287 |
}; |
|
306 |
AOS_SHELL_COMMAND(moduleTestDw1000ShellCmd, "test:DW1000", _testDw1000ShellCmdCb); |
|
288 | 307 |
#endif /* (BOARD_DW1000_CONNECTED == true) */ |
289 | 308 |
|
290 | 309 |
/* |
... | ... | |
308 | 327 |
status |= moduleTestButtonShellCb(stream, 0, targv, &result_test); |
309 | 328 |
result_total = aosTestResultAdd(result_total, result_test); |
310 | 329 |
|
330 |
#if (BOARD_DW1000_CONNECTED == true) || defined(__DOXYGEN__) |
|
311 | 331 |
/* DW1000 */ |
312 |
//TODO |
|
332 |
status |= moduleTestDw1000ShellCb(stream, 0, targv, &result_test); |
|
333 |
result_total = aosTestResultAdd(result_total, result_test); |
|
334 |
#endif /* (BOARD_DW1000_CONNECTED == true) */ |
|
313 | 335 |
|
314 | 336 |
// print total result |
315 | 337 |
chprintf(stream, "\n"); |
Also available in: Unified diff