NXShield  v1.07
NXShield Library Reference by OpenElectrons.com
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
NXShieldI2C.h
1 
2 /*
3  * NXShield interface library
4  * Copyright (C) 2011 mindsensors.com
5  *
6  * This file is part of NXShield interface library.
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 2.1 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License along with this library; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21 
22 #ifndef NXShieldI2C_H
23 #define NXShieldI2C_H
24 
25 #include "SHDefines.h"
26 #include "BaseI2CDevice.h"
27 #include "SoftI2cMaster.h"
28 
32 class NXShieldI2C : public BaseI2CDevice, public SoftI2cMaster
33 {
34 public:
37  void * mp_shield;
40  uint8_t *_i2c_buffer;
41 
42 public:
44  NXShieldI2C(uint8_t i2c_address);
45 
47  uint8_t m_protocol;
48 
50  void init(void * shield, SH_BankPort bp);
51 
56  uint8_t readByte (uint8_t location);
57 
62  uint16_t readInteger (uint8_t location);
63 
68  uint32_t readLong (uint8_t location);
69 
76  uint8_t* readRegisters (uint8_t start_register, uint8_t bytes, uint8_t* buf);
77 
85  char* readString (uint8_t location, uint8_t bytes_to_read,
86  uint8_t* buffer = 0, uint8_t buffer_length = 0);
87 
93  bool writeRegisters (uint8_t start_register, uint8_t bytes_to_write,
94  uint8_t* buffer = 0);
95 
100  bool writeByte (uint8_t location, uint8_t data);
101 
106  bool writeInteger(uint8_t location, uint16_t data);
107 
112  bool writeLong (uint8_t location, uint32_t data);
113 
115  char* getFirmwareVersion();
116 
118  char* getVendorID();
119 
121  char* getDeviceID();
122 
124  char* getFeatureSet();
125 
127  uint8_t getErrorCode();
128 
129  bool checkAddress();
130 
134  bool setAddress(uint8_t address);
135 
136 };
137 
138 
139 #endif
140 
This class implements software i2c interface used by NXShield on Arduino.
Definition: SoftI2cMaster.h:40
This class implements I2C interfaces used by NXShield.
Definition: NXShieldI2C.h:32
void * mp_shield
Definition: NXShieldI2C.h:37
uint8_t * _i2c_buffer
Definition: NXShieldI2C.h:40
bool writeRegisters(uint8_t start_register, uint8_t bytes_to_write, uint8_t *buffer=0)
Definition: NXShieldI2C.cpp:66
uint32_t readLong(uint8_t location)
Definition: NXShieldI2C.cpp:44
bool writeInteger(uint8_t location, uint16_t data)
Definition: NXShieldI2C.cpp:79
void init(void *shield, SH_BankPort bp)
Definition: NXShieldI2C.cpp:140
uint8_t readByte(uint8_t location)
Definition: NXShieldI2C.cpp:30
uint8_t * readRegisters(uint8_t start_register, uint8_t bytes, uint8_t *buf)
Definition: NXShieldI2C.cpp:51
uint8_t m_protocol
Definition: NXShieldI2C.h:47
char * readString(uint8_t location, uint8_t bytes_to_read, uint8_t *buffer=0, uint8_t buffer_length=0)
Definition: NXShieldI2C.cpp:58
char * getFeatureSet()
Definition: NXShieldI2C.cpp:135
uint8_t getErrorCode()
Definition: NXShieldI2C.cpp:91
char * getDeviceID()
Definition: NXShieldI2C.cpp:129
bool writeByte(uint8_t location, uint8_t data)
Definition: NXShieldI2C.cpp:72
char * getFirmwareVersion()
Definition: NXShieldI2C.cpp:117
uint16_t readInteger(uint8_t location)
Definition: NXShieldI2C.cpp:37
bool setAddress(uint8_t address)
Definition: NXShieldI2C.cpp:103
SH_BankPort
Definition: SHDefines.h:49
bool writeLong(uint8_t location, uint32_t data)
Definition: NXShieldI2C.cpp:85
char * getVendorID()
Definition: NXShieldI2C.cpp:123
NXShieldI2C(uint8_t i2c_address)
Definition: NXShieldI2C.cpp:25
This class implements hardware I2C protocol used by NXShield on an Arduino.
Definition: BaseI2CDevice.h:94