11#include " Arduino.h"
22#include " Wire.h"
33
4- // ****************************************************************************
5- // @Global Variables
6- // ****************************************************************************
7-
8- // Initialize Class Variables //////////////////////////////////////////////////
9-
10- // ****************************************************************************
11- // @Local Functions
12- // ****************************************************************************
13-
14- // Constructors ////////////////////////////////////////////////////////////////
154TwoWire::TwoWire (XMC_I2C_t *conf) {
165 XMC_I2C_config = conf;
176
@@ -35,11 +24,11 @@ TwoWire::TwoWire(XMC_I2C_t *conf) {
3524// Public Methods //////////////////////////////////////////////////////////////
3625
3726void TwoWire::begin (void ) {
38- // Check if desire USIC channel is already in use
27+ // To-Do for future work need to check
28+ // Check if desire USIC channel is already in use
3929 // if ((XMC_I2C_config->channel->CCR & USIC_CH_CCR_MODE_Msk) == XMC_USIC_CH_OPERATING_MODE_SPI) {
4030 // SPI.end();
4131 // }
42-
4332 hasError = false ;
4433 isMaster = true ;
4534
@@ -77,6 +66,7 @@ void TwoWire::begin(void) {
7766}
7867
7968void TwoWire::begin (uint8_t address) {
69+ // To-Do for future work need to check
8070 // Check if desire USIC channel is already in use
8171 // if ((XMC_I2C_config->channel->CCR & USIC_CH_CCR_MODE_Msk) == XMC_USIC_CH_OPERATING_MODE_SPI) {
8272 // SPI.end();
@@ -129,8 +119,6 @@ void TwoWire::begin(uint8_t address) {
129119 &(XMC_I2C_config->scl_config ));
130120}
131121
132- // void TwoWire::begin(int address) { begin((uint8_t)address); }
133-
134122void TwoWire::end (void ) {
135123 // Only disable HW when USIC is used for I2C
136124 if ((XMC_I2C_config->channel ->CCR & USIC_CH_CCR_MODE_Msk) == XMC_USIC_CH_OPERATING_MODE_I2C) {
@@ -174,12 +162,10 @@ uint8_t TwoWire::requestFrom(
174162 uint8_t address, size_t quantity, uint32_t iaddress, uint8_t isize, bool sendStop) {
175163 uint32_t StatusFlag;
176164 beginTransmission (address);
177-
178165 // clamp to buffer length
179166 if (quantity > BUFFER_LENGTH) {
180167 quantity = BUFFER_LENGTH;
181168 }
182-
183169 // send internal address; this mode allows sending a repeated start to access
184170 // some devices' internal registers. This function is executed by the hardware
185171 // TWI module on other processors (for example Due's TWI_IADR and TWI_MMR registers)
@@ -298,14 +284,6 @@ uint8_t TwoWire::requestFrom(uint8_t address, size_t quantity) {
298284 return requestFrom ((uint8_t )address, quantity, true );
299285}
300286
301- // uint8_t TwoWire::requestFrom(int address, int quantity) {
302- // return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t) true);
303- // }
304-
305- // uint8_t TwoWire::requestFrom(int address, int quantity, int sendStop) {
306- // return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)sendStop);
307- // }
308-
309287void TwoWire::beginTransmission (uint8_t address) {
310288 if ((XMC_I2C_config->channel ->CCR & USIC_CH_CCR_MODE_Msk) != XMC_USIC_CH_OPERATING_MODE_I2C) {
311289 if (isMaster) {
@@ -326,9 +304,6 @@ void TwoWire::beginTransmission(uint8_t address) {
326304 XMC_I2C_CH_ClearStatusFlag (XMC_I2C_config->channel , 0xFFFFFFFF );
327305}
328306
329- // void TwoWire::beginTransmission(int address) { beginTransmission((uint8_t)address); }
330-
331- //
332307// Originally, 'endTransmission' was an f(void) function.
333308// It has been modified to take one parameter indicating
334309// whether or not a STOP should be performed on the bus.
@@ -394,7 +369,6 @@ uint8_t TwoWire::endTransmission(bool sendStop) {
394369
395370// This provides backwards compatibility with the original
396371// definition, and expected behaviour, of endTransmission
397- //
398372uint8_t TwoWire::endTransmission (void ) { return endTransmission (true ); }
399373
400374// must be called in:
@@ -665,8 +639,6 @@ void USIC1_4_IRQHandler() { Wire1.ProtocolHandler(); }
665639#endif
666640} // extern "C"
667641
668- // Preinstantiate Objects //////////////////////////////////////////////////////
669-
670642TwoWire Wire = TwoWire(&XMC_I2C_default);
671643#if (NUM_I2C > 1)
672644TwoWire Wire1 = TwoWire(&XMC_I2C_1);
0 commit comments