Elisa3
spi.c File Reference
#include "spi.h"
#include <avr/io.h>
#include <avr/interrupt.h>

Defines

#define SPI_DDR   DDRB
#define SPI_PORT   PORTB
#define SPI_MOSI   PORTB2
#define SPI_MISO   PORTB3
#define SPI_SCK   PORTB1
#define SPI_SS   PORTB0

Functions

void SPI_WAIT ()
void initSPI ()
void closeSPI ()
void SPI_ReadWrite_Block (uint8_t *data, uint8_t *buffer, uint8_t len)
void SPI_Write_Block (uint8_t *data, uint8_t len)
uint8_t SPI_Write_Byte (uint8_t byte)

Define Documentation

#define SPI_DDR   DDRB
#define SPI_MISO   PORTB3
#define SPI_MOSI   PORTB2
#define SPI_PORT   PORTB
#define SPI_SCK   PORTB1
#define SPI_SS   PORTB0

Function Documentation

void closeSPI ( )
void initSPI ( )

Initialize the SPI port as a master. This function must be called once before using the SPI interface.

void SPI_ReadWrite_Block ( uint8_t *  data,
uint8_t *  buffer,
uint8_t  len 
)

Write a block of data to the slave, and read the data returned from the slave into a buffer. The data and buffer memory blocks must be the same length.

Parameters:
dataA pointer to the contiguous memory block to write to the slave.
bufferA pointer to the contiguous memory block to which the SPI data are to be written.
lenThe length of the memory blocks, in bytes.
void SPI_WAIT ( )
void SPI_Write_Block ( uint8_t *  data,
uint8_t  len 
)

Write a block to the slave.

Parameters:
dataA pointer to the contiguous memory block to write to the slave.
lenThe length of the block to write, in bytes.
uint8_t SPI_Write_Byte ( uint8_t  data)

Write a byte to the slave, and get the return byte from the slave.

 All Files Functions Variables Defines