EVShield  v1.3
EVShield Library Reference by mindsensors.com
EVShieldI2C.h
1 
2 /*
3  * EVShield interface library
4  * Copyright (C) 2015 mindsensors.com
5  *
6  * This file is part of EVShield 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 EVShieldI2C_H
23 #define EVShieldI2C_H
24 
25 #include "SHDefines.h"
26 #include "BaseI2CDevice.h"
27 #include "SoftI2cMaster.h"
28 
32 class EVShieldI2C : public BaseI2CDevice, public SoftI2cMaster
33 {
34 public:
37  void * mp_shield;
40  uint8_t *_i2c_buffer;
41 
42 public:
44  EVShieldI2C(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 EVShield/NXShield on Arduino.
Definition: SoftI2cMaster.h:40
bool writeInteger(uint8_t location, uint16_t data)
Definition: EVShieldI2C.cpp:84
char * getVendorID()
Definition: EVShieldI2C.cpp:125
void * mp_shield
Definition: EVShieldI2C.h:37
char * getFeatureSet()
Definition: EVShieldI2C.cpp:137
uint8_t readByte(uint8_t location)
Definition: EVShieldI2C.cpp:31
uint8_t * _i2c_buffer
Definition: EVShieldI2C.h:40
uint8_t m_protocol
Definition: EVShieldI2C.h:47
uint32_t readLong(uint8_t location)
Definition: EVShieldI2C.cpp:45
char * getFirmwareVersion()
Definition: EVShieldI2C.cpp:119
void init(void *shield, SH_BankPort bp)
Definition: EVShieldI2C.cpp:142
This class implements I2C interfaces used by EVShield.
Definition: EVShieldI2C.h:32
uint8_t * readRegisters(uint8_t start_register, uint8_t bytes, uint8_t *buf)
Definition: EVShieldI2C.cpp:52
char * readString(uint8_t location, uint8_t bytes_to_read, uint8_t *buffer=0, uint8_t buffer_length=0)
Definition: EVShieldI2C.cpp:59
bool writeByte(uint8_t location, uint8_t data)
Definition: EVShieldI2C.cpp:73
bool writeLong(uint8_t location, uint32_t data)
Definition: EVShieldI2C.cpp:90
bool writeRegisters(uint8_t start_register, uint8_t bytes_to_write, uint8_t *buffer=0)
Definition: EVShieldI2C.cpp:67
EVShieldI2C(uint8_t i2c_address)
Definition: EVShieldI2C.cpp:26
uint16_t readInteger(uint8_t location)
Definition: EVShieldI2C.cpp:38
SH_BankPort
Definition: SHDefines.h:52
char * getDeviceID()
Definition: EVShieldI2C.cpp:131
uint8_t getErrorCode()
Definition: EVShieldI2C.cpp:96
bool setAddress(uint8_t address)
Definition: EVShieldI2C.cpp:108
This class implements hardware I2C protocol used by EVShield/NXShield on an Arduino.
Definition: BaseI2CDevice.h:98