1- /*
2- * TwoWire.h - TWI/I2C library for Arduino & Wiring
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- * Copyright (c) 2018 Infineon Technologies AG
22- * This library has been modified for the XMC microcontroller series.
23- */
24-
25- // ****************************************************************************
26- // @Project Includes
27- // ****************************************************************************
28- extern " C" {
29- #include < stdlib.h>
30- #include < string.h>
31- #include < inttypes.h>
32- #include " xmc_gpio.h"
33- }
34-
1+ #include " Arduino.h"
352#include " Wire.h"
36- #include " SPI.h"
373
384// ****************************************************************************
395// @Global Variables
@@ -70,9 +36,9 @@ TwoWire::TwoWire(XMC_I2C_t *conf) {
7036
7137void TwoWire::begin (void ) {
7238 // Check if desire USIC channel is already in use
73- if ((XMC_I2C_config->channel ->CCR & USIC_CH_CCR_MODE_Msk) == XMC_USIC_CH_OPERATING_MODE_SPI) {
74- SPI.end ();
75- }
39+ // if ((XMC_I2C_config->channel->CCR & USIC_CH_CCR_MODE_Msk) == XMC_USIC_CH_OPERATING_MODE_SPI) {
40+ // SPI.end();
41+ // }
7642
7743 hasError = false ;
7844 isMaster = true ;
@@ -112,9 +78,9 @@ void TwoWire::begin(void) {
11278
11379void TwoWire::begin (uint8_t address) {
11480 // Check if desire USIC channel is already in use
115- if ((XMC_I2C_config->channel ->CCR & USIC_CH_CCR_MODE_Msk) == XMC_USIC_CH_OPERATING_MODE_SPI) {
116- SPI.end ();
117- }
81+ // if ((XMC_I2C_config->channel->CCR & USIC_CH_CCR_MODE_Msk) == XMC_USIC_CH_OPERATING_MODE_SPI) {
82+ // SPI.end();
83+ // }
11884 isMaster = false ;
11985 slaveAddress = address;
12086
@@ -163,7 +129,7 @@ void TwoWire::begin(uint8_t address) {
163129 &(XMC_I2C_config->scl_config ));
164130}
165131
166- void TwoWire::begin (int address) { begin ((uint8_t )address); }
132+ // void TwoWire::begin(int address) { begin((uint8_t)address); }
167133
168134void TwoWire::end (void ) {
169135 // Only disable HW when USIC is used for I2C
@@ -205,7 +171,7 @@ void TwoWire::end(void) {
205171void TwoWire::setClock (uint32_t clock) { XMC_I2C_CH_SetBaudrate (XMC_I2C_config->channel , clock); }
206172
207173uint8_t TwoWire::requestFrom (
208- uint8_t address, uint8_t quantity, uint32_t iaddress, uint8_t isize, uint8_t sendStop) {
174+ uint8_t address, size_t quantity, uint32_t iaddress, uint8_t isize, bool sendStop) {
209175 uint32_t StatusFlag;
210176 beginTransmission (address);
211177
@@ -323,22 +289,22 @@ uint8_t TwoWire::requestFrom(
323289 return quantity;
324290}
325291
326- uint8_t TwoWire::requestFrom (uint8_t address, uint8_t quantity, uint8_t sendStop) {
327- return requestFrom ((uint8_t )address, ( uint8_t ) quantity, (uint32_t )0 , (uint8_t )0 ,
328- ( uint8_t ) sendStop);
292+ uint8_t TwoWire::requestFrom (uint8_t address, size_t quantity, bool sendStop) {
293+ return requestFrom ((uint8_t )address, quantity, (uint32_t )0 , (uint8_t )0 ,
294+ sendStop);
329295}
330296
331- uint8_t TwoWire::requestFrom (uint8_t address, uint8_t quantity) {
332- return requestFrom ((uint8_t )address, ( uint8_t ) quantity, ( uint8_t ) true );
297+ uint8_t TwoWire::requestFrom (uint8_t address, size_t quantity) {
298+ return requestFrom ((uint8_t )address, quantity, true );
333299}
334300
335- uint8_t TwoWire::requestFrom (int address, int quantity) {
336- return requestFrom ((uint8_t )address, (uint8_t )quantity, (uint8_t ) true );
337- }
301+ // uint8_t TwoWire::requestFrom(int address, int quantity) {
302+ // return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t) true);
303+ // }
338304
339- uint8_t TwoWire::requestFrom (int address, int quantity, int sendStop) {
340- return requestFrom ((uint8_t )address, (uint8_t )quantity, (uint8_t )sendStop);
341- }
305+ // uint8_t TwoWire::requestFrom(int address, int quantity, int sendStop) {
306+ // return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)sendStop);
307+ // }
342308
343309void TwoWire::beginTransmission (uint8_t address) {
344310 if ((XMC_I2C_config->channel ->CCR & USIC_CH_CCR_MODE_Msk) != XMC_USIC_CH_OPERATING_MODE_I2C) {
@@ -360,7 +326,7 @@ void TwoWire::beginTransmission(uint8_t address) {
360326 XMC_I2C_CH_ClearStatusFlag (XMC_I2C_config->channel , 0xFFFFFFFF );
361327}
362328
363- void TwoWire::beginTransmission (int address) { beginTransmission ((uint8_t )address); }
329+ // void TwoWire::beginTransmission(int address) { beginTransmission((uint8_t)address); }
364330
365331//
366332// Originally, 'endTransmission' was an f(void) function.
@@ -375,7 +341,7 @@ void TwoWire::beginTransmission(int address) { beginTransmission((uint8_t)addres
375341// no call to endTransmission(true) is made. Some I2C
376342// devices will behave oddly if they do not see a STOP.
377343//
378- uint8_t TwoWire::endTransmission (uint8_t sendStop) {
344+ uint8_t TwoWire::endTransmission (bool sendStop) {
379345 uint32_t StatusFlag;
380346
381347 XMC_I2C_CH_MasterStart (XMC_I2C_config->channel , (txAddress << 1 ), XMC_I2C_CH_CMD_WRITE);
0 commit comments