amiro-os / modules / NUCLEO-F103RB / module.c @ 3106e8cc
History | View | Annotate | Download (7.233 KB)
| 1 |
/*
|
|---|---|
| 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 |
* @brief Structures and constant for the NUCLEO-F103RB module.
|
| 22 |
*
|
| 23 |
* @addtogroup NUCLEO-F103RB_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 |
SerialConfig moduleHalProgIfConfig = {
|
| 46 |
/* bit rate */ 115200, |
| 47 |
/* CR1 */ 0, |
| 48 |
/* CR1 */ 0, |
| 49 |
/* CR1 */ 0, |
| 50 |
}; |
| 51 |
|
| 52 |
#if defined(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 /* defined(AMIROLLD_CFG_DW1000) */ |
| 74 |
|
| 75 |
/** @} */
|
| 76 |
|
| 77 |
/*===========================================================================*/
|
| 78 |
/**
|
| 79 |
* @name GPIO definitions
|
| 80 |
* @{
|
| 81 |
*/
|
| 82 |
/*===========================================================================*/
|
| 83 |
|
| 84 |
/**
|
| 85 |
* @brief LED output signal GPIO.
|
| 86 |
*/
|
| 87 |
static apalGpio_t _gpioLed = {
|
| 88 |
/* line */ PAL_LINE(GPIOA, GPIOA_LED_GREEN),
|
| 89 |
}; |
| 90 |
ROMCONST apalControlGpio_t moduleGpioLed = {
|
| 91 |
/* GPIO */ &_gpioLed,
|
| 92 |
/* meta */ {
|
| 93 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
| 94 |
/* active state */ APAL_GPIO_ACTIVE_HIGH,
|
| 95 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
| 96 |
}, |
| 97 |
}; |
| 98 |
|
| 99 |
#if defined(AMIROLLD_CFG_DW1000)
|
| 100 |
|
| 101 |
/**
|
| 102 |
* @brief DW1000 reset output signal GPIO.
|
| 103 |
*/
|
| 104 |
static apalGpio_t _gpioDw1000Reset = {
|
| 105 |
/* line */ PAL_LINE(GPIOA, GPIOA_ARD_A0),
|
| 106 |
}; |
| 107 |
ROMCONST apalControlGpio_t moduleGpioDw1000Reset = {
|
| 108 |
/* GPIO */ &_gpioDw1000Reset,
|
| 109 |
/* meta */ {
|
| 110 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
| 111 |
/* active state */ APAL_GPIO_ACTIVE_HIGH,
|
| 112 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
| 113 |
}, |
| 114 |
}; |
| 115 |
|
| 116 |
|
| 117 |
/**
|
| 118 |
* @brief DW1000 interrrupt input signal GPIO.
|
| 119 |
*/
|
| 120 |
static apalGpio_t _gpioDw1000Irqn = {
|
| 121 |
/* line */ PAL_LINE(GPIOB, GPIOB_ARD_D6),
|
| 122 |
}; |
| 123 |
ROMCONST apalControlGpio_t moduleGpioDw1000Irqn = {
|
| 124 |
/* GPIO */ &_gpioDw1000Irqn,
|
| 125 |
/* meta */ {
|
| 126 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
| 127 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
| 128 |
/* interrupt edge */ APAL_GPIO_EDGE_RISING,
|
| 129 |
}, |
| 130 |
}; |
| 131 |
|
| 132 |
|
| 133 |
/**
|
| 134 |
* @brief DW1000 SPI chip select output signal GPIO.
|
| 135 |
*/
|
| 136 |
static apalGpio_t _gpioSpiChipSelect = {
|
| 137 |
/* line */ PAL_LINE(GPIOB, GPIOB_PIN12),
|
| 138 |
}; |
| 139 |
ROMCONST apalControlGpio_t moduleGpioSpiChipSelect = {
|
| 140 |
/* GPIO */ &_gpioSpiChipSelect,
|
| 141 |
/* meta */ {
|
| 142 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
| 143 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
| 144 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
| 145 |
}, |
| 146 |
}; |
| 147 |
|
| 148 |
#endif /* defined(AMIROLLD_CFG_DW1000) */ |
| 149 |
|
| 150 |
/**
|
| 151 |
* @brief User button input signal GPIO.
|
| 152 |
*/
|
| 153 |
static apalGpio_t _gpioUserButton = {
|
| 154 |
/* line */ PAL_LINE(GPIOC, GPIOC_BUTTON),
|
| 155 |
}; |
| 156 |
ROMCONST apalControlGpio_t moduleGpioUserButton = {
|
| 157 |
/* GPIO */ &_gpioUserButton,
|
| 158 |
/* meta */ {
|
| 159 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
| 160 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
| 161 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
| 162 |
}, |
| 163 |
}; |
| 164 |
|
| 165 |
/** @} */
|
| 166 |
|
| 167 |
/*===========================================================================*/
|
| 168 |
/**
|
| 169 |
* @name AMiRo-OS core configurations
|
| 170 |
* @{
|
| 171 |
*/
|
| 172 |
/*===========================================================================*/
|
| 173 |
|
| 174 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
| 175 |
ROMCONST char* moduleShellPrompt = "NUCLEO-F103RB"; |
| 176 |
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */ |
| 177 |
|
| 178 |
/** @} */
|
| 179 |
|
| 180 |
/*===========================================================================*/
|
| 181 |
/**
|
| 182 |
* @name Startup Shutdown Synchronization Protocol (SSSP)
|
| 183 |
* @{
|
| 184 |
*/
|
| 185 |
/*===========================================================================*/
|
| 186 |
|
| 187 |
|
| 188 |
/*===========================================================================*/
|
| 189 |
/**
|
| 190 |
* @name Hardware specific wrappers Functions
|
| 191 |
* @{
|
| 192 |
*/
|
| 193 |
/*===========================================================================*/
|
| 194 |
|
| 195 |
#if defined(AMIROLLD_CFG_DW1000)
|
| 196 |
|
| 197 |
/*! @brief TODO: Manual implementation of SPI configuration. Somehow, it is necessary in NUCLEO-F103RB */
|
| 198 |
void dw1000_spi_init(void){ |
| 199 |
palSetPadMode(GPIOB, GPIOB_PIN13, PAL_MODE_STM32_ALTERNATE_PUSHPULL); |
| 200 |
palSetPadMode(GPIOB, GPIOB_PIN14, PAL_MODE_STM32_ALTERNATE_PUSHPULL); |
| 201 |
palSetPadMode(GPIOB, GPIOB_PIN15, PAL_MODE_STM32_ALTERNATE_PUSHPULL); |
| 202 |
palSetLineMode(moduleGpioSpiChipSelect.gpio->line, PAL_MODE_OUTPUT_PUSHPULL); |
| 203 |
apalGpioWrite(moduleGpioSpiChipSelect.gpio, APAL_GPIO_LOW); |
| 204 |
} |
| 205 |
|
| 206 |
#endif /* defined(AMIROLLD_CFG_DW1000) */ |
| 207 |
/** @} */
|
| 208 |
|
| 209 |
/*===========================================================================*/
|
| 210 |
/**
|
| 211 |
* @name Low-level drivers
|
| 212 |
* @{
|
| 213 |
*/
|
| 214 |
/*===========================================================================*/
|
| 215 |
|
| 216 |
#if defined(AMIROLLD_CFG_DW1000)
|
| 217 |
|
| 218 |
DW1000Driver moduleLldDw1000 = {
|
| 219 |
/* SPI driver */ &MODULE_HAL_SPI_UWB,
|
| 220 |
/* ext interrupt */ &moduleGpioDw1000Irqn,
|
| 221 |
/* RESET DW1000 */ &moduleGpioDw1000Reset,
|
| 222 |
}; |
| 223 |
|
| 224 |
#endif /* defined(AMIROLLD_CFG_DW1000) */ |
| 225 |
/** @} */
|
| 226 |
|
| 227 |
/*===========================================================================*/
|
| 228 |
/**
|
| 229 |
* @name Unit tests (UT)
|
| 230 |
* @{
|
| 231 |
*/
|
| 232 |
/*===========================================================================*/
|
| 233 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
| 234 |
|
| 235 |
#if defined(AMIROLLD_CFG_DW1000)
|
| 236 |
|
| 237 |
/*
|
| 238 |
* UwB Driver (DW1000)
|
| 239 |
*/
|
| 240 |
static int _utShellCmdCb_Dw1000(BaseSequentialStream* stream, int argc, char* argv[]) |
| 241 |
{
|
| 242 |
(void)argc;
|
| 243 |
(void)argv;
|
| 244 |
aosUtRun(stream, &moduleUtAlldDw1000, NULL);
|
| 245 |
return AOS_OK;
|
| 246 |
} |
| 247 |
aos_unittest_t moduleUtAlldDw1000 = {
|
| 248 |
/* info */ "DW1000", |
| 249 |
/* name */ "UWB System", |
| 250 |
/* test function */ utAlldDw1000Func,
|
| 251 |
/* shell command */ {
|
| 252 |
/* name */ "unittest:Uwb", |
| 253 |
/* callback */ _utShellCmdCb_Dw1000,
|
| 254 |
/* next */ NULL, |
| 255 |
}, |
| 256 |
/* data */ &moduleLldDw1000,
|
| 257 |
}; |
| 258 |
#endif /* defined(AMIROLLD_CFG_DW1000) */ |
| 259 |
|
| 260 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
| 261 |
|
| 262 |
/** @} */
|
| 263 |
/** @} */
|