Classes | Macros | Typedefs | Functions
sam_usart_spi/usart_spi.h File Reference

SAM USART in SPI mode driver functions. More...

#include "compiler.h"
#include "usart.h"
#include "conf_usart_spi.h"
Include dependency graph for sam_usart_spi/usart_spi.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  usart_spi_device
 Polled SPI device definition. More...
 

Macros

#define SPI_TYPE_DEFS
 
USART in SPI mode Management Configuration.
#define CONFIG_USART_SPI_DUMMY   0xFF
 Default Configuration of SPI Master Dummy Field. More...
 

Typedefs

typedef uint32_t board_spi_select_id_t
 Board SPI Select Id Definition. More...
 
typedef uint8_t port_pin_t
 
typedef uint8_t spi_flags_t
 SPI Flags Definition. More...
 

Functions

void usart_spi_deselect_device (Usart *p_usart, struct usart_spi_device *device)
 De-select the given device on the SPI bus. More...
 
void usart_spi_disable (Usart *p_usart)
 Disable the USART for the specified USART in SPI mode. More...
 
void usart_spi_enable (Usart *p_usart)
 Enable the USART for the specified USART in SPI mode. More...
 
void usart_spi_init (Usart *p_usart)
 Enable the USART system clock in SPI master mode. More...
 
uint32_t usart_spi_is_rx_full (Usart *p_usart)
 Check if both receive buffers are full. More...
 
uint32_t usart_spi_is_rx_ready (Usart *p_usart)
 Check whether the USART in SPI master mode contains a received character. More...
 
uint32_t usart_spi_is_tx_empty (Usart *p_usart)
 Check whether there are data in Transmit Holding Register or Transmit Shift Register in SPI master mode. More...
 
uint32_t usart_spi_is_tx_ready (Usart *p_usart)
 Check if the USART Transmit Holding Register is empty or not in SPI mode. More...
 
uint32_t usart_spi_read_packet (Usart *p_usart, uint8_t *data, size_t len)
 Receive a sequence of bytes from a USART in SPI mode device. More...
 
void usart_spi_read_single (Usart *p_usart, uint8_t *data)
 Receive one byte from an SPI device using USART in SPI mode. More...
 
void usart_spi_select_device (Usart *p_usart, struct usart_spi_device *device)
 Select the given device on the SPI bus. More...
 
void usart_spi_setup_device (Usart *p_usart, struct usart_spi_device *device, spi_flags_t flags, unsigned long baud_rate, board_spi_select_id_t sel_id)
 Set up a USART in SPI master mode device. More...
 
uint32_t usart_spi_write_packet (Usart *p_usart, const uint8_t *data, size_t len)
 Send a sequence of bytes to an SPI device using USART in SPI mode. More...
 
void usart_spi_write_single (Usart *p_usart, uint8_t data)
 Write one byte to an SPI device using USART in SPI mode. More...
 

Detailed Description

SAM USART in SPI mode driver functions.

Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.

Definition in file sam_usart_spi/usart_spi.h.

Macro Definition Documentation

◆ CONFIG_USART_SPI_DUMMY

#define CONFIG_USART_SPI_DUMMY   0xFF

Default Configuration of SPI Master Dummy Field.

Definition at line 58 of file sam_usart_spi/usart_spi.h.

◆ SPI_TYPE_DEFS

#define SPI_TYPE_DEFS

Definition at line 63 of file sam_usart_spi/usart_spi.h.

Typedef Documentation

◆ board_spi_select_id_t

typedef uint32_t board_spi_select_id_t

Board SPI Select Id Definition.

Definition at line 68 of file sam_usart_spi/usart_spi.h.

◆ port_pin_t

typedef uint8_t port_pin_t

Definition at line 71 of file sam_usart_spi/usart_spi.h.

◆ spi_flags_t

typedef uint8_t spi_flags_t

SPI Flags Definition.

Definition at line 65 of file sam_usart_spi/usart_spi.h.

Function Documentation

◆ usart_spi_deselect_device()

void usart_spi_deselect_device ( Usart p_usart,
struct usart_spi_device device 
)

De-select the given device on the SPI bus.

Parameters
p_usartBase address of the USART instance.
deviceSPI device.

Definition at line 246 of file usart_spi.c.

◆ usart_spi_disable()

void usart_spi_disable ( Usart p_usart)

Disable the USART for the specified USART in SPI mode.

Ensure that nothing is transferred while setting up buffers.

Parameters
p_usartBase address of the USART instance.

Definition at line 324 of file usart_spi.c.

◆ usart_spi_enable()

void usart_spi_enable ( Usart p_usart)

Enable the USART for the specified USART in SPI mode.

