rewrite C library printf function to USART0
This commit is contained in:
parent
58a0bcc42c
commit
097dd5714b
13
src/main.c
13
src/main.c
@ -34,15 +34,20 @@ int main(void)
|
||||
delay_ms(5000);
|
||||
bldc_enable_set(SET);
|
||||
|
||||
printf("system start!");
|
||||
|
||||
while(1){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* retarget the C library printf function to the USART */
|
||||
int fputc(int ch, FILE *f)
|
||||
int _write (int fd, char *pBuffer, int size)
|
||||
{
|
||||
usart_data_transmit(USART0, (uint8_t)ch);
|
||||
while(RESET == usart_flag_get(USART0, USART_FLAG_TBE));
|
||||
return ch;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
usart_data_transmit(USART0, (uint8_t)pBuffer[i]);
|
||||
while(RESET == usart_flag_get(USART0, USART_FLAG_TBE));
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user