BSP430  20141115
Board Support Package for MSP430 microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Structures | Macros | Typedefs
serial_.h File Reference

Structures for abstracted serial interface. More...

#include <bsp430/core.h>
#include <bsp430/periph.h>
#include <bsp430/resource.h>

Go to the source code of this file.

Data Structures

struct  sBSP430halSERIAL
 

Macros

#define BSP430_SERIAL_ENABLE_RESOURCE   0
 
#define BSP430_SERIAL_HAL_HPL_VARIANT_USCI   1
 
#define BSP430_SERIAL_HAL_HPL_VARIANT_USCI5   2
 
#define BSP430_SERIAL_HAL_HPL_VARIANT_EUSCIA   3
 
#define BSP430_SERIAL_HAL_HPL_VARIANT_EUSCIB   4
 
#define BSP430_SERIAL_HAL_HPL_VARIANT_IS_USCI(hal_)   (BSP430_SERIAL_HAL_HPL_VARIANT_USCI == BSP430_PERIPH_HAL_STATE_CFLAGS_VARIANT(hal_))
 
#define BSP430_SERIAL_HAL_GET_HPL_USCI(hal_)   ((BSP430_SERIAL_HAL_HPL_VARIANT_IS_USCI(hal_)) ? (hal_)->hpl.usci : (void *)0)
 
#define BSP430_SERIAL_HAL_HPL_VARIANT_IS_USCI5(hal_)   (BSP430_SERIAL_HAL_HPL_VARIANT_USCI5 == BSP430_PERIPH_HAL_STATE_CFLAGS_VARIANT(hal_))
 
#define BSP430_SERIAL_HAL_GET_HPL_USCI5(hal_)   ((BSP430_SERIAL_HAL_HPL_VARIANT_IS_USCI5(hal_)) ? (hal_)->hpl.usci5 : (void *)0)
 
#define BSP430_SERIAL_HAL_HPL_VARIANT_IS_EUSCIA(hal_)   (BSP430_SERIAL_HAL_HPL_VARIANT_EUSCIA == BSP430_PERIPH_HAL_STATE_CFLAGS_VARIANT(hal_))
 
#define BSP430_SERIAL_HAL_GET_HPL_EUSCIA(hal_)   ((BSP430_SERIAL_HAL_HPL_VARIANT_IS_EUSCIA(hal_)) ? (hal_)->hpl.euscia : (void *)0)
 
#define BSP430_SERIAL_HAL_HPL_VARIANT_IS_EUSCIB(hal_)   (BSP430_SERIAL_HAL_HPL_VARIANT_EUSCIB == BSP430_PERIPH_HAL_STATE_CFLAGS_VARIANT(hal_))
 
#define BSP430_SERIAL_HAL_GET_HPL_EUSCIB(hal_)   ((BSP430_SERIAL_HAL_HPL_VARIANT_IS_EUSCIB(hal_)) ? (hal_)->hpl.euscib : (void *)0)
 
#define BSP430_SERIAL_HAL_GET_HPLAUX_USCI(hal_)   ((BSP430_SERIAL_HAL_HPL_VARIANT_IS_USCI(hal_)) ? (hal_)->hpl_aux.usci : (void *)0)
 
#define BSP430_SERIAL_HAL_GET_HPLAUX_USCI5(hal_)   ((BSP430_SERIAL_HAL_HPL_VARIANT_IS_USCI5(hal_)) ? (hal_)->hpl_aux.usci5 : (void *)0)
 
#define BSP430_SERIAL_HAL_GET_HPLAUX_EUSCIA(hal_)   ((BSP430_SERIAL_HAL_HPL_VARIANT_IS_EUSCIA(hal_)) ? (hal_)->hpl_aux.euscia : (void *)0)
 
#define BSP430_SERIAL_HAL_GET_HPLAUX_EUSCIB(hal_)   ((BSP430_SERIAL_HAL_HPL_VARIANT_IS_EUSCIB(hal_)) ? (hal_)->hpl_aux.euscib : (void *)0)
 
