Modbus with stm 32

Dependencies:   mbed

main.cpp

Committer:
lhakpa
Date:
2018-03-14
Revision:
1:00f04cdf25aa
Parent:
0:40b96f9186c3

File content as of revision 1:00f04cdf25aa:

#include "mbed.h"
#include "modbus.h"

DigitalOut myled(LED1);
RawSerial pc(USBTX, USBRX);

void serial_callback()
{
    uint8_t frame[6];
    
    char ch = pc.getc();
    if (modbus_parser(ch, frame)) {
        
    }
}

int main() {
    // setup code
    //Need to use interrupt
    pc.attach(serial_callback);
    // 1. button code
    //      a.Detect the press and push button and display on YAT
    // 2. timer code
    while(1) {
        // loop code
        myled = 1; // LED is ON
        wait(0.2); // 200 ms
        myled = 0; // LED is OFF
        wait(1.0); // 1 sec
    }
}