Self test boot program for testing icarus sensors
Dependencies: BLE_API mbed nRF51822
Fork of BLE_UARTConsole by
Diff: main.cpp
- Revision:
- 7:438b55fe8576
- Parent:
- 5:2607923acfa1
- Child:
- 8:e9ae7a01d866
--- a/main.cpp Tue Dec 09 09:08:27 2014 +0000 +++ b/main.cpp Mon Jan 26 13:57:26 2015 +0000 @@ -20,18 +20,30 @@ #include "UARTService.h" +//Icarus libraries +#include "RNGSensor.h" + #define NEED_CONSOLE_OUTPUT 1 /* Set this if you need debug messages on the console; * it will have an impact on code-size and power consumption. */ - +#define DEBUG_BUFFER 100 #if NEED_CONSOLE_OUTPUT -#define DEBUG(STR) { if (uart) uart->write(STR, strlen(STR)); } +#define DEBUG(...) do { if (uart) {snprintf(debugBuffer, DEBUG_BUFFER , __VA_ARGS__); uart->write(debugBuffer, strlen(debugBuffer));} } while (0) #else #define DEBUG(...) /* nothing */ #endif /* #if NEED_CONSOLE_OUTPUT */ + + + + BLEDevice ble; DigitalOut led1(LED1); UARTService *uart; +RNGSensor sensor; + +char debugBuffer[DEBUG_BUFFER]; +int sensorErrors[10]; + void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason) { @@ -45,6 +57,18 @@ led1 = !led1; DEBUG("ping\r\n"); } +int testSensors(void) +{ + int errorCount = sensor.verifyIntegrity(sensorErrors); + if (errorCount>0){ + for (int i=0;i<errorCount;i++){ + DEBUG("ERROR: Sensor %s failed with error code: %d",sensor.getSimpleName(),sensorErrors[i]); + } + } else { + DEBUG("Sensor %s validated!\n\r",sensor.getSimpleName()); + } + return errorCount; +} int main(void) {