Jirayu Samkunta / Mbed 2 deprecated TAIST_modbus_copy

Dependencies:   mbed

Fork of TAIST_modbus_copy by Ananya Kuasakunrungroj

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "modbus.h"
00003 
00004 DigitalOut myled(LED1);
00005 RawSerial pc(USBTX, USBRX);
00006 
00007 void serial_callback()
00008 {
00009     uint8_t frame[6];
00010     
00011     char ch = pc.getc();
00012     if (modbus_parser(ch, frame)) {
00013         
00014     }
00015 }
00016 
00017 int main() {
00018     // setup code
00019     pc.attach(serial_callback);
00020     // 1. button code
00021     // 2. timer code
00022     while(1) {
00023         // loop code
00024         myled = 1; // LED is ON
00025         wait(0.2); // 200 ms
00026         myled = 0; // LED is OFF
00027         wait(1.0); // 1 sec
00028     }
00029 }