Question about implementation of scanf

Discussion around product based on ARM Cortex M4 core.

Moderators: nferre, ncollot

Posts: 57
Joined: Wed Jul 23, 2014 3:25 pm

Question about implementation of scanf

Fri Dec 19, 2014 12:37 pm

Hello everyone,

I am working with SAM4S and trying to read data through UART from PC terminal. I am trying to use the scanf function from stdio.h, but I cannot exactly find its implementation since stdio.h has the declaration as follows

int _EXFUN(scanf, (const char *, ...) _ATTRIBUTE ((__format__ (__scanf__, 1, 2))));

I have written the low level function for reading a byte from the UART as follows

Code: Select all

int gchar (uint8_t *puc_data)
	/* Check if the receiver is ready */
	while(!(UART0->UART_SR & UART_SR_RXRDY));
	/* Read character from receive holding register */
	*puc_data = (uint8_t) UART0->UART_RHR;
	return 0;
Where should I put this in order to read string from the terminal? Thanks in advance.


Return to “SAM4 Cortex-M4 MCU”

Who is online

Users browsing this forum: No registered users and 1 guest