![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
SSI OpComms 3 CM TX
Dependencies: mbed
Fork of Optical3cmTXnucleo by
Diff: main.cpp
- Revision:
- 0:cb5d20585be4
- Child:
- 1:a5e80a54e72f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Oct 30 05:32:28 2015 +0000 @@ -0,0 +1,49 @@ +#include "mbed.h" + +DigitalOut tx(D15); + +Serial pc(USBTX, USBRX); // tx, rx + +void blink_binary(char c) +{ + for (int i = 7; i >= 0; --i) { + tx = 0; + wait_ms(10); + tx = 1; + wait_ms((c & (1 << i)) ? 20 : 10); + tx = 0; + } + wait_ms(30); +} + +int main() +{ + char* teststr = "Hello World\r\n"; + int testlen = strlen(teststr); + + pc.printf("3 CM Link Board - Transmit\r\n"); + char buffer[100]; + int idx = 0; + while(1) { + char a = pc.getc(); + if(a != '\n' && idx < 100){ + buffer[idx] = a; + idx++; + }else{ + for(int i=0;i<idx;i++){ + blink_binary(buffer[i]); + } + blink_binary('\r'); + blink_binary('\n'); + idx = 0; + } + + + + /* + for(int i=0;i<testlen;i++){ + blink_binary(teststr[i]); + } + */ + } +} \ No newline at end of file