spi.h File Reference

The header file describes the USART SPI mode (for avr) and SPI1 bus (for arm), hardware-independent module. More...

Go to the source code of this file.

Functions

int HAL_OpenSpi (HAL_SpiMode_t *spiMode, void(*callback)())
 Opens USART in MSPI mode(for avr) or opens SPI1(for arm).
fields of HAL_SpiMode_t structure:
.
int HAL_CloseSpi (void)
 Releases the channel and pins.
int HAL_WriteSpi (uint8_t *buffer, uint8_t length)
 Writes a number of bytes to the SPI.
Callback function will be used to notify when the transmission is finished.
The data read are placed to the buffer.


Detailed Description

The header file describes the USART SPI mode (for avr) and SPI1 bus (for arm), hardware-independent module.

Author:
Atmel Corporation: http://www.atmel.com
Support email: avr@atmel.com
Copyright (c) 2008 , Atmel Corporation. All rights reserved. Licensed under Atmel's Limited License Agreement (BitCloudTM).

Definition in file spi.h.


Function Documentation

int HAL_OpenSpi ( HAL_SpiMode_t *  spiMode,
void(*)()  callback 
)

Opens USART in MSPI mode(for avr) or opens SPI1(for arm).
fields of HAL_SpiMode_t structure:
.

SpiClockMode_t clockMode - spi clock mode (set by user). Must be chosen from:
SPI_CLOCK_MODE0
SPI_CLOCK_MODE1
SPI_CLOCK_MODE2
SPI_CLOCK_MODE3

parameters valid only for avr:

SpiDataOrder_t dataOrder - spi data order (set by user). Must be chosen from:
SPI_DATA_MSB_FIRST
SPI_DATA_LSB_FIRST
SpiBaudRate_t baudRate - spi clock rate (set by user). Must be chosen from:
SPI_CLOCK_RATE_62
SPI_CLOCK_RATE_125
SPI_CLOCK_RATE_250
SPI_CLOCK_RATE_500

parameters valid only for arm:

uint8_t csName - select CS signal (set by user). Must be set:
CS2
uint32_t pack_parameterCs - list of time parameter.
Must be use macros HAL_SPI_PACK_PARAMETER(freq_value, valid_delay_value, cons_delay_value).
Where is:
freq_value - spi frequency (Hz)
valid_delay_value - delay between setting CS and clock start (sec)
cons_delay_value - delay between consecutive transfers (sec)

Parameters:
[in] spiMode - SPI parametrs (see above).
[in] callback - address of the function to notify the application when a transmission was completed. When the synchronous method is used, callback must be NULL (only for avr).
Returns:
-1 - there are no free resources.
0 - SPI channel is ready.

int HAL_CloseSpi ( void   ) 

Releases the channel and pins.

Returns:
Returns 0 on success or -1 if channel was not opened.

int HAL_WriteSpi ( uint8_t *  buffer,
uint8_t  length 
)

Writes a number of bytes to the SPI.
Callback function will be used to notify when the transmission is finished.
The data read are placed to the buffer.

Parameters:
[in] buffer - pointer to the application data buffer
[in] length - number of bytes to transfer
Returns:
-1 - spi module was not opened, or there is unsent data, or the pointer to data or the length are NULL;
0 - success;
Number of written bytes - success (synchronous mode (only for avr)).


Generated on Mon Feb 16 17:53:40 2009 for BitCloud Stack Documentation by  doxygen 1.5.1-p1