LMS 2012
Main Page
Related Pages
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
d_iic.h
Go to the documentation of this file.
1
/*
2
* LEGO® MINDSTORMS EV3
3
*
4
* Copyright (C) 2010-2013 The LEGO Group
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
*/
20
21
22
#ifndef __D_IIC_H
23
#define __D_IIC_H
24
25
26
27
// Defines and Structures for internal and user space usage --------------------------------------------
28
29
enum
TransferState
{
30
TRANSFER_IDLE
,
31
TRANSFER_START
,
32
TRANSFER_START2
,
33
TRANSFER_ADDR
,
34
TRANSFER_DATA
,
35
TRANSFER_WRITE
,
36
TRANSFER_READ
,
37
TRANSFER_WBIT
,
38
TRANSFER_RBIT
,
39
TRANSFER_WACK
,
40
TRANSFER_RACK
,
41
TRANSFER_STOP
,
42
TRANSFER_STOP2
,
43
TRANSFER_STOP3
,
44
TRANSFER_RESTART
,
45
TRANSFER_WAIT
,
46
TRANSFER_TESTING
47
};
48
49
50
struct
IIC_data_package
{
51
__u8
addr
;
52
__u8
data
[32];
53
__u8
read_length
;
54
__u8
write_length
;
55
__u8
clock_state
;
56
__u8
bit
;
57
__u8
byte
;
58
__u8
data_byte
;
59
__u8
transfer_state
;
60
__u8
read_start_send
;
61
__u8
nacked
;
62
__u8
port
;
63
__u8
wait_cycles
;
64
};
65
66
#define IIC_MAGIC 'i' // defines the magic number
67
#define IIC_PORT_CONFIG_IOC _IOW(IIC_MAGIC,0, int) // defines our ioctl call.
68
#define IIC_READ_WRITE_IOC _IOWR(IIC_MAGIC,1, struct IIC_data_package) // defines our ioctl call.
69
70
71
// Defines and structures for internal usage --------------------------------------------------
72
73
#define IIC_INPUTS 4
74
75
struct
IIC_control_t
{
76
// For communication to FIQ and timer functions
77
struct
IIC_data_package
data_package
[
IIC_INPUTS
];
78
__u8
port_enabled
;
79
__u8
transfers_active
;
80
};
81
82
enum
IicPortPins
83
{
84
IIC_PORT_BUFFER_CTRL
,
85
IIC_PORT_CLOCK
,
86
IIC_PORT_DATA
,
87
IIC_PORT_PINS
,
88
};
89
90
#define PINInput(port,pin) { (*IicPortPin[port][pin].pGpio).dir |= IicPortPin[port][pin].Mask; }
91
#define PINOutput(port,pin) { (*IicPortPin[port][pin].pGpio).dir &= ~IicPortPin[port][pin].Mask; }
92
#define PINRead(port,pin) (((*IicPortPin[port][pin].pGpio).in_data & IicPortPin[port][pin].Mask)?1:0)
93
#define PINHigh(port,pin) { (*IicPortPin[port][pin].pGpio).set_data = IicPortPin[port][pin].Mask; }
94
#define PINLow(port,pin) { (*IicPortPin[port][pin].pGpio).clr_data = IicPortPin[port][pin].Mask; }
95
96
#endif
IIC_data_package::read_start_send
__u8 read_start_send
Definition:
d_iic.h:60
IIC_data_package::data
__u8 data[32]
Definition:
d_iic.h:52
IIC_PORT_CLOCK
Definition:
d_iic.h:85
TRANSFER_WAIT
Definition:
d_iic.h:45
IIC_control_t::port_enabled
__u8 port_enabled
Definition:
d_iic.h:78
IIC_PORT_PINS
Definition:
d_iic.h:87
IIC_data_package::data_byte
__u8 data_byte
Definition:
d_iic.h:58
TRANSFER_WRITE
Definition:
d_iic.h:35
IIC_control_t::transfers_active
__u8 transfers_active
Definition:
d_iic.h:79
TRANSFER_START2
Definition:
d_iic.h:32
IIC_control_t::data_package
struct IIC_data_package data_package[IIC_INPUTS]
Definition:
d_iic.h:77
IIC_data_package::write_length
__u8 write_length
Definition:
d_iic.h:54
IIC_data_package::read_length
__u8 read_length
Definition:
d_iic.h:53
IIC_PORT_DATA
Definition:
d_iic.h:86
IIC_PORT_BUFFER_CTRL
Definition:
d_iic.h:84
TRANSFER_ADDR
Definition:
d_iic.h:33
IIC_INPUTS
#define IIC_INPUTS
Definition:
d_iic.h:73
TRANSFER_TESTING
Definition:
d_iic.h:46
TRANSFER_STOP
Definition:
d_iic.h:41
IIC_data_package::wait_cycles
__u8 wait_cycles
Definition:
d_iic.h:63
IicPortPins
IicPortPins
Definition:
d_iic.h:82
TRANSFER_WACK
Definition:
d_iic.h:39
TRANSFER_READ
Definition:
d_iic.h:36
IIC_control_t
Definition:
d_iic.h:75
IIC_data_package
Definition:
d_iic.h:50
TRANSFER_RBIT
Definition:
d_iic.h:38
TRANSFER_RESTART
Definition:
d_iic.h:44
IIC_data_package::clock_state
__u8 clock_state
Definition:
d_iic.h:55
IIC_data_package::nacked
__u8 nacked
Definition:
d_iic.h:61
IIC_data_package::addr
__u8 addr
Definition:
d_iic.h:51
TRANSFER_DATA
Definition:
d_iic.h:34
IIC_data_package::port
__u8 port
Definition:
d_iic.h:62
TRANSFER_START
Definition:
d_iic.h:31
TRANSFER_STOP3
Definition:
d_iic.h:43
TRANSFER_RACK
Definition:
d_iic.h:40
IIC_data_package::transfer_state
__u8 transfer_state
Definition:
d_iic.h:59
TRANSFER_STOP2
Definition:
d_iic.h:42
TRANSFER_WBIT
Definition:
d_iic.h:37
TRANSFER_IDLE
Definition:
d_iic.h:30
IIC_data_package::byte
__u8 byte
Definition:
d_iic.h:57
IIC_data_package::bit
__u8 bit
Definition:
d_iic.h:56
TransferState
TransferState
Definition:
d_iic.h:29
ev3sources-master-2
lms2012
d_iic
Linuxmod_AM1808
d_iic.h
Generated on Tue Jul 29 2014 19:20:27 for LMS 2012 by
1.8.7