Fraise
2.1
FRAmework for Interfacing Software and Electronics
Main Page
Modules
Classes
Files
File List
File Members
All
Classes
Files
Functions
Typedefs
Groups
i2c_master.h
1
/*********************************************************************
2
*
3
* i2c master library for Fraise pic18f device
4
*********************************************************************
5
* Author Date Comment
6
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7
* Antoine Rousseau october 2013 adapted from Vangelis Rokas's sdcc i2c lib.
8
********************************************************************/
9
10
/*
11
# This program is free software; you can redistribute it and/or
12
# modify it under the terms of the GNU General Public License
13
# as published by the Free Software Foundation; either version 2
14
# of the License, or (at your option) any later version.
15
#
16
# This program is distributed in the hope that it will be useful,
17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
# GNU General Public License for more details.
20
21
# You should have received a copy of the GNU General Public License
22
# along with this program; if not, write to the Free Software
23
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
24
# MA 02110-1301, USA.
25
*/
26
27
#ifndef __I2CM_H__
28
#define __I2CM_H__
29
30
#include <config.h>
31
32
#define _I2CPARAM_SPEC __data
33
34
35
/* I2C modes of operation */
36
#define I2C_SLAVE10B_INT 0x0f
37
#define I2C_SLAVE7B_INT 0x0e
38
#define I2C_SLAVE_IDLE 0x0b
39
#define I2C_MASTER 0x08
40
#define I2C_SLAVE10B 0x07
41
#define I2C_SLAVE7B 0x06
42
43
44
/* slew rate control */
45
#define I2C_SLEW_OFF 0x80
46
#define I2C_SLEW_ON 0x00
47
48
/* stop */
49
void
i2cm_stop(
void
);
50
51
/* start */
52
void
i2cm_start(
void
);
53
54
/* restart */
55
void
i2cm_restart(
void
);
56
57
/* not acknowledge */
58
void
i2cm_nack(
void
);
59
60
/* acknowledge */
61
void
i2cm_ack(
void
);
62
63
/* wait until I2C goes idle */
64
void
i2cm_idle(
void
);
65
66
/* is character ready in I2C buffer ?? */
67
unsigned
char
i2cm_drdy(
void
);
68
69
/* read a character from I2C module */
70
unsigned
char
i2cm_readchar(
void
);
71
72
/* read a string from I2C module */
73
char
i2cm_readstr(_I2CPARAM_SPEC
unsigned
char
*ptr,
unsigned
char
len);
74
75
/* write a character to I2C module */
76
char
i2cm_writechar(
unsigned
char
dat);
77
78
/* write a string to I2C module */
79
char
i2cm_writestr(
unsigned
char
*ptr);
80
81
/* begin communication to I2C module */
82
void
i2cm_begin(
unsigned
char
address,
unsigned
char
doread);
83
84
/* configure I2C port for operation */
85
void
i2cm_init(
unsigned
char
mode,
unsigned
char
slew,
unsigned
char
addr_brd);
86
87
void
i2cm_close(
void
);
88
89
#endif
/* __I2C_H__ */
i2c_master
i2c_master.h
Generated on Mon Jan 18 2016 00:28:53 for Fraise by
1.8.6