#define BSP430_SERIAL_SPI_READ_TX_BYTE(i_)   (i_)
 

Typedefs

typedef struct sBSP430halSERIAL sBSP430halSERIAL
 
typedef struct sBSP430halSERIALhBSP430halSERIAL
 

Detailed Description

Structures for abstracted serial interface.

The MSP430 line has a variety of peripherals that support serial communications, including the origin 2xx/4xx family USCI, 5xx USCI, and 5xx eUSCI. These are sufficiently similar in function that it is useful to have a hardware abstraction layer that delegates to the peripherals available on the current platform.

To break circular dependencies between the shared <bsp430/serial.h> file and the individual peripherals that are supported by it, this header contains the structures that are required by the individual peripherals to declare their own interfaces. Those headers then include this one, and <bsp430/serial.h> includes the relevant individual peripheral headers.

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

Macro Definition Documentation

#define BSP430_SERIAL_ENABLE_RESOURCE   0

Indicate whether serial HAL structures should include a resource object.

The bulk of the serial interface requires exclusive access consistent with The _rh "resource held" suffix. By defining this to a true value the sBSP430halSERIAL::resource field will be available in each hBSP430halSERIAL instance to simplify resource management between subsystems.

Note
It is the responsibility of application code to properly use or ignore the resource.
Defaulted:
The value here is superseded by previously encountered definitions.
C Preprocessor Only:
This macro may have a value that restricts its use to C preprocessor conditional directives.
#define BSP430_SERIAL_HAL_GET_HPL_EUSCIA (   hal_)    ((BSP430_SERIAL_HAL_HPL_VARIANT_IS_EUSCIA(hal_)) ? (hal_)->hpl.euscia : (void *)0)

Get the serial HPL pointer if the HAL is a EUSCIA variant.

Value is a null pointer if the HAL references a different HPL type.

#define BSP430_SERIAL_HAL_GET_HPL_EUSCIB (   hal_)    ((BSP430_SERIAL_HAL_HPL_VARIANT_IS_EUSCIB(hal_)) ? (hal_)->hpl.euscib : (void *)0)

Get the serial HPL pointer if the HAL is a EUSCIB variant.

Value is a null pointer if the HAL references a different HPL type.

#define BSP430_SERIAL_HAL_GET_HPL_USCI (   hal_)    ((BSP430_SERIAL_HAL_HPL_VARIANT_IS_USCI(hal_)) ? (hal_)->hpl.usci : (void *)0)

Get the serial HPL pointer if the HAL is a USCI variant.

Value is a null pointer if the HAL references a different HPL type.

#define BSP430_SERIAL_HAL_GET_HPL_USCI5 (   hal_)    ((BSP430_SERIAL_HAL_HPL_VARIANT_IS_USCI5(hal_)) ? (hal_)->hpl.usci5 : (void *)0)

Get the serial HPL pointer if the HAL is a USCI5 variant.

Value is a null pointer if the HAL references a different HPL type.

Examples:
utility/m25p/main.c.
#define BSP430_SERIAL_HAL_GET_HPLAUX_EUSCIA (   hal_)    ((BSP430_SERIAL_HAL_HPL_VARIANT_IS_EUSCIA(hal_)) ? (hal_)->hpl_aux.euscia : (void *)0)

Get the serial HPL auxiliary pointer if the HAL is a EUSCIA variant.

Value is a null pointer if the HAL references a different HPL type.

#define BSP430_SERIAL_HAL_GET_HPLAUX_EUSCIB (   hal_)    ((BSP430_SERIAL_HAL_HPL_VARIANT_IS_EUSCIB(hal_)) ? (hal_)->hpl_aux.euscib : (void *)0)

Get the serial HPL auxiliary pointer if the HAL is a EUSCIB variant.

