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.
Dependencies: mbed
usart.cpp
- Committer:
- ryuna
- Date:
- 2014-06-16
- Revision:
- 0:ae8fbdc800ba
- Child:
- 1:a47cb7834afe
File content as of revision 0:ae8fbdc800ba:
#include "mbed.h" //#include "common.h" #define KEYCODE 0xAA #define TX_CHECKCODE (tx_data[1]^tx_data[2]^tx_data[3]^tx_data[4]^tx_data[5]^tx_data[6]^tx_data[7]^tx_data[8]^tx_data[9]) #define RX_CHECKCODE (rx_data[1]^rx_data[2]^rx_data[3]^rx_data[4]^rx_data[5]^rx_data[6]^rx_data[7]^rx_data[8]^rx_data[9]) #define DATA_NUM 11 #define CHECK (DATA_NUM - 1) #define ALL_IR 11 extern Serial sensor; extern Serial pc; extern uint8_t ping[4]; //extern uint8_t line[4]; extern uint8_t ir_max, ir_num; extern int compass; extern uint8_t ir_central; extern uint8_t ir_main; void micon_rx(){ static uint8_t rx; static int rx_data[DATA_NUM]; rx_data[rx] = sensor.getc(); if(rx_data[0] == KEYCODE){ rx++; } if(rx >= DATA_NUM){ if(rx_data[CHECK] == RX_CHECKCODE){ compass = rx_data[7] + rx_data[8]; ir_max = rx_data[1]; ir_num = rx_data[2]; ping[FRONT] = rx_data[3]; ping[LEFT] = rx_data[4]; ping[BACK] = rx_data[5]; ping[RIGHT] = rx_data[6]; ir_central = rx_data[9]; ir_main = ir_central; //pc.printf("%d ,%d\n", ir_max,ir_num); } rx = 0; } //pc.printf("%d\n", rx_data[rx]); } /* void micon_tx(){ static uint8_t tx; static uint8_t tx_data[DATA_NUM]; if(tx >= DATA_NUM){ tx_data[0] = KEYCODE; tx_data[1] = KEYCODE; tx_data[2] = KEYCODE; tx_data[3] = KEYCODE; tx_data[4] = KEYCODE; tx_data[5] = KEYCODE; tx_data[6] = KEYCODE; tx_data[7] = KEYCODE; tx_data[8] = KEYCODE; tx_data[9] = KEYCODE; tx_data[10] = KEYCODE; tx_data[11] = TX_CHECKCODE; tx = 0; } sensor.putc(tx_data[tx]); tx++; } */