Revision deaaa47e modules/NUCLEO-F103RB/module.c
modules/NUCLEO-F103RB/module.c | ||
---|---|---|
49 | 49 |
/* CR1 */ 0, |
50 | 50 |
}; |
51 | 51 |
|
52 |
#ifdef AMIROLLD_CFG_DW1000 |
|
53 |
|
|
54 |
/*! SPI (high and low speed) configuration for DW1000 */ |
|
55 |
SPIConfig moduleHalSpiUwbHsConfig = { |
|
56 |
/* circular buffer mode */ false, |
|
57 |
/* callback function pointer */ NULL, |
|
58 |
/* chip select line port */ GPIOB, |
|
59 |
/* chip select line pad number */ GPIOB_PIN12, |
|
60 |
/* CR1 */ 0, |
|
61 |
/* CR2 */ 0, |
|
62 |
}; |
|
63 |
|
|
64 |
SPIConfig moduleHalSpiUwbLsConfig = { |
|
65 |
/* circular buffer mode */ false, |
|
66 |
/* callback function pointer */ NULL, |
|
67 |
/* chip select line port */ GPIOB, |
|
68 |
/* chip select line pad number */ GPIOB_PIN12, |
|
69 |
/* CR1 */ SPI_CR1_BR_1 | SPI_CR1_BR_0, |
|
70 |
/* CR2 */ 0, |
|
71 |
}; |
|
72 |
|
|
73 |
#endif |
|
74 |
|
|
52 | 75 |
/** @} */ |
53 | 76 |
|
54 | 77 |
/*===========================================================================*/ |
... | ... | |
74 | 97 |
}, |
75 | 98 |
}; |
76 | 99 |
|
100 |
#ifdef AMIROLLD_CFG_DW1000 |
|
101 |
|
|
102 |
/** |
|
103 |
* @brief DW1000 reset output signal GPIO. |
|
104 |
*/ |
|
105 |
static apalGpio_t _gpioDw1000Reset = { |
|
106 |
/* port */ GPIOA, |
|
107 |
/* pad */ GPIOA_ARD_A0, // PIN0 |
|
108 |
}; |
|
109 |
ROMCONST apalControlGpio_t moduleGpioDw1000Reset = { |
|
110 |
/* GPIO */ &_gpioDw1000Reset, |
|
111 |
/* meta */ { |
|
112 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL, |
|
113 |
/* active state */ APAL_GPIO_ACTIVE_HIGH, |
|
114 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE, |
|
115 |
}, |
|
116 |
}; |
|
117 |
|
|
118 |
|
|
119 |
/** |
|
120 |
* @brief DW1000 interrrupt input signal GPIO. |
|
121 |
*/ |
|
122 |
static apalGpio_t _gpioDw1000Irqn = { |
|
123 |
/* port */ GPIOB, |
|
124 |
/* pad */ GPIOB_ARD_D6, // GPIOB_PIN10 |
|
125 |
}; |
|
126 |
ROMCONST apalControlGpio_t moduleGpioDw1000Irqn = { |
|
127 |
/* GPIO */ &_gpioDw1000Irqn, |
|
128 |
/* meta */ { |
|
129 |
/* direction */ APAL_GPIO_DIRECTION_INPUT, |
|
130 |
/* active state */ APAL_GPIO_ACTIVE_LOW, |
|
131 |
/* interrupt edge */ APAL_GPIO_EDGE_RISING, |
|
132 |
}, |
|
133 |
}; |
|
134 |
|
|
135 |
|
|
136 |
/** |
|
137 |
* @brief DW1000 SPI chip select output signal GPIO. |
|
138 |
*/ |
|
139 |
static apalGpio_t _gpioSpiChipSelect = { |
|
140 |
/* port */ GPIOB, |
|
141 |
/* pad */ GPIOB_PIN12, // GPIOB_PIN10 |
|
142 |
}; |
|
143 |
ROMCONST apalControlGpio_t moduleGpioSpiChipSelect = { |
|
144 |
/* GPIO */ &_gpioSpiChipSelect, |
|
145 |
/* meta */ { |
|
146 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT, |
|
147 |
/* active state */ APAL_GPIO_ACTIVE_LOW, |
|
148 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE, |
|
149 |
}, |
|
150 |
}; |
|
151 |
|
|
152 |
#endif /* AMIROLLD_CFG_DW1000 */ |
|
153 |
|
|
77 | 154 |
/** |
78 | 155 |
* @brief User button input signal GPIO. |
79 | 156 |
*/ |
... | ... | |
112 | 189 |
*/ |
113 | 190 |
/*===========================================================================*/ |
114 | 191 |
|
192 |
|
|
193 |
/*===========================================================================*/ |
|
194 |
/** |
|
195 |
* @name Hardware specific wrappers Functions |
|
196 |
* @{ |
|
197 |
*/ |
|
198 |
/*===========================================================================*/ |
|
199 |
|
|
200 |
#ifdef AMIROLLD_CFG_DW1000 |
|
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 |
|
|
213 |
/*! @brief Check the current value of GPIO pin and return the value */ |
|
214 |
apalGpioState_t port_CheckEXT_IRQ(void) { |
|
215 |
apalGpioState_t val; |
|
216 |
apalGpioRead(moduleGpioDw1000Irqn.gpio, &val); |
|
217 |
return val; |
|
218 |
} |
|
219 |
|
|
220 |
|
|
221 |
/*! @brief TODO: Manual implementation of SPI configuration. Somehow, it is necessary in NUCLEO-F103RB */ |
|
222 |
void dw1000_spi_init(void){ |
|
223 |
palSetPadMode(GPIOB, GPIOB_PIN13, PAL_MODE_STM32_ALTERNATE_PUSHPULL); |
|
224 |
palSetPadMode(GPIOB, GPIOB_PIN14, PAL_MODE_STM32_ALTERNATE_PUSHPULL); |
|
225 |
palSetPadMode(GPIOB, GPIOB_PIN15, PAL_MODE_STM32_ALTERNATE_PUSHPULL); |
|
226 |
palSetPadMode(moduleGpioSpiChipSelect.gpio->port, moduleGpioSpiChipSelect.gpio->pad, PAL_MODE_OUTPUT_PUSHPULL); |
|
227 |
apalGpioWrite(moduleGpioSpiChipSelect.gpio, APAL_GPIO_LOW); |
|
228 |
} |
|
229 |
|
|
230 |
#endif /* AMIROLLD_CFG_DW1000 */ |
|
115 | 231 |
/** @} */ |
116 | 232 |
|
117 | 233 |
/*===========================================================================*/ |
... | ... | |
121 | 237 |
*/ |
122 | 238 |
/*===========================================================================*/ |
123 | 239 |
|
240 |
#ifdef AMIROLLD_CFG_DW1000 |
|
241 |
|
|
242 |
DW1000Driver moduleLldDw1000 = { |
|
243 |
/* SPI driver */ &MODULE_HAL_SPI_UWB, |
|
244 |
/* ext interrupt */ &moduleGpioDw1000Irqn, |
|
245 |
/* RESET DW1000 */ &moduleGpioDw1000Reset, |
|
246 |
}; |
|
247 |
|
|
248 |
#endif /* AMIROLLD_CFG_DW1000 */ |
|
124 | 249 |
/** @} */ |
125 | 250 |
|
126 | 251 |
/*===========================================================================*/ |
... | ... | |
131 | 256 |
/*===========================================================================*/ |
132 | 257 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
133 | 258 |
|
259 |
#ifdef AMIROLLD_CFG_DW1000 |
|
260 |
|
|
261 |
/* |
|
262 |
* UwB Driver (DW1000) |
|
263 |
*/ |
|
264 |
static int _utShellCmdCb_Dw1000(BaseSequentialStream* stream, int argc, char* argv[]) |
|
265 |
{ |
|
266 |
(void)argc; |
|
267 |
(void)argv; |
|
268 |
aosUtRun(stream, &moduleUtAlldDw1000, NULL); |
|
269 |
return AOS_OK; |
|
270 |
} |
|
271 |
aos_unittest_t moduleUtAlldDw1000 = { |
|
272 |
/* info */ "DW1000", |
|
273 |
/* name */ "UWB System", |
|
274 |
/* test function */ utAlldDw1000Func, |
|
275 |
/* shell command */ { |
|
276 |
/* name */ "unittest:Uwb", |
|
277 |
/* callback */ _utShellCmdCb_Dw1000, |
|
278 |
/* next */ NULL, |
|
279 |
}, |
|
280 |
/* data */ &moduleLldDw1000, |
|
281 |
}; |
|
282 |
#endif /* AMIROLLD_CFG_DW1000 */ |
|
283 |
|
|
134 | 284 |
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */ |
135 | 285 |
|
136 | 286 |
/** @} */ |
Also available in: Unified diff