# CoffeePi: spi.cpp File Reference

spi.cpp File Reference
`#include <wiringPi.h>`
`#include <wiringPiSPI.h>`
`#include <stdio.h>`
`#include <string.h>`
`#include <errno.h>`
`#include "global.h"`
`#include "logger.h"`
`#include <inttypes.h>`
`#include <unistd.h>`
`#include "spi.h"`

## Functions

uint8_t | spi_readwrite (uint8_t data)
| Writes the data on the SPI bus and returns the reply. More...
void | spi_init (void)
| Initializes the SPI bus. More...
void | shift_init (void)
| Initializes the shift register. More...
void | shift_data (uint8_t data)
| Sends a byte to the shift register. More...

## Function Documentation

void shift_data | ( | uint8_t | data | ) |

Sends a byte to the shift register.

Parameters

  data | Data byte

void shift_init | ( | void |  | ) |

Initializes the shift register.

void spi_init | ( | void |  | ) |

Initializes the SPI bus.

uint8_t spi_readwrite | ( | uint8_t | data | ) |

Writes the data on the SPI bus and returns the reply.

Parameters

  data | byte to write to the bus

Returns
  byte read from the bus