Nut/OS  5.0.5
API Reference
stm32_usart3_spi.c File Reference
#include <arch/arm.h>
#include <sys/timer.h>
#include <cfg/spi.h>
#include <cfg/arch/gpio.h>
#include <dev/spibus.h>
#include <dev/gpio.h>
#include <arch/cm3/stm/stm32f10x_rcc.h>
#include <arch/cm3/stm/stm32f10x_gpio.h>
#include <arch/cm3/stm/stm32f10x_usart.h>
#include <dev/irqreg.h>
#include <sys/event.h>
#include <sys/nutdebug.h>
#include <stdlib.h>
#include <errno.h>
Include dependency graph for stm32_usart3_spi.c:

Functions

int Stm32UsartBusWait (NUTSPINODE *node, uint32_t tmo)
 Wait until all SPI bus transfers are done.
int Stm32UsartSpiSetup (NUTSPINODE *node)
 Update SPI shadow registers.
int Stm32Usart3ChipSelect (uint_fast8_t cs, uint_fast8_t hi)
 Set the specified chip select to a given level.
int Stm32Usart3BusDeselect (NUTSPINODE *node)
 Deselect a device on the first SPI bus.
int Stm32Usart3BusSelect (NUTSPINODE *node, uint32_t tmo)
 Select a device on the first SPI bus.
int Stm32UsartBusNodeInit (NUTSPINODE *node)
 Initialize an SPI bus node.
int Stm32UsartBusTransfer (NUTSPINODE *node, const void *txbuf, void *rxbuf, int xlen)
 Transfer data on the SPI bus using single buffered interrupt mode.

Variables

IRQ_HANDLER sig_USART3
 IRQ Handler for USART 1.
NUTSPIBUS spiUsart3BusStm32

Function Documentation

int Stm32UsartBusWait ( NUTSPINODE node,
uint32_t  tmo 
)

Wait until all SPI bus transfers are done.

Parameters:
nodeSpecifies the SPI bus node.
tmoTimeout in milliseconds. To disable timeout, set this parameter to NUT_WAIT_INFINITE.
Returns:
Always 0.

Referenced by Stm32Usart3BusDeselect().

int Stm32Usart3ChipSelect ( uint_fast8_t  cs,
uint_fast8_t  hi 
)

Set the specified chip select to a given level.

References EIO, errno, GpioPinSetHigh, GpioPinSetLow, NUTGPIO_PORTD, and rc.

Referenced by Stm32Usart3BusDeselect(), Stm32Usart3BusSelect(), and Stm32UsartBusNodeInit().

int Stm32Usart3BusDeselect ( NUTSPINODE node)

Deselect a device on the first SPI bus.

Deactivates the chip select and unlocks the bus.

Parameters:
nodeSpecifies the SPI bus node.
Returns:
Always 0.

References _NUTSPIBUS::bus_mutex, _NUTSPINODE::node_bus, _NUTSPINODE::node_cs, _NUTSPINODE::node_mode, NULL, NUT_WAIT_INFINITE, NUTASSERT, NutEventPost(), SPI_MODE_CSHIGH, Stm32Usart3ChipSelect(), and Stm32UsartBusWait().

Here is the call graph for this function:

int Stm32Usart3BusSelect ( NUTSPINODE node,
uint32_t  tmo 
)

Select a device on the first SPI bus.

Locks and activates the bus for the specified node.

Parameters:
nodeSpecifies the SPI bus node.
tmoTimeout in milliseconds. To disable timeout, set this parameter to NUT_WAIT_INFINITE.
Returns:
0 on success. In case of an error, -1 is returned and the bus is not locked.

References AFIO, USART_TypeDef::BRR, _NUTSPIBUS::bus_base, _NUTSPIBUS::bus_mutex, USART_TypeDef::CR1, USART_TypeDef::CR2, EIO, errno, GPIO_CFG_DISABLED, GPIO_CFG_OUTPUT, GPIO_FullRemap_USART3, GpioPinConfigSet(), _NUTSPINODE::node_bus, _NUTSPINODE::node_cs, _NUTSPINODE::node_mode, _NUTSPINODE::node_stat, NULL, NUTASSERT, NutEventPost(), NutEventWait(), NUTGPIO_PORTD, rc, RCC, RCC_APB1Periph_USART3, RCC_APB2Periph_AFIO, RCC_APB2Periph_GPIOD, SPI_MODE_CSHIGH, SPI_MODE_UPDATE, Stm32Usart3ChipSelect(), and Stm32UsartSpiSetup().

Here is the call graph for this function:

int Stm32UsartBusNodeInit ( NUTSPINODE node)

Initialize an SPI bus node.

This routine is called for each SPI node, which is registered via NutRegisterSpiDevice().

Parameters:
nodeSpecifies the SPI bus node.
Returns:
0 on success or -1 if there is no valid chip select.

References USART_TypeDef::BRR, USART_TypeDef::CR1, USART_TypeDef::CR2, malloc(), _NUTSPINODE::node_bus, _NUTSPINODE::node_cs, _NUTSPINODE::node_mode, _NUTSPINODE::node_stat, NULL, NUTASSERT, rc, SPI_MODE_CSHIGH, Stm32Usart3ChipSelect(), Stm32UsartSpiSetup(), USART_Clock_Enable, USART_LastBit_Enable, USART_Mode_Rx, and USART_Mode_Tx.

Here is the call graph for this function:

int Stm32UsartBusTransfer ( NUTSPINODE node,
const void *  txbuf,
void *  rxbuf,
int  xlen 
)

Transfer data on the SPI bus using single buffered interrupt mode.

A device must have been selected by calling At91SpiSelect().

Parameters:
nodeSpecifies the SPI bus node.
txbufPointer to the transmit buffer. If NULL, undetermined byte values are transmitted.
rxbufPointer to the receive buffer. If NULL, then incoming data is discarded.
xlenNumber of bytes to transfer.
Returns:
Always 0.

References _NUTSPIBUS::bus_base, USART_TypeDef::DR, _NUTSPINODE::node_bus, NULL, NUTASSERT, USART_TypeDef::SR, and USART_FLAG_RXNE.


Variable Documentation

Initial value:
 {



    NULL,                       
    NULL,                       
    NULL
}

IRQ Handler for USART 1.

IRQ Handler for USART 3.