vasko ozo
/
TxRxService
20190816
main.cpp@7:7aaa14391264, 2019-08-03 (annotated)
- Committer:
- VASKO
- Date:
- Sat Aug 03 14:02:58 2019 +0000
- Revision:
- 7:7aaa14391264
- Parent:
- 6:1364a236ee22
- Child:
- 8:cad966c09853
"PrjDefs.h" added. Obvious changes.
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 | 5:ad4e5a078834 | 11 | |
VASKO | 0:5152e3f9df72 | 12 | void IntrTx() { |
VASKO | 5:ad4e5a078834 | 13 | if ( ++pArrTx <= &ArrTx[ArrTxSize-1] ){ |
VASKO | 5:ad4e5a078834 | 14 | pc.putc(*pArrTx); |
VASKO | 0:5152e3f9df72 | 15 | } |
VASKO | 0:5152e3f9df72 | 16 | else{ |
VASKO | 2:56a194afd255 | 17 | pc.attach(NULL, Serial::TxIrq); |
VASKO | 2:56a194afd255 | 18 | myled=0; |
VASKO | 0:5152e3f9df72 | 19 | } |
VASKO | 0:5152e3f9df72 | 20 | } |
VASKO | 0:5152e3f9df72 | 21 | |
VASKO | 4:d461cadeb702 | 22 | void CopyMemUint8(uint8_t *src = &ArrRx[0], uint8_t *dst = &ArrTx[0], int qty = ArrTxSize){ |
VASKO | 3:7cdb20aac969 | 23 | for ( ; qty > 0; src++,dst++,qty-- ) *dst = *src; |
VASKO | 3:7cdb20aac969 | 24 | } |
VASKO | 4:d461cadeb702 | 25 | |
VASKO | 2:56a194afd255 | 26 | void IntrRx() { |
VASKO | 4:d461cadeb702 | 27 | *pArrRx = pc.getc(); |
VASKO | 5:ad4e5a078834 | 28 | if ( pArrRx++ >= &ArrRx[ArrRxSize-1] ) { |
VASKO | 4:d461cadeb702 | 29 | pArrRx = &ArrRx[0]; |
VASKO | 4:d461cadeb702 | 30 | CopyMemUint8(); |
VASKO | 5:ad4e5a078834 | 31 | pArrTx = &ArrTx[0]; |
VASKO | 5:ad4e5a078834 | 32 | pc.putc(*pArrTx); |
VASKO | 2:56a194afd255 | 33 | pc.attach(&IntrTx, Serial::TxIrq); |
VASKO | 2:56a194afd255 | 34 | myled=1; |
VASKO | 2:56a194afd255 | 35 | } |
VASKO | 0:5152e3f9df72 | 36 | } |
VASKO | 0:5152e3f9df72 | 37 | |
VASKO | 0:5152e3f9df72 | 38 | int main() { |
VASKO | 0:5152e3f9df72 | 39 | pc.attach(&IntrRx, Serial::RxIrq); |
VASKO | 0:5152e3f9df72 | 40 | pc.attach(NULL, Serial::TxIrq);//я УПЁРТЫЙ дебил |
VASKO | 0:5152e3f9df72 | 41 | |
VASKO | 2:56a194afd255 | 42 | //Exige Monumentum |
VASKO | 2:56a194afd255 | 43 | //Я дебил,потому что хотел выполнить действия,которые |
VASKO | 2:56a194afd255 | 44 | //требуются постоянно,один раз и именно здесь. |
VASKO | 0:5152e3f9df72 | 45 | |
VASKO | 0:5152e3f9df72 | 46 | while(1) { |
VASKO | 0:5152e3f9df72 | 47 | } |
VASKO | 0:5152e3f9df72 | 48 | } |