initial commit
This commit is contained in:
41
port/picolibc/port.c
Normal file
41
port/picolibc/port.c
Normal file
@@ -0,0 +1,41 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
extern void uart_putc(char c);
|
||||
extern int uart_getc(void);
|
||||
|
||||
static int
|
||||
board_putc(char c, FILE *file)
|
||||
{
|
||||
(void) file; /* Not used in this function */
|
||||
uart_putc(c); /* Defined by underlying system */
|
||||
return c;
|
||||
}
|
||||
|
||||
static int
|
||||
board_getc(FILE *file)
|
||||
{
|
||||
unsigned char c;
|
||||
(void) file; /* Not used in this function */
|
||||
c = uart_getc(); /* Defined by underlying system */
|
||||
return c;
|
||||
}
|
||||
|
||||
static int
|
||||
board_flush(FILE *file)
|
||||
{
|
||||
(void) file; /* Not used in this function */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FILE __stdio = FDEV_SETUP_STREAM(board_putc, board_getc, board_flush, _FDEV_SETUP_RW);
|
||||
/*
|
||||
* Picolibc requires the application to define these
|
||||
* when using stdio in freestanding environments.
|
||||
*/
|
||||
// FILE * const stdin = NULL;
|
||||
// FILE * const stdout = NULL;
|
||||
// FILE * const stderr = NULL;
|
||||
FILE *const stdin = &__stdio;
|
||||
__strong_reference(stdin, stdout);
|
||||
__strong_reference(stdin, stderr);
|
||||
Reference in New Issue
Block a user