Revision 4c72a54c modules/NUCLEO-L476RG/module.c

View differences:

modules/NUCLEO-L476RG/module.c
49 49
  /* CR1      */ 0,
50 50
};
51 51

  
52
#if defined(AMIROLLD_CFG_MPU6050)
52
#if (BOARD_MPU6050_CONNECTED == true)
53 53

  
54 54
I2CConfig moduleHalI2c3Config = {
55
  /* timing reg */ 0, // configured later in MODULE_INIT_PERIPHERY_COMM_MPU6050() hook
55
  /* timing reg */ 0, // configured later in MODULE_INIT_PERIPHERY_IF_MPU6050() hook
56 56
  /* CR1        */ 0,
57 57
  /* CR2        */ 0,
58 58
};
59 59

  
60
#endif /* defined(AMIROLLD_CFG_MPU6050) */
60
#endif /* (BOARD_MPU6050_CONNECTED == true) */
61 61

  
62 62
/** @} */
63 63

  
......
129 129
 */
130 130
/*===========================================================================*/
131 131

  
132
#if defined(AMIROLLD_CFG_MPU6050)
132
LEDDriver moduleLldLed = {
133
  /* LED enable Gpio */ &moduleGpioLed,
134
};
135

  
136
ButtonDriver moduleLldUserButton = {
137
  /* Button Gpio  */ &moduleGpioUserButton,
138
};
139

  
140
#if (BOARD_MPU6050_CONNECTED == true)
133 141

  
134 142
MPU6050Driver moduleLldMpu6050 = {
135 143
  /* I2C Driver       */ &MODULE_HAL_I2C3,
136 144
  /* I²C address      */ MPU6050_LLD_I2C_ADDR_FIXED,
137 145
};
138 146

  
139
#endif /* defined(AMIROLLD_CFG_MPU6050) */
147
#endif /* (BOARD_MPU6050_CONNECTED == true) */
140 148

  
141 149
/** @} */
142 150

  
143 151
/*===========================================================================*/
144 152
/**
145
 * @name Unit tests (UT)
153
 * @name Tests
146 154
 * @{
147 155
 */
148 156
/*===========================================================================*/
149 157
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
150 158

  
151
#if defined(AMIROLLD_CFG_MPU6050)
159
/*
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) */
152 192

  
153
/* MPU6050 */
154
static int _utShellCmdCb_AlldMpu6050(BaseSequentialStream* stream, int argc, char* argv[])
193
/*
194
 * entire module
195
 */
196
static int _testAllShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
155 197
{
156 198
  (void)argc;
157 199
  (void)argv;
158
  aosUtRun(stream, &moduleUtAlldMpu6050, NULL);
159
  return AOS_OK;
160
}
161
static ut_mpu6050data_t _utAlldMpu6050Data = {
162
   /* driver */ &moduleLldMpu6050,
163
  /* timeout  */ MICROSECONDS_PER_SECOND,
164
};
165
aos_unittest_t moduleUtAlldMpu6050 = {
166
  /* name           */ "MPU6050",
167
  /* info           */ "accelerometer and gyroscope",
168
  /* test function  */ utAlldMpu6050Func,
169
  /* shell command  */ {
170
    /* name     */ "unittest:Accelerometer&Gyroscope",
171
    /* callback */ _utShellCmdCb_AlldMpu6050,
172
    /* next     */ NULL,
173
  },
174
  /* data           */ &_utAlldMpu6050Data
175
};
176 200

  
177
#endif /* defined(AMIROLLD_CFG_MPU6050) */
201
  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);
178 227

  
179 228
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
180 229

  

Also available in: Unified diff