| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LT_Wire.cpp
Go to the documentation of this file.
1 /*
2 LT_TwoWire.cpp - TWI/I2C library for Wiring & Arduino
3 Copyright (c) 2006 Nicholas Zambetti. All right reserved.
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts
20
21 Modified 2014 to conserve memory for master mode and PMBus compliance
22 */
23
24 //! @ingroup PMBus_SMBus
25 //! @{
26 //! @defgroup LT_Wire LT_Wire: Routines to Communicate With the hardware I2C port.
27 //@ @}
28
29 /*! @file
30 @ingroup LT_Wire
31 Library File for LT_Wire
32 */
33 extern "C" {
34 #include <stdlib.h>
35 #include <string.h>
36 #include <inttypes.h>
37 #include <utility/twi.h>
38
39 }
40
41 #include "LT_Wire.h"
42 #include "Arduino.h" //for serial debug
43
44 // Constructors ////////////////////////////////////////////////////////////////
45
46 LT_TwoWire::LT_TwoWire()
47 {
48 }
49
50 // Public Methods //////////////////////////////////////////////////////////////
51
52 void LT_TwoWire::begin(uint32_t speed)
53 {
54 TwoWire::begin();
55 }
56
57
58 uint8_t LT_TwoWire::requestFrom(uint8_t address, uint8_t *acceptBuffer, uint16_t quantity, uint8_t sendStop)
59 {
60
61 // perform blocking read into buffer
62 uint16_t read = twi_readFrom(address, acceptBuffer, quantity, sendStop);
63
64 return read;
65 }
66
67 uint8_t LT_TwoWire::requestFrom(uint8_t address, uint8_t *acceptBuffer, uint16_t quantity)
68 {
69 return requestFrom((uint8_t)address, (uint8_t *) acceptBuffer, (uint16_t)quantity, (uint8_t)true);
70 }
71
72 uint8_t LT_TwoWire::requestFrom(int address, uint8_t *acceptBuffer, int quantity)
73 {
74 return requestFrom((uint8_t)address, (uint8_t *) acceptBuffer, (uint16_t)quantity, (uint8_t)true);
75 }
76
77 uint8_t LT_TwoWire::requestFrom(int address, uint8_t *acceptBuffer, int quantity, int sendStop)
78 {
79 return requestFrom((uint8_t)address, (uint8_t *) acceptBuffer, (uint16_t)quantity, (uint8_t)sendStop);
80 }
81
82 // Preinstantiate Objects //////////////////////////////////////////////////////
83
84 LT_TwoWire LT_Wire = LT_TwoWire();
85
LT_TwoWire
Definition: LT_Wire.h:36
LT_TwoWire::requestFrom
uint8_t requestFrom(uint8_t address, uint8_t *acceptBuffer, uint16_t quantity)
Read from a slave I2C device.
Definition: LT_Wire.cpp:67
address
static uint8_t address
Definition: DC2091A.ino:83
LT_Wire.h
TwoWire.h - TWI/I2C library for Arduino & Wiring Copyright (c) 2006 Nicholas Zambetti.
LT_Wire
LT_TwoWire LT_Wire
Definition: LT_Wire.cpp:84
LT_TwoWire::LT_TwoWire
LT_TwoWire()
Definition: LT_Wire.cpp:46
LT_TwoWire::begin
void begin(uint32_t speed)
Initiate Prep 10000 to 400000.
Definition: LT_Wire.cpp:52