Root/
1 | /* |
2 | * fw/spi.h - SPI I/O |
3 | * |
4 | * Written 2012 by Werner Almesberger |
5 | * Copyright 2012 Werner Almesberger |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2 of the License, or |
10 | * (at your option) any later version. |
11 | */ |
12 | |
13 | #ifndef SPI_H |
14 | #define SPI_H |
15 | |
16 | #include <stdint.h> |
17 | |
18 | |
19 | void spi_init(void); |
20 | void spi_begin(void); |
21 | uint8_t spi_io(uint8_t v); |
22 | void spi_end(void); |
23 | |
24 | |
25 | /* |
26 | * Interestingly, the #defines below produce slightly shorter code (6 bytes) |
27 | * than the inlines. |
28 | */ |
29 | |
30 | #if 0 |
31 | static inline void spi_send(uint8_t v) |
32 | { |
33 | spi_io(v); |
34 | } |
35 | |
36 | |
37 | static inline uint8_t spi_recv(void) |
38 | { |
39 | return spi_io(0); |
40 | } |
41 | #endif |
42 | |
43 | #define spi_send(v) spi_io(v) |
44 | #define spi_recv() spi_io(0) |
45 | |
46 | #endif /* !SPI_H */ |
47 |
Branches:
master
tornado-v1