-
Notifications
You must be signed in to change notification settings - Fork 4
/
sw_spi.h
99 lines (77 loc) · 3.51 KB
/
sw_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
93
94
95
96
97
98
99
#ifndef __SW_SPI_H
#define __SW_SPI_H
/******************************************************************************
// * SW_SPI PERIPHERAL LIBRARY HEADER FILE
******************************************************************************
* FileName: sw_spi.h
* Dependencies: See include below
* Processor: PIC18
* Compiler: MCC18
* Company: Microchip Technology, Inc.
*
* Software License Agreement
* The software supplied herewith by Microchip Technology Incorporated
* (the “Company”) for its PICmicro® Microcontroller is intended and
* supplied to you, the Company’s customer, for use solely and
* exclusively on Microchip PICmicro Microcontroller products. The
* software is owned by the Company and/or its supplier, and is
* protected under applicable copyright laws. All rights are reserved.
* Any use in violation of the foregoing restrictions may subject the
* user to criminal sanctions under applicable laws, as well as to
* civil liability for the breach of the terms and conditions of this
* license.
*
* THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
* WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
* TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
* IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
* CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*****************************************************************************/
#include <pconfig.h>
#include "HardwareProfile.h"
/* PIC18 Software SPI library header
*
* To use the software spi routines, the user must define
* the port and tris register for each of the CS, DIN, DOUT,
* and SCK pins. The SPI mode must also be defined (MODE0,
* MODE1, MODE2, MODE3).
*
* Define the port and pin for each of the software SPI pins
* - Chip select pin CS must have a port and tris definition.
* - Data in pin DIN must have a port and tris definition.
* - Data out pin DOUT must have a port and tris definition.
* - Clock pin SCK must have a port and tris definition.
*/
// Define the mode for software SPI
// Refer to the SPI module for PIC17C756 for definitions of CKP and CKE
// Only one mode can be uncommented, otherwise the software will not work
#ifndef MODE0
#define MODE0 // Setting for SPI bus Mode 0,0
#endif
//#define MODE1 // Setting for SPI bus Mode 0,1
//#define MODE2 // Setting for SPI bus Mode 1,0
//#define MODE3 // Setting for SPI bus Mode 1,1
void OpenSWSPI(void);
#define SWOpenSPI OpenSWSPI
char WriteSWSPI( char output);
#define SWWriteSPI WriteSWSPI
void SetCSSWSPI(void);
#define SWSetCSSPI SetCSSWSPI
void ClearCSSWSPI(void);
#define SWClearCSSPI ClearCSSWSPI
/**************************************************************************
Macro : putcSWSPI
Description : macro is identical to WriteSWSPI,#define to WriteSWSPI in sw_spi.h
Arguments : None
Remarks : None
***************************************************************************/
#define putcSWSPI WriteSWSPI
/**************************************************************************
Macro : SWputcSPI
Description : macro is identical to WriteSWSPI,#define to WriteSWSPI in sw_spi.h
Arguments : None
Remarks : None
***************************************************************************/
#define SWputcSPI putcSWSPI
#endif /* __SW_SPI_H */