vasko ozo
/
TxRxService
20190816
Diff: TxRxService.cpp
- Revision:
- 11:6519744c77f9
- Child:
- 13:b9e066badefa
diff -r f7a320faef76 -r 6519744c77f9 TxRxService.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TxRxService.cpp Sat Aug 03 20:03:56 2019 +0000 @@ -0,0 +1,44 @@ +#include "PrjDefs.h" + +Serial pc(pcTx,pcRx); + +uint8_t ArrTx[ArrTxSize] = ArrTxInitializer; +uint8_t ArrRx[ArrRxSize] = ArrRxInitializer; +uint8_t RxBuff[ArrRxSize]; +uint8_t TxBuff[ArrTxSize]; +uint8_t *pArrTx = &ArrTx[0]; +uint8_t *pArrRx = &ArrRx[0]; +bool ArrRxCmplt = 0; +bool ArrTxBusy = 0; +bool TxBuffFull = 0; + +void IntrTx() { + if ( ++pArrTx <= &ArrTx[ArrTxSize-1] ) pc.putc(*pArrTx); + else { + pc.attach(NULL, Serial::TxIrq); + ArrTxBusy = 0; + } + }//IntrTx + +void StartTx(){ + memcpy(&ArrTx, &TxBuff, ArrTxSize); + pArrTx = &ArrTx[0]; + pc.putc(*pArrTx); + pc.attach(&IntrTx, Serial::TxIrq); + ArrTxBusy = 1; + }//StartTx + +void IntrRx() { + *pArrRx = pc.getc(); + if ( pArrRx++ >= &ArrRx[ArrRxSize-1] ) { + pArrRx = &ArrRx[0]; + ArrRxCmplt = 1; + memcpy(&RxBuff, &ArrRx, ArrTxSize); + } + }//IntrRx + +void TxRxServiceInit(){ + pc.attach(&IntrRx, Serial::RxIrq); + pc.attach(NULL, Serial::TxIrq);//я УПЁРТЫЙ дебил + } +