LTlib LaurTec Library
4.0.0 Beta
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
#ifdef _18F4580
89
#include "
PIC18F4580_config.h
"
90
#define CHIP_SUPPORTED
91
#endif
92
93
#ifndef CHIP_SUPPORTED
94
#error LTlib is not tested on the microcontroller you have selected
95
#endif
96
97
98
//***************************************************
99
// PERIPHERAL SETTINGS
100
//***************************************************
101
102
//I2C_MODULE_TYPE_1 : 1 I2C module standard location
103
//I2C_MODULE_TYPE_2 : 2 I2C modules standard locations
104
//I2C_MODULE_TYPE_3 : 1 I2C module special location (USB devices)
105
//I2C_MODULE_TYPE_4 : 1 I2C module PIC16
106
107
//SPI_MODULE_TYPE_1 : 1 SPI module standard location
108
//SPI_MODULE_TYPE_2 : 2 SPI modules standard locations
109
110
//UART_MODULE_TYPE_1: 1 UART module standard location
111
//UART_MODULE_TYPE_2: 2 UART module standard locations
112
113
//******************************************************************************
114
// DEVICE PIN SETTINGS
115
//******************************************************************************
116
117
//***************************************************
118
// I2C PIN SETTINGS
119
//***************************************************
120
121
#ifdef I2C_MODULE_TYPE_1
122
#define I2C1_SDA_LINE_TRIS TRISCbits.RC4
123
#define I2C1_SCL_LINE_TRIS TRISCbits.RC3
124
#endif
125
126
127
#ifdef I2C_MODULE_TYPE_2
128
#define I2C1_SDA_LINE_TRIS TRISCbits.RC4
129
#define I2C1_SCL_LINE_TRIS TRISCbits.RC3
130
131
#define I2C2_SDA_LINE_TRIS TRISDbits.RD1
132
#define I2C2_SCL_LINE_TRIS TRISDbits.RD0
133
#endif
134
135
#ifdef I2C_MODULE_TYPE_3
136
#define I2C1_SDA_LINE_TRIS TRISBbits.RB0
137
#define I2C1_SCL_LINE_TRIS TRISBbits.RB1
138
#endif
139
140
141
#ifdef I2C_MODULE_TYPE_4
142
#define I2C1_SDA_LINE_TRIS TRISCbits.TRISC4
143
#define I2C1_SCL_LINE_TRIS TRISCbits.TRISC3
144
145
//Register renaming required for PIC16
146
#define SSPCON1 SSPCON
147
#define SSPCON1bits SSPCONbits
148
#endif
149
150
//***************************************************
151
// UART PIN SETTINGS
152
//***************************************************
153
154
#ifdef UART_MODULE_TYPE_1
155
#define UART1_TX_LINE_TRIS TRISCbits.RC6
156
#define UART1_RX_LINE_TRIS TRISCbits.RC7
157
158
#endif
159
160
161
#ifdef UART_MODULE_TYPE_2
162
163
#define UART1_TX_LINE_TRIS TRISCbits.RC6
164
#define UART1_RX_LINE_TRIS TRISCbits.RC7
165
166
#define UART2_TX_LINE_TRIS TRISDbits.RD6
167
#define UART2_RX_LINE_TRIS TRISDbits.RD7
168
169
#endif
170
171
#ifdef UART_MODULE_TYPE_3
172
#define UART1_TX_LINE_TRIS TRISBbits.RB6
173
#define UART1_RX_LINE_TRIS TRISBbits.RB5
174
#endif
175
176
#ifdef UART_MODULE_TYPE_4
177
#define UART1_TX_LINE_TRIS TRISCbits.TRISC6
178
#define UART1_RX_LINE_TRIS TRISCbits.TRISC7
179
#endif
180
181
//***************************************************
182
// CAN PIN SETTINGS
183
//***************************************************
184
185
#ifdef CAN_MODULE_TYPE_1
186
#define CAN1_TX_LINE_TRIS TRISBbits.RB2
187
#define CAN1_RX_LINE_TRIS TRISBbits.RB3
188
#endif
189
190
191
//***************************************************
192
// SPI PIN SETTINGS
193
//***************************************************
194
195
#ifdef SPI_MODULE_TYPE_1
196
#define SPI1_SCK_LINE_TRIS TRISBbits.RB1
197
#define SPI1_SDI_LINE_TRIS TRISBbits.RB0
198
#define SPI1_SDO_LINE_TRIS TRISCbits.RC7
199
#define SPI1_SS_LINE_TRIS TRISAbits.RA5
200
#endif
201
202
#ifdef SPI_MODULE_TYPE_2
203
#define SPI1_SCK_LINE_TRIS TRISCbits.RC3
204
#define SPI1_SDI_LINE_TRIS TRISCbits.RC4
205
#define SPI1_SDO_LINE_TRIS TRISCbits.RC5
206
#define SPI1_SS_LINE_TRIS TRISAbits.RA5
207
208
#define SPI2_SCK_LINE_TRIS TRISDbits.RD0
209
#define SPI2_SDI_LINE_TRIS TRISDbits.RD1
210
#define SPI2_SDO_LINE_TRIS TRISDbits.RD4
211
#define SPI2_SS_LINE_TRIS TRISDbits.RD3
212
#endif
213
214
#ifdef SPI_MODULE_TYPE_3
215
#define SPI1_SCK_LINE_TRIS TRISCbits.RC3
216
#define SPI1_SDI_LINE_TRIS TRISCbits.RC4
217
#define SPI1_SDO_LINE_TRIS TRISCbits.RC5
218
#define SPI1_SS_LINE_TRIS TRISAbits.RA5
219
#endif
220
221
//PIC16
222
#ifdef SPI_MODULE_TYPE_4
223
#define SPI1_SCK_LINE_TRIS TRISCbits.TRISC3
224
#define SPI1_SDI_LINE_TRIS TRISCbits.TRISC4
225
#define SPI1_SDO_LINE_TRIS TRISCbits.TRISC5
226
#define SPI1_SS_LINE_TRIS TRISAbits.TRISA4
227
#endif
228
229
230
#endif
LTlib_v_4.0.0
conf
LTlib.h
Generated on Sun Feb 21 2016 13:52:58 for LTlib LaurTec Library by
1.8.3.1