#include <bf52x_uart.h>
#include <syscall.h>
Include dependency graph for console.c:
Defines | |
#define | CHARS_TX_MAX 128 |
Functions | |
static int | console_open (const char *path, int flags, int mode) |
Is not called for console. | |
static int | console_close (int fd) |
Is not called for console. | |
static int | console_write (int fd, const void *ptr, int len) |
Writes to uart console. | |
static int | console_read (int fd, void *ptr, int len) |
Reads from the console uart. | |
Variables | |
const devoptab_t | console_devoptab |
Console table. |
#define CHARS_TX_MAX 128 |
static int console_close | ( | int | fd | ) | [static] |
Is not called for console.
The newlib directly calls write and read
fd | file descriptor |
static int console_open | ( | const char * | path, | |
int | flags, | |||
int | mode | |||
) | [static] |
Is not called for console.
The newlib directly calls write and read
path | file to be opened | |
flags | opening flags | |
mode | opening mode |
static int console_read | ( | int | fd, | |
void * | ptr, | |||
int | len | |||
) | [static] |
Reads from the console uart.
fd | file descriptor | |
ptr | pointer to buffer where the read data will be placed | |
len | length og the expected data |
The bf52x_uart_receive returns 0 for success and negative for failure For the newlib we have to return the number of char transfered. So we check the result and return binary value either fully transfered or nothing transfered.
GS: Note bf52x_uart_receive has unsigned char as len paramter, will overflow if called from within scanf (with 1024). Hence, bf52x_uart_receive will see a 0 as len and return 0, which is improperly handled in newlibc. Workaround (given the todo above), always request len 1 only, and let newlibc iterate if it wants more chars.static int console_write | ( | int | fd, | |
const void * | ptr, | |||
int | len | |||
) | [static] |
Writes to uart console.
fd | file descriptor | |
ptr | pointer to the buffer to be tx | |
len | length of data to be transfered |
The bf52x_uart_transmit returns 0 for success and negative for failure For the newlib we have to return the number of char transfered. So we check the result and return binary value either fully transfered or nothing transfered.
const devoptab_t console_devoptab |
Initial value:
{ "console", console_open, console_close, console_write, console_read }