Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:ed169b9ebb06, committed 2014-10-18
- Comitter:
- ststanko
- Date:
- Sat Oct 18 03:57:42 2014 +0000
- Commit message:
- PPM output v1
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Oct 18 03:57:42 2014 +0000 @@ -0,0 +1,55 @@ +#include "mbed.h" +#include "usb.h" + +//------------------------------------ +// Hyperterminal configuration +// 9600 bauds, 8-bit data, no parity +//------------------------------------ + + +#define PULSE_WIDTH 1000 +#define ONE_DELAY 10000 +#define ZERO_DELAY 40000 + +DigitalOut myled(LED1); +DigitalOut outpin(D15); +void transmit_bit(char c) { + int i; + for (i = 0; i < 8; i++) { + myled = 1; + outpin = 1; + wait_us(PULSE_WIDTH); + myled = 0; + outpin = 0; + if (c & 0x1) { + wait_us(ONE_DELAY); + } else { + wait_us(ZERO_DELAY); + } + c >>= 1; + } +} + +void transmit(char * data, unsigned int size) { + int i; + for (i = 0; i < size; i++) { + transmit_bit(data[i]); + } +} + +int main() { + myled = 1; + outpin = 1; + int i = 0; + usb_write("Hello World !\n"); + while(1) { + myled = 1; + outpin = 1; + i = 0; + wait(1); + char * str = "This program is alive \n"; + usb_write(str); + transmit("Hello", 5); + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Oct 18 03:57:42 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/transmitter.c Sat Oct 18 03:57:42 2014 +0000 @@ -0,0 +1,29 @@ +#include "transmitter.h" + +#define PULSE_WIDTH 1000 +#define ONE_DELAY 10000 +#define ZERO_DELAY 40000 + + +/* +void transmit_bit(char c) { + int i; + for (i = 0; i < 8; i++) { + myled = 1; + wait_us(PULSE_WIDTH); + myled = 0; + if (c & 0x1) { + wait_us(ONE_DELAY); + } else { + wait_us(ZERO_DELAY); + } + c >>= 1; + } +} + +void transmit(char * data, unsigned int size) { + int i; + for (i = 0; i < size; i++) { + transmit_bit(data[i]); + } +}*/ \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/transmitter.h Sat Oct 18 03:57:42 2014 +0000 @@ -0,0 +1,7 @@ +#ifndef transmitter_h +#define transmitter_h + +void transmit_bit(char c); +void transmit(char * data, unsigned int size); + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usb.cpp Sat Oct 18 03:57:42 2014 +0000 @@ -0,0 +1,8 @@ +#include "mbed.h" +#include "usb.h" + +Serial pc(SERIAL_TX, SERIAL_RX); + +void usb_write(char * text) { + pc.printf(text); + } \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usb.h Sat Oct 18 03:57:42 2014 +0000 @@ -0,0 +1,7 @@ +#ifndef usb_h +#define usb_h + +char * usb_read(); +void usb_write(char * text); + +#endif \ No newline at end of file