Minor update to the UART write function in the IAR/QEMU/MPS2 demo (#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 <60444055+AniruddhaKanhere@users.noreply.github.com>
This commit is contained in:
RichardBarry
2021-04-20 21:04:29 -07:00
committed by GitHub
parent 5ac8279c1b
commit 9f10725bee

View File

@ -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.
@ -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;
}