20190816

Dependencies:   mbed

Committer:
VASKO
Date:
Sat Aug 03 13:44:32 2019 +0000
Revision:
6:1364a236ee22
Parent:
5:ad4e5a078834
Child:
7:7aaa14391264
Minor reorganization of previous.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
VASKO 0:5152e3f9df72 1 #include "mbed.h"
VASKO 0:5152e3f9df72 2
VASKO 0:5152e3f9df72 3 #define ArrTxSize 16
VASKO 0:5152e3f9df72 4 #define ArrRxSize 16
VASKO 0:5152e3f9df72 5
VASKO 2:56a194afd255 6 Serial pc(USBTX,USBRX);
VASKO 0:5152e3f9df72 7
VASKO 0:5152e3f9df72 8 DigitalOut myled(LED1);
VASKO 0:5152e3f9df72 9
VASKO 2:56a194afd255 10 uint8_t ArrTx[ArrTxSize] = {0x20,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4b,0x4c,0x4d,0x4e,0x4f};
VASKO 2:56a194afd255 11 uint8_t ArrRx[ArrRxSize] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
VASKO 6:1364a236ee22 12 uint8_t *pArrTx = &ArrTx[0];
VASKO 6:1364a236ee22 13 uint8_t *pArrRx = &ArrRx[0];
VASKO 5:ad4e5a078834 14
VASKO 0:5152e3f9df72 15 void IntrTx() {
VASKO 5:ad4e5a078834 16 if ( ++pArrTx <= &ArrTx[ArrTxSize-1] ){
VASKO 5:ad4e5a078834 17 pc.putc(*pArrTx);
VASKO 0:5152e3f9df72 18 }
VASKO 0:5152e3f9df72 19 else{
VASKO 2:56a194afd255 20 pc.attach(NULL, Serial::TxIrq);
VASKO 2:56a194afd255 21 myled=0;
VASKO 0:5152e3f9df72 22 }
VASKO 0:5152e3f9df72 23 }
VASKO 0:5152e3f9df72 24
VASKO 4:d461cadeb702 25 void CopyMemUint8(uint8_t *src = &ArrRx[0], uint8_t *dst = &ArrTx[0], int qty = ArrTxSize){
VASKO 3:7cdb20aac969 26 for ( ; qty > 0; src++,dst++,qty-- ) *dst = *src;
VASKO 3:7cdb20aac969 27 }
VASKO 4:d461cadeb702 28
VASKO 2:56a194afd255 29 void IntrRx() {
VASKO 4:d461cadeb702 30 *pArrRx = pc.getc();
VASKO 5:ad4e5a078834 31 if ( pArrRx++ >= &ArrRx[ArrRxSize-1] ) {
VASKO 4:d461cadeb702 32 pArrRx = &ArrRx[0];
VASKO 4:d461cadeb702 33 CopyMemUint8();
VASKO 5:ad4e5a078834 34 pArrTx = &ArrTx[0];
VASKO 5:ad4e5a078834 35 pc.putc(*pArrTx);
VASKO 2:56a194afd255 36 pc.attach(&IntrTx, Serial::TxIrq);
VASKO 2:56a194afd255 37 myled=1;
VASKO 2:56a194afd255 38 }
VASKO 0:5152e3f9df72 39 }
VASKO 0:5152e3f9df72 40
VASKO 0:5152e3f9df72 41 int main() {
VASKO 0:5152e3f9df72 42 pc.attach(&IntrRx, Serial::RxIrq);
VASKO 0:5152e3f9df72 43 pc.attach(NULL, Serial::TxIrq);//я УПЁРТЫЙ дебил
VASKO 0:5152e3f9df72 44
VASKO 2:56a194afd255 45 //Exige Monumentum
VASKO 2:56a194afd255 46 //Я дебил,потому что хотел выполнить действия,которые
VASKO 2:56a194afd255 47 //требуются постоянно,один раз и именно здесь.
VASKO 0:5152e3f9df72 48
VASKO 0:5152e3f9df72 49 while(1) {
VASKO 0:5152e3f9df72 50 }
VASKO 0:5152e3f9df72 51 }