/* TODO: Add any necessary local functions. */ ssize_t SYS_CONSOLE_ReadX(const SYS_MODULE_INDEX index, int fd, void *buf, size_t count ) { size_t numBytes = 0; char* pReadByte = (char*)buf; do { if( !DRV_USART0_ReceiverBufferIsEmpty() ) { *pReadByte = DRV_USART0_ReadByte(); numBytes++; pReadByte++; } } while( numBytes < count ); return numBytes; }
void IntHandlerDrvUsartInstance0(void) { /* TODO: Add code to process interrupt here */ //if (!DRV_USART0_ReceiverBufferIsEmpty()){ //stopAll(); char incomingByte = DRV_USART0_ReadByte(); receiveSendValFromISR(&incomingByte); // } // If transmitter not enabled, interrupt never occurs here (messages still go through over wifly) // Transmitter enable -> Empty Flag up if (PLIB_USART_TransmitterIsEmpty(USART_ID_1)) { receiveDataFromISR(); } PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_USART_1_RECEIVE); PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_USART_1_TRANSMIT); PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_USART_1_ERROR); }
//Byte Model uint8_t DRV_USART_ReadByte( const DRV_HANDLE handle ) { uintptr_t instance; uint8_t returnValue; instance = handle & 0x00FF; //As we are handling single client, only multiple instance is taken care. switch(instance) { case DRV_USART_INDEX_0: { returnValue = DRV_USART0_ReadByte(); break; } default: { SYS_ASSERT(false, "Incorrect Driver Handle"); returnValue = 0; break; } } return returnValue; }