Defines | Functions

SPI.h File Reference

#include <avr/io.h>
#include "..\device\device.h"

Go to the source code of this file.

Defines

#define DOXYGEN
#define SPI0
#define SPI0_HARD
#define spi_hard_clear_ss()   (SS_HARDWARE_PORT &= ~(1<<SS_HARDWARE_PIN))
#define spi_hard_set_ss()   (SS_HARDWARE_PORT |= (1<<SS_HARDWARE_PIN))
#define MOSI_HARDWARE_PIN   PORTxx
#define MOSI_HARDWARE_DDR   DDBx
#define MISO_HARDWARE_PIN   PORTxx
#define MISO_HARDWARE_DDR   DDxx
#define SCLK_HARDWARE_PIN   PORTxx
#define SCLK_HARDWARE_DDR   DDxx
#define SS_HARDWARE_PORT   PORTB
#define SS_HARDWARE_PIN   PORTB4
#define SS_HARDWARE_DDR   DDB4

Functions

void spi0_init_master (void)
 Initializes spi0 as master.
uint8_t spi0_master_rw8 (uint8_t to_slave)
 Writes and reads an 8-bit byte via SPI.
uint16_t spi0_master_rw16 (uint16_t to_slave)
 Writes and reads a 16-bit word via SPI.
void spi0_hard_init_master (void)
 Initializes the AVR hardware SPI for spi0.
uint8_t spi0_hard_master_rw8 (uint8_t to_slave)
 Writes and reads an 8-bit byte via hardware SPI for spi0.
uint16_t spi0_hard_master_rw16 (uint16_t to_slave)
 Writes and reads a 16-bit word via hardware SPI for spi0.

Define Documentation

#define DOXYGEN

Doxygen has a problem with the if statements when the required define is in another file, so we will add a special section just for Doxygen. Remove the comment '//' to define DOXYGEN before running Doxygen. Make sure the '//' is back in place before compiling the code.

#define MISO_HARDWARE_DDR   DDxx

Defines the MISI Data Direction Register

#define MISO_HARDWARE_PIN   PORTxx

Defines the MISI port and pin number

#define MOSI_HARDWARE_DDR   DDBx

Defines the MOSI Data Direction Register

#define MOSI_HARDWARE_PIN   PORTxx
Note:
Set up SPI hardware pins. The actual port and pin numbers, shown here with x are selected by device specific definitions.

Defines the MOSI port and pin number

#define SCLK_HARDWARE_DDR   DDxx

Defines the SCLK Data Direction Register

#define SCLK_HARDWARE_PIN   PORTxx

Defines the SCLK port and pin number

#define SPI0
#define SPI0_HARD
#define spi_hard_clear_ss (  )     (SS_HARDWARE_PORT &= ~(1<<SS_HARDWARE_PIN))

Defines a macro to clear the hardware slave select pin

#define spi_hard_set_ss (  )     (SS_HARDWARE_PORT |= (1<<SS_HARDWARE_PIN))

Defines a macro to set the hardware slave select pin

#define SS_HARDWARE_DDR   DDB4

Defines the SS Data Direction Register

#define SS_HARDWARE_PIN   PORTB4

Defines the SCLK port and pin number

#define SS_HARDWARE_PORT   PORTB

Defines the SCLK port


Function Documentation

void spi0_hard_init_master ( void   ) 

Initializes the AVR hardware SPI for spi0.

Author:
Joe Pardue
Date:
October 29, 2010
Version:
1.00
uint16_t spi0_hard_master_rw16 ( uint16_t  to_slave  ) 

Writes and reads a 16-bit word via hardware SPI for spi0.

Note:
Blocks waiting for send to complete
Returns:
16-bit word from the slave device.
Parameters:
to_slave - 16-bit word to send to the slave device.
Author:
Joe Pardue
Date:
October 29, 2010
Version:
1.00
uint8_t spi0_hard_master_rw8 ( uint8_t  to_slave  ) 

Writes and reads an 8-bit byte via hardware SPI for spi0.

Note:
Blocks waiting for send to complete
Returns:
8-bit byte from the slave device.
Parameters:
to_slave - 8-bit byte to send to the slave device.
Author:
Joe Pardue
Date:
October 29, 2010
Version:
1.00
void spi0_init_master ( void   ) 

Initializes spi0 as master.

Note:
Selects hardware or software SPI based on constant defintion SPI0_SOFT.
Author:
Joe Pardue
Date:
October 29, 2010
Version:
1.00
uint16_t spi0_master_rw16 ( uint16_t  to_slave  ) 

Writes and reads a 16-bit word via SPI.

Note:
Selects hardware or software SPI based on constant defintion SPI0_SOFT.
Author:
Joe Pardue
Date:
October 29, 2010
Version:
1.00
uint8_t spi0_master_rw8 ( uint8_t  to_slave  ) 

Writes and reads an 8-bit byte via SPI.

Note:
Selects hardware or software SPI based on constant defintion SPI0_SOFT.
Author:
Joe Pardue
Date:
October 29, 2010
Version:
1.00