aboutsummaryrefslogtreecommitdiff
path: root/src/inc/spi/spi.h
blob: bb92caceef02ed781a8e4ee9663cf99d011768c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef SPI_H
#define SPI_H

  #include <avr/io.h>
  #include <util/delay.h>
  #include "../uart/uart.h"
  #include "../stdout.h"

  #define SPICLK_DEFAULT  SPICLK_64
  #define SPICLK_FAST     SPICLK_X2

  #define PORT_SPI        PORTB
  #define DDR_SPI         DDRB
  #define DD_SS           DDB4
  #define DD_MOSI         DDB5
  #define DD_MISO         DDB6
  #define DD_SCK          DDB7

  typedef enum
  {
    SPICLK_4,   // vv nominal clk-speeds
    SPICLK_16,
    SPICLK_64,
    SPICLK_128,
    SPICLK_X2,   // vv with SPI2x
    SPICLK_X32,
    SPICLK_X64
  } SPICLK;


  void spi_init();
  void spi_putc(unsigned char c);
  unsigned char spi_getc();
  void spi_setspeed(SPICLK speed);


#endif
..