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
PCF8574.h
Go to the documentation of this file.
1
/*******************************************************************************
2
3
Author : Mauro Laurenti
4
Version : 1.3
5
Created on Date : 19/03/2011
6
Last update : 26/11/2015
7
8
CopyRight 2006-2015 all rights are reserved
9
10
********************************************************
11
SOFTWARE LICENSE AGREEMENT
12
********************************************************
13
14
The usage of the supplied software imply the acceptance of the following license.
15
16
The software supplied herewith by Mauro Laurenti (the Author) is intended for
17
use solely and exclusively on Microchip PIC Microcontroller (registered mark).
18
The software is owned by the Author, and is protected under applicable
19
copyright laws. All rights are reserved.
20
Any use in violation of the foregoing restrictions may subject the
21
user to criminal sanctions under applicable laws, as well as to civil liability
22
for the breach of the terms and conditions of this license.
23
Commercial use is forbidden without a written acknowledgement with the Author.
24
Personal or educational use is allowed if the application containing the
25
following software doesn't aim to commercial use or monetary earning of any kind.
26
27
THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,
28
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
29
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
30
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE AUTHOR SHALL NOT,
31
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
32
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
33
34
********************************************************
35
PURPOSES
36
********************************************************
37
38
These functions allow the user to read/write to the data
39
port of the I2C I/O extender PCF8574.
40
Either PCF8574 or PCF8574A can be used. The user must set the
41
proper internal address (see the define below).
42
43
PCF8574 Address : 0100xxx0
44
PCF8574A Address : 0111xxx0
45
46
xxx = A2 A1 A0 (External Address Pins)
47
48
*******************************************************************************/
49
50
#ifndef LTLIB_PCF8574_H
51
#define LTLIB_PCF8574_H
52
53
54
#ifdef __XC8
55
#include <xc.h>
56
#endif
57
58
59
//*****************************************
60
// Library Test
61
//*****************************************
62
63
#include "
LTlib.h
"
64
65
#ifndef LTLIB_I2C_MODULE_H
66
#error The PCF8574 Library requires the "module_I2C" library to be included.
67
#endif
68
69
//*****************************************
70
// I2C Module Switch
71
//*****************************************
72
#define PCF8574_I2C_MODULE_1
73
//#define PCF8574_I2C_MODULE_2
74
75
#ifdef PCF8574_I2C_MODULE_1
76
#define PCF8574_I2C_open I2C1_open
77
#define PCF8574_I2C_baud_rate I2C1_baud_rate
78
#define PCF8574_I2C_wait_bus_IDLE I2C1_wait_bus_IDLE
79
#define PCF8574_I2C_start_bit I2C1_start_bit
80
#define PCF8574_I2C_check_bus_collision I2C1_check_bus_collision
81
#define PCF8574_I2C_write_byte I2C1_write_byte
82
#define PCF8574_I2C_stop_bit I2C1_stop_bit
83
#define PCF8574_I2C_check_ACK I2C1_check_ACK
84
#define PCF8574_I2C_negative_ACK I2C1_negative_ACK
85
#define PCF8574_I2C_read_byte I2C1_read_byte
86
#define PCF8574_I2C_set_master_as_receiver I2C1_set_master_as_receiver
87
88
#endif
89
90
#ifdef PCF8574_I2C_MODULE_2
91
#define PCF8574_I2C_open I2C2_open
92
#define PCF8574_I2C_baud_rate I2C2_baud_rate
93
#define PCF8574_I2C_wait_bus_IDLE I2C2_wait_bus_IDLE
94
#define PCF8574_I2C_start_bit I2C2_start_bit
95
#define PCF8574_I2C_check_bus_collision I2C2_check_bus_collision
96
#define PCF8574_I2C_write_byte I2C2_write_byte
97
#define PCF8574_I2C_stop_bit I2C2_stop_bit
98
#define PCF8574_I2C_check_ACK I2C2_check_ACK
99
#define PCF8574_I2C_negative_ACK I2C2_negative_ACK
100
#define PCF8574_I2C_read_byte I2C2_read_byte
101
#define PCF8574_I2C_set_master_as_receiver I2C2_set_master_as_receiver
102
#endif
103
104
105
//*****************************************
106
// Device Settings
107
//*****************************************
108
109
#define USED_DEVICE_PCF8574 0x40
110
#define USED_DEVICE_PCF8574A 0x70
111
112
#define PCF8574_INTERNAL_ADDRESS USED_DEVICE_PCF8574A
113
114
127
void
PCF8574_initialize
(
unsigned
int
baud_rate_KHz);
128
#define initialize_PCF8574 PCF8574_initialize
129
130
148
signed
char
PCF8574_write_data
(
unsigned
char
device_address,
unsigned
char
data );
149
#define write_data_PCF8574 PCF8574_write_data
150
151
168
signed
char
PCF8574_read_data
(
unsigned
char
device_address,
unsigned
char
*data);
169
#define read_data_PCF8574 PCF8574_read_data
170
171
172
#endif
LTlib_v_4.0.0
inc
PCF8574.h
Generated on Sun Feb 21 2016 13:52:59 for LTlib LaurTec Library by
1.8.3.1