LPC824

Dependencies:   mbed

Fork of CubeFine by wu le

Committer:
beian10
Date:
Mon Jul 04 07:17:39 2016 +0000
Revision:
2:7964622fb5a5
Parent:
1:54a2d380f8c7
V2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lixianyu 0:362c1482232c 1 #include "Microduino_Protocol_HardSer.h"
lixianyu 0:362c1482232c 2
lixianyu 0:362c1482232c 3 //BLE//////////////////////
beian10 2:7964622fb5a5 4 Serial pc(D3, D2);
beian10 1:54a2d380f8c7 5
lixianyu 0:362c1482232c 6 Protocol bleProtocol(&pc, TYPE_NUM); //软串口,校验数据类
lixianyu 0:362c1482232c 7
lixianyu 0:362c1482232c 8 #define this_node 1 //设置本机ID
lixianyu 0:362c1482232c 9 #define other_node 0
lixianyu 0:362c1482232c 10 struct send_a { //发送
lixianyu 0:362c1482232c 11 uint32_t node_ms; //节点运行时间
lixianyu 0:362c1482232c 12 };
lixianyu 0:362c1482232c 13 struct receive_a { //接收
lixianyu 0:362c1482232c 14 uint32_t ms;
lixianyu 0:362c1482232c 15 uint16_t rf_CH[CHANNEL_NUM];
lixianyu 0:362c1482232c 16 };
lixianyu 0:362c1482232c 17
lixianyu 0:362c1482232c 18 //Mode//////////////////////
lixianyu 0:362c1482232c 19 enum _Mode {
lixianyu 0:362c1482232c 20 NRF,
lixianyu 0:362c1482232c 21 BLE
lixianyu 0:362c1482232c 22 };
lixianyu 0:362c1482232c 23
lixianyu 0:362c1482232c 24 bool protocolSetup(void)
lixianyu 0:362c1482232c 25 {
lixianyu 0:362c1482232c 26 bleProtocol.begin(BLE_SPEED);
lixianyu 0:362c1482232c 27 return BLE;
lixianyu 0:362c1482232c 28 }
lixianyu 0:362c1482232c 29
lixianyu 0:362c1482232c 30 bool protocolRead(uint16_t *_channel, bool _mode)
lixianyu 0:362c1482232c 31 {
lixianyu 0:362c1482232c 32 switch (bleProtocol.parse(_channel, MODE_WHILE)) {
lixianyu 0:362c1482232c 33 case P_NONE: //DATA NONE
lixianyu 0:362c1482232c 34 break;
lixianyu 0:362c1482232c 35 case P_FINE: //DATA OK
lixianyu 0:362c1482232c 36 return true;
lixianyu 0:362c1482232c 37 case P_ERROR: //DATA ERROR
beian10 2:7964622fb5a5 38
lixianyu 0:362c1482232c 39 break;
lixianyu 0:362c1482232c 40 case P_TIMEOUT: //DATA TIMEOUT
beian10 2:7964622fb5a5 41
lixianyu 0:362c1482232c 42 break;
lixianyu 0:362c1482232c 43 }
lixianyu 0:362c1482232c 44 return false;
lixianyu 0:362c1482232c 45 }