vasko ozo / Mbed 2 deprecated TxRxService

Dependencies:   mbed

Committer:
VASKO
Date:
Wed Aug 07 21:03:37 2019 +0000
Revision:
20:b60d2a5cd128
Parent:
19:09c21f5f0625
Child:
21:3e7a3d9e6885
Duplex L432KC<->F072RB is working, but Rx header detection not realized yet ))))

Who changed what in which revision?

UserRevisionLine numberNew contents of line
VASKO 16:459ad1bd82fd 1
VASKO 19:09c21f5f0625 2 #define HeaderByte 0x00
VASKO 15:30e45bd5902e 3 #define HeaderLength 5
VASKO 12:6f63e376c0aa 4
VASKO 20:b60d2a5cd128 5 #ifndef WorkTx
VASKO 20:b60d2a5cd128 6 #ifdef TARGET_NUCLEO_L432KC
VASKO 20:b60d2a5cd128 7 #define WorkTx PA_9
VASKO 20:b60d2a5cd128 8 #elif defined TARGET_NUCLEO_F072RB
VASKO 20:b60d2a5cd128 9 #define WorkTx PA_9
VASKO 20:b60d2a5cd128 10 #else
VASKO 20:b60d2a5cd128 11 #define WorkTx USBTX
VASKO 20:b60d2a5cd128 12 #endif
VASKO 20:b60d2a5cd128 13 #endif
VASKO 20:b60d2a5cd128 14 #ifndef WorkRx
VASKO 20:b60d2a5cd128 15 #ifdef TARGET_NUCLEO_L432KC
VASKO 20:b60d2a5cd128 16 #define WorkRx PA_10
VASKO 20:b60d2a5cd128 17 #elif defined TARGET_NUCLEO_F072RB
VASKO 20:b60d2a5cd128 18 #define WorkRx PA_10
VASKO 20:b60d2a5cd128 19 #else
VASKO 20:b60d2a5cd128 20 #define WorkRx USBRX
VASKO 20:b60d2a5cd128 21 #endif
VASKO 20:b60d2a5cd128 22 #endif
VASKO 20:b60d2a5cd128 23
VASKO 20:b60d2a5cd128 24
VASKO 16:459ad1bd82fd 25 #pragma pack(push, 1)//https://os.mbed.com/forum/bugs-suggestions/topic/4264/ проблема выравнивания данных
VASKO 12:6f63e376c0aa 26 typedef union {
VASKO 12:6f63e376c0aa 27 uint8_t ui8[4];
VASKO 12:6f63e376c0aa 28 int8_t i8[4];
VASKO 12:6f63e376c0aa 29 uint16_t ui16[2];
VASKO 12:6f63e376c0aa 30 int16_t i16[2];
VASKO 12:6f63e376c0aa 31 uint32_t ui32;
VASKO 12:6f63e376c0aa 32 int32_t i32;
VASKO 12:6f63e376c0aa 33 float f;
VASKO 12:6f63e376c0aa 34 } ParsType;
VASKO 12:6f63e376c0aa 35
VASKO 12:6f63e376c0aa 36 typedef struct {
VASKO 12:6f63e376c0aa 37 uint8_t cmd;
VASKO 12:6f63e376c0aa 38 ParsType pars;
VASKO 12:6f63e376c0aa 39 uint8_t cs;
VASKO 12:6f63e376c0aa 40 } MsgType;
VASKO 16:459ad1bd82fd 41 #pragma pack(pop)
VASKO 15:30e45bd5902e 42
VASKO 16:459ad1bd82fd 43 #define ArrTxSize (HeaderLength + sizeof(MsgType))
VASKO 16:459ad1bd82fd 44 #define ArrRxSize (HeaderLength + sizeof(MsgType))
VASKO 16:459ad1bd82fd 45
VASKO 16:459ad1bd82fd 46 enum StartTxStates {
VASKO 16:459ad1bd82fd 47 StartOK,
VASKO 16:459ad1bd82fd 48 TxBusy,
VASKO 16:459ad1bd82fd 49 Undefined
VASKO 16:459ad1bd82fd 50 };
VASKO 16:459ad1bd82fd 51
VASKO 20:b60d2a5cd128 52 #define ArrTxInitializer {HeaderByte,HeaderByte,HeaderByte,HeaderByte,HeaderByte}
VASKO 16:459ad1bd82fd 53 #define ArrRxInitializer {}
VASKO 16:459ad1bd82fd 54
VASKO 15:30e45bd5902e 55 extern MsgType RxBuff;
VASKO 15:30e45bd5902e 56 extern bool RxBuffFull;
VASKO 15:30e45bd5902e 57 extern StartTxStates StartTx(uint8_t *parr);
VASKO 15:30e45bd5902e 58 extern void TxRxServiceInit();
VASKO 15:30e45bd5902e 59 extern uint8_t GetCheckSum(uint8_t *p);