Revision 126ace3c
| modules/NUCLEO-L476RG/alldconf.h | ||
|---|---|---|
| 18 | 18 |
|
| 19 | 19 |
/** |
| 20 | 20 |
* @file |
| 21 |
* @brief AMiRo-LLD configuration file for the STM32L476RG-NUCLEO64 module.
|
|
| 21 |
* @brief AMiRo-LLD configuration file for the NUCLEO-L476RG module.
|
|
| 22 | 22 |
* @details Contains the application specific AMiRo-LLD settings. |
| 23 | 23 |
* |
| 24 |
* @addtogroup STM32L476RG-NUCLEO64_config
|
|
| 24 |
* @addtogroup NUCLEO-L476RG_config
|
|
| 25 | 25 |
* @{
|
| 26 | 26 |
*/ |
| 27 | 27 |
|
| ... | ... | |
| 43 | 43 |
*/ |
| 44 | 44 |
#define AMIROLLD_CFG_TIME_SIZE 32 |
| 45 | 45 |
|
| 46 |
/** |
|
| 47 |
* @brief Enable flag for the MPU6050 proximity sensor. |
|
| 48 |
* @note Uncomment this if the device is attached. |
|
| 49 |
*/ |
|
| 50 |
//#define AMIROLLD_CFG_MPU6050 1 |
|
| 51 |
|
|
| 46 | 52 |
#endif /* ALLDCONF_H */ |
| 47 | 53 |
|
| 48 | 54 |
/** @} */ |
| modules/NUCLEO-L476RG/aosconf.h | ||
|---|---|---|
| 18 | 18 |
|
| 19 | 19 |
/** |
| 20 | 20 |
* @file |
| 21 |
* @brief AMiRo-OS Configuration file for the STM32L476RG-NUCLEO64 module.
|
|
| 21 |
* @brief AMiRo-OS Configuration file for the NUCLEO-L476RG module.
|
|
| 22 | 22 |
* @details Contains the application specific AMiRo-OS settings. |
| 23 | 23 |
* |
| 24 |
* @addtogroup STM32L476RG-NUCLEO64_aos_config
|
|
| 24 |
* @addtogroup NUCLEO-L476RG_aos_config
|
|
| 25 | 25 |
* @{
|
| 26 | 26 |
*/ |
| 27 | 27 |
|
| modules/NUCLEO-L476RG/halconf.h | ||
|---|---|---|
| 18 | 18 |
|
| 19 | 19 |
/** |
| 20 | 20 |
* @file |
| 21 |
* @brief HAL configuration header for the DiWheelDrive v1.1 module.
|
|
| 21 |
* @brief HAL configuration header for the NUCLEO-L476RG module.
|
|
| 22 | 22 |
* @details HAL configuration file, this file allows to enable or disable the |
| 23 | 23 |
* various device drivers from your application. You may also use |
| 24 | 24 |
* this file in order to override the device drivers default settings. |
| 25 | 25 |
* |
| 26 |
* @addtogroup STM32L476RGNUCLEO64_HAL_CONF
|
|
| 26 |
* @addtogroup NUCLEO-L476RG_HAL_CONF
|
|
| 27 | 27 |
* @{
|
| 28 | 28 |
*/ |
| 29 | 29 |
|
| ... | ... | |
| 33 | 33 |
#define _CHIBIOS_HAL_CONF_ |
| 34 | 34 |
#define _CHIBIOS_HAL_CONF_VER_6_0_ |
| 35 | 35 |
|
| 36 |
#include <alldconf.h> |
|
| 36 | 37 |
#include "mcuconf.h" |
| 37 | 38 |
|
| 38 | 39 |
/** |
| ... | ... | |
| 88 | 89 |
* @brief Enables the I2C subsystem. |
| 89 | 90 |
*/ |
| 90 | 91 |
#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__) |
| 92 |
// enable if MPU6050 demo is enabled |
|
| 93 |
#if defined(AMIROLLD_CFG_MPU6050) |
|
| 94 |
#define HAL_USE_I2C TRUE |
|
| 95 |
#else |
|
| 91 | 96 |
#define HAL_USE_I2C FALSE |
| 92 | 97 |
#endif |
| 98 |
#endif |
|
| 93 | 99 |
|
| 94 | 100 |
/** |
| 95 | 101 |
* @brief Enables the I2S subsystem. |
| modules/NUCLEO-L476RG/module.c | ||
|---|---|---|
| 18 | 18 |
|
| 19 | 19 |
/** |
| 20 | 20 |
* @file |
| 21 |
* @brief Structures and constant for the STM32L476RG-NUCLEO64 module.
|
|
| 21 |
* @brief Structures and constant for the NUCLEO-L476RG module.
|
|
| 22 | 22 |
* |
| 23 |
* @addtogroup STM32L476RG-NUCLEO64_module
|
|
| 23 |
* @addtogroup NUCLEO-L476RG_module
|
|
| 24 | 24 |
* @{
|
| 25 | 25 |
*/ |
| 26 | 26 |
|
| 27 |
#include "module.h"
|
|
| 27 |
#include <amiroos.h>
|
|
| 28 | 28 |
|
| 29 | 29 |
/*===========================================================================*/ |
| 30 | 30 |
/** |
| ... | ... | |
| 49 | 49 |
/* CR1 */ 0, |
| 50 | 50 |
}; |
| 51 | 51 |
|
| 52 |
#if defined(AMIROLLD_CFG_MPU6050) |
|
| 53 |
|
|
| 54 |
I2CConfig moduleHalI2c3Config = {
|
|
| 55 |
/* timing reg */ 0, // configured later in MODULE_INIT_PERIPHERY_COMM_MPU6050() hook |
|
| 56 |
/* CR1 */ 0, |
|
| 57 |
/* CR2 */ 0, |
|
| 58 |
}; |
|
| 59 |
|
|
| 60 |
#endif /* defined(AMIROLLD_CFG_MPU6050) */ |
|
| 61 |
|
|
| 52 | 62 |
/** @} */ |
| 53 | 63 |
|
| 54 | 64 |
/*===========================================================================*/ |
| ... | ... | |
| 121 | 131 |
*/ |
| 122 | 132 |
/*===========================================================================*/ |
| 123 | 133 |
|
| 134 |
#if defined(AMIROLLD_CFG_MPU6050) |
|
| 135 |
|
|
| 136 |
MPU6050Driver moduleLldMpu6050 = {
|
|
| 137 |
/* I2C Driver */ &MODULE_HAL_I2C3, |
|
| 138 |
/* I²C address */ MPU6050_LLD_I2C_ADDR_FIXED, |
|
| 139 |
}; |
|
| 140 |
|
|
| 141 |
#endif /* defined(AMIROLLD_CFG_MPU6050) */ |
|
| 142 |
|
|
| 124 | 143 |
/** @} */ |
| 125 | 144 |
|
| 126 | 145 |
/*===========================================================================*/ |
| ... | ... | |
| 131 | 150 |
/*===========================================================================*/ |
| 132 | 151 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
| 133 | 152 |
|
| 153 |
#if defined(AMIROLLD_CFG_MPU6050) |
|
| 154 |
|
|
| 155 |
/* MPU6050 */ |
|
| 156 |
static int _utShellCmdCb_AlldMpu6050(BaseSequentialStream* stream, int argc, char* argv[]) |
|
| 157 |
{
|
|
| 158 |
(void)argc; |
|
| 159 |
(void)argv; |
|
| 160 |
aosUtRun(stream, &moduleUtAlldMpu6050, NULL); |
|
| 161 |
return AOS_OK; |
|
| 162 |
} |
|
| 163 |
static ut_mpu6050data_t _utAlldMpu6050Data = {
|
|
| 164 |
/* driver */ &moduleLldMpu6050, |
|
| 165 |
/* timeout */ MICROSECONDS_PER_SECOND, |
|
| 166 |
}; |
|
| 167 |
aos_unittest_t moduleUtAlldMpu6050 = {
|
|
| 168 |
/* name */ "MPU6050", |
|
| 169 |
/* info */ "accelerometer and gyroscope", |
|
| 170 |
/* test function */ utAlldMpu6050Func, |
|
| 171 |
/* shell command */ {
|
|
| 172 |
/* name */ "unittest:Accelerometer&Gyroscope", |
|
| 173 |
/* callback */ _utShellCmdCb_AlldMpu6050, |
|
| 174 |
/* next */ NULL, |
|
| 175 |
}, |
|
| 176 |
/* data */ &_utAlldMpu6050Data |
|
| 177 |
}; |
|
| 178 |
|
|
| 179 |
#endif /* defined(AMIROLLD_CFG_MPU6050) */ |
|
| 180 |
|
|
| 134 | 181 |
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */ |
| 135 | 182 |
|
| 136 | 183 |
/** @} */ |
| modules/NUCLEO-L476RG/module.h | ||
|---|---|---|
| 18 | 18 |
|
| 19 | 19 |
/** |
| 20 | 20 |
* @file |
| 21 |
* @brief Structures and constant for the STM32L476RG-NUCLEO64 module.
|
|
| 21 |
* @brief Structures and constant for the NUCLEO-L476RG module.
|
|
| 22 | 22 |
* |
| 23 |
* @addtogroup STM32L476RG-NUCLEO64_module
|
|
| 23 |
* @addtogroup NUCLEO-L476RG_module
|
|
| 24 | 24 |
* @{
|
| 25 | 25 |
*/ |
| 26 | 26 |
|
| ... | ... | |
| 28 | 28 |
#define AMIROOS_MODULE_H |
| 29 | 29 |
|
| 30 | 30 |
#include <amiroos.h> |
| 31 |
#include <math.h> |
|
| 31 | 32 |
|
| 32 | 33 |
/*===========================================================================*/ |
| 33 | 34 |
/** |
| ... | ... | |
| 60 | 61 |
*/ |
| 61 | 62 |
#define MODULE_HAL_RTC RTCD1 |
| 62 | 63 |
|
| 64 |
#if defined(AMIROLLD_CFG_MPU6050) |
|
| 65 |
|
|
| 66 |
/** |
|
| 67 |
* @brief I2C driver to access multiplexer, proximity sensors 5 to 8, power monitors for VSYS4.2, VIO 5.0 and VDD, EEPROM, touch sensor, and fuel gauge (front battery). |
|
| 68 |
*/ |
|
| 69 |
#define MODULE_HAL_I2C3 I2CD3 |
|
| 70 |
|
|
| 71 |
/** |
|
| 72 |
* @brief Configuration for the I2C driver #3. |
|
| 73 |
*/ |
|
| 74 |
extern I2CConfig moduleHalI2c3Config; |
|
| 75 |
|
|
| 76 |
#endif /* defined(AMIROLLD_CFG_MPU6050) */ |
|
| 77 |
|
|
| 63 | 78 |
/** @} */ |
| 64 | 79 |
|
| 65 | 80 |
/*===========================================================================*/ |
| ... | ... | |
| 115 | 130 |
*/ |
| 116 | 131 |
#define MODULE_INIT_TESTS() { \
|
| 117 | 132 |
/* add unit-test shell commands */ \ |
| 133 |
MODULE_INIT_TEST_MPU6050(); \ |
|
| 118 | 134 |
} |
| 135 |
#if defined(AMIROLLD_CFG_MPU6050) |
|
| 136 |
#define MODULE_INIT_TEST_MPU6050() { \
|
|
| 137 |
/* add unit-test shell commands */ \ |
|
| 138 |
aosShellAddCommand(&aos.shell, &moduleUtAlldMpu6050.shellcmd); \ |
|
| 139 |
} |
|
| 140 |
#else |
|
| 141 |
#define MODULE_INIT_TEST_MPU6050() {}
|
|
| 142 |
#endif |
|
| 119 | 143 |
|
| 120 | 144 |
/** |
| 121 | 145 |
* @brief Periphery communication interfaces initialization hook. |
| ... | ... | |
| 123 | 147 |
#define MODULE_INIT_PERIPHERY_COMM() { \
|
| 124 | 148 |
/* serial driver */ \ |
| 125 | 149 |
sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig); \ |
| 150 |
/* MPU6050 demo */ \ |
|
| 151 |
MODULE_INIT_PERIPHERY_COMM_MPU6050(); \ |
|
| 126 | 152 |
} |
| 153 |
#if defined(AMIROLLD_CFG_MPU6050) |
|
| 154 |
#define MODULE_INIT_PERIPHERY_COMM_MPU6050() { \
|
|
| 155 |
/* maximum I2C frequency is 1MHz for this MCU */ \ |
|
| 156 |
uint32_t i2c3_freq = 1000000; \ |
|
| 157 |
/* find minimum amon all devices connected to this bus */ \ |
|
| 158 |
i2c3_freq = (MPU6050_LLD_I2C_MAXFREQUENCY < i2c3_freq) ? MPU6050_LLD_I2C_MAXFREQUENCY : i2c3_freq; \ |
|
| 159 |
/* calculate PRESC (prescaler): \ |
|
| 160 |
* target is 1/(I2CXCLK * (PRESC + 1)) = 125ns \ |
|
| 161 |
*/ \ |
|
| 162 |
moduleHalI2c3Config.timingr = ((uint8_t)((0.000000125f * STM32_I2C3CLK) - 1)) << I2C_TIMINGR_PRESC_Pos; \ |
|
| 163 |
/* SCL shall be low half of the time. */ \ |
|
| 164 |
moduleHalI2c3Config.timingr |= ((uint8_t)((1.f / i2c3_freq / 2 / 0.000000125f) - 1)) << I2C_TIMINGR_SCLL_Pos; \ |
|
| 165 |
/* SCL shall be high half the time of low or slightly longer. */ \ |
|
| 166 |
moduleHalI2c3Config.timingr |= (uint8_t)(ceilf(((moduleHalI2c3Config.timingr & I2C_TIMINGR_SCLL_Msk) >> I2C_TIMINGR_SCLL_Pos) / 2.f)) << I2C_TIMINGR_SCLH_Pos; \ |
|
| 167 |
/* SDA shall be delayed 1/10 of SCL low, or shorter */ \ |
|
| 168 |
moduleHalI2c3Config.timingr |= (uint8_t)(((moduleHalI2c3Config.timingr & I2C_TIMINGR_SCLL_Msk) >> I2C_TIMINGR_SCLL_Pos) * 0.1f) << I2C_TIMINGR_SDADEL_Pos; \ |
|
| 169 |
/* SCL shall be delyed twice as long as SDA, but longer than 0. */ \ |
|
| 170 |
moduleHalI2c3Config.timingr |= ((((moduleHalI2c3Config.timingr & I2C_TIMINGR_SDADEL_Msk) >> I2C_TIMINGR_SDADEL_Pos) * 2) + 1) << I2C_TIMINGR_SCLDEL_Pos; \ |
|
| 171 |
/* now we can start the I2C driver */ \ |
|
| 172 |
i2cStart(&MODULE_HAL_I2C3, &moduleHalI2c3Config); \ |
|
| 173 |
} |
|
| 174 |
#else |
|
| 175 |
#define MODULE_INIT_PERIPHERY_COMM_MPU6050() {}
|
|
| 176 |
#endif |
|
| 127 | 177 |
|
| 128 | 178 |
/** |
| 129 | 179 |
* @brief Periphery communication interface deinitialization hook. |
| ... | ... | |
| 160 | 210 |
*/ |
| 161 | 211 |
/*===========================================================================*/ |
| 162 | 212 |
|
| 213 |
#if defined(AMIROLLD_CFG_MPU6050) |
|
| 214 |
|
|
| 215 |
#include <alld_MPU6050.h> |
|
| 216 |
|
|
| 217 |
/** |
|
| 218 |
* @brief Accelerometer (MPU6050) driver. |
|
| 219 |
*/ |
|
| 220 |
extern MPU6050Driver moduleLldMpu6050; |
|
| 221 |
|
|
| 222 |
#endif /* defined(AMIROLLD_CFG_MPU6050) */ |
|
| 223 |
|
|
| 163 | 224 |
/** @} */ |
| 164 | 225 |
|
| 165 | 226 |
/*===========================================================================*/ |
| ... | ... | |
| 170 | 231 |
/*===========================================================================*/ |
| 171 | 232 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
| 172 | 233 |
|
| 234 |
#if defined(AMIROLLD_CFG_MPU6050) |
|
| 235 |
|
|
| 236 |
#include <ut_alld_MPU6050_v1.h> |
|
| 237 |
|
|
| 238 |
/** |
|
| 239 |
* @brief MPU6050 unit test object. |
|
| 240 |
*/ |
|
| 241 |
extern aos_unittest_t moduleUtAlldMpu6050; |
|
| 242 |
|
|
| 243 |
#endif /* defined(AMIROLLD_CFG_MPU6050) */ |
|
| 244 |
|
|
| 173 | 245 |
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */ |
| 174 | 246 |
|
| 175 | 247 |
/** @} */ |
| modules/PowerManagement_1-1/module.h | ||
|---|---|---|
| 434 | 434 |
#define MODULE_INIT_TESTS() { \
|
| 435 | 435 |
/* add unit-test shell commands */ \ |
| 436 | 436 |
aosShellAddCommand(&aos.shell, &moduleUtAdcVsys.shellcmd); \ |
| 437 |
aosShellAddCommand(&aos.shell, &moduleUtAlldAt24c01b.shellcmd); \ |
|
| 437 |
aosShellAddCommand(&aos.shell, &moduleUtAlldAt24c01b.shellcmd); \
|
|
| 438 | 438 |
aosShellAddCommand(&aos.shell, &moduleUtAlldBq24103a.shellcmd); \ |
| 439 | 439 |
aosShellAddCommand(&aos.shell, &moduleUtAlldBq27500.shellcmd); \ |
| 440 | 440 |
aosShellAddCommand(&aos.shell, &moduleUtAlldBq27500Bq24103a.shellcmd); \ |
| periphery-lld/AMiRo-LLD | ||
|---|---|---|
| 1 |
Subproject commit 5d4d14a3a119bb8b75f59eaa33496d46e5963a7a |
|
| 1 |
Subproject commit b6364b519575c41733beff4c8df8b935f373ee53 |
|
| unittests/periphery-lld/src/ut_alld_MPU6050_v1.c | ||
|---|---|---|
| 49 | 49 |
{
|
| 50 | 50 |
aos_utresult_t result = {0, 0};
|
| 51 | 51 |
|
| 52 |
const mpu6050_lld_register_t addr = 0x75; // register to read from |
|
| 53 |
uint16_t const data; // buffer for data |
|
| 54 |
const uint8_t num = 1; // read one register |
|
| 55 |
const apalTime_t timeout = 100; // TODO: Check units |
|
| 52 |
uint8_t data[1] = {0};
|
|
| 53 |
uint32_t status = 0; |
|
| 56 | 54 |
|
| 55 |
status = mpu6050_lld_read_register(((ut_mpu6050data_t*)ut->data)->mpu, MPU6050_LLD_WHO_AM_I, data, 1, ((ut_mpu6050data_t*)ut->data)->timeout); |
|
| 56 |
if (status == APAL_STATUS_OK && data[0] == MPU6050_I_AM) {
|
|
| 57 |
aosUtPassed(stream, &result); |
|
| 58 |
} else {
|
|
| 59 |
aosUtFailedMsg(stream, &result, "0x%08X | 0x%02X\n", status, data[0]); |
|
| 60 |
} |
|
| 57 | 61 |
|
| 58 |
mpu6050_lld_read_register(((ut_mpu6050data_t*)ut->data)->mpu, addr, &data, num, ((ut_mpu6050data_t*)ut->data)->timeout); |
|
| 59 |
/** registers to read: |
|
| 60 |
0x75: WHO AM I (should return I2C-Adress without the last bit, which is determined by the state of the AO pin!) returns 0x68 |
|
| 61 |
*/ |
|
| 62 |
|
|
| 63 |
return result; // TODO: Adjust |
|
| 62 |
return result; |
|
| 64 | 63 |
} |
| 65 | 64 |
|
| 66 | 65 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_MPU6050) && (AMIROLLD_CFG_MPU6050 == 1) */ |
Also available in: Unified diff