diff --git a/module_usb_aud_shared/i2c/i2c.h b/module_usb_aud_shared/i2c/i2c.h deleted file mode 100644 index 7bce33f0..00000000 --- a/module_usb_aud_shared/i2c/i2c.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Module: module_usb_aud_shared - * Version: 2v3_iosrc0 - * Build: 5247dfd8ec69594e0670e3b8073efd3c453ad07d - * File: i2c.h - * - * The copyrights, all other intellectual and industrial - * property rights are retained by XMOS and/or its licensors. - * Terms and conditions covering the use of this code can - * be found in the Xmos End User License Agreement. - * - * Copyright XMOS Ltd 2010 - * - * In the case where this code is a modification of existing code - * under a separate license, the separate license terms are shown - * below. The modifications to the code are still covered by the - * copyright notice above. - * - **/ - -// Channel interface -void I2cRegWriteC(int deviceAdrs, int Adrs, int WrData, chanend c); - -int I2cRegReadC(int deviceAdrs, int Adrs, chanend c); - -// Function interface -void I2cRegWrite(int deviceAdrs, int Adrs, int WrData, port AUD_SCLK, port AUD_SDIN); - -int I2cRegRead(int deviceAdrs, int Adrs, port AUD_SCLK, port AUD_SDIN); diff --git a/module_usb_aud_shared/i2c/i2c.xc b/module_usb_aud_shared/i2c/i2c.xc deleted file mode 100755 index ba56c22a..00000000 --- a/module_usb_aud_shared/i2c/i2c.xc +++ /dev/null @@ -1,362 +0,0 @@ -/** - * Module: module_usb_aud_shared - * Version: 2v3_iosrc0 - * Build: c1785ffa61c5d34613093518d78adcebd79ae1cc - * File: i2c.xc - * - * The copyrights, all other intellectual and industrial - * property rights are retained by XMOS and/or its licensors. - * Terms and conditions covering the use of this code can - * be found in the Xmos End User License Agreement. - * - * Copyright XMOS Ltd 2010 - * - * In the case where this code is a modification of existing code - * under a separate license, the separate license terms are shown - * below. The modifications to the code are still covered by the - * copyright notice above. - * - **/ -#include -#include - -int I2cRegReadC(int device, int addr, chanend c) { - int read; - int retVal; - c <: 0; // isWrite - c <: device; - c <: addr; - c <: 1; // only ever one byte - c :> read; - c :> retVal; - return read; -} - -void I2cRegWriteC(int device, int addr, int data, chanend c) { - int retVal; - c <: 1; // isWrite - c <: device; - c <: addr; - c <: 1; // only ever one byte - c <: data; - c :> retVal; -} - -int I2cRegRead(int device, int addr, port scl, port sda) -{ - //int Result; - timer gt; - unsigned time; - int Temp, CtlAdrsData, i; - // three device ACK - int ack[3]; - int rdData; - - // initial values. - scl <: 1; - sda <: 1; - sync(sda); - gt :> time; - time += 1000 + 1000; - gt when timerafter(time) :> int _; - // start bit on SDI - scl <: 1; - sda <: 0; - gt :> time; - time += 1000; - gt when timerafter(time) :> int _; - scl <: 0; - // shift 7bits of address and 1bit R/W (fixed to write). - // WARNING: Assume MSB first. - for (i = 0; i < 8; i += 1) - { - Temp = (device >> (7 - i)) & 0x1; - sda <: Temp; - gt :> time; - time += 1000; - gt when timerafter(time) :> int _; - scl <: 1; - gt :> time; - time += 1000; - gt when timerafter(time) :> int _; - scl <: 0; - } - // turn the data to input - sda :> Temp; - gt :> time; - time += 1000; - gt when timerafter(time) :> int _; - scl <: 1; - // sample first ACK. - sda :> ack[0]; - gt :> time; - time += 1000; - gt when timerafter(time) :> int _; - scl <: 0; - - CtlAdrsData = (addr & 0xFF); - // shift first 8 bits. - for (i = 0; i < 8; i += 1) - { - Temp = (CtlAdrsData >> (7 - i)) & 0x1; - sda <: Temp; - gt :> time; - time += 1000; - gt when timerafter(time) :> int _; - scl <: 1; - gt :> time; - time += 1000; - gt when timerafter(time) :> int _; - scl <: 0; - } - // turn the data to input - sda :> Temp; - gt :> time; - time += 1000; - gt when timerafter(time) :> int _; - scl <: 1; - // sample second ACK. - sda :> ack[1]; - gt :> time; - time += 1000; - gt when timerafter(time) :> int _; - scl <: 0; - - - // stop bit - gt :> time; - time += 1000 + 1000; - gt when timerafter(time) :> int _; - // start bit on SDI - scl <: 1; - sda <: 1; - time += 1000 + 1000; - gt when timerafter(time) :> int _; - scl <: 0; - time += 1000 + 1000; - gt when timerafter(time) :> int _; - - - // send address and read - scl <: 1; - sda <: 1; - sync(sda); - gt :> time; - time += 1000 + 1000; - gt when timerafter(time) :> int _; - // start bit on SDI - scl <: 1; - sda <: 0; - gt :> time; - time += 1000; - gt when timerafter(time) :> int _; - scl <: 0; - // shift 7bits of address and 1bit R/W (fixed to write). - // WARNING: Assume MSB first. - for (i = 0; i < 8; i += 1) - { - int deviceAddr = device | 1; - Temp = (deviceAddr >> (7 - i)) & 0x1; - sda <: Temp; - gt :> time; - time += 1000; - gt when timerafter(time) :> int _; - scl <: 1; - gt :> time; - time += 1000; - gt when timerafter(time) :> int _; - scl <: 0; - } - // turn the data to input - sda :> Temp; - gt :> time; - time += 1000; - gt when timerafter(time) :> int _; - scl <: 1; - // sample first ACK. - sda :> ack[0]; - gt :> time; - time += 1000; - gt when timerafter(time) :> int _; - scl <: 0; - - - rdData = 0; - // shift second 8 bits. - for (i = 0; i < 8; i += 1) - { - - gt :> time; - time += 1000; - gt when timerafter(time) :> int _; - scl <: 1; - - sda :> Temp; - rdData = (rdData << 1) | (Temp & 1); - - gt :> time; - time += 1000; - gt when timerafter(time) :> int _; - scl <: 0; - } - - // turn the data to input - sda :> Temp; - gt :> time; - time += 1000; - gt when timerafter(time) :> int _; - scl <: 1; - // sample second ACK. - sda :> ack[2]; - gt :> time; - time += 1000; - gt when timerafter(time) :> int _; - scl <: 0; - gt :> time; - time += 1000; - gt when timerafter(time) :> int _; - scl <: 1; - // put the data to a good value for next round. - sda <: 1; - // validate all items are ACK properly. - //Result = 0; - //for (i = 0; i < 3; i += 1) - //{ - //if ((ack[i]&1) != 0) - //{ - //Result = Result | (1 << i); - //} - //} - - return rdData; -} - -void I2cRegWrite(int device, int addr, int data, port scl, port sda) -{ - //int Result; - timer gt; - unsigned time; - int Temp, CtlAdrsData, i; - // three device ACK - int ack[3]; - - // initial values. - scl <: 1; - sda <: 1; - sync(sda); - - gt :> time; - time += 1000 + 1000; - gt when timerafter(time) :> void; - - // start bit on SDI - scl <: 1; - sda <: 0; - gt :> time; - time += 1000; - gt when timerafter(time) :> void; - scl <: 0; - - // shift 7bits of address and 1bit R/W (fixed to write). - // WARNING: Assume MSB first. - for (i = 0; i < 8; i += 1) - { - Temp = (device >> (7 - i)) & 0x1; - sda <: Temp; - gt :> time; - time += 1000; - gt when timerafter(time) :> void; - scl <: 1; - gt :> time; - time += 1000; - gt when timerafter(time) :> void; - scl <: 0; - } - - // turn the data to input - sda :> Temp; - gt :> time; - time += 1000; - gt when timerafter(time) :> void; - scl <: 1; - - // sample first ACK. - sda :> ack[0]; - gt :> time; - time += 1000; - gt when timerafter(time) :> void; - scl <: 0; - - CtlAdrsData = (addr & 0xFF); - - // shift first 8 bits. - for (i = 0; i < 8; i += 1) - { - Temp = (CtlAdrsData >> (7 - i)) & 0x1; - sda <: Temp; - gt :> time; - time += 1000; - gt when timerafter(time) :> void; - scl <: 1; - gt :> time; - time += 1000; - gt when timerafter(time) :> void; - scl <: 0; - } - // turn the data to input - sda :> Temp; - gt :> time; - time += 1000; - gt when timerafter(time) :> void; - scl <: 1; - // sample second ACK. - sda :> ack[1]; - gt :> time; - time += 1000; - gt when timerafter(time) :> void; - scl <: 0; - - CtlAdrsData = (data & 0xFF); - // shift second 8 bits. - for (i = 0; i < 8; i += 1) - { - Temp = (CtlAdrsData >> (7 - i)) & 0x1; - sda <: Temp; - gt :> time; - time += 1000; - gt when timerafter(time) :> void; - scl <: 1; - gt :> time; - time += 1000; - gt when timerafter(time) :> void; - scl <: 0; - } - // turn the data to input - sda :> Temp; - gt :> time; - time += 1000; - gt when timerafter(time) :> void; - scl <: 1; - // sample second ACK. - sda :> ack[2]; - gt :> time; - time += 1000; - gt when timerafter(time) :> void; - scl <: 0; - gt :> time; - time += 1000; - gt when timerafter(time) :> void; - scl <: 1; - // put the data to a good value for next round. - sda <: 1; - // validate all items are ACK properly. - //Result = 0; - //for (i = 0; i < 3; i += 1) - //{ - //if ((ack[i]&1) != 0) - //{ - //Result = Result | (1 << i); - //} - //} - //return(Result); -}