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.
main.cpp
- Committer:
- yuhangzhu
- Date:
- 2013-07-12
- Revision:
- 3:32e67d121c7f
- Parent:
- 2:45db4f4ca70d
- Child:
- 4:e8142db2bbfd
File content as of revision 3:32e67d121c7f:
#include "mbed.h" #include "menu.h" #include "parameters.h" #include "handlers.h" Serial pc(USBTX, USBRX); char recv; int state; unsigned char cha1_pha, cha2_pha; unsigned char cha1_amp, cha2_amp; short spi_data; char line_buf[4]; //line_buf[3] is used to indicate if it's empty 0 empty 1 not int line_pt; int main() { pc.baud(115200); //config buad rate state = MODE_IDLE; line_buf[3] = 0; line_buf[2] = 255; line_buf[1] = 255; line_buf[0] = 255; while(1) { switch(state) { case MODE_IDLE: pc.printf("%s", main_menu); recv = pc.getc(); mode_idle_handler(&state, recv); //pc.printf("%d", state); break; case MODE_CHA1PHA: pc.printf("%s", cmd1); line_buf[3] = 0; line_pt = 0; while(1) { recv = pc.getc(); if(recv == 13) { if(line_pt == 0) line_buf[3] = 0; else line_buf[3] = 1; break; //enter pressed } else if(recv == 8) { pc.putc(8); pc.putc(32); pc.putc(8); if(line_pt == 0) line_buf[0] = 255; else if(line_pt > 0) { line_buf[line_pt] = 255; line_pt --; } } else { pc.putc(recv); line_buf[line_pt] = recv; if(line_pt < 2) line_pt ++; } } state = MODE_IDLE; break; case MODE_CHA1AMP: pc.printf("%s", cmd2); state = MODE_IDLE; break; } } return 0; }