Nut/OS  4.10.3
API Reference
spibus1.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 spibus1.c:

Go to the source code of this file.

Functions

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

Variables

NUTSPIBUS spiBus1Avr32
 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: spibus1.c,v 1.3 2009/01/30 08:56:39 haraldkipp Exp $
* 

Definition in file spibus1.c.


Function Documentation

int Avr32Spi1ChipSelect ( uint_fast8_t  cs,
uint_fast8_t  hi 
)

Set the specified chip select to a given level.

Definition at line 194 of file spibus1.c.

References EIO, and errno.

Referenced by Avr32SpiBus1Deselect(), Avr32SpiBus1Select(), and Avr32SpiBusNodeInit().

int Avr32SpiBus1Select ( 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 258 of file spibus1.c.

References Avr32Spi1ChipSelect(), 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 Avr32SpiBus1Deselect ( 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 311 of file spibus1.c.

References Avr32Spi1ChipSelect(), 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 Avr32SpiBus1Interrupt ( void *  arg)

Definition at line 335 of file spibus1.c.

References inr, NutEventPostFromIrq, and outr.

Referenced by Avr32SpiBusNodeInit().

int Avr32SpiBus1Transfer ( 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 371 of file spibus1.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

Initial value:

Avr32 SPI bus driver implementation structure.

Definition at line 403 of file spibus1.c.