20190816

Dependencies:   mbed

main.cpp

Committer:
VASKO
Date:
2019-08-02
Revision:
2:56a194afd255
Parent:
1:e5810b8734ec
Child:
3:7cdb20aac969

File content as of revision 2:56a194afd255:

#include "mbed.h"

#define ArrTxSize 16
#define ArrRxSize 16

Serial pc(USBTX,USBRX);

DigitalOut myled(LED1);

int nCharTx = 0;
int nCharRx = 0;

uint8_t ArrTx[ArrTxSize] = {0x20,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4b,0x4c,0x4d,0x4e,0x4f};
uint8_t ArrRx[ArrRxSize] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
    
void IntrTx() {
    nCharTx++;
    if (nCharTx < ArrTxSize ){
    pc.putc(ArrTx[nCharTx]);
    }
    else{
        pc.attach(NULL, Serial::TxIrq);
        myled=0;  
        }
    }

void IntrRx() {
    ArrRx[nCharRx++] = pc.getc();
    if (nCharRx >= ArrRxSize ) {
        for(int i = 0; i < ArrTxSize; i++){
            ArrTx[i] = ArrRx[i];
            }
        nCharTx = 0;
        pc.putc(ArrTx[nCharTx]);                          
        pc.attach(&IntrTx, Serial::TxIrq);
        nCharRx = 0;
        myled=1;  
        }
    }

int main() {
            pc.attach(&IntrRx, Serial::RxIrq);
            pc.attach(NULL, Serial::TxIrq);//я УПЁРТЫЙ дебил
            
            //Exige Monumentum
            //Я дебил,потому что хотел выполнить действия,которые 
            //требуются постоянно,один раз и именно здесь.
            
    while(1) {
    }
}