Root/fw/spi.h

Source at commit 0e9b093d2ee3f8195e9848f5a931c2068d37e59f created 11 years 1 day ago.
By Werner Almesberger, tornado/cpu/cpu.brd: improve 3V3 routing
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
19void spi_init(void);
20void spi_begin(void);
21uint8_t spi_io(uint8_t v);
22void 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
31static inline void spi_send(uint8_t v)
32{
33    spi_io(v);
34}
35
36
37static 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

Archive Download this file

Branches:
master
tornado-v1



interactive