テストモード追加、LED有効化 left -> SerialRX, Data Recieve Complete , Serial Tx , Light Tx

Dependencies:   XBee mbed NetServicesMin

Committer:
recotana
Date:
Wed Apr 18 07:52:46 2012 +0000
Revision:
2:dec6319cf02c
Parent:
1:36eb173eb52b

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
recotana 0:42adca80439c 1 #ifndef _DATA_MODELS_
recotana 0:42adca80439c 2 #define _DATA_MODELS_
recotana 0:42adca80439c 3
recotana 0:42adca80439c 4 #include "types.h"
recotana 0:42adca80439c 5
recotana 0:42adca80439c 6 //frame type
recotana 0:42adca80439c 7 typedef enum{
recotana 0:42adca80439c 8 Ftype_NoID =0,
recotana 0:42adca80439c 9 Ftype_Type_A=1,
recotana 0:42adca80439c 10 Ftype_Type_B=4
recotana 0:42adca80439c 11 } Ftype;
recotana 0:42adca80439c 12
recotana 0:42adca80439c 13 typedef enum{
recotana 0:42adca80439c 14 SERVER,
recotana 0:42adca80439c 15 LED_SENDER,
recotana 0:42adca80439c 16 LED_RECIEVER
recotana 0:42adca80439c 17 } Device;
recotana 0:42adca80439c 18
recotana 0:42adca80439c 19 typedef enum{
recotana 0:42adca80439c 20 PING,
recotana 0:42adca80439c 21 ACK,
recotana 0:42adca80439c 22 RECIEVE,
recotana 0:42adca80439c 23 SEND_SINGLE,
recotana 0:42adca80439c 24 SEND_CONTINUEOUS,
recotana 0:42adca80439c 25 SEND_CONT_STOP,
recotana 1:36eb173eb52b 26 SET_TX_GAIN,
recotana 1:36eb173eb52b 27 SET_LIGHT_CONTROL
recotana 0:42adca80439c 28 } Command;
recotana 0:42adca80439c 29 //
recotana 0:42adca80439c 30 //for TCP/IP data structure
recotana 0:42adca80439c 31 //
recotana 0:42adca80439c 32
recotana 0:42adca80439c 33 //message data 48byte(size fix)
recotana 0:42adca80439c 34 typedef struct{
recotana 1:36eb173eb52b 35 uint16_t totalSize; //2(total size) + 2(frame number) + 1(device) + 1(command) + 40(data:max 40) <--- max 46
recotana 0:42adca80439c 36 uint16_t frameNumber;
recotana 0:42adca80439c 37 Device device;
recotana 0:42adca80439c 38 Command command;
recotana 1:36eb173eb52b 39 uint8_t data[40]; //0 fill,size fix
recotana 1:36eb173eb52b 40 uint16_t sum;
recotana 0:42adca80439c 41 } Message;
recotana 0:42adca80439c 42
recotana 0:42adca80439c 43 //payload id 16byte
recotana 0:42adca80439c 44 typedef struct{
recotana 1:36eb173eb52b 45 // uint16_t head; //reserve 0x0000
recotana 1:36eb173eb52b 46 uint8_t personalId[16];
recotana 0:42adca80439c 47 } ID;
recotana 0:42adca80439c 48
recotana 0:42adca80439c 49 typedef struct{
recotana 0:42adca80439c 50 ID id; // 16 byte
recotana 0:42adca80439c 51 Message message; // 48 byte
recotana 0:42adca80439c 52 } Frame;
recotana 0:42adca80439c 53
recotana 0:42adca80439c 54 //66byte Payload
recotana 0:42adca80439c 55 typedef struct{
recotana 0:42adca80439c 56 uint16_t size; // 2(size) + 1(dummy) + 1(Ftype) + 64(frame) = 68 byte
recotana 0:42adca80439c 57 uint8_t dummy; //adjust Alignment
recotana 0:42adca80439c 58 Ftype ftype;
recotana 0:42adca80439c 59 Frame frame; //64byte
recotana 0:42adca80439c 60 } Payload;
recotana 0:42adca80439c 61
recotana 0:42adca80439c 62
recotana 1:36eb173eb52b 63
recotana 1:36eb173eb52b 64
recotana 1:36eb173eb52b 65 /* ---------------------------------------------------
recotana 1:36eb173eb52b 66 message data structure
recotana 1:36eb173eb52b 67 ---------------------------------------------------*/
recotana 1:36eb173eb52b 68
recotana 1:36eb173eb52b 69 /* light&#65533;@illuminate level */
recotana 1:36eb173eb52b 70 typedef struct{
recotana 1:36eb173eb52b 71 uint8_t gain; //1~10
recotana 1:36eb173eb52b 72 uint8_t middleLevel; //1~10
recotana 1:36eb173eb52b 73 } TxGainData;
recotana 1:36eb173eb52b 74
recotana 1:36eb173eb52b 75 typedef struct{
recotana 1:36eb173eb52b 76 uint16_t currentFrameNumber;
recotana 1:36eb173eb52b 77 TxGainData gainData;
recotana 1:36eb173eb52b 78 uint8_t lightsw; //0:light off 1:light on
recotana 1:36eb173eb52b 79 uint8_t continueusMode; //0:single 1:continueus
recotana 1:36eb173eb52b 80 uint8_t isSend;
recotana 1:36eb173eb52b 81 uint8_t dummy;
recotana 1:36eb173eb52b 82 uint32_t xbeeAdress;
recotana 1:36eb173eb52b 83 } PrefSender;
recotana 1:36eb173eb52b 84
recotana 1:36eb173eb52b 85 typedef struct{
recotana 1:36eb173eb52b 86 uint32_t xbeeAdress;
recotana 1:36eb173eb52b 87 } PrefReciever;
recotana 1:36eb173eb52b 88
recotana 1:36eb173eb52b 89 typedef struct{
recotana 1:36eb173eb52b 90 uint32_t xbeeAdress;
recotana 1:36eb173eb52b 91
recotana 1:36eb173eb52b 92 uint8_t serverAddress[4];
recotana 1:36eb173eb52b 93 uint8_t subnetMask[4];
recotana 1:36eb173eb52b 94 uint8_t routerAddress[4];
recotana 1:36eb173eb52b 95 uint16_t serverPort;
recotana 1:36eb173eb52b 96
recotana 1:36eb173eb52b 97 uint8_t destinationAddress[4];
recotana 1:36eb173eb52b 98 uint16_t destinationPort;
recotana 1:36eb173eb52b 99 } PrefServer;
recotana 1:36eb173eb52b 100
recotana 1:36eb173eb52b 101
recotana 1:36eb173eb52b 102
recotana 0:42adca80439c 103 void initPayload(Payload *_payload);
recotana 0:42adca80439c 104
recotana 0:42adca80439c 105 void payloadToNetwork(Payload *_payload);
recotana 0:42adca80439c 106 void networkToPayload(Payload *_payload);
recotana 0:42adca80439c 107
recotana 0:42adca80439c 108 void initTestPayloadData(Payload *_payload);
recotana 1:36eb173eb52b 109 uint16_t culcSum(Payload *_payload);
recotana 0:42adca80439c 110
recotana 0:42adca80439c 111 void dumpPayload(Payload *_payload);
recotana 1:36eb173eb52b 112 void dumpPrefSender(PrefSender *prf);
recotana 1:36eb173eb52b 113 void dumpPrefReciever(PrefReciever *prf);
recotana 1:36eb173eb52b 114 void dumpPrefServer(PrefServer *prf);
recotana 0:42adca80439c 115
recotana 0:42adca80439c 116 #endif