Skip to content

Commit

Permalink
Minor update to the UART write function in the IAR/QEMU/MPS2 demo (Fr…
Browse files Browse the repository at this point in the history
…eeRTOS#535)

* Minor update to the UART write function in the IAR/QEMU/MPS2 demo project.  Now the function checks to ensure there is space in the Tx buffer before writing to the buffer - although this does not appear to be necessary in QEMU it is more correct.

* Update main.c

Co-authored-by: Aniruddha Kanhere <[email protected]>
  • Loading branch information
RichardBarry and AniruddhaKanhere authored Apr 21, 2021
1 parent 5ac8279 commit 9f10725
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ implemented and described in main_full.c. */
required UART registers. */
#define UART0_ADDRESS ( 0x40004000UL )
#define UART0_DATA ( * ( ( ( volatile uint32_t * )( UART0_ADDRESS + 0UL ) ) ) )
#define UART0_STATE ( * ( ( ( volatile uint32_t * )( UART0_ADDRESS + 4UL ) ) ) )
#define UART0_CTRL ( * ( ( ( volatile uint32_t * )( UART0_ADDRESS + 8UL ) ) ) )
#define UART0_BAUDDIV ( * ( ( ( volatile uint32_t * )( UART0_ADDRESS + 16UL ) ) ) )
#define TX_BUFFER_MASK ( 1UL )

/*
* main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.
Expand Down Expand Up @@ -257,25 +259,26 @@ static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];

static void prvUARTInit( void )
{
UART0_BAUDDIV = 16;
UART0_CTRL = 1;
UART0_BAUDDIV = 16;
UART0_CTRL = 1;
}
/*-----------------------------------------------------------*/

int __write( int iFile, char *pcString, int iStringLength )
{
uint32_t ulNextChar;
uint32_t ulNextChar;

/* Avoid compiler warnings about unused parameters. */
( void ) iFile;

/* Output the formatted string to the UART. */
for( ulNextChar = 0; ulNextChar < iStringLength; ulNextChar++ )
for( ulNextChar = 0; ulNextChar < iStringLength; ulNextChar++ )
{
UART0_DATA = *pcString;
while( ( UART0_STATE & TX_BUFFER_MASK ) != 0 );
UART0_DATA = *pcString;
pcString++;
}
}

return iStringLength;
return iStringLength;
}

0 comments on commit 9f10725

Please sign in to comment.