spi_lib.h File Reference

This file containsSPI lib header file. More...

#include "lib_mcu/spi/spi_drv.h"

Include dependency graph for spi_lib.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  spi_cf_t { SPI_MASTER, SPI_SLAVE }
 This enumeration allows to define a MASTER or SLAVE configuration. More...

Functions

bit spi_init (spi_cf_t config)
 This function configures the SPI controller:
  1. MASTER or SLAVE
  2. bit timing
  3. enable the controller.

char spi_putchar (char uc_wr_byte)
 This function sends a byte on the SPI.
bit spi_test_hit (void)
 This function checks if a bytes has been received on the SPI.
char spi_getchar (void)
 This function reads a byte on the SPI.
void SPI_Transmit_Master (char cData)
 SPI Make the transmission possible.
char spi_rw (char tx)
 
Parameters:
(char tx), the data byte to send


Detailed Description

This file containsSPI lib header file.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file spi_lib.h.


Enumeration Type Documentation

enum spi_cf_t

This enumeration allows to define a MASTER or SLAVE configuration.

Enumerator:
SPI_MASTER 
SPI_SLAVE 

Definition at line 60 of file spi_lib.h.


Function Documentation

bit spi_init ( spi_cf_t  config  ) 

This function configures the SPI controller:

  1. MASTER or SLAVE
  2. bit timing
  3. enable the controller.

Parameters:
configuration of the node (MASTER or SLAVE).
configuration of mode (SPI_MASTER_MODE_0...SPI_MASTER_MODE_3 or SPI_SLAVE_MODE_0...SPI_SLAVE_MODE_3).
Returns:
status of the init:
  1. TRUE
  2. FALSE
Precondition:
before calling this function some declaration must be define in config.h:
  • SPI_CONFIG select the prescaler, CPHA leading, CPOL LOW, LSB first.

Definition at line 59 of file spi_lib.c.

References SPI_CONFIG, Spi_enable, Spi_hw_init, Spi_init_bus, SPI_MASTER, Spi_select_master_mode, Spi_select_slave_mode, Spi_set_doublespeed, and TRUE.

Referenced by cdc_rf_task_init().

00060 {
00061    Spi_init_bus();
00062    if(config == SPI_MASTER){Spi_select_master_mode();}
00063    else                    {Spi_select_slave_mode();}
00064 
00065    Spi_hw_init(SPI_CONFIG);
00066    Spi_set_doublespeed();/*to delete if wished*/
00067    Spi_enable();
00068    return TRUE;
00069 }

Here is the caller graph for this function:

char spi_putchar ( char  uc_wr_byte  ) 

This function sends a byte on the SPI.

Parameters:
character to send on the SPI.
Returns:
character sent

Definition at line 72 of file spi_lib.c.

References Spi_send_byte, and Spi_tx_ready.

00073 {
00074    Spi_send_byte(ch);
00075    while(!Spi_tx_ready());
00076    return ch;
00077 }

bit spi_test_hit ( void   ) 

This function checks if a bytes has been received on the SPI.

Returns:
TRUE if byte received

Definition at line 53 of file spi_lib.c.

References Spi_rx_ready.

00054 {
00055 return Spi_rx_ready();
00056 }

char spi_getchar ( void   ) 

This function reads a byte on the SPI.

Returns:
character read

Definition at line 81 of file spi_lib.c.

References Spi_get_byte, and Spi_rx_ready.

00082 {
00083 
00084    register char c;
00085 
00086    while(!Spi_rx_ready());
00087    c = Spi_get_byte();
00088    return c;
00089 }

void SPI_Transmit_Master ( char  cData  ) 

SPI Make the transmission possible.

Warning:
See SPI section in datasheet
Parameters:
(char cData)
Returns:
nothing.

Definition at line 91 of file spi_lib.c.

References Spi_send_byte, and Spi_wait_eot.

00092 {
00093      /* Wait for transmission complete */
00094    Spi_wait_eot();
00095      /* Start new transmission */
00096    Spi_send_byte(cData);
00097 
00098 }

char spi_rw ( char  tx  ) 

Parameters:
(char tx), the data byte to send

Returns:
(char) the received byte.

Definition at line 100 of file spi_lib.c.

References Spi_read_data, and Spi_send_byte.

Referenced by NRF_Read(), NRF_read_buf(), NRF_RW_Reg(), and NRF_write_buf().

00101 {
00102    Spi_send_byte(tx);
00103    return Spi_read_data();
00104 }

Here is the caller graph for this function:


Generated on Mon May 5 15:58:10 2008 for ATMEL by  doxygen 1.5.1-p1