forked from kbr-net/sdrive-max
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspi.h
66 lines (58 loc) · 2.33 KB
/
spi.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*! \file spi.h \brief SPI interface driver. */
//*****************************************************************************
//
// File Name : 'spi.h'
// Title : SPI interface driver
// Author : Pascal Stang - Copyright (C) 2000-2002
// Created : 11/22/2000
// Revised : 06/06/2002
// Version : 0.6
// Target MCU : Atmel AVR series
// Editor Tabs : 4
//
// NOTE: This code is currently below version 1.0, and therefore is considered
// to be lacking in some functionality or documentation, or may not be fully
// tested. Nonetheless, you can expect most functions to work.
//
/// \ingroup driver_avr
/// \defgroup spi SPI (Serial Peripheral Interface) Function Library (spi.c)
/// \code #include "spi.h" \endcode
/// \par Overview
/// Provides basic byte and word transmitting and receiving via the AVR
/// SPI interface. Due to the nature of SPI, every SPI communication operation
/// is both a transmit and simultaneous receive.
///
/// \note Currently, only MASTER mode is supported.
//
// ----------------------------------------------------------------------------
// 17.8.2008
// Bob!k & Raster, C.P.U.
// Original code was modified especially for the SDrive device.
// Some parts of code have been added, removed, rewrited or optimized due to
// lack of MCU AVR Atmega8 memory.
// ----------------------------------------------------------------------------
//
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
//*****************************************************************************
#ifndef SPI_H
#define SPI_H
#include "avrlibdefs.h" // global AVRLIB defines
#include "avrlibtypes.h" // global AVRLIB types definitions
// function prototypes
// SPI interface initializer
void spiInit(void);
// spiSendByte(u08 data) waits until the SPI interface is ready
// and then sends a single byte over the SPI port. This command
// does not receive anything.
void spiSendByte(u08 data);
// spiTransferByte(u08 data) waits until the SPI interface is ready
// and then sends a single byte over the SPI port. The function also
// returns the byte that was received during transmission.
u08 spiTransferByte(u08 data);
// spiTransferWord(u08 data) works just like spiTransferByte but
// operates on a whole word (16-bits of data).
u08 spiTransferFF();
void spiTransferTwoFF();
#endif