Stephen Davis
/
BT_Hub
Library set up as dummy module on mbed to mimic Nordic.
comms.cpp@2:9ab591cf81b8, 2016-12-13 (annotated)
- Committer:
- Stephen_NewVistas
- Date:
- Tue Dec 13 00:20:29 2016 +0000
- Revision:
- 2:9ab591cf81b8
- Parent:
- 0:226550611f0d
everything commented . now going to strip out mbed stuff.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Stephen_NewVistas | 0:226550611f0d | 1 | #include "mbed.h" |
Stephen_NewVistas | 0:226550611f0d | 2 | #include "comms.h" |
Stephen_NewVistas | 0:226550611f0d | 3 | |
Stephen_NewVistas | 0:226550611f0d | 4 | #define SERIAL1_TX PA_9 |
Stephen_NewVistas | 0:226550611f0d | 5 | #define SERIAL1_RX PA_10 |
Stephen_NewVistas | 0:226550611f0d | 6 | |
Stephen_NewVistas | 0:226550611f0d | 7 | I2C i2c( D4 , D5 ); |
Stephen_NewVistas | 0:226550611f0d | 8 | Serial pc( USBTX , USBRX ); |
Stephen_NewVistas | 0:226550611f0d | 9 | Serial bus( SERIAL1_TX , SERIAL1_RX ); |
Stephen_NewVistas | 0:226550611f0d | 10 | |
Stephen_NewVistas | 0:226550611f0d | 11 | |
Stephen_NewVistas | 0:226550611f0d | 12 | void initComms() { |
Stephen_NewVistas | 0:226550611f0d | 13 | pc.baud( 115200 ); |
Stephen_NewVistas | 0:226550611f0d | 14 | i2c.frequency( 400000 ); |
Stephen_NewVistas | 0:226550611f0d | 15 | bus.baud( 115200 ); |
Stephen_NewVistas | 0:226550611f0d | 16 | } |
Stephen_NewVistas | 0:226550611f0d | 17 | |
Stephen_NewVistas | 0:226550611f0d | 18 | void debugLog( char* fmt, ...) { |
Stephen_NewVistas | 0:226550611f0d | 19 | char buf[100]; // this should really be sized appropriately |
Stephen_NewVistas | 0:226550611f0d | 20 | // possibly in response to a call to vsnprintf() |
Stephen_NewVistas | 0:226550611f0d | 21 | va_list vl; |
Stephen_NewVistas | 0:226550611f0d | 22 | va_start(vl, fmt); |
Stephen_NewVistas | 0:226550611f0d | 23 | |
Stephen_NewVistas | 0:226550611f0d | 24 | vsnprintf( buf, sizeof( buf), fmt, vl); |
Stephen_NewVistas | 0:226550611f0d | 25 | |
Stephen_NewVistas | 0:226550611f0d | 26 | va_end( vl); |
Stephen_NewVistas | 0:226550611f0d | 27 | |
Stephen_NewVistas | 0:226550611f0d | 28 | pc.printf(buf); |
Stephen_NewVistas | 0:226550611f0d | 29 | } |