Firmware for the mbed in the BlueSync Sensor platform. Intended to communicate with a BlueGiga BLE112 Bluetooth LE module over UART.
Dependencies: TimerCapture mbed
Diff: main.cpp
- Revision:
- 3:54fef6ac433b
- Parent:
- 2:ac474fccf29b
- Child:
- 4:778626dfcc92
--- a/main.cpp Sat May 30 01:53:17 2015 +0000 +++ b/main.cpp Sat May 30 04:34:45 2015 +0000 @@ -11,6 +11,7 @@ DigitalOut bleScanningLed(LED2); DigitalOut bleAdvRecv(LED3); DigitalOut bleTimeStampRecv(LED4); +Ticker ticker; void blankOutLeds() { bleSlaveLed = 0; @@ -59,11 +60,11 @@ bleSlaveLed = 1; intByteArray bitArray; bitArray.integer = capPin->getTime(); - printf("Sending timestamp %d (%x)\r\n", bitArray.integer, bitArray.integer); + printf("Sending timestamp %d (%08x)\r\n", bitArray.integer, bitArray.integer); uint8_t event = (uint8_t) EventCode::SET_TIMESTAMP; printf("Sending event: %x\r\n", event); ble112.putc(0x05); - for (int i = 3; i >= 0; i--) { + for (int i = 0; i < 4; i++) { ble112.putc(bitArray.byte[i]); } } @@ -104,12 +105,18 @@ } } +void on_tick() { + uint32_t timestamp = capPin->getTime(); + printf("+++Capture register: %d (%08x)\r\n", timestamp, timestamp); +} + int main() { printf("Booted!\r\n"); + ticker.attach(&on_tick, 5.0); TimerCapture::startTimer(); capPin = new TimerCapture(p30); - ble112.baud(115200); - //ble112.set_flow_control(SerialBase::RTSCTS, p7, p8); + ble112.baud(9600); + ble112.set_flow_control(SerialBase::RTSCTS, p7, p8); ble112.attach(&on_serial_rcv); uint8_t command = (uint8_t) EventCode::GET_STATE; printf("Sending command %x\r\n", command);