-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathavrbus.h
43 lines (33 loc) · 823 Bytes
/
avrbus.h
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
38
39
40
41
42
43
/*
* SPI Expansion bus driver - addressable spi bus with 1Mbs throughput at 16Mhz F_CPU
*
* Martin Schröder, [email protected]
* http://github.com/mkschreder
*
* Released under GPLv3
*/
#ifndef _SPI_H_
#define _SPI_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <avr/io.h>
//spi ports
#define SPI_DDR DDRB
#define SPI_PORT PORTB
#define SPI_PIN PINB
#define SPI_CE PB0
#define SPI_RDY PB1
#define SPI_SS PB2
#define SPI_MOSI PB3
#define SPI_MISO PB4
#define SPI_SCK PB5
uint8_t bus_exchange_byte(uint8_t data);
void bus_master_init(void);
void bus_slave_init(uint16_t base_addr, char *buf, uint8_t size);
uint8_t bus_read(uint16_t addr, char *data, uint8_t size);
uint8_t bus_write(uint16_t addr, const char *data, uint8_t size);
#ifdef __cplusplus
}
#endif
#endif