amiro-os / modules / NUCLEO-L476RG / module.c @ 98949060
History | View | Annotate | Download (6.107 KB)
| 1 | 27d0378b | Simon Welzel | /*
|
|---|---|---|---|
| 2 | AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
|
||
| 3 | 8543d0d9 | Thomas Schöpping | Copyright (C) 2016..2019 Thomas Schöpping et al.
|
| 4 | 27d0378b | Simon Welzel | |
| 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 | 126ace3c | Thomas Schöpping | * @brief Structures and constant for the NUCLEO-L476RG module.
|
| 22 | 27d0378b | Simon Welzel | *
|
| 23 | 126ace3c | Thomas Schöpping | * @addtogroup NUCLEO-L476RG_module
|
| 24 | 27d0378b | Simon Welzel | * @{
|
| 25 | */
|
||
| 26 | |||
| 27 | 126ace3c | Thomas Schöpping | #include <amiroos.h> |
| 28 | 27d0378b | Simon Welzel | |
| 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 | 4c72a54c | Thomas Schöpping | #if (BOARD_MPU6050_CONNECTED == true) |
| 53 | 126ace3c | Thomas Schöpping | |
| 54 | I2CConfig moduleHalI2c3Config = {
|
||
| 55 | 4c72a54c | Thomas Schöpping | /* timing reg */ 0, // configured later in MODULE_INIT_PERIPHERY_IF_MPU6050() hook |
| 56 | 126ace3c | Thomas Schöpping | /* CR1 */ 0, |
| 57 | /* CR2 */ 0, |
||
| 58 | }; |
||
| 59 | |||
| 60 | 4c72a54c | Thomas Schöpping | #endif /* (BOARD_MPU6050_CONNECTED == true) */ |
| 61 | 126ace3c | Thomas Schöpping | |
| 62 | 27d0378b | Simon Welzel | /** @} */
|
| 63 | |||
| 64 | 8543d0d9 | Thomas Schöpping | /*===========================================================================*/
|
| 65 | /**
|
||
| 66 | * @name GPIO definitions
|
||
| 67 | * @{
|
||
| 68 | */
|
||
| 69 | /*===========================================================================*/
|
||
| 70 | |||
| 71 | /**
|
||
| 72 | a0301104 | Thomas Schöpping | * @brief LED output signal GPIO.
|
| 73 | 8543d0d9 | Thomas Schöpping | */
|
| 74 | static apalGpio_t _gpioLed = {
|
||
| 75 | 3106e8cc | Thomas Schöpping | /* line */ LINE_LED_GREEN,
|
| 76 | 8543d0d9 | Thomas Schöpping | }; |
| 77 | ROMCONST apalControlGpio_t moduleGpioLed = {
|
||
| 78 | /* GPIO */ &_gpioLed,
|
||
| 79 | /* meta */ {
|
||
| 80 | /* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
||
| 81 | /* active state */ APAL_GPIO_ACTIVE_HIGH,
|
||
| 82 | /* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
||
| 83 | }, |
||
| 84 | }; |
||
| 85 | |||
| 86 | /**
|
||
| 87 | * @brief User button input signal GPIO.
|
||
| 88 | */
|
||
| 89 | static apalGpio_t _gpioUserButton = {
|
||
| 90 | 3106e8cc | Thomas Schöpping | /* line */ LINE_BUTTON,
|
| 91 | 8543d0d9 | Thomas Schöpping | }; |
| 92 | ROMCONST apalControlGpio_t moduleGpioUserButton = {
|
||
| 93 | /* GPIO */ &_gpioUserButton,
|
||
| 94 | /* meta */ {
|
||
| 95 | /* direction */ APAL_GPIO_DIRECTION_INPUT,
|
||
| 96 | 83e94d4b | Thomas Schöpping | /* active state */ APAL_GPIO_ACTIVE_LOW,
|
| 97 | 8543d0d9 | Thomas Schöpping | /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
| 98 | }, |
||
| 99 | }; |
||
| 100 | |||
| 101 | /** @} */
|
||
| 102 | 27d0378b | Simon Welzel | |
| 103 | /*===========================================================================*/
|
||
| 104 | /**
|
||
| 105 | * @name AMiRo-OS core configurations
|
||
| 106 | * @{
|
||
| 107 | */
|
||
| 108 | /*===========================================================================*/
|
||
| 109 | |||
| 110 | cda14729 | Thomas Schöpping | #if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
| 111 | a0301104 | Thomas Schöpping | ROMCONST char* moduleShellPrompt = "NUCLEO-L476RG"; |
| 112 | cda14729 | Thomas Schöpping | #endif /* (AMIROOS_CFG_SHELL_ENABLE == true) */ |
| 113 | 27d0378b | Simon Welzel | |
| 114 | 8543d0d9 | Thomas Schöpping | /** @} */
|
| 115 | 27d0378b | Simon Welzel | |
| 116 | 8543d0d9 | Thomas Schöpping | /*===========================================================================*/
|
| 117 | /**
|
||
| 118 | * @name Startup Shutdown Synchronization Protocol (SSSP)
|
||
| 119 | * @{
|
||
| 120 | */
|
||
| 121 | /*===========================================================================*/
|
||
| 122 | |||
| 123 | /** @} */
|
||
| 124 | |||
| 125 | /*===========================================================================*/
|
||
| 126 | /**
|
||
| 127 | * @name Low-level drivers
|
||
| 128 | * @{
|
||
| 129 | */
|
||
| 130 | /*===========================================================================*/
|
||
| 131 | |||
| 132 | 4c72a54c | Thomas Schöpping | LEDDriver moduleLldLed = {
|
| 133 | /* LED enable Gpio */ &moduleGpioLed,
|
||
| 134 | }; |
||
| 135 | |||
| 136 | ButtonDriver moduleLldUserButton = {
|
||
| 137 | /* Button Gpio */ &moduleGpioUserButton,
|
||
| 138 | }; |
||
| 139 | |||
| 140 | #if (BOARD_MPU6050_CONNECTED == true) |
||
| 141 | 126ace3c | Thomas Schöpping | |
| 142 | MPU6050Driver moduleLldMpu6050 = {
|
||
| 143 | /* I2C Driver */ &MODULE_HAL_I2C3,
|
||
| 144 | /* I²C address */ MPU6050_LLD_I2C_ADDR_FIXED,
|
||
| 145 | }; |
||
| 146 | |||
| 147 | 4c72a54c | Thomas Schöpping | #endif /* (BOARD_MPU6050_CONNECTED == true) */ |
| 148 | 126ace3c | Thomas Schöpping | |
| 149 | 8543d0d9 | Thomas Schöpping | /** @} */
|
| 150 | |||
| 151 | /*===========================================================================*/
|
||
| 152 | /**
|
||
| 153 | 4c72a54c | Thomas Schöpping | * @name Tests
|
| 154 | 8543d0d9 | Thomas Schöpping | * @{
|
| 155 | */
|
||
| 156 | /*===========================================================================*/
|
||
| 157 | #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
||
| 158 | 1678f270 | Simon Welzel | |
| 159 | 4c72a54c | Thomas Schöpping | /*
|
| 160 | * LED
|
||
| 161 | */
|
||
| 162 | #include <module_test_LED.h> |
||
| 163 | static int _testLedShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
| 164 | {
|
||
| 165 | return moduleTestLedShellCb(stream, argc, argv, NULL); |
||
| 166 | } |
||
| 167 | AOS_SHELL_COMMAND(moduleTestLedShellCmd, "test:LED", _testLedShellCmdCb);
|
||
| 168 | |||
| 169 | /*
|
||
| 170 | * User button
|
||
| 171 | */
|
||
| 172 | #include <module_test_button.h> |
||
| 173 | static int _testButtonShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
| 174 | {
|
||
| 175 | return moduleTestButtonShellCb(stream, argc, argv, NULL); |
||
| 176 | } |
||
| 177 | AOS_SHELL_COMMAND(moduleTestButtonShellCmd, "test:button", _testButtonShellCmdCb);
|
||
| 178 | |||
| 179 | #if (BOARD_MPU6050_CONNECTED == true) || defined(__DOXYGEN__) |
||
| 180 | |||
| 181 | /*
|
||
| 182 | * MPU6050 (accelerometer & gyroscope)
|
||
| 183 | */
|
||
| 184 | #include <module_test_MPU6050.h> |
||
| 185 | static int _testMpu6050ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
| 186 | {
|
||
| 187 | return moduleTestMpu6050ShellCb(stream, argc, argv, NULL); |
||
| 188 | } |
||
| 189 | AOS_SHELL_COMMAND(moduleTestMpu6050ShellCmd, "test:IMU", _testMpu6050ShellCmdCb);
|
||
| 190 | |||
| 191 | #endif /* (BOARD_MPU6050_CONNECTED == true) */ |
||
| 192 | 126ace3c | Thomas Schöpping | |
| 193 | 4c72a54c | Thomas Schöpping | /*
|
| 194 | * entire module
|
||
| 195 | */
|
||
| 196 | static int _testAllShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
||
| 197 | 126ace3c | Thomas Schöpping | {
|
| 198 | (void)argc;
|
||
| 199 | (void)argv;
|
||
| 200 | |||
| 201 | 4c72a54c | Thomas Schöpping | int status = AOS_OK;
|
| 202 | char* targv[AMIROOS_CFG_SHELL_MAXARGS] = {NULL}; |
||
| 203 | aos_testresult_t result_test = {0, 0};
|
||
| 204 | aos_testresult_t result_total = {0, 0};
|
||
| 205 | |||
| 206 | /* LED */
|
||
| 207 | status |= moduleTestLedShellCb(stream, 0, targv, &result_test);
|
||
| 208 | result_total = aosTestResultAdd(result_total, result_test); |
||
| 209 | |||
| 210 | /* User button */
|
||
| 211 | status |= moduleTestButtonShellCb(stream, 0, targv, &result_test);
|
||
| 212 | result_total = aosTestResultAdd(result_total, result_test); |
||
| 213 | |||
| 214 | /* MPU6050 (accelerometer & gyroscope) */
|
||
| 215 | #if (BOARD_MPU6050_CONNECTED == true) |
||
| 216 | status |= moduleTestMpu6050ShellCb(stream, 0, targv, &result_test);
|
||
| 217 | result_total = aosTestResultAdd(result_total, result_test); |
||
| 218 | #endif /* (BOARD_MPU6050_CONNECTED == true) */ |
||
| 219 | |||
| 220 | // print total result
|
||
| 221 | chprintf(stream, "\n");
|
||
| 222 | aosTestResultPrintSummary(stream, &result_total, "entire module");
|
||
| 223 | |||
| 224 | return status;
|
||
| 225 | } |
||
| 226 | AOS_SHELL_COMMAND(moduleTestAllShellCmd, "test:all", _testAllShellCmdCb);
|
||
| 227 | 126ace3c | Thomas Schöpping | |
| 228 | 7de0cc90 | Thomas Schöpping | #endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
| 229 | 8543d0d9 | Thomas Schöpping | |
| 230 | /** @} */
|
||
| 231 | 27d0378b | Simon Welzel | /** @} */ |