Nut/OS  4.10.3
API Reference
spibus0.c File Reference

Primary AVR32 SPI bus controller. More...

#include <cfg/spi.h>
#include <arch/avr32.h>
#include <arch/avr32/gpio.h>
#include <dev/spibus_avr32.h>
#include <dev/irqreg.h>
#include <dev/gpio.h>
#include <sys/event.h>
#include <sys/nutdebug.h>
#include <stdlib.h>
#include <errno.h>
#include <avr32/io.h>
Include dependency graph for spibus0.c:

Go to the source code of this file.

Defines

#define AVR32_SPI0_ADDRESS   AVR32_SPI_ADDRESS
#define AVR32_SPI0   AVR32_SPI

Functions

int Avr32Spi0ChipSelect (uint_fast8_t cs, uint_fast8_t hi)
 Set the specified chip select to a given level.
int Avr32SpiBus0Select (NUTSPINODE *node, uint32_t tmo)
 Select a device on the first SPI bus.
int Avr32SpiBus0Deselect (NUTSPINODE *node)
 Deselect a device on the first SPI bus.
void Avr32SpiBus0Interrupt (void *arg)
int Avr32SpiBus0Transfer (NUTSPINODE *node, CONST void *txbuf, void *rxbuf, int xlen)
 Transfer data on the SPI bus using single buffered interrupt mode.

Variables

NUTSPIBUS spiBus0Avr32
 Avr32 SPI bus driver implementation structure.

Detailed Description

Primary AVR32 SPI bus controller.

Copyright (C) 2001-2010 by egnite Software GmbH

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

For additional information see http://www.ethernut.de/

May be configured as an interrupt driven or polling driver. The interrupt driven version may use single or double buffering.

* $Id: spibus0.c,v 1.3 2009/01/30 08:56:39 haraldkipp Exp $
* 

Definition in file spibus0.c.


Define Documentation

#define AVR32_SPI0_ADDRESS   AVR32_SPI_ADDRESS

Definition at line 65 of file spibus0.c.

Referenced by Avr32SpiBus0Interrupt(), and Avr32SpiBus0Select().

#define AVR32_SPI0   AVR32_SPI

Definition at line 69 of file spibus0.c.

Referenced by Avr32SpiBus0Select().


Function Documentation

int Avr32Spi0ChipSelect ( uint_fast8_t  cs,
uint_fast8_t  hi 
)

Set the specified chip select to a given level.

Definition at line 212 of file spibus0.c.

References EIO, and errno.

Referenced by Avr32SpiBus0Deselect(), Avr32SpiBus0Select(), and Avr32SpiBusNodeInit().

int Avr32SpiBus0Select ( 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.

Definition at line 276 of file spibus0.c.

References AVR32_SPI0, AVR32_SPI0_ADDRESS, Avr32Spi0ChipSelect(), Avr32SpiSetup(), _NUTSPIBUS::bus_mutex, _AVR32SPIREG::csr, EIO, errno, gpio_enable_module_pin(), _AVR32SPIREG::mr, _NUTSPINODE::node_bus, _NUTSPINODE::node_cs, _NUTSPINODE::node_mode, _NUTSPINODE::node_stat, NUTASSERT, NutEventPost(), NutEventWait(), outr, SPI_MODE_CSHIGH, and SPI_MODE_UPDATE.

Here is the call graph for this function:

int Avr32SpiBus0Deselect ( 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.

Definition at line 329 of file spibus0.c.

References Avr32Spi0ChipSelect(), Avr32SpiBusWait(), _NUTSPIBUS::bus_mutex, _NUTSPINODE::node_bus, _NUTSPINODE::node_cs, _NUTSPINODE::node_mode, NUT_WAIT_INFINITE, NUTASSERT, NutEventPost(), and SPI_MODE_CSHIGH.

Here is the call graph for this function:

void Avr32SpiBus0Interrupt ( void *  arg)

Definition at line 353 of file spibus0.c.

References AVR32_SPI0_ADDRESS, inr, NutEventPostFromIrq, and outr.

Referenced by Avr32SpiBusNodeInit().

int Avr32SpiBus0Transfer ( 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 Avr32SpiSelect().

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.

Definition at line 389 of file spibus0.c.

References _NUTSPIBUS::bus_base, _NUTSPIBUS::bus_ready, _NUTSPINODE::node_bus, NUT_WAIT_INFINITE, NUTASSERT, NutEventWait(), and outr.

Here is the call graph for this function:


Variable Documentation