FTHR USB Serial
Dependencies: BMI160 max32630fthr USBDevice
Diff: main.cpp
- Revision:
- 1:6923b075c8d7
- Parent:
- 0:60a522ae2e35
- Child:
- 2:57500e991166
--- a/main.cpp Fri Nov 11 21:08:36 2016 +0000 +++ b/main.cpp Sat Nov 12 00:34:35 2016 +0000 @@ -1,16 +1,20 @@ #include "mbed.h" +#include "USBSerial.h" #define MAX14690_I2C_ADDR 0x50 +// Hardware serial port over DAPLink +Serial pc(USBTX, USBRX); + DigitalOut led1(LED1); I2C i2cm2(P5_7, P6_0); - // main() runs in its own thread in the OS // (note the calls to Thread::wait below for delays) int main() { char data[5]; + int c; data[0] = 0x14; // I2C address for first register (LDO2 CFG) data[1] = 0x00; // Dissable LDO2 data[2] = 0x19; // Set voltage to 3.3V @@ -21,9 +25,14 @@ data[3] = 0x02; // Enable LDO3 i2cm2.write(MAX14690_I2C_ADDR, data, 5); - while (true) { - led1 = !led1; - Thread::wait(500); + // Virtual serial port over USB + USBSerial serial; + + while(1) { + c = serial.getc(); + serial.putc(c); + pc.putc(c); + led1 = c & 1; } }