ATtiny85 Template Code
Code snippets for the ATtiny85
 All Files Functions Variables Typedefs Enumerations Enumerator Macros
softspi.c File Reference
#include <avr/io.h>
#include "iohelp.h"
Include dependency graph for softspi.c:

Go to the source code of this file.

Functions

void sspiInit (uint8_t sck, uint8_t mosi, uint8_t miso)
 
void sspiOutMSB (uint8_t sck, uint8_t mosi, uint16_t data, uint8_t bits)
 
uint16_t sspiInMSB (uint8_t sck, uint8_t miso, uint8_t bits)
 
uint16_t sspiInOutMSB (uint8_t sck, uint8_t mosi, uint8_t miso, uint16_t data, uint8_t bits)
 
void sspiOutLSB (uint8_t sck, uint8_t mosi, uint16_t data, uint8_t bits)
 
uint16_t sspiInLSB (uint8_t sck, uint8_t miso, uint8_t bits)
 
uint16_t sspiInOutLSB (uint8_t sck, uint8_t mosi, uint8_t miso, uint16_t data, uint8_t bits)
 

Function Documentation

void sspiInit ( uint8_t  sck,
uint8_t  mosi,
uint8_t  miso 
)

Initialise pins for software SPI

It is not necessary to call this in order to use software SPI, it is simply a convenience function to do the necessary setup. You can initialise the pins directly if needed.

Parameters
sckthe pin to use for the SCK output
mosithe pin to use for the MOSI output
misothe pin to use for the MISO input

Definition at line 22 of file softspi.c.

uint16_t sspiInLSB ( uint8_t  sck,
uint8_t  miso,
uint8_t  bits 
)

Transfer data from a slave (LSB first)

Parameters
sckthe pin to use for the SCK output
misothe pin to use for the MISO input
bitsthe number of bits to transfer
Returns
a 16 bit value containing the data in the lowest bits.

Definition at line 156 of file softspi.c.

uint16_t sspiInMSB ( uint8_t  sck,
uint8_t  miso,
uint8_t  bits 
)

Transfer data from a slave (MSB first)

Parameters
sckthe pin to use for the SCK output
misothe pin to use for the MISO input
bitsthe number of bits to transfer
Returns
a 16 bit value containing the data in the lowest bits.

Definition at line 68 of file softspi.c.

uint16_t sspiInOutLSB ( uint8_t  sck,
uint8_t  mosi,
uint8_t  miso,
uint16_t  data,
uint8_t  bits 
)

Transfer data to and from a slave (LSB first)

Parameters
sckthe pin to use for the SCK output
mosithe pin to use for the MOSI output
misothe pin to use for the MISO input
datathe data to transfer out
bitsthe number of bits to transfer
Returns
a 16 bit value containing the read data in the lowest bits.

Definition at line 184 of file softspi.c.

uint16_t sspiInOutMSB ( uint8_t  sck,
uint8_t  mosi,
uint8_t  miso,
uint16_t  data,
uint8_t  bits 
)

Transfer data to and from a slave (MSB first)

Parameters
sckthe pin to use for the SCK output
mosithe pin to use for the MOSI output
misothe pin to use for the MISO input
datathe data to transfer out
bitsthe number of bits to transfer
Returns
a 16 bit value containing the read data in the lowest bits.

Definition at line 95 of file softspi.c.

void sspiOutLSB ( uint8_t  sck,
uint8_t  mosi,
uint16_t  data,
uint8_t  bits 
)

Transfer data to a slave (LSB first)

Parameters
sckthe pin to use for the SCK output
mosithe pin to use for the MOSI output
datathe data to transfer
bitsthe number of bits to transfer

Definition at line 129 of file softspi.c.

void sspiOutMSB ( uint8_t  sck,
uint8_t  mosi,
uint16_t  data,
uint8_t  bits 
)

Transfer data to a slave (MSB first)

Parameters
sckthe pin to use for the SCK output
mosithe pin to use for the MOSI output
datathe data to transfer
bitsthe number of bits to transfer

Definition at line 40 of file softspi.c.