opentvc
Main Page
Related Pages
Modules
Files
File List
board
driver
spi.h
1
#ifndef SPI_H
2
#define SPI_H
3
4
#include <avr/io.h>
5
6
#define DDR_SPI DDRB
7
#define DD_SCK DDB5
8
#define DD_MOSI DDB3
9
#define DD_MISO DDB4
10
#define DD_SS_GYRO DDD2
11
#define DD_SS_AM DDC3
12
#define SS_GYRO PD2 // Slave select for gyroscope
13
#define SS_AM PC3 // Slave select for acceleromter & magnetometer
14
#define GYRO_SPI_PORT PORTC
15
#define AM_SPI_PORT PORTD
16
17
#define SLAVE_DESELECT_AM AM_SPI_PORT |= (1 << SS_AM)
18
#define SLAVE_SELECT_AM AM_SPI_PORT &= ~(1 << SS_AM)
19
20
#define SLAVE_DESELECT_GYRO GYRO_SPI_PORT |= (1 << SS_GYRO)
21
#define SLAVE_SELECT_GYRO GYRO_SPI_PORT &= ~(1 << SS_GYRO)
22
23
#define GYRO_SPI_PORT PORTC
24
#define AM_SPI_PORT PORTD
25
#define spiRead() spi(0xff)
26
27
unsigned
char
junk;
28
void
spiInit
(
void
);
29
unsigned
char
spi
(
unsigned
char
data);
30
31
#endif // SPI_H
spi
unsigned char spi(unsigned char data)
Definition:
spi.c:18
spiInit
void spiInit(void)
Definition:
spi.c:9
Generated by
1.8.11