-
Notifications
You must be signed in to change notification settings - Fork 0
/
spi.h
92 lines (70 loc) · 2.77 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/************************************************************************/
/* */
/* spi.h -- SPI Interface Declarations */
/* */
/************************************************************************/
/* Author: Michael T. Alexander */
/* Copyright 2009, Digilent Inc. */
/************************************************************************/
/* File Description: */
/* */
/* This header file contains interface declarations for SPI */
/* communication. */
/* */
/************************************************************************/
/* Revision History: */
/* */
/* 05/21/2009 (MichaelA): created */
/* */
/************************************************************************/
#if !defined(_SPI_INC)
#define _SPI_INC
#include "config.h"
#include "stdtypes.h"
/* ------------------------------------------------------------ */
/* Miscellaneous Declarations */
/* ------------------------------------------------------------ */
#if OPT_HWSPI == 1
// M00TODO: implement this
#elif OPT_HWSPI == 2
#define trisSpiSsSet TRISGSET
#define trisSpiSsClr TRISGCLR
#define prtSpiSsSet PORTGSET
#define prtSpiSsClr PORTGCLR
#define bnSpiSs 9
#else
#error "undefined SPI hardware interface"
#endif
/* ------------------------------------------------------------ */
/* Register Field Definitions */
/* ------------------------------------------------------------ */
/* SPI2CON
*/
#define bnSpi2On 15
#define bnSpi2Smp 9
#define bnSpi2Cke 8
#define bnSpi2Msten 5
/* SPI2STAT
*/
#define bnSpi2Spibusy 11
#define bnSpi2Spitbe 3
#define bnSpi2Spirbf 0
/* ------------------------------------------------------------ */
/* General Type Declarations */
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
/* Variable Declarations */
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
/* Procedure Declarations */
/* ------------------------------------------------------------ */
void SpiInit();
void SpiEnable();
void SpiDisable();
BYTE BSpiPutByte( BYTE bSnd );
void SpiPutBuff( BYTE* pbBuff, WORD cbBuff );
void SpiGetBuff( BYTE bFill, BYTE* pbBuff, WORD cbBuff );
void SpiPutGetBuff( BYTE* pbSnd, BYTE* pbRcv, WORD cbSnd );
/* ------------------------------------------------------------ */
#endif
/************************************************************************/