vasko ozo
/
TxRxService
20190816
TxRxService.cpp@13:b9e066badefa, 2019-08-04 (annotated)
- Committer:
- VASKO
- Date:
- Sun Aug 04 09:56:54 2019 +0000
- Revision:
- 13:b9e066badefa
- Parent:
- 11:6519744c77f9
- Child:
- 14:b113f676ef42
"ArrRxCmplt" renamed to "RxBuffFull".
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
VASKO | 11:6519744c77f9 | 1 | #include "PrjDefs.h" |
VASKO | 11:6519744c77f9 | 2 | |
VASKO | 11:6519744c77f9 | 3 | Serial pc(pcTx,pcRx); |
VASKO | 11:6519744c77f9 | 4 | |
VASKO | 11:6519744c77f9 | 5 | uint8_t ArrTx[ArrTxSize] = ArrTxInitializer; |
VASKO | 11:6519744c77f9 | 6 | uint8_t ArrRx[ArrRxSize] = ArrRxInitializer; |
VASKO | 11:6519744c77f9 | 7 | uint8_t RxBuff[ArrRxSize]; |
VASKO | 11:6519744c77f9 | 8 | uint8_t TxBuff[ArrTxSize]; |
VASKO | 11:6519744c77f9 | 9 | uint8_t *pArrTx = &ArrTx[0]; |
VASKO | 11:6519744c77f9 | 10 | uint8_t *pArrRx = &ArrRx[0]; |
VASKO | 13:b9e066badefa | 11 | bool RxBuffFull = 0; |
VASKO | 11:6519744c77f9 | 12 | bool ArrTxBusy = 0; |
VASKO | 11:6519744c77f9 | 13 | bool TxBuffFull = 0; |
VASKO | 11:6519744c77f9 | 14 | |
VASKO | 11:6519744c77f9 | 15 | void IntrTx() { |
VASKO | 11:6519744c77f9 | 16 | if ( ++pArrTx <= &ArrTx[ArrTxSize-1] ) pc.putc(*pArrTx); |
VASKO | 11:6519744c77f9 | 17 | else { |
VASKO | 11:6519744c77f9 | 18 | pc.attach(NULL, Serial::TxIrq); |
VASKO | 11:6519744c77f9 | 19 | ArrTxBusy = 0; |
VASKO | 11:6519744c77f9 | 20 | } |
VASKO | 11:6519744c77f9 | 21 | }//IntrTx |
VASKO | 11:6519744c77f9 | 22 | |
VASKO | 11:6519744c77f9 | 23 | void StartTx(){ |
VASKO | 11:6519744c77f9 | 24 | memcpy(&ArrTx, &TxBuff, ArrTxSize); |
VASKO | 11:6519744c77f9 | 25 | pArrTx = &ArrTx[0]; |
VASKO | 11:6519744c77f9 | 26 | pc.putc(*pArrTx); |
VASKO | 11:6519744c77f9 | 27 | pc.attach(&IntrTx, Serial::TxIrq); |
VASKO | 11:6519744c77f9 | 28 | ArrTxBusy = 1; |
VASKO | 11:6519744c77f9 | 29 | }//StartTx |
VASKO | 11:6519744c77f9 | 30 | |
VASKO | 11:6519744c77f9 | 31 | void IntrRx() { |
VASKO | 11:6519744c77f9 | 32 | *pArrRx = pc.getc(); |
VASKO | 11:6519744c77f9 | 33 | if ( pArrRx++ >= &ArrRx[ArrRxSize-1] ) { |
VASKO | 11:6519744c77f9 | 34 | pArrRx = &ArrRx[0]; |
VASKO | 13:b9e066badefa | 35 | RxBuffFull = 1; |
VASKO | 11:6519744c77f9 | 36 | memcpy(&RxBuff, &ArrRx, ArrTxSize); |
VASKO | 11:6519744c77f9 | 37 | } |
VASKO | 11:6519744c77f9 | 38 | }//IntrRx |
VASKO | 11:6519744c77f9 | 39 | |
VASKO | 11:6519744c77f9 | 40 | void TxRxServiceInit(){ |
VASKO | 11:6519744c77f9 | 41 | pc.attach(&IntrRx, Serial::RxIrq); |
VASKO | 11:6519744c77f9 | 42 | pc.attach(NULL, Serial::TxIrq);//я УПЁРТЫЙ дебил |
VASKO | 11:6519744c77f9 | 43 | } |
VASKO | 11:6519744c77f9 | 44 |