Droni e Droidi / Mbed 2 deprecated EMF32-SerMonitor

Dependencies:   EFM32_SegmentLCD IOFuncLib mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "EFM32_SegmentLCD.h"
00003 #include "IOFuncLib.h"
00004 
00005 
00006 silabs::EFM32_SegmentLCD segmentDisplay;
00007 
00008 
00009 /*------------ Constant definitions --------------*/
00010 #define TX_PIN          USBTX
00011 #define RX_PIN          USBRX
00012 #define BRATE           9600
00013 #define LED_PIN         LED1
00014 #define TOGGLE_RATE     (1.0f)
00015 #define BUFF_LENGTH     7
00016 
00017 #define INIT_SECONDS        0
00018 
00019 /*-------- Check if platform compatible ----------*/
00020 #if DEVICE_SERIAL_ASYNCH
00021 Serial test_connection(USBTX, USBRX);
00022 #else
00023 #error "Platform not compatible with Low Power APIs for Serial"
00024 #endif
00025 
00026 /*------------------ Variables -------------------*/
00027 LowPowerTicker      blinker;
00028 bool                blinking = false;
00029 event_callback_t    serialEventCb;
00030 //DigitalOut          LED(LED_PIN);
00031 uint8_t             rx_buf[BUFF_LENGTH + 1];
00032 
00033 volatile uint32_t seconds = INIT_SECONDS;
00034 Flasher led(LED_PIN);
00035 
00036 /******************** Define Timers *****************************/
00037 // devo separare i timers. Non so il perche'
00038 LowPowerTicker refreshTicker;
00039 /*------------------ Callbacks -------------------*/
00040 
00041 
00042 //------------ Funzioni -------------
00043 #include "Functions.h"
00044 
00045 //-------------------------------------
00046 
00047 
00048 /*-------------------- Main ----------------------*/
00049 int main()
00050 {
00051     /* Very Simple Main (tm) */
00052     serialEventCb.attach(serialCb);
00053 
00054     /* Setup serial connection */
00055     test_connection.baud(BRATE);
00056     test_connection.printf("Low Power API test\n\nSend 'X' to toggle blinking\n");
00057     test_connection.read(rx_buf, BUFF_LENGTH, serialEventCb, SERIAL_EVENT_RX_ALL, 'X');
00058 
00059     /* Let the callbacks take care of everything */
00060     refreshTicker.attach(&tickerCallback, 1.0f);
00061 
00062     while(1) sleep();
00063 }