Parameters
p_usartBase address of the USART instance.

Definition at line 311 of file usart_spi.c.

◆ usart_spi_init()

void usart_spi_init ( Usart p_usart)

Enable the USART system clock in SPI master mode.

Parameters
p_usartPointer to Base address of the USART instance.

Definition at line 57 of file usart_spi.c.

◆ usart_spi_is_rx_full()

uint32_t usart_spi_is_rx_full ( Usart p_usart)

Check if both receive buffers are full.

Parameters
p_usartBase address of the USART instance.
Return values
1Receive buffers are full.
0Receive buffers are not full.

Definition at line 298 of file usart_spi.c.

◆ usart_spi_is_rx_ready()

uint32_t usart_spi_is_rx_ready ( Usart p_usart)

Check whether the USART in SPI master mode contains a received character.

Parameters
p_usartBase address of the USART instance.
Return values
1Some data have been received.
0No data has been received.

Definition at line 274 of file usart_spi.c.

◆ usart_spi_is_tx_empty()

uint32_t usart_spi_is_tx_empty ( Usart p_usart)

Check whether there are data in Transmit Holding Register or Transmit Shift Register in SPI master mode.

Parameters
p_usartBase address of the USART instance.
Return values
1The two registers are empty.
0One of the two registers contains data.

Definition at line 262 of file usart_spi.c.

◆ usart_spi_is_tx_ready()

uint32_t usart_spi_is_tx_ready ( Usart p_usart)

Check if the USART Transmit Holding Register is empty or not in SPI mode.

Parameters
p_usartBase address of the USART instance.
Return values
1There is no data in the Transmit Holding Register.
0There are data in the Transmit Holding Register.

Definition at line 286 of file usart_spi.c.

◆ usart_spi_read_packet()

uint32_t usart_spi_read_packet ( Usart p_usart,
uint8_t *  data,
size_t  len 
)

Receive a sequence of bytes from a USART in SPI mode device.

All bytes sent out on usart bus are sent as value 0.

Parameters
p_usartBase address of the usart instance.
dataData buffer to put read data.
lenLength of data.
Returns
0 if the USART in SPI master mode reads packet successfully.
Precondition
USART device must be selected with usart_spi_select_device() first.

Definition at line 207 of file usart_spi.c.

◆ usart_spi_read_single()

void usart_spi_read_single ( Usart p_usart,
uint8_t *  data 
)

Receive one byte from an SPI device using USART in SPI mode.

Parameters
p_usartBase address of the USART instance.
dataPointer to the data byte where to store the received data.
Precondition
USART device must be selected with usart_spi_select_device() first.

Definition at line 184 of file usart_spi.c.

◆ usart_spi_select_device()

void usart_spi_select_device ( Usart p_usart,
struct usart_spi_device device 
)

Select the given device on the SPI bus.

Parameters
p_usartBase address of the USART instance.
deviceSPI device.

Definition at line 232 of file usart_spi.c.

◆ usart_spi_setup_device()

void usart_spi_setup_device ( Usart p_usart,
struct usart_spi_device device,
spi_flags_t  flags,
unsigned long  baud_rate,
board_spi_select_id_t  sel_id 
)

Set up a USART in SPI master mode device.

The returned device descriptor structure must be passed to the driver whenever that device should be used as current slave device.

Parameters
p_usartBase address of the USART instance.
devicePointer to usart device struct that should be initialized.
flagsUSART configuration flags. Common flags for all implementations are the usart modes, which should be SPI_MODE_0, SPI_MODE_1, SPI_MODE_2, SPI_MODE_3.
baud_rateBaud rate for communication with slave device in Hz.
sel_idBoard specific select id.

Definition at line 113 of file usart_spi.c.

◆ usart_spi_write_packet()

uint32_t usart_spi_write_packet ( Usart p_usart,
const uint8_t *  data,
size_t  len 
)

Send a sequence of bytes to an SPI device using USART in SPI mode.

Received bytes on the USART in SPI mode are discarded.

Parameters
p_usartBase address of the USART instance.
dataData buffer to write.
lenLength of data.
Returns
0 if the USART in SPI master mode sends packet successfully.
Precondition
USART device must be selected with usart_spi_select_device() first.

Definition at line 164 of file usart_spi.c.

◆ usart_spi_write_single()

void usart_spi_write_single ( Usart p_usart,
uint8_t  data 
)

Write one byte to an SPI device using USART in SPI mode.

Parameters
p_usartBase address of the USART instance.
dataThe data to be sent out.

Definition at line 146 of file usart_spi.c.



inertial_sense_ros
Author(s):
autogenerated on Sat Sep 19 2020 03:19:07