LTlib LaurTec Library
4.0.1
Open Source C Library for Microchip Microcontrollers based on XC8 Compiler
Main Page
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
LTlib.h
Go to the documentation of this file.
1
/*******************************************************************************
2
3
Autore : Mauro Laurenti
4
Versione : 1.0
5
6
Created on Date : 25/10/2015
7
Last update : 25/10/2015
8
9
CopyRight 2006-2015 all rights are reserved
10
11
********************************************************
12
SOFTWARE LICENSE AGREEMENT
13
********************************************************
14
15
The usage of the supplied software imply the acceptance of the following license.
16
17
The software supplied herewith by Mauro Laurenti (the Author) is intended for
18
use solely and exclusively on Microchip PIC Microcontroller (registered mark).
19
The software is owned by the Author, and is protected under applicable
20
copyright laws. All rights are reserved.
21
Any use in violation of the foregoing restrictions may subject the
22
user to criminal sanctions under applicable laws, as well as to civil liability
23
for the breach of the terms and conditions of this license.
24
Commercial use is forbidden without a written acknowledgement with the Author.
25
Personal or educational use is allowed if the application containing the
26
following software doesn't aim to commercial use or monetary earning of any kind.
27
28
THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,
29
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
30
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
31
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE AUTHOR SHALL NOT,
32
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
33
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
34
35
*******************************************************************************/
36
37
38
#include <xc.h>
39
40
#include "
LTlib_type.h
"
41
42
#ifndef LTLIB_SETTINGS_H
43
#define LTLIB_SETTINGS_H
44
45
46
//***************************************************
47
// SYSTEM CLOCK
48
//***************************************************
49
50
#define SYSTEM_CLOCK 20000000
51
52
#define I2C_CLOCK SYSTEM_CLOCK
53
#define UART_CLOCK SYSTEM_CLOCK
54
55
56
//***************************************************
57
// SUPPORT CONSTANT
58
//***************************************************
59
60
#define PIN_AS_INPUT 0x01
61
#define PIN_AS_OUTPUT 0x00
62
63
64
//***************************************************
65
// DEVICE CONFIGURATION
66
//***************************************************
67
68
#ifdef _16F877
69
#include "
PIC16F877_config.h
"
70
#define CHIP_SUPPORTED
71
#endif
72
73
#ifdef _16F877A
74
#include "
PIC16F877A_config.h
"
75
#define CHIP_SUPPORTED
76
#endif
77
78
#ifdef _18F46K22
79
#include "
PIC18F46K22_config.h
"
80
#define CHIP_SUPPORTED
81
#endif
82
83
#ifdef _18F4550
84
#include "
PIC18F4550_config.h
"
85
#define CHIP_SUPPORTED
86
#endif
87
88
89
#ifdef _18F14K50
90
#include "
PIC18F14K50_config.h
"
91
#define CHIP_SUPPORTED
92
#endif
93
94
#ifdef _18F4580
95
#include "
PIC18F4580_config.h
"
96
#define CHIP_SUPPORTED
97
#endif
98
99
#ifndef CHIP_SUPPORTED
100
#error LTlib is not tested on the microcontroller you have selected
101
#endif
102
103
104
//***************************************************
105
// PERIPHERAL SETTINGS
106
//***************************************************
107
108
//I2C_MODULE_TYPE_1 : 1 I2C module standard location
109
//I2C_MODULE_TYPE_2 : 2 I2C modules standard locations
110
//I2C_MODULE_TYPE_3 : 1 I2C module special location (USB devices)
111
//I2C_MODULE_TYPE_4 : 1 I2C module PIC16
112
113
//SPI_MODULE_TYPE_1 : 1 SPI module standard location
114
//SPI_MODULE_TYPE_2 : 2 SPI modules standard locations
115
116
//UART_MODULE_TYPE_1: 1 UART module standard location
117
//UART_MODULE_TYPE_2: 2 UART module standard locations
118
119
//******************************************************************************
120
// DEVICE PIN SETTINGS
121
//******************************************************************************
122
123
//***************************************************
124
// I2C PIN SETTINGS
125
//***************************************************
126
127
#ifdef I2C_MODULE_TYPE_1
128
#define I2C1_SDA_LINE_TRIS TRISCbits.RC4
129
#define I2C1_SCL_LINE_TRIS TRISCbits.RC3
130
#endif
131
132
133
#ifdef I2C_MODULE_TYPE_2
134
#define I2C1_SDA_LINE_TRIS TRISCbits.RC4
135
#define I2C1_SCL_LINE_TRIS TRISCbits.RC3
136
137
#define I2C2_SDA_LINE_TRIS TRISDbits.RD1
138
#define I2C2_SCL_LINE_TRIS TRISDbits.RD0
139
#endif
140
141
#ifdef I2C_MODULE_TYPE_3
142
#define I2C1_SDA_LINE_TRIS TRISBbits.RB0
143
#define I2C1_SCL_LINE_TRIS TRISBbits.RB1
144
#endif
145
146
147
#ifdef I2C_MODULE_TYPE_4
148
#define I2C1_SDA_LINE_TRIS TRISCbits.TRISC4
149
#define I2C1_SCL_LINE_TRIS TRISCbits.TRISC3
150
151
//Register renaming required for PIC16
152
#define SSPCON1 SSPCON
153
#define SSPCON1bits SSPCONbits
154
#endif
155
156
157
#ifdef I2C_MODULE_TYPE_5
158
#define I2C1_SDA_LINE_TRIS TRISBbits.RB4
159
#define I2C1_SCL_LINE_TRIS TRISBbits.RB6
160
#endif
161
162
//***************************************************
163
// UART PIN SETTINGS
164
//***************************************************
165
166
#ifdef UART_MODULE_TYPE_1
167
#define UART1_TX_LINE_TRIS TRISCbits.RC6
168
#define UART1_RX_LINE_TRIS TRISCbits.RC7
169
170
#endif
171
172
173
#ifdef UART_MODULE_TYPE_2
174
175
#define UART1_TX_LINE_TRIS TRISCbits.RC6
176
#define UART1_RX_LINE_TRIS TRISCbits.RC7
177
178
#define UART2_TX_LINE_TRIS TRISDbits.RD6
179
#define UART2_RX_LINE_TRIS TRISDbits.RD7
180
181
#endif
182
183
#ifdef UART_MODULE_TYPE_3
184
#define UART1_TX_LINE_TRIS TRISBbits.RB6
185
#define UART1_RX_LINE_TRIS TRISBbits.RB5
186
#endif
187
188
#ifdef UART_MODULE_TYPE_4
189
#define UART1_TX_LINE_TRIS TRISCbits.TRISC6
190
#define UART1_RX_LINE_TRIS TRISCbits.TRISC7
191
#endif
192
193
#ifdef UART_MODULE_TYPE_5
194
#define UART1_TX_LINE_TRIS TRISBbits.RB7
195
#define UART1_RX_LINE_TRIS TRISBbits.RB5
196
#endif
197
198
//***************************************************
199
// CAN PIN SETTINGS
200
//***************************************************
201
202
#ifdef CAN_MODULE_TYPE_1
203
#define CAN1_TX_LINE_TRIS TRISBbits.RB2
204
#define CAN1_RX_LINE_TRIS TRISBbits.RB3
205
#endif
206
207
208
//***************************************************
209
// SPI PIN SETTINGS
210
//***************************************************
211
212
#ifdef SPI_MODULE_TYPE_1
213
#define SPI1_SCK_LINE_TRIS TRISBbits.RB1
214
#define SPI1_SDI_LINE_TRIS TRISBbits.RB0
215
#define SPI1_SDO_LINE_TRIS TRISCbits.RC7
216
#define SPI1_SS_LINE_TRIS TRISAbits.RA5
217
#endif
218
219
#ifdef SPI_MODULE_TYPE_2
220
#define SPI1_SCK_LINE_TRIS TRISCbits.RC3
221
#define SPI1_SDI_LINE_TRIS TRISCbits.RC4
222
#define SPI1_SDO_LINE_TRIS TRISCbits.RC5
223
#define SPI1_SS_LINE_TRIS TRISAbits.RA5
224
225
#define SPI2_SCK_LINE_TRIS TRISDbits.RD0
226
#define SPI2_SDI_LINE_TRIS TRISDbits.RD1
227
#define SPI2_SDO_LINE_TRIS TRISDbits.RD4
228
#define SPI2_SS_LINE_TRIS TRISDbits.RD3
229
#endif
230
231
#ifdef SPI_MODULE_TYPE_3
232
#define SPI1_SCK_LINE_TRIS TRISCbits.RC3
233
#define SPI1_SDI_LINE_TRIS TRISCbits.RC4
234
#define SPI1_SDO_LINE_TRIS TRISCbits.RC5
235
#define SPI1_SS_LINE_TRIS TRISAbits.RA5
236
#endif
237
238
//PIC16
239
#ifdef SPI_MODULE_TYPE_4
240
#define SPI1_SCK_LINE_TRIS TRISCbits.TRISC3
241
#define SPI1_SDI_LINE_TRIS TRISCbits.TRISC4
242
#define SPI1_SDO_LINE_TRIS TRISCbits.TRISC5
243
#define SPI1_SS_LINE_TRIS TRISAbits.TRISA4
244
#endif
245
246
#ifdef SPI_MODULE_TYPE_5
247
#define SPI1_SCK_LINE_TRIS TRISBbits.RB6
248
#define SPI1_SDI_LINE_TRIS TRISBbits.RB4
249
#define SPI1_SDO_LINE_TRIS TRISCbits.RC7
250
#define SPI1_SS_LINE_TRIS TRISCbits.RC6
251
#endif
252
253
254
#endif
LTlib_v_4.0.1
conf
LTlib.h
Generated on Sat Mar 12 2016 11:01:40 for LTlib LaurTec Library by
1.8.3.1