void onInterrupt(UsartEventType uet) { if(uet==UsartEventType::EVENT_RECEIVE) { // receive the next character _buffer[_index++]=_usart.receive(); // if we've got the 5 characters then disable receiving interrupts // and enable sending if(_index==5) { _index=0; _usart.disableInterrupts(MyUsartInterrupt::RECEIVE); _usart.enableInterrupts(MyUsartInterrupt::TRANSMIT); } } else if(uet==UsartEventType::EVENT_READY_TO_TRANSMIT) { // send the next character _usart.send(_buffer[_index++]); // if we've sent back all 5 then disable sending interrupts and go back // to receiving again if(_index==5) { _index=0; _usart.disableInterrupts(MyUsartInterrupt::TRANSMIT); _usart.enableInterrupts(MyUsartInterrupt::RECEIVE); } } }
virtual void onNotify(Observable&,ObservableEvent::E event,void *) { if(event==ObservableEvent::USART_ReadyToTransmit && *_dataToSend) { // send the next character and increment the pointer _usart.send(*_dataToSend++); // if we are now at the end of the string then disable further interrupts // because we are done if(*_dataToSend=='\0') _usart.disableInterrupts(MyUsartInterrupt::TRANSMIT); } }