Skip to content

Commit

Permalink
[USART] add Rx timeout handling to USART interrupt handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Pertsch committed Dec 17, 2021
1 parent 6048f90 commit acc4c82
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions peripheral/usart_6089/templates/plib_usart.c.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,16 @@ void ${USART_INSTANCE_NAME}_InterruptHandler( void )
}
}
<#else>

/* Receiver timeout */
if (${USART_INSTANCE_NAME}_REGS->US_CSR & US_CSR_USART_TIMEOUT_Msk)
{
if(${USART_INSTANCE_NAME?lower_case}Obj.rxTimeoutCallback != NULL)
{
${USART_INSTANCE_NAME?lower_case}Obj.rxTimeoutCallback(${USART_INSTANCE_NAME?lower_case}Obj.rxTimeoutContext);
}
}

/* Receiver status */
if (${USART_INSTANCE_NAME}_REGS->US_CSR & US_CSR_USART_RXRDY_Msk)
{
Expand Down Expand Up @@ -565,6 +575,13 @@ void ${USART_INSTANCE_NAME}_ReadCallbackRegister( USART_CALLBACK callback, uintp
${USART_INSTANCE_NAME?lower_case}Obj.rxContext = context;
}

void ${USART_INSTANCE_NAME}_ReadTimeoutCallbackRegister( USART_CALLBACK callback, uintptr_t context )
{
${USART_INSTANCE_NAME?lower_case}Obj.rxTimeoutCallback = callback;

${USART_INSTANCE_NAME?lower_case}Obj.rxTimeoutContext = context;
}

bool ${USART_INSTANCE_NAME}_WriteIsBusy( void )
{
return ${USART_INSTANCE_NAME?lower_case}Obj.txBusyStatus;
Expand Down
2 changes: 2 additions & 0 deletions peripheral/usart_6089/templates/plib_usart.h.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ void ${USART_INSTANCE_NAME}_WriteCallbackRegister( USART_CALLBACK callback, uint

void ${USART_INSTANCE_NAME}_ReadCallbackRegister( USART_CALLBACK callback, uintptr_t context );

void ${USART_INSTANCE_NAME}_ReadTimeoutCallbackRegister( USART_CALLBACK callback, uintptr_t context );

</#if>

// DOM-IGNORE-BEGIN
Expand Down
2 changes: 2 additions & 0 deletions peripheral/usart_6089/templates/plib_usart_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ typedef struct
volatile size_t rxProcessedSize;
USART_CALLBACK rxCallback;
uintptr_t rxContext;
USART_CALLBACK rxTimeoutCallback;
uintptr_t rxTimeoutContext;
bool rxBusyStatus;

volatile USART_ERROR errorStatus;
Expand Down

0 comments on commit acc4c82

Please sign in to comment.