BSPACM  20150113
Board Support Package for ARM Cortex-M Microcontrollers
Functions | Variables
uart.h File Reference

File-descriptor capabilities associated with UART/CONSOLE peripherals. More...

#include <bspacm/core.h>
#include <bspacm/newlib/fdops.h>
#include <bspacm/periph/uart.h>

Go to the source code of this file.

Functions

hBSPACMnewlibFDOPSfile hBSPACMnewlibFDOPSdriverUARTbind (hBSPACMperiphUART usp)
 
sBSPACMnewlibFDOPSfilefBSPACMnewlibFDOPSdriverCONSOLE (const char *pathname, int flags)
 

Variables

const sBSPACMperiphUARTconfiguration xBSPACMnewlibFDOPSconsoleConfiguration
 

Detailed Description

File-descriptor capabilities associated with UART/CONSOLE peripherals.

Homepage
http://github.com/pabigot/bspacm

Function Documentation

sBSPACMnewlibFDOPSfile* fBSPACMnewlibFDOPSdriverCONSOLE ( const char *  pathname,
int  flags 
)

A driver function to support /dev/console as a UART.

The UART will be configured at a peripheral-specific speed. This should be 115200 8N1 for most UARTs, but if a low-speed peripheral is selected it may be 9600 8N1.

This should be placed into xBSPACMnewlibFDOPSdriver if the BSPACM board default UART is to be recognized as the console device for stdin/stdout/stderr.

Because there is only one console device, but it may need to be referenced by multiple descriptors, the returned structure is reference counted. The associated UART is deconfigured and the structure released only when no descriptors still reference it.

If the console device was already bound to a non-console descriptor through hBSPACMnewlibFDOPSdriverUARTbind(), the call will fail with errno set to EBUSY.

Parameters
pathnamethe path that was passed to open(). This function returns a null pointer if pathname is not equal to "/dev/console".
flagsignored
Returns
pointer to the singleton instance of the console descriptor state.
hBSPACMnewlibFDOPSfile hBSPACMnewlibFDOPSdriverUARTbind ( hBSPACMperiphUART  usp)

Utility function to bind a UART peripheral to file descriptor state.

This function allocates a file descriptor state object, assigns usp into its dev field, and assigning the standard UART operations table.

Note
If usp refers to the default console device, and that device is already open, the call will fail with errno set to EBUSY. Similarly, successfully binding the default console device through this API will prevent fBSPACMnewlibFDOPSdriverCONSOLE() from succeeding.
Parameters
uspa pointer to a UART peripheral. The peripheral is not configured by this function. (The peripheral is deconfigured by the implementation of close() in the operations table assigned by this function.
Returns
a newly allocated file descriptor state object, or null if something went wrong.

Variable Documentation

const sBSPACMperiphUARTconfiguration xBSPACMnewlibFDOPSconsoleConfiguration

The configuration that will be used by the console driver.

Weakly Defined
A weak definition of this that uses a device-specific default baud rate is provided in the newlib_fdops library, but may be overridden by an application that requires another configuration, e.g. when the clock rate will be reduced below the speed required to support the UART-specific default.