vasko ozo
/
TxRxService
20190816
main.cpp@9:dcddb19ad551, 2019-08-03 (annotated)
- Committer:
- VASKO
- Date:
- Sat Aug 03 15:29:28 2019 +0000
- Revision:
- 9:dcddb19ad551
- Parent:
- 8:cad966c09853
- Child:
- 10:f7a320faef76
Using "memcpy" instead od "CopyMemUint8".; ---------------
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
VASKO | 7:7aaa14391264 | 1 | #include "PrjDefs.h" |
VASKO | 0:5152e3f9df72 | 2 | |
VASKO | 2:56a194afd255 | 3 | Serial pc(USBTX,USBRX); |
VASKO | 0:5152e3f9df72 | 4 | |
VASKO | 0:5152e3f9df72 | 5 | DigitalOut myled(LED1); |
VASKO | 0:5152e3f9df72 | 6 | |
VASKO | 7:7aaa14391264 | 7 | uint8_t ArrTx[ArrTxSize] = ArrTxInitializer; |
VASKO | 7:7aaa14391264 | 8 | uint8_t ArrRx[ArrRxSize] = ArrRxInitializer; |
VASKO | 6:1364a236ee22 | 9 | uint8_t *pArrTx = &ArrTx[0]; |
VASKO | 6:1364a236ee22 | 10 | uint8_t *pArrRx = &ArrRx[0]; |
VASKO | 8:cad966c09853 | 11 | bool ArrRxCmplt = 0; |
VASKO | 5:ad4e5a078834 | 12 | |
VASKO | 0:5152e3f9df72 | 13 | void IntrTx() { |
VASKO | 8:cad966c09853 | 14 | if ( ++pArrTx <= &ArrTx[ArrTxSize-1] ) pc.putc(*pArrTx); |
VASKO | 8:cad966c09853 | 15 | else pc.attach(NULL, Serial::TxIrq); |
VASKO | 0:5152e3f9df72 | 16 | } |
VASKO | 8:cad966c09853 | 17 | |
VASKO | 8:cad966c09853 | 18 | void StartTx(){ |
VASKO | 8:cad966c09853 | 19 | pArrTx = &ArrTx[0]; |
VASKO | 8:cad966c09853 | 20 | pc.putc(*pArrTx); |
VASKO | 8:cad966c09853 | 21 | pc.attach(&IntrTx, Serial::TxIrq); |
VASKO | 8:cad966c09853 | 22 | }//StartTx |
VASKO | 0:5152e3f9df72 | 23 | |
VASKO | 2:56a194afd255 | 24 | void IntrRx() { |
VASKO | 4:d461cadeb702 | 25 | *pArrRx = pc.getc(); |
VASKO | 8:cad966c09853 | 26 | if ( pArrRx++ >= &ArrRx[ArrRxSize-1] ) { pArrRx = &ArrRx[0]; ArrRxCmplt = 1; } |
VASKO | 8:cad966c09853 | 27 | }//IntrRx |
VASKO | 0:5152e3f9df72 | 28 | |
VASKO | 0:5152e3f9df72 | 29 | int main() { |
VASKO | 0:5152e3f9df72 | 30 | pc.attach(&IntrRx, Serial::RxIrq); |
VASKO | 0:5152e3f9df72 | 31 | pc.attach(NULL, Serial::TxIrq);//я УПЁРТЫЙ дебил |
VASKO | 0:5152e3f9df72 | 32 | |
VASKO | 2:56a194afd255 | 33 | //Exige Monumentum |
VASKO | 9:dcddb19ad551 | 34 | //Я дебил,потому что хотел выполнить действия,которые |
VASKO | 2:56a194afd255 | 35 | //требуются постоянно,один раз и именно здесь. |
VASKO | 0:5152e3f9df72 | 36 | |
VASKO | 0:5152e3f9df72 | 37 | while(1) { |
VASKO | 8:cad966c09853 | 38 | if ( ArrRxCmplt == 1 ){ |
VASKO | 9:dcddb19ad551 | 39 | memcpy(&ArrTx[0], &ArrRx[0], ArrTxSize); |
VASKO | 8:cad966c09853 | 40 | StartTx(); |
VASKO | 8:cad966c09853 | 41 | ArrRxCmplt = 0; |
VASKO | 8:cad966c09853 | 42 | } |
VASKO | 8:cad966c09853 | 43 | }//while(1) |
VASKO | 9:dcddb19ad551 | 44 | }//main |
VASKO | 9:dcddb19ad551 | 45 |