src/console.c File Reference

More...

#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.

Detailed Description

Author:
Rohan Kangralkar
Date:
11/11/2011
LastChange:
Id
console.c 1069 2013-02-25 18:19:21Z ovaskevi

Define Documentation

#define CHARS_TX_MAX   128


Function Documentation

static int console_close ( int  fd  )  [static]

Is not called for console.

The newlib directly calls write and read

Parameters:
fd file descriptor
Returns:
negative for console

static int console_open ( const char *  path,
int  flags,
int  mode 
) [static]

Is not called for console.

The newlib directly calls write and read

Parameters:
path file to be opened
flags opening flags
mode opening mode
Returns:
failure for console

static int console_read ( int  fd,
void *  ptr,
int  len 
) [static]

Reads from the console uart.

Parameters:
fd file descriptor
ptr pointer to buffer where the read data will be placed
len length og the expected data
Returns:
number of char read

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.

Todo:
https://discussions.zoho.com/tlldesignbfn1/topic/return-value-for-transfers-of-data-over-uart
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.

Parameters:
fd file descriptor
ptr pointer to the buffer to be tx
len length of data to be transfered
Returns:
number of bytes written.

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.

Todo:
https://discussions.zoho.com/tlldesignbfn1/topic/return-value-for-transfers-of-data-over-uart


Variable Documentation

const devoptab_t console_devoptab

Initial value:

Console table.


Generated on 3 Mar 2014 for PAL bare-c Library by  doxygen 1.4.7