Value is a null pointer if the HAL references a different HPL type.

#define BSP430_SERIAL_HAL_GET_HPLAUX_USCI (   hal_)    ((BSP430_SERIAL_HAL_HPL_VARIANT_IS_USCI(hal_)) ? (hal_)->hpl_aux.usci : (void *)0)

Get the serial HPL auxiliary pointer if the HAL is a USCI variant.

Value is a null pointer if the HAL references a different HPL type.

#define BSP430_SERIAL_HAL_GET_HPLAUX_USCI5 (   hal_)    ((BSP430_SERIAL_HAL_HPL_VARIANT_IS_USCI5(hal_)) ? (hal_)->hpl_aux.usci5 : (void *)0)

Get the serial HPL auxiliary pointer if the HAL is a USCI5 variant.

Value is a null pointer if the HAL references a different HPL type.

#define BSP430_SERIAL_HAL_HPL_VARIANT_EUSCIA   3

Field value for variant stored in sBSP430halSERIAL.hal_state.cflags when HPL reference is to an sBSP430hplEUSCIA.

#define BSP430_SERIAL_HAL_HPL_VARIANT_EUSCIB   4

Field value for variant stored in sBSP430halSERIAL.hal_state.cflags when HPL reference is to an sBSP430hplEUSCIA.

#define BSP430_SERIAL_HAL_HPL_VARIANT_IS_EUSCIA (   hal_)    (BSP430_SERIAL_HAL_HPL_VARIANT_EUSCIA == BSP430_PERIPH_HAL_STATE_CFLAGS_VARIANT(hal_))

True iff the HPL pointer of the serial HAL is a EUSCIA variant.

#define BSP430_SERIAL_HAL_HPL_VARIANT_IS_EUSCIB (   hal_)    (BSP430_SERIAL_HAL_HPL_VARIANT_EUSCIB == BSP430_PERIPH_HAL_STATE_CFLAGS_VARIANT(hal_))

True iff the HPL pointer of the serial HAL is a EUSCIB variant.

#define BSP430_SERIAL_HAL_HPL_VARIANT_IS_USCI (   hal_)    (BSP430_SERIAL_HAL_HPL_VARIANT_USCI == BSP430_PERIPH_HAL_STATE_CFLAGS_VARIANT(hal_))

True iff the HPL pointer of the serial HAL is a USCI variant.

#define BSP430_SERIAL_HAL_HPL_VARIANT_IS_USCI5 (   hal_)    (BSP430_SERIAL_HAL_HPL_VARIANT_USCI5 == BSP430_PERIPH_HAL_STATE_CFLAGS_VARIANT(hal_))

True iff the HPL pointer of the serial HAL is a USCI5 variant.

#define BSP430_SERIAL_HAL_HPL_VARIANT_USCI   1

Field value for variant stored in sBSP430halSERIAL.hal_state.cflags when HPL reference is to an sBSP430hplUSCI.

#define BSP430_SERIAL_HAL_HPL_VARIANT_USCI5   2

Field value for variant stored in sBSP430halSERIAL.hal_state.cflags when HPL reference is to an sBSP430hplUSCI5.

#define BSP430_SERIAL_SPI_READ_TX_BYTE (   i_)    (i_)

Specify byte written when reading a SPI byte.

The SPI protocal requires that a byte be written for every byte received; the reception occurs during the write. In many cases, the value of the byte written is completely irrelevant. For the purposes of debugging a SPI bus trace, it's nice to have an ordinal value written, so this is the default.

However, some peripherals require a specific value; in particular an MMC-based SD card apparently requires 0xFF. Allow the default to be overridden by the application.

Parameters
i_the ordinal of the received byte
Defaulted:
The value here is superseded by previously encountered definitions.

Typedef Documentation

Handle for a serial HAL instance

Examples:
bootstrap/applpm/main.c.

Structure holding hardware abstraction layer state for serial devices.