PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
propgcc
propeller-elf
include
i2c_driver.h
Go to the documentation of this file.
1
6
/*
7
Copyright (c) 2012 David Michael Betz
8
9
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
10
and associated documentation files (the "Software"), to deal in the Software without restriction,
11
including without limitation the rights to use, copy, modify, merge, publish, distribute,
12
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
13
furnished to do so, subject to the following conditions:
14
15
The above copyright notice and this permission notice shall be included in all copies or
16
substantial portions of the Software.
17
18
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
19
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24
*/
25
26
#ifndef __I2C_DRIVER_H__
27
#define __I2C_DRIVER_H__
28
29
#include <stdint.h>
30
31
typedef
enum
{
32
I2C_CMD_IDLE,
33
I2C_CMD_INIT,
34
I2C_CMD_SEND,
35
I2C_CMD_SEND_MORE,
36
I2C_CMD_RECEIVE,
37
I2C_CMD_RECEIVE_MORE
38
} I2C_CMD;
39
40
typedef
enum
{
41
I2C_OK = 0,
42
I2C_ERR_UNKNOWN_CMD,
43
I2C_ERR_SEND_HDR,
44
I2C_ERR_SEND,
45
I2C_ERR_RECEIVE_HDR,
46
I2C_ERR_RECEIVE
47
} I2C_RESULT;
48
49
typedef
struct
{
50
uint32_t cmd;
51
uint32_t sts;
52
uint32_t hdr;
53
uint8_t *buffer;
54
uint32_t
count
;
55
uint32_t stop;
56
}
I2C_MAILBOX
;
57
58
typedef
struct
{
59
uint32_t scl;
60
uint32_t sda;
61
uint32_t ticks_per_cycle;
62
volatile
I2C_MAILBOX
*mailbox;
63
}
I2C_INIT
;
64
65
#define I2C_READ 1
66
#define I2C_WRITE 0
67
68
#endif
I2C_INIT
Definition:
i2c_driver.h:58
count
long count(int pin, long duration)
Count number of low to high transitions an external input applies to an I/O pin over a certain period...
Definition:
count.c:19
I2C_MAILBOX
Definition:
i2c_driver.h:49
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17