Revision bffb3465
| modules/PowerManagement_1-1/alldconf.h | ||
|---|---|---|
| 106 | 106 |
#endif /* BOARD_SENSORRING == BOARD_PROXIMITYSENSOR */ |
| 107 | 107 |
|
| 108 | 108 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) || defined(__DOXYGEN__) |
| 109 |
// TODO |
|
| 109 |
|
|
| 110 |
/** |
|
| 111 |
* @brief Enable flag for the PCAL6524 GPIO extender |
|
| 112 |
*/ |
|
| 113 |
#define AMIROLLD_CFG_USE_PCAL6524 |
|
| 114 |
|
|
| 115 |
/** |
|
| 116 |
* @brief Enable flag for the AT42Q1050 touch sensor. |
|
| 117 |
*/ |
|
| 118 |
#define AMIROLLD_CFG_USE_AT42QT1050 |
|
| 119 |
|
|
| 110 | 120 |
#endif /* BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X */ |
| 111 | 121 |
|
| 112 | 122 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) || defined(__DOXYGEN__) |
| 113 |
// TODO |
|
| 123 |
|
|
| 124 |
/** |
|
| 125 |
* @brief Enable flag for the PCAL6524 GPIO extender |
|
| 126 |
*/ |
|
| 127 |
#define AMIROLLD_CFG_USE_PCAL6524 |
|
| 128 |
|
|
| 129 |
/** |
|
| 130 |
* @brief Enable flag for the AT42Q1050 touch sensor. |
|
| 131 |
*/ |
|
| 132 |
#define AMIROLLD_CFG_USE_AT42QT1050 |
|
| 133 |
|
|
| 114 | 134 |
#endif /* BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X */ |
| 115 | 135 |
|
| 116 | 136 |
#endif /* _ALLDCONF_H_ */ |
| modules/PowerManagement_1-1/module.c | ||
|---|---|---|
| 153 | 153 |
/* active state */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW, |
| 154 | 154 |
/* interrupt edge */ VCNL4020_LLD_INT_EDGE, |
| 155 | 155 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) |
| 156 |
/* active state */ APAL_GPIO_ACTIVE_LOW, |
|
| 157 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
|
| 156 |
/* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
|
| 157 |
/* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
|
| 158 | 158 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) |
| 159 |
/* active state */ APAL_GPIO_ACTIVE_LOW, |
|
| 160 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
|
| 159 |
/* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
|
| 160 |
/* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
|
| 161 | 161 |
#else |
| 162 | 162 |
/* active state */ APAL_GPIO_ACTIVE_LOW, |
| 163 | 163 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE, |
| ... | ... | |
| 356 | 356 |
/* active state */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW, |
| 357 | 357 |
/* interrupt edge */ VCNL4020_LLD_INT_EDGE, |
| 358 | 358 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) |
| 359 |
/* active state */ APAL_GPIO_ACTIVE_LOW, |
|
| 360 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
|
| 359 |
/* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
|
| 360 |
/* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
|
| 361 | 361 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) |
| 362 |
/* active state */ APAL_GPIO_ACTIVE_LOW, |
|
| 363 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
|
| 362 |
/* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
|
| 363 |
/* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
|
| 364 | 364 |
#else |
| 365 | 365 |
/* active state */ APAL_GPIO_ACTIVE_LOW, |
| 366 | 366 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE, |
| ... | ... | |
| 383 | 383 |
/* active state */ (MPR121_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW, |
| 384 | 384 |
/* interrupt edge */ MPR121_LLD_INT_EDGE, |
| 385 | 385 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) |
| 386 |
/* active state */ APAL_GPIO_ACTIVE_LOW, |
|
| 387 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
|
| 386 |
/* active state */ (AT42QT1050_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
|
| 387 |
/* interrupt edge */ AT42QT1050_LLD_INT_EDGE,
|
|
| 388 | 388 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) |
| 389 |
/* active state */ APAL_GPIO_ACTIVE_LOW, |
|
| 390 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
|
| 389 |
/* active state */ (AT42QT1050_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
|
| 390 |
/* interrupt edge */ AT42QT1050_LLD_INT_EDGE,
|
|
| 391 | 391 |
#else |
| 392 | 392 |
/* active state */ APAL_GPIO_ACTIVE_LOW, |
| 393 | 393 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE, |
| ... | ... | |
| 667 | 667 |
#endif /* BOARD_SENSORRING == BOARD_PROXIMITYSENSOR */ |
| 668 | 668 |
|
| 669 | 669 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) || defined(__DOXYGEN__) |
| 670 |
// TODO |
|
| 670 |
|
|
| 671 |
PCAL6524Driver moduleLldGpioExtender1 = {
|
|
| 672 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR, |
|
| 673 |
/* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD, |
|
| 674 |
}; |
|
| 675 |
|
|
| 676 |
PCAL6524Driver moduleLldGpioExtender2 = {
|
|
| 677 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT, |
|
| 678 |
/* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD, |
|
| 679 |
}; |
|
| 680 |
|
|
| 681 |
AT42QT1050Driver moduleLldTouch = {
|
|
| 682 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT, |
|
| 683 |
/* I²C address */ AT42QT1050_LLD_I2C_ADDRSEL_LOW, |
|
| 684 |
}; |
|
| 685 |
|
|
| 671 | 686 |
#endif /* BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X */ |
| 672 | 687 |
|
| 673 | 688 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) || defined(__DOXYGEN__) |
| 674 |
// TODO |
|
| 689 |
|
|
| 690 |
PCAL6524Driver moduleLldGpioExtender1 = {
|
|
| 691 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR, |
|
| 692 |
/* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD, |
|
| 693 |
}; |
|
| 694 |
|
|
| 695 |
PCAL6524Driver moduleLldGpioExtender2 = {
|
|
| 696 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT, |
|
| 697 |
/* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD, |
|
| 698 |
}; |
|
| 699 |
|
|
| 700 |
AT42QT1050Driver moduleLldTouch = {
|
|
| 701 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT, |
|
| 702 |
/* I²C address */ AT42QT1050_LLD_I2C_ADDRSEL_LOW, |
|
| 703 |
}; |
|
| 704 |
|
|
| 675 | 705 |
#endif /* BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X */ |
| 676 | 706 |
|
| 677 | 707 |
/** @} */ |
| ... | ... | |
| 1290 | 1320 |
#endif /* BOARD_SENSORRING == BOARD_PROXIMITYSENSOR */ |
| 1291 | 1321 |
|
| 1292 | 1322 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) || defined(__DOXYGEN__) |
| 1293 |
// TODO |
|
| 1323 |
|
|
| 1324 |
/* |
|
| 1325 |
* PCAL6524 (GPIO extender) |
|
| 1326 |
*/ |
|
| 1327 |
static int _utShellCmdCb_AlldPcal6524(BaseSequentialStream* stream, int argc, char* argv[]) |
|
| 1328 |
{
|
|
| 1329 |
// evaluate arguments |
|
| 1330 |
if (argc == 2) {
|
|
| 1331 |
if (strcmp(argv[1], "#1") == 0) {
|
|
| 1332 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender1; |
|
| 1333 |
aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #1"); |
|
| 1334 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL; |
|
| 1335 |
return AOS_OK; |
|
| 1336 |
} |
|
| 1337 |
else if (strcmp(argv[1], "#2") == 0) {
|
|
| 1338 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender2; |
|
| 1339 |
aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #2"); |
|
| 1340 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL; |
|
| 1341 |
return AOS_OK; |
|
| 1342 |
} |
|
| 1343 |
} |
|
| 1344 |
// print help |
|
| 1345 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
|
| 1346 |
chprintf(stream, "Options:\n"); |
|
| 1347 |
chprintf(stream, " #1\n"); |
|
| 1348 |
chprintf(stream, " Test the GPIO extender on the I2C bus #1.\n"); |
|
| 1349 |
chprintf(stream, " #2\n"); |
|
| 1350 |
chprintf(stream, " Test the GPIO extender on the I2C bus #2.\n"); |
|
| 1351 |
return AOS_INVALID_ARGUMENTS; |
|
| 1352 |
} |
|
| 1353 |
static ut_pcal6524data_t _utAlldPcal6524Data = {
|
|
| 1354 |
/* driver */ NULL, |
|
| 1355 |
/* timeout */ MICROSECONDS_PER_SECOND, |
|
| 1356 |
}; |
|
| 1357 |
aos_unittest_t moduleUtAlldPcal6524 = {
|
|
| 1358 |
/* name */ "PCAL6524", |
|
| 1359 |
/* info */ "GPIO extender", |
|
| 1360 |
/* test function */ utAlldPcal6524Func, |
|
| 1361 |
/* shell command */ {
|
|
| 1362 |
/* name */ "unittest:GPIOExtender", |
|
| 1363 |
/* callback */ _utShellCmdCb_AlldPcal6524, |
|
| 1364 |
/* next */ NULL, |
|
| 1365 |
}, |
|
| 1366 |
/* data */ &_utAlldPcal6524Data, |
|
| 1367 |
}; |
|
| 1368 |
|
|
| 1369 |
/* |
|
| 1370 |
* AT42QT1050 (touch sensor) |
|
| 1371 |
*/ |
|
| 1372 |
static int _utShellCmdCb_AlldAt42qt1050(BaseSequentialStream* stream, int argc, char* argv[]) |
|
| 1373 |
{
|
|
| 1374 |
(void)argc; |
|
| 1375 |
(void)argv; |
|
| 1376 |
aosUtRun(stream, &moduleUtAlldAt42qt1050, NULL); |
|
| 1377 |
return AOS_OK; |
|
| 1378 |
} |
|
| 1379 |
static ut_at42qt1050data_t _utAlldMpr121Data= {
|
|
| 1380 |
/* AT42QT1050 driver */ &moduleLldTouch, |
|
| 1381 |
/* timeout */ MICROSECONDS_PER_SECOND, |
|
| 1382 |
/* event source */ &aos.events.io, |
|
| 1383 |
/* event flags */ MODULE_OS_IOEVENTFLAGS_TOUCHINT, |
|
| 1384 |
}; |
|
| 1385 |
aos_unittest_t moduleUtAlldAt42qt1050 = {
|
|
| 1386 |
/* name */ "AT42QT1050", |
|
| 1387 |
/* info */ "touch sensor", |
|
| 1388 |
/* test function */ utAlldAt42qt1050Func, |
|
| 1389 |
/* shell command */ {
|
|
| 1390 |
/* name */ "unittest:Touch", |
|
| 1391 |
/* callback */ _utShellCmdCb_AlldAt42qt1050, |
|
| 1392 |
/* next */ NULL, |
|
| 1393 |
}, |
|
| 1394 |
/* data */ &_utAlldMpr121Data, |
|
| 1395 |
}; |
|
| 1396 |
|
|
| 1294 | 1397 |
#endif /* BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X */ |
| 1295 | 1398 |
|
| 1296 | 1399 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) || defined(__DOXYGEN__) |
| 1297 |
// TODO |
|
| 1400 |
|
|
| 1401 |
/* |
|
| 1402 |
* PCAL6524 (GPIO extender) |
|
| 1403 |
*/ |
|
| 1404 |
static int _utShellCmdCb_AlldPcal6524(BaseSequentialStream* stream, int argc, char* argv[]) |
|
| 1405 |
{
|
|
| 1406 |
// evaluate arguments |
|
| 1407 |
if (argc == 2) {
|
|
| 1408 |
if (strcmp(argv[1], "#1") == 0) {
|
|
| 1409 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender1; |
|
| 1410 |
aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #1"); |
|
| 1411 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL; |
|
| 1412 |
return AOS_OK; |
|
| 1413 |
} |
|
| 1414 |
else if (strcmp(argv[1], "#2") == 0) {
|
|
| 1415 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender2; |
|
| 1416 |
aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #2"); |
|
| 1417 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL; |
|
| 1418 |
return AOS_OK; |
|
| 1419 |
} |
|
| 1420 |
} |
|
| 1421 |
// print help |
|
| 1422 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
|
| 1423 |
chprintf(stream, "Options:\n"); |
|
| 1424 |
chprintf(stream, " #1\n"); |
|
| 1425 |
chprintf(stream, " Test the GPIO extender on the I2C bus #1.\n"); |
|
| 1426 |
chprintf(stream, " #2\n"); |
|
| 1427 |
chprintf(stream, " Test the GPIO extender on the I2C bus #2.\n"); |
|
| 1428 |
return AOS_INVALID_ARGUMENTS; |
|
| 1429 |
} |
|
| 1430 |
static ut_pcal6524data_t _utAlldPcal6524Data = {
|
|
| 1431 |
/* driver */ NULL, |
|
| 1432 |
/* timeout */ MICROSECONDS_PER_SECOND, |
|
| 1433 |
}; |
|
| 1434 |
aos_unittest_t moduleUtAlldPcal6524 = {
|
|
| 1435 |
/* name */ "PCAL6524", |
|
| 1436 |
/* info */ "GPIO extender", |
|
| 1437 |
/* test function */ utAlldPcal6524Func, |
|
| 1438 |
/* shell command */ {
|
|
| 1439 |
/* name */ "unittest:GPIOExtender", |
|
| 1440 |
/* callback */ _utShellCmdCb_AlldPcal6524, |
|
| 1441 |
/* next */ NULL, |
|
| 1442 |
}, |
|
| 1443 |
/* data */ &_utAlldPcal6524Data, |
|
| 1444 |
}; |
|
| 1445 |
|
|
| 1446 |
/* |
|
| 1447 |
* AT42QT1050 (touch sensor) |
|
| 1448 |
*/ |
|
| 1449 |
static int _utShellCmdCb_AlldAt42qt1050(BaseSequentialStream* stream, int argc, char* argv[]) |
|
| 1450 |
{
|
|
| 1451 |
(void)argc; |
|
| 1452 |
(void)argv; |
|
| 1453 |
aosUtRun(stream, &moduleUtAlldAt42qt1050, NULL); |
|
| 1454 |
return AOS_OK; |
|
| 1455 |
} |
|
| 1456 |
static ut_at42qt1050data_t _utAlldMpr121Data= {
|
|
| 1457 |
/* AT42QT1050 driver */ &moduleLldTouch, |
|
| 1458 |
/* timeout */ MICROSECONDS_PER_SECOND, |
|
| 1459 |
/* event source */ &aos.events.io, |
|
| 1460 |
/* event flags */ MODULE_OS_IOEVENTFLAGS_TOUCHINT, |
|
| 1461 |
}; |
|
| 1462 |
aos_unittest_t moduleUtAlldAt42qt1050 = {
|
|
| 1463 |
/* name */ "AT42QT1050", |
|
| 1464 |
/* info */ "touch sensor", |
|
| 1465 |
/* test function */ utAlldAt42qt1050Func, |
|
| 1466 |
/* shell command */ {
|
|
| 1467 |
/* name */ "unittest:Touch", |
|
| 1468 |
/* callback */ _utShellCmdCb_AlldAt42qt1050, |
|
| 1469 |
/* next */ NULL, |
|
| 1470 |
}, |
|
| 1471 |
/* data */ &_utAlldMpr121Data, |
|
| 1472 |
}; |
|
| 1473 |
|
|
| 1298 | 1474 |
#endif /* BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X */ |
| 1299 | 1475 |
|
| 1300 | 1476 |
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */ |
| modules/PowerManagement_1-1/module.h | ||
|---|---|---|
| 453 | 453 |
} |
| 454 | 454 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) || defined(__DOXYGEN__) |
| 455 | 455 |
#define MODULE_INIT_TEST_SENSORRING() { \
|
| 456 |
/* TODO */ \ |
|
| 456 |
aosShellAddCommand(&aos.shell, &moduleUtAlldPcal6524.shellcmd); \ |
|
| 457 |
aosShellAddCommand(&aos.shell, &moduleUtAlldAt42qt1050.shellcmd); \ |
|
| 457 | 458 |
} |
| 458 | 459 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) || defined(__DOXYGEN__) |
| 459 | 460 |
#define MODULE_INIT_TEST_SENSORRING() { \
|
| 460 |
/* TODO */ \ |
|
| 461 |
aosShellAddCommand(&aos.shell, &moduleUtAlldPcal6524.shellcmd); \ |
|
| 462 |
aosShellAddCommand(&aos.shell, &moduleUtAlldAt42qt1050.shellcmd); \ |
|
| 461 | 463 |
} |
| 462 | 464 |
#else |
| 463 | 465 |
#define MODULE_INIT_TEST_SENSORRING() {}
|
| ... | ... | |
| 499 | 501 |
} |
| 500 | 502 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) || defined(__DOXYGEN__) |
| 501 | 503 |
#define MODULE_INIT_PERIPHERY_COMM_SENSORRING() { \
|
| 502 |
/* TODO */ \ |
|
| 504 |
moduleHalI2cSrPm18Pm33GaugeRearConfig.clock_speed = (PCAL6524_LLD_I2C_MAXFREQUENCY < moduleHalI2cSrPm18Pm33GaugeRearConfig.clock_speed) ? PCAL6524_LLD_I2C_MAXFREQUENCY : moduleHalI2cSrPm18Pm33GaugeRearConfig.clock_speed; \ |
|
| 505 |
moduleHalI2cSrPm42Pm50PmVddEepromGaugeFrontConfig.clock_speed = (PCAL6524_LLD_I2C_MAXFREQUENCY < moduleHalI2cSrPm42Pm50PmVddEepromGaugeFrontConfig.clock_speed) ? PCAL6524_LLD_I2C_MAXFREQUENCY : moduleHalI2cSrPm42Pm50PmVddEepromGaugeFrontConfig.clock_speed; \ |
|
| 506 |
moduleHalI2cSrPm42Pm50PmVddEepromGaugeFrontConfig.clock_speed = (AT42QT1050_LLD_I2C_MAXFREQUENCY < moduleHalI2cSrPm42Pm50PmVddEepromGaugeFrontConfig.clock_speed) ? AT42QT1050_LLD_I2C_MAXFREQUENCY : moduleHalI2cSrPm42Pm50PmVddEepromGaugeFrontConfig.clock_speed; \ |
|
| 503 | 507 |
} |
| 504 | 508 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) || defined(__DOXYGEN__) |
| 505 | 509 |
#define MODULE_INIT_PERIPHERY_COMM_SENSORRING() { \
|
| 506 |
/* TODO */ \ |
|
| 510 |
moduleHalI2cSrPm18Pm33GaugeRearConfig.clock_speed = (PCAL6524_LLD_I2C_MAXFREQUENCY < moduleHalI2cSrPm18Pm33GaugeRearConfig.clock_speed) ? PCAL6524_LLD_I2C_MAXFREQUENCY : moduleHalI2cSrPm18Pm33GaugeRearConfig.clock_speed; \ |
|
| 511 |
moduleHalI2cSrPm42Pm50PmVddEepromGaugeFrontConfig.clock_speed = (PCAL6524_LLD_I2C_MAXFREQUENCY < moduleHalI2cSrPm42Pm50PmVddEepromGaugeFrontConfig.clock_speed) ? PCAL6524_LLD_I2C_MAXFREQUENCY : moduleHalI2cSrPm42Pm50PmVddEepromGaugeFrontConfig.clock_speed; \ |
|
| 512 |
moduleHalI2cSrPm42Pm50PmVddEepromGaugeFrontConfig.clock_speed = (AT42QT1050_LLD_I2C_MAXFREQUENCY < moduleHalI2cSrPm42Pm50PmVddEepromGaugeFrontConfig.clock_speed) ? AT42QT1050_LLD_I2C_MAXFREQUENCY : moduleHalI2cSrPm42Pm50PmVddEepromGaugeFrontConfig.clock_speed; \ |
|
| 507 | 513 |
} |
| 508 | 514 |
#else |
| 509 | 515 |
#define MODULE_INIT_PERIPHERY_COMM_SENSORRING() {}
|
| ... | ... | |
| 683 | 689 |
#endif /* BOARD_SENSORRING == BOARD_PROXIMITYSENSOR */ |
| 684 | 690 |
|
| 685 | 691 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) || defined(__DOXYGEN__) |
| 686 |
// TODO |
|
| 692 |
|
|
| 693 |
#include <alld_pcal6524.h> |
|
| 694 |
#include <alld_at42qt1050.h> |
|
| 695 |
|
|
| 696 |
/** |
|
| 697 |
* @brief GPIO extender (I2C #1) driver. |
|
| 698 |
*/ |
|
| 699 |
extern PCAL6524Driver moduleLldGpioExtender1; |
|
| 700 |
|
|
| 701 |
/** |
|
| 702 |
* @brief GPIO extender (I2C #2) driver. |
|
| 703 |
*/ |
|
| 704 |
extern PCAL6524Driver moduleLldGpioExtender2; |
|
| 705 |
|
|
| 706 |
/** |
|
| 707 |
* @brief Touch sensor driver. |
|
| 708 |
*/ |
|
| 709 |
extern AT42QT1050Driver moduleLldTouch; |
|
| 710 |
|
|
| 687 | 711 |
#endif /* BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X */ |
| 688 | 712 |
|
| 689 | 713 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) || defined(__DOXYGEN__) |
| 690 |
// TODO |
|
| 714 |
|
|
| 715 |
#include <alld_pcal6524.h> |
|
| 716 |
#include <alld_at42qt1050.h> |
|
| 717 |
|
|
| 718 |
/** |
|
| 719 |
* @brief GPIO extender (I2C #1) driver. |
|
| 720 |
*/ |
|
| 721 |
extern PCAL6524Driver moduleLldGpioExtender1; |
|
| 722 |
|
|
| 723 |
/** |
|
| 724 |
* @brief GPIO extender (I2C #2) driver. |
|
| 725 |
*/ |
|
| 726 |
extern PCAL6524Driver moduleLldGpioExtender2; |
|
| 727 |
|
|
| 728 |
/** |
|
| 729 |
* @brief Touch sensor driver. |
|
| 730 |
*/ |
|
| 731 |
extern AT42QT1050Driver moduleLldTouch; |
|
| 732 |
|
|
| 691 | 733 |
#endif /* BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X */ |
| 692 | 734 |
|
| 693 | 735 |
/** @} */ |
| ... | ... | |
| 784 | 826 |
#endif /* BOARD_SENSORRING == BOARD_PROXIMITYSENSOR */ |
| 785 | 827 |
|
| 786 | 828 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) || defined(__DOXYGEN__) |
| 787 |
// TODO |
|
| 829 |
|
|
| 830 |
#include <ut_alld_pcal6524.h> |
|
| 831 |
#include <ut_alld_at42qt1050.h> |
|
| 832 |
|
|
| 833 |
/** |
|
| 834 |
* @brief PCAL6524 (GPIO extender) unit test object. |
|
| 835 |
*/ |
|
| 836 |
extern aos_unittest_t moduleUtAlldPcal6524; |
|
| 837 |
|
|
| 838 |
/** |
|
| 839 |
* @brief AT42QT1050 (touch sensor) unit test object. |
|
| 840 |
*/ |
|
| 841 |
extern aos_unittest_t moduleUtAlldAt42qt1050; |
|
| 842 |
|
|
| 788 | 843 |
#endif /* BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X */ |
| 789 | 844 |
|
| 790 | 845 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) || defined(__DOXYGEN__) |
| 791 |
// TODO |
|
| 846 |
|
|
| 847 |
#include <ut_alld_pcal6524.h> |
|
| 848 |
#include <ut_alld_at42qt1050.h> |
|
| 849 |
|
|
| 850 |
/** |
|
| 851 |
* @brief PCAL6524 (GPIO extender) unit test object. |
|
| 852 |
*/ |
|
| 853 |
extern aos_unittest_t moduleUtAlldPcal6524; |
|
| 854 |
|
|
| 855 |
/** |
|
| 856 |
* @brief AT42QT1050 (touch sensor) unit test object. |
|
| 857 |
*/ |
|
| 858 |
extern aos_unittest_t moduleUtAlldAt42qt1050; |
|
| 859 |
|
|
| 792 | 860 |
#endif /* BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X */ |
| 793 | 861 |
|
| 794 | 862 |
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */ |
| periphery-lld/AMiRo-LLD | ||
|---|---|---|
| 1 |
Subproject commit f125ae07972ff44a651eb3e4bd2acc2f635066d2 |
|
| 1 |
Subproject commit 9e45662eac51cb2ae4eb48a079f30e5d5c5e80aa |
|
| unittests/periphery-lld/inc/ut_alld_at42qt1050.h | ||
|---|---|---|
| 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 |
#ifndef _AMIROOS_UT_ALLD_AT42QT1050_H_ |
|
| 20 |
#define _AMIROOS_UT_ALLD_AT42QT1050_H_ |
|
| 21 |
|
|
| 22 |
#include <aos_unittest.h> |
|
| 23 |
#include <amiro-lld.h> |
|
| 24 |
|
|
| 25 |
#if ((AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_USE_AT42QT1050)) || defined(__DOXYGEN__) |
|
| 26 |
|
|
| 27 |
#include <alld_at42qt1050.h> |
|
| 28 |
|
|
| 29 |
/** |
|
| 30 |
* @brief Custom data structure for the unit test. |
|
| 31 |
*/ |
|
| 32 |
typedef struct {
|
|
| 33 |
/** |
|
| 34 |
* @brief Pointer to the AT42QT1050 driver to use. |
|
| 35 |
*/ |
|
| 36 |
AT42QT1050Driver* at42qt1050d; |
|
| 37 |
|
|
| 38 |
/** |
|
| 39 |
* @brief Timeout value (in µs). |
|
| 40 |
*/ |
|
| 41 |
apalTime_t timeout; |
|
| 42 |
|
|
| 43 |
/** |
|
| 44 |
* @brief Event source to listen to. |
|
| 45 |
*/ |
|
| 46 |
event_source_t* evtsource; |
|
| 47 |
|
|
| 48 |
/** |
|
| 49 |
* @brief Event flags to watch. |
|
| 50 |
*/ |
|
| 51 |
eventflags_t evtflags; |
|
| 52 |
} ut_at42qt1050data_t; |
|
| 53 |
|
|
| 54 |
#ifdef __cplusplus |
|
| 55 |
extern "C" {
|
|
| 56 |
#endif |
|
| 57 |
aos_utresult_t utAlldAt42qt1050Func(BaseSequentialStream* stream, aos_unittest_t* ut); |
|
| 58 |
#ifdef __cplusplus |
|
| 59 |
} |
|
| 60 |
#endif |
|
| 61 |
|
|
| 62 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_USE_AT42QT1050) */ |
|
| 63 |
|
|
| 64 |
#endif /* _AMIROOS_UT_ALLD_AT42QT1050_H_ */ |
|
| unittests/periphery-lld/inc/ut_alld_pcal6524.h | ||
|---|---|---|
| 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 |
#ifndef _AMIROOS_UT_PCAL6524_LLD_H_ |
|
| 20 |
#define _AMIROOS_UT_PCAL6524_LLD_H_ |
|
| 21 |
|
|
| 22 |
#include <aos_unittest.h> |
|
| 23 |
#include <amiro-lld.h> |
|
| 24 |
|
|
| 25 |
#if ((AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_USE_PCAL6524)) || defined(__DOXYGEN__) |
|
| 26 |
|
|
| 27 |
#include <alld_pcal6524.h> |
|
| 28 |
|
|
| 29 |
/** |
|
| 30 |
* @brief Custom data structure for the unit test. |
|
| 31 |
*/ |
|
| 32 |
typedef struct {
|
|
| 33 |
/** |
|
| 34 |
* @brief pointer to the PCAL6524 driver to use. |
|
| 35 |
*/ |
|
| 36 |
PCAL6524Driver* pcal6524d; |
|
| 37 |
|
|
| 38 |
/** |
|
| 39 |
* @brief Timeout value (in µs). |
|
| 40 |
*/ |
|
| 41 |
apalTime_t timeout; |
|
| 42 |
} ut_pcal6524data_t; |
|
| 43 |
|
|
| 44 |
#ifdef __cplusplus |
|
| 45 |
extern "C" {
|
|
| 46 |
#endif |
|
| 47 |
aos_utresult_t utAlldPcal6524Func(BaseSequentialStream* stream, aos_unittest_t *ut); |
|
| 48 |
#ifdef __cplusplus |
|
| 49 |
} |
|
| 50 |
#endif |
|
| 51 |
|
|
| 52 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_USE_PCAL6524) */ |
|
| 53 |
|
|
| 54 |
#endif /* _AMIROOS_UT_PCAL6524_LLD_H_ */ |
|
| unittests/periphery-lld/src/ut_alld_at42qt1050.c | ||
|---|---|---|
| 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 |
#include <ut_alld_at42qt1050.h> |
|
| 20 |
|
|
| 21 |
#if ((AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_USE_AT42QT1050)) || defined(__DOXYGEN__) |
|
| 22 |
|
|
| 23 |
#include <aos_debug.h> |
|
| 24 |
#include <chprintf.h> |
|
| 25 |
#include <aos_thread.h> |
|
| 26 |
#include <amiroos.h> |
|
| 27 |
|
|
| 28 |
#define INTERRUPT_EVENT_ID 1 |
|
| 29 |
|
|
| 30 |
aos_utresult_t utAlldAt42qt1050Func(BaseSequentialStream* stream, aos_unittest_t* ut) |
|
| 31 |
{
|
|
| 32 |
aosDbgCheck(ut->data != NULL && ((ut_at42qt1050data_t*)ut->data)->at42qt1050d != NULL); |
|
| 33 |
|
|
| 34 |
// local variables |
|
| 35 |
aos_utresult_t result = {0, 0};
|
|
| 36 |
uint32_t status; |
|
| 37 |
uint8_t buffer8[4] = {0, 0};
|
|
| 38 |
uint16_t buffer16[5]; |
|
| 39 |
event_listener_t event_listener; |
|
| 40 |
aos_timestamp_t tstart, tcurrent, tend; |
|
| 41 |
|
|
| 42 |
chprintf(stream, "read register...\n"); |
|
| 43 |
status = at42qt1050_lld_read_reg(((ut_at42qt1050data_t*)ut->data)->at42qt1050d, AT42QT1050_LLD_REG_CHIPID, &buffer8[0], ((ut_at42qt1050data_t*)ut->data)->timeout); |
|
| 44 |
status |= at42qt1050_lld_read_reg(((ut_at42qt1050data_t*)ut->data)->at42qt1050d, AT42QT1050_LLD_REG_FIRMWAREVERSION, &buffer8[1], ((ut_at42qt1050data_t*)ut->data)->timeout); |
|
| 45 |
chprintf(stream, "\t\tchip ID: 0x%02X\n", buffer8[0]); |
|
| 46 |
chprintf(stream, "\t\tfirmware version: %u.%u (0x%02X)\n", ((at42qt1050_lld_firmwarereg_t)buffer8[1]).major, ((at42qt1050_lld_firmwarereg_t)buffer8[1]).minor, buffer8[1]); |
|
| 47 |
if (status == APAL_STATUS_SUCCESS && buffer8[0] == AT42QT1050_LLD_CHIPID) {
|
|
| 48 |
aosUtPassed(stream, &result); |
|
| 49 |
} else {
|
|
| 50 |
aosUtFailedMsg(stream, &result, "0x%08X\n", status); |
|
| 51 |
} |
|
| 52 |
|
|
| 53 |
chprintf(stream, "write register...\n"); |
|
| 54 |
buffer8[1] = (((uint8_t)(at42qt1050_lld_samples2pulse(4096) + 0.5f)) << 4) | ((uint8_t)(at42qt1050_lld_scaling2scale(1024) + 0.5f)); |
|
| 55 |
status = at42qt1050_lld_read_reg(((ut_at42qt1050data_t*)ut->data)->at42qt1050d, AT42QT1050_LLD_REG_PULSE_SCALE_1, &buffer8[0], ((ut_at42qt1050data_t*)ut->data)->timeout); |
|
| 56 |
status |= at42qt1050_lld_write_reg(((ut_at42qt1050data_t*)ut->data)->at42qt1050d, AT42QT1050_LLD_REG_PULSE_SCALE_1, buffer8[1] , ((ut_at42qt1050data_t*)ut->data)->timeout); |
|
| 57 |
status |= at42qt1050_lld_read_reg(((ut_at42qt1050data_t*)ut->data)->at42qt1050d, AT42QT1050_LLD_REG_PULSE_SCALE_1, &buffer8[2], ((ut_at42qt1050data_t*)ut->data)->timeout); |
|
| 58 |
status |= at42qt1050_lld_write_reg(((ut_at42qt1050data_t*)ut->data)->at42qt1050d, AT42QT1050_LLD_REG_PULSE_SCALE_1, buffer8[0] , ((ut_at42qt1050data_t*)ut->data)->timeout); |
|
| 59 |
status |= at42qt1050_lld_read_reg(((ut_at42qt1050data_t*)ut->data)->at42qt1050d, AT42QT1050_LLD_REG_PULSE_SCALE_1, &buffer8[3], ((ut_at42qt1050data_t*)ut->data)->timeout); |
|
| 60 |
if (status == APAL_STATUS_SUCCESS && |
|
| 61 |
buffer8[3] == buffer8[0] && |
|
| 62 |
buffer8[2] == buffer8[1] && |
|
| 63 |
at42qt1050_lld_pulse2samples(((at42qt1050_lld_pulsescalereg_t)buffer8[2]).pulse) == 4096 && |
|
| 64 |
at42qt1050_lld_scale2scaling(((at42qt1050_lld_pulsescalereg_t)buffer8[2]).scale) == 1024) {
|
|
| 65 |
aosUtPassed(stream, &result); |
|
| 66 |
} else {
|
|
| 67 |
aosUtFailedMsg(stream, &result, "0x%08X [0x%02X 0x%02X 0x%02X 0x%02X]\n", status, buffer8[0], buffer8[1], buffer8[2], buffer8[3]); |
|
| 68 |
} |
|
| 69 |
|
|
| 70 |
chprintf(stream, "read reference data...\n"); |
|
| 71 |
status = APAL_STATUS_OK; |
|
| 72 |
for (uint8_t key = 0; key < AT42QT1050_LLD_NUM_KEYS; ++key) {
|
|
| 73 |
status |= at42qt1050_lld_read_referencedata(((ut_at42qt1050data_t*)ut->data)->at42qt1050d, key, &buffer16[key], ((ut_at42qt1050data_t*)ut->data)->timeout); |
|
| 74 |
chprintf(stream, "\t\tkey %u: 0x%04X\n", key, buffer16[key]); |
|
| 75 |
} |
|
| 76 |
if (status == APAL_STATUS_SUCCESS) {
|
|
| 77 |
aosUtPassed(stream, &result); |
|
| 78 |
} else {
|
|
| 79 |
aosUtFailedMsg(stream, &result, "0x%08X\n", status); |
|
| 80 |
} |
|
| 81 |
|
|
| 82 |
chprintf(stream, "read key signal for ten seconds...\n"); |
|
| 83 |
status = APAL_STATUS_OK; |
|
| 84 |
chprintf(stream, "\t\t key 0 key 1 key 2 key 3 key 4\n"); |
|
| 85 |
for (uint8_t s = 0; s < 10; ++s) {
|
|
| 86 |
aosThdSSleep(1); |
|
| 87 |
for (uint8_t key = 0; key < AT42QT1050_LLD_NUM_KEYS; ++key) {
|
|
| 88 |
status |= at42qt1050_lld_read_keyssignal(((ut_at42qt1050data_t*)ut->data)->at42qt1050d, key, &buffer16[key], ((ut_at42qt1050data_t*)ut->data)->timeout); |
|
| 89 |
} |
|
| 90 |
chprintf(stream, "\t\t0x%04X 0x%04X 0x%04X 0x%04X 0x%04X\n", buffer16[0], buffer16[1], buffer16[2], buffer16[3], buffer16[4]); |
|
| 91 |
} |
|
| 92 |
if (status == APAL_STATUS_SUCCESS) {
|
|
| 93 |
aosUtPassed(stream, &result); |
|
| 94 |
} else {
|
|
| 95 |
aosUtFailedMsg(stream, &result, "0x%08X\n", status); |
|
| 96 |
} |
|
| 97 |
|
|
| 98 |
chprintf(stream, "test interrupts...\n"); |
|
| 99 |
status = AOS_OK; |
|
| 100 |
chEvtRegister(((ut_at42qt1050data_t*)ut->data)->evtsource, &event_listener, INTERRUPT_EVENT_ID); |
|
| 101 |
aosSysGetUptime(&tstart); |
|
| 102 |
tend = tstart + (30 * MICROSECONDS_PER_SECOND); |
|
| 103 |
do {
|
|
| 104 |
aosSysGetUptime(&tcurrent); |
|
| 105 |
const aos_timestamp_t ttimeout = MICROSECONDS_PER_SECOND - ((tcurrent - tstart) % MICROSECONDS_PER_SECOND); |
|
| 106 |
const eventmask_t emask = chEvtWaitOneTimeout(EVENT_MASK(INTERRUPT_EVENT_ID), chTimeUS2I(ttimeout)); |
|
| 107 |
const eventflags_t eflags = chEvtGetAndClearFlags(&event_listener); |
|
| 108 |
if (emask == EVENT_MASK(INTERRUPT_EVENT_ID) && eflags == ((ut_at42qt1050data_t*)ut->data)->evtflags) {
|
|
| 109 |
// interrupt detected |
|
| 110 |
chprintf(stream, "\t\tinterrupt detected\n"); |
|
| 111 |
} // else: timeout |
|
| 112 |
status |= at42qt1050_lld_read_reg(((ut_at42qt1050data_t*)ut->data)->at42qt1050d, AT42QT1050_LLD_REG_KEYSTATUS, &buffer8[0], ((ut_at42qt1050data_t*)ut->data)->timeout); |
|
| 113 |
chprintf(stream, "\t\tkey status: %u %u %u %u %u\n", |
|
| 114 |
(((buffer8[0] & AT42QT1050_LLD_KEYSTATUS_KEY0) == 0) ? 0 : 1), |
|
| 115 |
(((buffer8[0] & AT42QT1050_LLD_KEYSTATUS_KEY1) == 0) ? 0 : 1), |
|
| 116 |
(((buffer8[0] & AT42QT1050_LLD_KEYSTATUS_KEY2) == 0) ? 0 : 1), |
|
| 117 |
(((buffer8[0] & AT42QT1050_LLD_KEYSTATUS_KEY3) == 0) ? 0 : 1), |
|
| 118 |
(((buffer8[0] & AT42QT1050_LLD_KEYSTATUS_KEY4) == 0) ? 0 : 1)); |
|
| 119 |
aosSysGetUptime(&tcurrent); |
|
| 120 |
} while (tcurrent < tend); |
|
| 121 |
chEvtUnregister(((ut_at42qt1050data_t*)ut->data)->evtsource, &event_listener); |
|
| 122 |
if (status == APAL_STATUS_SUCCESS) {
|
|
| 123 |
aosUtPassed(stream, &result); |
|
| 124 |
} else {
|
|
| 125 |
aosUtFailedMsg(stream, &result, "0x%08X\n", status); |
|
| 126 |
} |
|
| 127 |
|
|
| 128 |
aosUtInfoMsg(stream,"driver object memory footprint: %u bytes\n", sizeof(AT42QT1050Driver)); |
|
| 129 |
|
|
| 130 |
return result; |
|
| 131 |
} |
|
| 132 |
|
|
| 133 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_USE_AT42QT1050) */ |
|
| unittests/periphery-lld/src/ut_alld_pcal6524.c | ||
|---|---|---|
| 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 |
#include <ut_alld_pcal6524.h> |
|
| 20 |
|
|
| 21 |
#if ((AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_USE_PCAL6524)) || defined(__DOXYGEN__) |
|
| 22 |
|
|
| 23 |
#include <chprintf.h> |
|
| 24 |
#include <string.h> |
|
| 25 |
|
|
| 26 |
aos_utresult_t utAlldPcal6524Func(BaseSequentialStream* stream, aos_unittest_t *ut) |
|
| 27 |
{
|
|
| 28 |
aosDbgCheck((ut->data != NULL) && |
|
| 29 |
(((ut_pcal6524data_t*)ut->data)->pcal6524d != NULL)); |
|
| 30 |
|
|
| 31 |
// local variables |
|
| 32 |
aos_utresult_t result = {0, 0};
|
|
| 33 |
uint32_t status; |
|
| 34 |
uint8_t buffer[24]; |
|
| 35 |
memset(buffer, 0xAA, sizeof(buffer)); |
|
| 36 |
|
|
| 37 |
// This test is currently not supported. See PCAL6524 driver implementation for further information. |
|
| 38 |
// chprintf(stream, "reading device ID...\n"); |
|
| 39 |
// status = pcal6524_lld_read_id(((ut_pcal6524data_t*)ut->data)->pcal6524d, buffer, ((ut_pcal6524data_t*)ut->data)->timeout); |
|
| 40 |
// chprintf(stream, "\t\traw: 0x%02X 0x%02X 0x%02X\n", buffer[0], buffer[1], buffer[2]); |
|
| 41 |
// chprintf(stream, "\t\tname: 0x%03X\n", ((pcal6524_lld_deviceid_t*)buffer)->name); |
|
| 42 |
// chprintf(stream, "\t\tpart: 0x%03X\n", ((pcal6524_lld_deviceid_t*)buffer)->part); |
|
| 43 |
// chprintf(stream, "\t\trevision: 0x%01X\n", ((pcal6524_lld_deviceid_t*)buffer)->revision); |
|
| 44 |
// if ((status == APAL_STATUS_OK) || (status == APAL_STATUS_WARNING)) {
|
|
| 45 |
// aosUtPassed(stream, &result); |
|
| 46 |
// } else {
|
|
| 47 |
// aosUtFailedMsg(stream, &result, "0x%08X\n", status); |
|
| 48 |
// } |
|
| 49 |
|
|
| 50 |
chprintf(stream, "reading register...\n"); |
|
| 51 |
status = pcal6524_lld_read_reg(((ut_pcal6524data_t*)ut->data)->pcal6524d, PCAL6524_LLD_CMD_SWITCHDEBOUNCECOUNT, buffer, ((ut_pcal6524data_t*)ut->data)->timeout); |
|
| 52 |
chprintf(stream, "\t\tdebounce count: %u\n", buffer[0]); |
|
| 53 |
if ((status == APAL_STATUS_OK) || (status == APAL_STATUS_WARNING)) {
|
|
| 54 |
aosUtPassed(stream, &result); |
|
| 55 |
} else {
|
|
| 56 |
aosUtFailedMsg(stream, &result, "0x%08X\n", status); |
|
| 57 |
} |
|
| 58 |
|
|
| 59 |
chprintf(stream, "writing register...\n"); |
|
| 60 |
buffer[3] = 0xFF; |
|
| 61 |
status = pcal6524_lld_write_reg(((ut_pcal6524data_t*)ut->data)->pcal6524d, PCAL6524_LLD_CMD_SWITCHDEBOUNCECOUNT, buffer[3], ((ut_pcal6524data_t*)ut->data)->timeout); |
|
| 62 |
status |= pcal6524_lld_read_reg(((ut_pcal6524data_t*)ut->data)->pcal6524d, PCAL6524_LLD_CMD_SWITCHDEBOUNCECOUNT, &buffer[4], ((ut_pcal6524data_t*)ut->data)->timeout); |
|
| 63 |
status |= pcal6524_lld_write_reg(((ut_pcal6524data_t*)ut->data)->pcal6524d, PCAL6524_LLD_CMD_SWITCHDEBOUNCECOUNT, buffer[0], ((ut_pcal6524data_t*)ut->data)->timeout); |
|
| 64 |
status |= pcal6524_lld_read_reg(((ut_pcal6524data_t*)ut->data)->pcal6524d, PCAL6524_LLD_CMD_SWITCHDEBOUNCECOUNT, &buffer[1], ((ut_pcal6524data_t*)ut->data)->timeout); |
|
| 65 |
if (((status == APAL_STATUS_OK) || (status == APAL_STATUS_WARNING)) && |
|
| 66 |
((buffer[1] == buffer[0]) && (buffer[4] == buffer[3]))) {
|
|
| 67 |
aosUtPassed(stream, &result); |
|
| 68 |
} else {
|
|
| 69 |
aosUtFailedMsg(stream, &result, "0x%08X\n", status); |
|
| 70 |
} |
|
| 71 |
|
|
| 72 |
chprintf(stream, "reading group...\n"); |
|
| 73 |
status = pcal6524_lld_read_group(((ut_pcal6524data_t*)ut->data)->pcal6524d, PCAL6524_LLD_CMD_OUTPUTDRIVESTRENGTH_P0A, buffer, ((ut_pcal6524data_t*)ut->data)->timeout); |
|
| 74 |
chprintf(stream, "\t\toutput drive strength: 0x%04X 0x%04X 0x%04X\n", |
|
| 75 |
(((uint16_t)buffer[0]) << 8) | buffer[1], |
|
| 76 |
(((uint16_t)buffer[2]) << 8) | buffer[3], |
|
| 77 |
(((uint16_t)buffer[4]) << 8) | buffer[5]); |
|
| 78 |
if ((status == APAL_STATUS_OK) || (status == APAL_STATUS_WARNING)) {
|
|
| 79 |
aosUtPassed(stream, &result); |
|
| 80 |
} else {
|
|
| 81 |
aosUtFailedMsg(stream, &result, "0x%08X\n", status); |
|
| 82 |
} |
|
| 83 |
|
|
| 84 |
chprintf(stream, "writing group...\n"); |
|
| 85 |
memset(&buffer[6], PCAL6524_LL_OUTPUTDRIVESTRENGTH_0_25, 6); |
|
| 86 |
status = pcal6524_lld_write_group(((ut_pcal6524data_t*)ut->data)->pcal6524d, PCAL6524_LLD_CMD_OUTPUTDRIVESTRENGTH_P0A, &buffer[6], ((ut_pcal6524data_t*)ut->data)->timeout); |
|
| 87 |
status |= pcal6524_lld_read_group(((ut_pcal6524data_t*)ut->data)->pcal6524d, PCAL6524_LLD_CMD_OUTPUTDRIVESTRENGTH_P0A, &buffer[12], ((ut_pcal6524data_t*)ut->data)->timeout); |
|
| 88 |
status |= pcal6524_lld_write_group(((ut_pcal6524data_t*)ut->data)->pcal6524d, PCAL6524_LLD_CMD_OUTPUTDRIVESTRENGTH_P0A, &buffer[0], ((ut_pcal6524data_t*)ut->data)->timeout); |
|
| 89 |
status |= pcal6524_lld_read_group(((ut_pcal6524data_t*)ut->data)->pcal6524d, PCAL6524_LLD_CMD_OUTPUTDRIVESTRENGTH_P0A, &buffer[18], ((ut_pcal6524data_t*)ut->data)->timeout); |
|
| 90 |
if (((status == APAL_STATUS_OK) || (status == APAL_STATUS_WARNING)) && |
|
| 91 |
((memcmp(&buffer[12], &buffer[6], 6) == 0) && (memcmp(&buffer[18], &buffer[0], 6) == 0))) {
|
|
| 92 |
aosUtPassed(stream, &result); |
|
| 93 |
} else {
|
|
| 94 |
aosUtFailedMsg(stream, &result, "0x%08X\n", status); |
|
| 95 |
} |
|
| 96 |
|
|
| 97 |
chprintf(stream, "reading continuously...\n"); |
|
| 98 |
// read the following registers continously (24 bytes): |
|
| 99 |
// output 0-3 + polarity inversions 0-3 + configuration 0-3 + output drive strength 0A-2B + input latch 0-3 + pupd enable 0-3 + pupd selection 0-3 |
|
| 100 |
status = pcal6524_lld_read_continuous(((ut_pcal6524data_t*)ut->data)->pcal6524d, PCAL6524_LLD_CMD_OUTPUT_P0, buffer, 24, ((ut_pcal6524data_t*)ut->data)->timeout); |
|
| 101 |
chprintf(stream, "\t\toutput: 0x%02X 0x%02X 0x%02X\n", buffer[0], buffer[1], buffer[2]); |
|
| 102 |
chprintf(stream, "\t\tpolarity inversion: 0x%02X 0x%02X 0x%02X\n", buffer[3], buffer[4], buffer[5]); |
|
| 103 |
chprintf(stream, "\t\tconfiguration: 0x%02X 0x%02X 0x%02X\n", buffer[6], buffer[7], buffer[8]); |
|
| 104 |
chprintf(stream, "\t\toutput drive strength: 0x%04X 0x%04X 0x%04X\n", |
|
| 105 |
(((uint16_t)buffer[9]) << 8) | buffer[10], |
|
| 106 |
(((uint16_t)buffer[11]) << 8) | buffer[12], |
|
| 107 |
(((uint16_t)buffer[13]) << 8) | buffer[14]); |
|
| 108 |
chprintf(stream, "\t\tinput latch: 0x%02X 0x%02X 0x%02X\n", buffer[15], buffer[16], buffer[17]); |
|
| 109 |
chprintf(stream, "\t\tpupd enable: 0x%02X 0x%02X 0x%02X\n", buffer[18], buffer[19], buffer[20]); |
|
| 110 |
chprintf(stream, "\t\tpupd selection: 0x%02X 0x%02X 0x%02X\n", buffer[21], buffer[22], buffer[23]); |
|
| 111 |
if ((status == APAL_STATUS_OK) || (status == APAL_STATUS_WARNING)) {
|
|
| 112 |
aosUtPassed(stream, &result); |
|
| 113 |
} else {
|
|
| 114 |
aosUtFailedMsg(stream, &result, "0x%08X\n", status); |
|
| 115 |
} |
|
| 116 |
|
|
| 117 |
chprintf(stream, "writing continuously...\n"); |
|
| 118 |
{
|
|
| 119 |
uint8_t writebuffer[24]; |
|
| 120 |
uint8_t readbuffer[2][24]; |
|
| 121 |
// copy the read configuration but set the output drive strength to factor 0.25 |
|
| 122 |
memcpy(writebuffer, buffer, sizeof(buffer)); |
|
| 123 |
memset(&writebuffer[9], PCAL6524_LL_OUTPUTDRIVESTRENGTH_0_25, 6); |
|
| 124 |
status = pcal6524_lld_write_continuous(((ut_pcal6524data_t*)ut->data)->pcal6524d, PCAL6524_LLD_CMD_OUTPUT_P0, writebuffer, 24, ((ut_pcal6524data_t*)ut->data)->timeout); |
|
| 125 |
status |= pcal6524_lld_read_continuous(((ut_pcal6524data_t*)ut->data)->pcal6524d, PCAL6524_LLD_CMD_OUTPUT_P0, readbuffer[0], 24, ((ut_pcal6524data_t*)ut->data)->timeout); |
|
| 126 |
status |= pcal6524_lld_write_continuous(((ut_pcal6524data_t*)ut->data)->pcal6524d, PCAL6524_LLD_CMD_OUTPUT_P0, buffer, 24, ((ut_pcal6524data_t*)ut->data)->timeout); |
|
| 127 |
status |= pcal6524_lld_read_continuous(((ut_pcal6524data_t*)ut->data)->pcal6524d, PCAL6524_LLD_CMD_OUTPUT_P0, readbuffer[1], 24, ((ut_pcal6524data_t*)ut->data)->timeout); |
|
| 128 |
if (((status == APAL_STATUS_OK) || (status == APAL_STATUS_WARNING)) && |
|
| 129 |
((memcmp(writebuffer, readbuffer[0], 24) == 0) && (memcmp(buffer, readbuffer[1], 24) == 0))) {
|
|
| 130 |
aosUtPassed(stream, &result); |
|
| 131 |
} else {
|
|
| 132 |
aosUtFailedMsg(stream, &result, "0x%08X\n", status); |
|
| 133 |
} |
|
| 134 |
} |
|
| 135 |
|
|
| 136 |
aosUtInfoMsg(stream, "driver object memory footprint: %u bytes\n", sizeof(PCAL6524Driver)); |
|
| 137 |
|
|
| 138 |
return result; |
|
| 139 |
} |
|
| 140 |
|
|
| 141 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_USE_PCAL6524) */ |
|
| unittests/unittests.mk | ||
|---|---|---|
| 34 | 34 |
UNITTESTSCSRC = $(UNITTESTS_DIR)lld/src/ut_lld_adc.c \ |
| 35 | 35 |
$(UNITTESTS_DIR)periphery-lld/src/ut_alld_a3906.c \ |
| 36 | 36 |
$(UNITTESTS_DIR)periphery-lld/src/ut_alld_at24c01bn-sh-b.c \ |
| 37 |
$(UNITTESTS_DIR)periphery-lld/src/ut_alld_at42qt1050.c \ |
|
| 37 | 38 |
$(UNITTESTS_DIR)periphery-lld/src/ut_alld_bq24103a.c \ |
| 38 | 39 |
$(UNITTESTS_DIR)periphery-lld/src/ut_alld_bq27500.c \ |
| 39 | 40 |
$(UNITTESTS_DIR)periphery-lld/src/ut_alld_bq27500_bq24103a.c \ |
| ... | ... | |
| 45 | 46 |
$(UNITTESTS_DIR)periphery-lld/src/ut_alld_ltc4412.c \ |
| 46 | 47 |
$(UNITTESTS_DIR)periphery-lld/src/ut_alld_mpr121.c \ |
| 47 | 48 |
$(UNITTESTS_DIR)periphery-lld/src/ut_alld_pca9544a.c \ |
| 49 |
$(UNITTESTS_DIR)periphery-lld/src/ut_alld_pcal6524.c \ |
|
| 48 | 50 |
$(UNITTESTS_DIR)periphery-lld/src/ut_alld_pklcs1212e4001.c \ |
| 49 | 51 |
$(UNITTESTS_DIR)periphery-lld/src/ut_alld_tlc5947.c \ |
| 50 | 52 |
$(UNITTESTS_DIR)periphery-lld/src/ut_alld_tps2051bdbv.c \ |
Also available in: Unified diff