Self test boot program for testing icarus sensors
Dependencies: BLE_API mbed nRF51822
Fork of BLE_UARTConsole by
Diff: main.cpp
- Revision:
- 14:cb369746225d
- Parent:
- 13:ef0ce8fa871f
--- a/main.cpp Sun Apr 05 09:54:04 2015 +0000
+++ b/main.cpp Wed Apr 15 20:01:16 2015 +0000
@@ -17,8 +17,6 @@
#include <string.h>
#include <stdarg.h>
#include "mbed.h"
-#include "BLEDevice.h"
-#include "UARTService.h"
#define DEBUG 1 /* Set this if you need debug messages on the console;
@@ -28,8 +26,10 @@
#include "ADXL362Sensor.h"
#include "MPU9250Sensor.h"
-BLEDevice ble;
-UARTService *uart;
+
+
+#define BAUD_RATE 115200
+Serial s(P0_5, P0_6);
#if DEBUG
#define LOG_BUFFER 100
@@ -42,16 +42,17 @@
void debug ( const char* format, ...) {
va_list argptr;
va_start(argptr, format);
- vsnprintf(debugBuffer, LOG_BUFFER ,format, argptr);
+// vsnprintf(debugBuffer, LOG_BUFFER ,format, argptr);
+ vprintf(format, argptr);
va_end(argptr);
- if (uart){
- uart->write(debugBuffer, strlen(debugBuffer));
- }
+// if (uart){
+// uart->write(debugBuffer, strlen(debugBuffer));
+// }
}
-SPI spi1(P0_28, p24, P0_29); // mosi, miso, sclk
+SPI spi1(P0_28, P0_24, P0_29); // mosi, miso, sclk
DigitalOut adxl_cs(P0_23);
DigitalOut mpu_cs(P0_18);
@@ -61,18 +62,14 @@
DigitalIn button(P0_16,PullDown);
+
uint32_t sensorErrors[10];
ADXL362Sensor adxl362(spi1, adxl_cs, debug);
MPU9250Sensor mpu9250(spi1, mpu_cs, debug);
-void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
-{
- LOG("Disconnected!\n\r");
- LOG("Restarting the advertising process\n\r");
- ble.startAdvertising();
-}
+
int testSensors(BaseSensor& sensor)
@@ -88,39 +85,18 @@
return errorCount;
}
-void periodicCallback(void)
-{
- led=!led;
- LOG("ping\r\n");
- testSensors(adxl362);
- testSensors(mpu9250);
-}
+
int main(void)
{
-
- led=1;
- Ticker ticker;
- ticker.attach(periodicCallback, 1);
+ s.baud(BAUD_RATE);
+
LOG("Initialising the nRF51822\n\r");
- ble.init();
- ble.onDisconnection(disconnectionCallback);
-
- uart = new UARTService(ble);
-
- /* setup advertising */
- ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED);
- ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
- ble.accumulateAdvertisingPayload(GapAdvertisingData::SHORTENED_LOCAL_NAME,
- (const uint8_t *)"BLE UART", sizeof("BLE UART") - 1);
- ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_128BIT_SERVICE_IDS,
- (const uint8_t *)UARTServiceUUID_reversed, sizeof(UARTServiceUUID_reversed));
-
- ble.setAdvertisingInterval(160); /* 100ms; in multiples of 0.625ms. */
- ble.startAdvertising();
while (true) {
- ble.waitForEvent();
+ testSensors(adxl362);
+// testSensors(mpu9250);
+ wait(10.0f);
}
}
\ No newline at end of file
