mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-03-20 06:08:24 +01:00
i2c merge part 2 - unfinished
This commit is contained in:
@@ -29,33 +29,33 @@ void BP1658CJ_Write(float *rgbcw) {
|
||||
//ADDLOG_DEBUG(LOG_FEATURE_CMD, "Writing to Lamp (hex): #%02X%02X%02X%02X%02X", cur_col_10[0], cur_col_10[1], cur_col_10[2], cur_col_10[3], cur_col_10[4]);
|
||||
// If we receive 0 for all channels, we'll assume that the lightbulb is off, and activate BP1658CJ's sleep mode ([0x80] ).
|
||||
if (cur_col_10[0]==0 && cur_col_10[1]==0 && cur_col_10[2]==0 && cur_col_10[3]==0 && cur_col_10[4]==0) {
|
||||
SM2135_Start(BP1658CJ_ADDR_SLEEP);
|
||||
SM2135_WriteByte(BP1658CJ_SUBADDR);
|
||||
Soft_I2C_Start(BP1658CJ_ADDR_SLEEP);
|
||||
Soft_I2C_WriteByte(BP1658CJ_SUBADDR);
|
||||
for(i = 0; i<10; ++i) //set all 10 channels to 00
|
||||
SM2135_WriteByte(0x00);
|
||||
SM2135_Stop();
|
||||
Soft_I2C_WriteByte(0x00);
|
||||
Soft_I2C_Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
// Even though we could address changing channels only, in practice we observed that the lightbulb always sets all channels.
|
||||
SM2135_Start(BP1658CJ_ADDR_OUT);
|
||||
Soft_I2C_Start(BP1658CJ_ADDR_OUT);
|
||||
|
||||
// The First Byte is the Subadress
|
||||
SM2135_WriteByte(BP1658CJ_SUBADDR);
|
||||
Soft_I2C_WriteByte(BP1658CJ_SUBADDR);
|
||||
// Brigtness values are transmitted as two bytes. The light-bulb accepts a 10-bit integer (0-1023) as an input value.
|
||||
// The first 5bits of this input are transmitted in second byte, the second 5bits in the first byte.
|
||||
SM2135_WriteByte((uint8_t)(cur_col_10[0] & 0x1F)); //Red
|
||||
SM2135_WriteByte((uint8_t)(cur_col_10[0] >> 5));
|
||||
SM2135_WriteByte((uint8_t)(cur_col_10[1] & 0x1F)); //Green
|
||||
SM2135_WriteByte((uint8_t)(cur_col_10[1] >> 5));
|
||||
SM2135_WriteByte((uint8_t)(cur_col_10[2] & 0x1F)); //Blue
|
||||
SM2135_WriteByte((uint8_t)(cur_col_10[2] >> 5));
|
||||
SM2135_WriteByte((uint8_t)(cur_col_10[4] & 0x1F)); //Cold
|
||||
SM2135_WriteByte((uint8_t)(cur_col_10[4] >> 5));
|
||||
SM2135_WriteByte((uint8_t)(cur_col_10[3] & 0x1F)); //Warm
|
||||
SM2135_WriteByte((uint8_t)(cur_col_10[3] >> 5));
|
||||
Soft_I2C_WriteByte((uint8_t)(cur_col_10[0] & 0x1F)); //Red
|
||||
Soft_I2C_WriteByte((uint8_t)(cur_col_10[0] >> 5));
|
||||
Soft_I2C_WriteByte((uint8_t)(cur_col_10[1] & 0x1F)); //Green
|
||||
Soft_I2C_WriteByte((uint8_t)(cur_col_10[1] >> 5));
|
||||
Soft_I2C_WriteByte((uint8_t)(cur_col_10[2] & 0x1F)); //Blue
|
||||
Soft_I2C_WriteByte((uint8_t)(cur_col_10[2] >> 5));
|
||||
Soft_I2C_WriteByte((uint8_t)(cur_col_10[4] & 0x1F)); //Cold
|
||||
Soft_I2C_WriteByte((uint8_t)(cur_col_10[4] >> 5));
|
||||
Soft_I2C_WriteByte((uint8_t)(cur_col_10[3] & 0x1F)); //Warm
|
||||
Soft_I2C_WriteByte((uint8_t)(cur_col_10[3] >> 5));
|
||||
|
||||
SM2135_Stop();
|
||||
Soft_I2C_Stop();
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ void BP1658CJ_Init() {
|
||||
g_i2c_pin_clk = PIN_FindPinIndexForRole(IOR_BP1658CJ_CLK,g_i2c_pin_clk);
|
||||
g_i2c_pin_data = PIN_FindPinIndexForRole(IOR_BP1658CJ_DAT,g_i2c_pin_data);
|
||||
|
||||
SM2135_PreInit();
|
||||
Soft_I2C_PreInit();
|
||||
|
||||
//cmddetail:{"name":"BP1658CJ_RGBCW","args":"[HexColor]",
|
||||
//cmddetail:"descr":"Don't use it. It's for direct access of BP1658CJ driver. You don't need it because LED driver automatically calls it, so just use led_basecolor_rgb",
|
||||
|
||||
@@ -20,7 +20,7 @@ static byte g_chosenCurrent = BP5758D_14MA;
|
||||
bool bIsSleeping = false; //Save sleep state of Lamp
|
||||
|
||||
static void BP5758D_SetCurrent(byte curVal) {
|
||||
SM2135_Stop();
|
||||
Soft_I2C_Stop();
|
||||
|
||||
usleep(SM2135_DELAY);
|
||||
|
||||
@@ -30,48 +30,48 @@ static void BP5758D_SetCurrent(byte curVal) {
|
||||
//g_chosenCurrent = curVal;
|
||||
|
||||
// For it's init sequence, BP5758D just sets all fields
|
||||
SM2135_Start(BP5758D_ADDR_SETUP);
|
||||
Soft_I2C_Start(BP5758D_ADDR_SETUP);
|
||||
// Output enabled: enable all outputs since we're using a RGBCW light
|
||||
SM2135_WriteByte(BP5758D_ENABLE_OUTPUTS_ALL);
|
||||
Soft_I2C_WriteByte(BP5758D_ENABLE_OUTPUTS_ALL);
|
||||
// Set currents for OUT1-OUT5
|
||||
SM2135_WriteByte(g_chosenCurrent);
|
||||
SM2135_WriteByte(g_chosenCurrent);
|
||||
SM2135_WriteByte(g_chosenCurrent);
|
||||
SM2135_WriteByte(g_chosenCurrent);
|
||||
SM2135_WriteByte(g_chosenCurrent);
|
||||
SM2135_Stop();
|
||||
Soft_I2C_WriteByte(g_chosenCurrent);
|
||||
Soft_I2C_WriteByte(g_chosenCurrent);
|
||||
Soft_I2C_WriteByte(g_chosenCurrent);
|
||||
Soft_I2C_WriteByte(g_chosenCurrent);
|
||||
Soft_I2C_WriteByte(g_chosenCurrent);
|
||||
Soft_I2C_Stop();
|
||||
usleep(SM2135_DELAY);
|
||||
}
|
||||
static void BP5758D_PreInit() {
|
||||
HAL_PIN_Setup_Output(g_i2c_pin_clk);
|
||||
HAL_PIN_Setup_Output(g_i2c_pin_data);
|
||||
|
||||
SM2135_Stop();
|
||||
Soft_I2C_Stop();
|
||||
|
||||
usleep(SM2135_DELAY);
|
||||
|
||||
// For it's init sequence, BP5758D just sets all fields
|
||||
SM2135_Start(BP5758D_ADDR_SETUP);
|
||||
Soft_I2C_Start(BP5758D_ADDR_SETUP);
|
||||
// Output enabled: enable all outputs since we're using a RGBCW light
|
||||
SM2135_WriteByte(BP5758D_ENABLE_OUTPUTS_ALL);
|
||||
Soft_I2C_WriteByte(BP5758D_ENABLE_OUTPUTS_ALL);
|
||||
// Set currents for OUT1-OUT5
|
||||
SM2135_WriteByte(g_chosenCurrent); //TODO: Make this configurable from webapp / console
|
||||
SM2135_WriteByte(g_chosenCurrent);
|
||||
SM2135_WriteByte(g_chosenCurrent);
|
||||
SM2135_WriteByte(g_chosenCurrent);
|
||||
SM2135_WriteByte(g_chosenCurrent);
|
||||
Soft_I2C_WriteByte(g_chosenCurrent); //TODO: Make this configurable from webapp / console
|
||||
Soft_I2C_WriteByte(g_chosenCurrent);
|
||||
Soft_I2C_WriteByte(g_chosenCurrent);
|
||||
Soft_I2C_WriteByte(g_chosenCurrent);
|
||||
Soft_I2C_WriteByte(g_chosenCurrent);
|
||||
// Set grayscale levels ouf all outputs to 0
|
||||
SM2135_WriteByte(0x00);
|
||||
SM2135_WriteByte(0x00);
|
||||
SM2135_WriteByte(0x00);
|
||||
SM2135_WriteByte(0x00);
|
||||
SM2135_WriteByte(0x00);
|
||||
SM2135_WriteByte(0x00);
|
||||
SM2135_WriteByte(0x00);
|
||||
SM2135_WriteByte(0x00);
|
||||
SM2135_WriteByte(0x00);
|
||||
SM2135_WriteByte(0x00);
|
||||
SM2135_Stop();
|
||||
Soft_I2C_WriteByte(0x00);
|
||||
Soft_I2C_WriteByte(0x00);
|
||||
Soft_I2C_WriteByte(0x00);
|
||||
Soft_I2C_WriteByte(0x00);
|
||||
Soft_I2C_WriteByte(0x00);
|
||||
Soft_I2C_WriteByte(0x00);
|
||||
Soft_I2C_WriteByte(0x00);
|
||||
Soft_I2C_WriteByte(0x00);
|
||||
Soft_I2C_WriteByte(0x00);
|
||||
Soft_I2C_WriteByte(0x00);
|
||||
Soft_I2C_Stop();
|
||||
}
|
||||
|
||||
|
||||
@@ -90,37 +90,37 @@ void BP5758D_Write(float *rgbcw) {
|
||||
// If we receive 0 for all channels, we'll assume that the lightbulb is off, and activate BP5758d's sleep mode.
|
||||
if (cur_col_10[0]==0 && cur_col_10[1]==0 && cur_col_10[2]==0 && cur_col_10[3]==0 && cur_col_10[4]==0) {
|
||||
bIsSleeping = true;
|
||||
SM2135_Start(BP5758D_ADDR_SETUP); //Select B1: Output enable setup
|
||||
SM2135_WriteByte(BP5758D_DISABLE_OUTPUTS_ALL); //Set all outputs to OFF
|
||||
SM2135_Stop(); //Stop transmission since we have to set Sleep mode (can probably be removed)
|
||||
SM2135_Start(BP5758D_ADDR_SLEEP); //Enable sleep mode
|
||||
SM2135_Stop();
|
||||
Soft_I2C_Start(BP5758D_ADDR_SETUP); //Select B1: Output enable setup
|
||||
Soft_I2C_WriteByte(BP5758D_DISABLE_OUTPUTS_ALL); //Set all outputs to OFF
|
||||
Soft_I2C_Stop(); //Stop transmission since we have to set Sleep mode (can probably be removed)
|
||||
Soft_I2C_Start(BP5758D_ADDR_SLEEP); //Enable sleep mode
|
||||
Soft_I2C_Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if(bIsSleeping) {
|
||||
bIsSleeping = false; //No need to run it every time a val gets changed
|
||||
SM2135_Start(BP5758D_ADDR_SETUP); //Sleep mode gets disabled too since bits 5:6 get set to 01
|
||||
SM2135_WriteByte(BP5758D_ENABLE_OUTPUTS_ALL); //Set all outputs to ON
|
||||
SM2135_Stop();
|
||||
Soft_I2C_Start(BP5758D_ADDR_SETUP); //Sleep mode gets disabled too since bits 5:6 get set to 01
|
||||
Soft_I2C_WriteByte(BP5758D_ENABLE_OUTPUTS_ALL); //Set all outputs to ON
|
||||
Soft_I2C_Stop();
|
||||
}
|
||||
|
||||
// Even though we could address changing channels only, in practice we observed that the lightbulb always sets all channels.
|
||||
SM2135_Start(BP5758D_ADDR_OUT1_GL);
|
||||
Soft_I2C_Start(BP5758D_ADDR_OUT1_GL);
|
||||
// Brigtness values are transmitted as two bytes. The light-bulb accepts a 10-bit integer (0-1023) as an input value.
|
||||
// The first 5bits of this input are transmitted in second byte, the second 5bits in the first byte.
|
||||
SM2135_WriteByte((uint8_t)(cur_col_10[0] & 0x1F)); //Red
|
||||
SM2135_WriteByte((uint8_t)(cur_col_10[0] >> 5));
|
||||
SM2135_WriteByte((uint8_t)(cur_col_10[1] & 0x1F)); //Green
|
||||
SM2135_WriteByte((uint8_t)(cur_col_10[1] >> 5));
|
||||
SM2135_WriteByte((uint8_t)(cur_col_10[2] & 0x1F)); //Blue
|
||||
SM2135_WriteByte((uint8_t)(cur_col_10[2] >> 5));
|
||||
SM2135_WriteByte((uint8_t)(cur_col_10[4] & 0x1F)); //Cold
|
||||
SM2135_WriteByte((uint8_t)(cur_col_10[4] >> 5));
|
||||
SM2135_WriteByte((uint8_t)(cur_col_10[3] & 0x1F)); //Warm
|
||||
SM2135_WriteByte((uint8_t)(cur_col_10[3] >> 5));
|
||||
Soft_I2C_WriteByte((uint8_t)(cur_col_10[0] & 0x1F)); //Red
|
||||
Soft_I2C_WriteByte((uint8_t)(cur_col_10[0] >> 5));
|
||||
Soft_I2C_WriteByte((uint8_t)(cur_col_10[1] & 0x1F)); //Green
|
||||
Soft_I2C_WriteByte((uint8_t)(cur_col_10[1] >> 5));
|
||||
Soft_I2C_WriteByte((uint8_t)(cur_col_10[2] & 0x1F)); //Blue
|
||||
Soft_I2C_WriteByte((uint8_t)(cur_col_10[2] >> 5));
|
||||
Soft_I2C_WriteByte((uint8_t)(cur_col_10[4] & 0x1F)); //Cold
|
||||
Soft_I2C_WriteByte((uint8_t)(cur_col_10[4] >> 5));
|
||||
Soft_I2C_WriteByte((uint8_t)(cur_col_10[3] & 0x1F)); //Warm
|
||||
Soft_I2C_WriteByte((uint8_t)(cur_col_10[3] >> 5));
|
||||
|
||||
SM2135_Stop();
|
||||
Soft_I2C_Stop();
|
||||
}
|
||||
|
||||
// see drv_bp5758d.h for sample values
|
||||
|
||||
@@ -33,15 +33,15 @@ static void CHT8305_ReadEnv(float* temp, float* hum)
|
||||
uint8_t buff[4];
|
||||
unsigned int th, tl, hh, hl;
|
||||
|
||||
SM2135_Start(CHT8305_I2C_ADDR);
|
||||
SM2135_WriteByte(0x00);
|
||||
SM2135_Stop();
|
||||
Soft_I2C_Start(CHT8305_I2C_ADDR);
|
||||
Soft_I2C_WriteByte(0x00);
|
||||
Soft_I2C_Stop();
|
||||
|
||||
rtos_delay_milliseconds(20); //give the sensor time to do the conversion
|
||||
|
||||
SM2135_Start(CHT8305_I2C_ADDR | 1);
|
||||
SM2135_ReadBytes(buff, 4);
|
||||
SM2135_Stop();
|
||||
Soft_I2C_Start(CHT8305_I2C_ADDR | 1);
|
||||
Soft_I2C_ReadBytes(buff, 4);
|
||||
Soft_I2C_Stop();
|
||||
|
||||
th = buff[0];
|
||||
tl = buff[1];
|
||||
@@ -65,14 +65,14 @@ void CHT8305_Init() {
|
||||
g_i2c_pin_clk = PIN_FindPinIndexForRole(IOR_CHT8305_CLK, g_i2c_pin_clk);
|
||||
g_i2c_pin_data = PIN_FindPinIndexForRole(IOR_CHT8305_DAT, g_i2c_pin_data);
|
||||
|
||||
SM2135_PreInit();
|
||||
Soft_I2C_PreInit();
|
||||
|
||||
SM2135_Start(CHT8305_I2C_ADDR);
|
||||
SM2135_WriteByte(0xfe); //manufacturer ID
|
||||
SM2135_Stop();
|
||||
SM2135_Start(CHT8305_I2C_ADDR | 1);
|
||||
SM2135_ReadBytes(buff, 2);
|
||||
SM2135_Stop();
|
||||
Soft_I2C_Start(CHT8305_I2C_ADDR);
|
||||
Soft_I2C_WriteByte(0xfe); //manufacturer ID
|
||||
Soft_I2C_Stop();
|
||||
Soft_I2C_Start(CHT8305_I2C_ADDR | 1);
|
||||
Soft_I2C_ReadBytes(buff, 2);
|
||||
Soft_I2C_Stop();
|
||||
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_SENSOR, "DRV_CHT8304_init: ID: %02X %02X\n", buff[0], buff[1]);
|
||||
|
||||
|
||||
@@ -78,14 +78,14 @@ void WEMO_AppendInformationToHTTPIndexPage(http_request_t* request);
|
||||
extern int g_i2c_pin_clk;
|
||||
extern int g_i2c_pin_data;
|
||||
extern byte g_channelOrder[5];
|
||||
void SM2135_SetLow(uint8_t pin);
|
||||
void SM2135_SetHigh(uint8_t pin);
|
||||
bool SM2135_PreInit(void);
|
||||
bool SM2135_WriteByte(uint8_t value);
|
||||
bool SM2135_Start(uint8_t addr);
|
||||
void SM2135_Stop(void);
|
||||
uint8_t SM2135_ReadByte(bool nack);
|
||||
void SM2135_ReadBytes(uint8_t* buf, int numOfBytes);
|
||||
void Soft_I2C_SetLow(uint8_t pin);
|
||||
void Soft_I2C_SetHigh(uint8_t pin);
|
||||
bool Soft_I2C_PreInit(void);
|
||||
bool Soft_I2C_WriteByte(uint8_t value);
|
||||
bool Soft_I2C_Start(uint8_t addr);
|
||||
void Soft_I2C_Stop(void);
|
||||
uint8_t Soft_I2C_ReadByte(bool nack);
|
||||
void Soft_I2C_ReadBytes(uint8_t* buf, int numOfBytes);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -39,22 +39,22 @@ commandResult_t SHT3X_Calibrate(const void* context, const char* cmd, const char
|
||||
|
||||
|
||||
void SHT3X_StopPer() {
|
||||
SM2135_Start(SHT3X_I2C_ADDR);
|
||||
Soft_I2C_Start(SHT3X_I2C_ADDR);
|
||||
// Stop Periodic Data
|
||||
SM2135_WriteByte(0x30);
|
||||
Soft_I2C_WriteByte(0x30);
|
||||
// medium repeteability
|
||||
SM2135_WriteByte(0x93);
|
||||
SM2135_Stop();
|
||||
Soft_I2C_WriteByte(0x93);
|
||||
Soft_I2C_Stop();
|
||||
}
|
||||
|
||||
void SM2135_StartPer(uint8_t msb, uint8_t lsb) {
|
||||
// Start Periodic Data capture
|
||||
SM2135_Start(SHT3X_I2C_ADDR);
|
||||
Soft_I2C_Start(SHT3X_I2C_ADDR);
|
||||
// Measure per seconds
|
||||
SM2135_WriteByte(msb);
|
||||
Soft_I2C_WriteByte(msb);
|
||||
// repeteability
|
||||
SM2135_WriteByte(lsb);
|
||||
SM2135_Stop();
|
||||
Soft_I2C_WriteByte(lsb);
|
||||
Soft_I2C_Stop();
|
||||
}
|
||||
|
||||
void SHT3X_ChangePer(const void* context, const char* cmd, const char* args, int cmdFlags) {
|
||||
@@ -85,21 +85,21 @@ void SHT3X_Heater(const void* context, const char* cmd, const char* args, int cm
|
||||
return CMD_RES_NOT_ENOUGH_ARGUMENTS;
|
||||
}
|
||||
g_state_heat = Tokenizer_GetArgInteger(0);
|
||||
SM2135_Start(SHT3X_I2C_ADDR);
|
||||
Soft_I2C_Start(SHT3X_I2C_ADDR);
|
||||
|
||||
if (g_state_heat > 0) {
|
||||
// medium repeteability
|
||||
SM2135_WriteByte(0x30);
|
||||
SM2135_WriteByte(0x6D);
|
||||
Soft_I2C_WriteByte(0x30);
|
||||
Soft_I2C_WriteByte(0x6D);
|
||||
ADDLOG_INFO(LOG_FEATURE_SENSOR, "SHT Heater activated");
|
||||
}
|
||||
else {
|
||||
// medium repeteability
|
||||
SM2135_WriteByte(0x30);
|
||||
SM2135_WriteByte(0x66);
|
||||
Soft_I2C_WriteByte(0x30);
|
||||
Soft_I2C_WriteByte(0x66);
|
||||
ADDLOG_INFO(LOG_FEATURE_SENSOR, "SHT Heater deactivated");
|
||||
}
|
||||
SM2135_Stop();
|
||||
Soft_I2C_Stop();
|
||||
return CMD_RES_OK;
|
||||
}
|
||||
|
||||
@@ -108,16 +108,16 @@ void SHT3X_MeasurePer(const void* context, const char* cmd, const char* args, in
|
||||
uint8_t buff[6];
|
||||
unsigned int th, tl, hh, hl;
|
||||
|
||||
SM2135_Start(SHT3X_I2C_ADDR);
|
||||
Soft_I2C_Start(SHT3X_I2C_ADDR);
|
||||
// Ask for fetching data
|
||||
SM2135_WriteByte(0xE0);
|
||||
Soft_I2C_WriteByte(0xE0);
|
||||
// medium repeteability
|
||||
SM2135_WriteByte(0x00);
|
||||
SM2135_Stop();
|
||||
Soft_I2C_WriteByte(0x00);
|
||||
Soft_I2C_Stop();
|
||||
|
||||
SM2135_Start(SHT3X_I2C_ADDR | 1);
|
||||
SM2135_ReadBytes(buff, 6);
|
||||
SM2135_Stop();
|
||||
Soft_I2C_Start(SHT3X_I2C_ADDR | 1);
|
||||
Soft_I2C_ReadBytes(buff, 6);
|
||||
Soft_I2C_Stop();
|
||||
|
||||
th = buff[0];
|
||||
tl = buff[1];
|
||||
@@ -145,18 +145,18 @@ void SHT3X_Measure(const void* context, const char* cmd, const char* args, int c
|
||||
uint8_t buff[6];
|
||||
unsigned int th, tl, hh, hl;
|
||||
|
||||
SM2135_Start(SHT3X_I2C_ADDR);
|
||||
Soft_I2C_Start(SHT3X_I2C_ADDR);
|
||||
// no clock stretching
|
||||
SM2135_WriteByte(0x24);
|
||||
Soft_I2C_WriteByte(0x24);
|
||||
// medium repeteability
|
||||
SM2135_WriteByte(0x16);
|
||||
SM2135_Stop();
|
||||
Soft_I2C_WriteByte(0x16);
|
||||
Soft_I2C_Stop();
|
||||
|
||||
rtos_delay_milliseconds(20); //give the sensor time to do the conversion
|
||||
|
||||
SM2135_Start(SHT3X_I2C_ADDR | 1);
|
||||
SM2135_ReadBytes(buff, 6);
|
||||
SM2135_Stop();
|
||||
Soft_I2C_Start(SHT3X_I2C_ADDR | 1);
|
||||
Soft_I2C_ReadBytes(buff, 6);
|
||||
Soft_I2C_Stop();
|
||||
|
||||
th = buff[0];
|
||||
tl = buff[1];
|
||||
@@ -183,10 +183,10 @@ void SHT3X_StopDriver() {
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_SENSOR, "SHT3X : Stopping Driver and reset sensor");
|
||||
SHT3X_StopPer();
|
||||
// Reset the sensor
|
||||
SM2135_Start(SHT3X_I2C_ADDR);
|
||||
SM2135_WriteByte(0x30);
|
||||
SM2135_WriteByte(0xA2);
|
||||
SM2135_Stop();
|
||||
Soft_I2C_Start(SHT3X_I2C_ADDR);
|
||||
Soft_I2C_WriteByte(0x30);
|
||||
Soft_I2C_WriteByte(0xA2);
|
||||
Soft_I2C_Stop();
|
||||
}
|
||||
|
||||
void SHT3X_StopPerCmd(const void* context, const char* cmd, const char* args, int cmdFlags) {
|
||||
@@ -198,13 +198,13 @@ void SHT3X_StopPerCmd(const void* context, const char* cmd, const char* args, in
|
||||
void SHT3X_GetStatus()
|
||||
{
|
||||
uint8_t status[2];
|
||||
SM2135_Start(SHT3X_I2C_ADDR);
|
||||
SM2135_WriteByte(0xf3); //Get Status should be 00000xxxxx00x0x0
|
||||
SM2135_WriteByte(0x2d); //Cheksum/Cmd_status/x/reset/res*5/Talert/RHalert/x/Heater/x/Alert
|
||||
SM2135_Stop();
|
||||
SM2135_Start(SHT3X_I2C_ADDR | 1);
|
||||
SM2135_ReadBytes(status, 2);
|
||||
SM2135_Stop();
|
||||
Soft_I2C_Start(SHT3X_I2C_ADDR);
|
||||
Soft_I2C_WriteByte(0xf3); //Get Status should be 00000xxxxx00x0x0
|
||||
Soft_I2C_WriteByte(0x2d); //Cheksum/Cmd_status/x/reset/res*5/Talert/RHalert/x/Heater/x/Alert
|
||||
Soft_I2C_Stop();
|
||||
Soft_I2C_Start(SHT3X_I2C_ADDR | 1);
|
||||
Soft_I2C_ReadBytes(status, 2);
|
||||
Soft_I2C_Stop();
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_SENSOR, "SHT : Status : %02X %02X\n", status[0], status[1]);
|
||||
}
|
||||
void SHT3X_GetStatusCmd(const void* context, const char* cmd, const char* args, int cmdFlags)
|
||||
@@ -223,7 +223,7 @@ void SHT3X_Init() {
|
||||
g_i2c_pin_clk = PIN_FindPinIndexForRole(IOR_SHT3X_CLK, g_i2c_pin_clk);
|
||||
g_i2c_pin_data = PIN_FindPinIndexForRole(IOR_SHT3X_DAT, g_i2c_pin_data);
|
||||
|
||||
SM2135_PreInit();
|
||||
Soft_I2C_PreInit();
|
||||
|
||||
SHT3X_GetStatus();
|
||||
|
||||
|
||||
@@ -39,106 +39,106 @@ void usleep(int r) //delay function do 10*r nops, because rtos_delay_millisecond
|
||||
#endif
|
||||
}
|
||||
|
||||
void SM2135_SetLow(uint8_t pin) {
|
||||
void Soft_I2C_SetLow(uint8_t pin) {
|
||||
HAL_PIN_Setup_Output(pin);
|
||||
HAL_PIN_SetOutputValue(pin, 0);
|
||||
}
|
||||
|
||||
void SM2135_SetHigh(uint8_t pin) {
|
||||
void Soft_I2C_SetHigh(uint8_t pin) {
|
||||
HAL_PIN_Setup_Input_Pullup(pin);
|
||||
}
|
||||
|
||||
bool SM2135_PreInit(void) {
|
||||
bool Soft_I2C_PreInit(void) {
|
||||
HAL_PIN_SetOutputValue(g_i2c_pin_data, 0);
|
||||
HAL_PIN_SetOutputValue(g_i2c_pin_clk, 0);
|
||||
SM2135_SetHigh(g_i2c_pin_data);
|
||||
SM2135_SetHigh(g_i2c_pin_clk);
|
||||
Soft_I2C_SetHigh(g_i2c_pin_data);
|
||||
Soft_I2C_SetHigh(g_i2c_pin_clk);
|
||||
return (!((HAL_PIN_ReadDigitalInput(g_i2c_pin_data) == 0 || HAL_PIN_ReadDigitalInput(g_i2c_pin_clk) == 0)));
|
||||
}
|
||||
|
||||
bool SM2135_WriteByte(uint8_t value) {
|
||||
bool Soft_I2C_WriteByte(uint8_t value) {
|
||||
uint8_t curr;
|
||||
uint8_t ack;
|
||||
|
||||
for (curr = 0X80; curr != 0; curr >>= 1) {
|
||||
if (curr & value) {
|
||||
SM2135_SetHigh(g_i2c_pin_data);
|
||||
Soft_I2C_SetHigh(g_i2c_pin_data);
|
||||
} else {
|
||||
SM2135_SetLow(g_i2c_pin_data);
|
||||
Soft_I2C_SetLow(g_i2c_pin_data);
|
||||
}
|
||||
SM2135_SetHigh(g_i2c_pin_clk);
|
||||
Soft_I2C_SetHigh(g_i2c_pin_clk);
|
||||
usleep(SM2135_DELAY);
|
||||
SM2135_SetLow(g_i2c_pin_clk);
|
||||
Soft_I2C_SetLow(g_i2c_pin_clk);
|
||||
}
|
||||
// get Ack or Nak
|
||||
SM2135_SetHigh(g_i2c_pin_data);
|
||||
SM2135_SetHigh(g_i2c_pin_clk);
|
||||
Soft_I2C_SetHigh(g_i2c_pin_data);
|
||||
Soft_I2C_SetHigh(g_i2c_pin_clk);
|
||||
usleep(SM2135_DELAY / 2);
|
||||
ack = HAL_PIN_ReadDigitalInput(g_i2c_pin_data);
|
||||
SM2135_SetLow(g_i2c_pin_clk);
|
||||
Soft_I2C_SetLow(g_i2c_pin_clk);
|
||||
usleep(SM2135_DELAY / 2);
|
||||
SM2135_SetLow(g_i2c_pin_data);
|
||||
Soft_I2C_SetLow(g_i2c_pin_data);
|
||||
return (0 == ack);
|
||||
}
|
||||
|
||||
bool SM2135_Start(uint8_t addr) {
|
||||
SM2135_SetLow(g_i2c_pin_data);
|
||||
bool Soft_I2C_Start(uint8_t addr) {
|
||||
Soft_I2C_SetLow(g_i2c_pin_data);
|
||||
usleep(SM2135_DELAY);
|
||||
SM2135_SetLow(g_i2c_pin_clk);
|
||||
return SM2135_WriteByte(addr);
|
||||
Soft_I2C_SetLow(g_i2c_pin_clk);
|
||||
return Soft_I2C_WriteByte(addr);
|
||||
}
|
||||
|
||||
void SM2135_Stop(void) {
|
||||
SM2135_SetLow(g_i2c_pin_data);
|
||||
void Soft_I2C_Stop(void) {
|
||||
Soft_I2C_SetLow(g_i2c_pin_data);
|
||||
usleep(SM2135_DELAY);
|
||||
SM2135_SetHigh(g_i2c_pin_clk);
|
||||
Soft_I2C_SetHigh(g_i2c_pin_clk);
|
||||
usleep(SM2135_DELAY);
|
||||
SM2135_SetHigh(g_i2c_pin_data);
|
||||
Soft_I2C_SetHigh(g_i2c_pin_data);
|
||||
usleep(SM2135_DELAY);
|
||||
}
|
||||
|
||||
|
||||
void SM2135_ReadBytes(uint8_t* buf, int numOfBytes)
|
||||
void Soft_I2C_ReadBytes(uint8_t* buf, int numOfBytes)
|
||||
{
|
||||
|
||||
for (int i = 0; i < numOfBytes - 1; i++)
|
||||
{
|
||||
|
||||
buf[i] = SM2135_ReadByte(false);
|
||||
buf[i] = Soft_I2C_ReadByte(false);
|
||||
|
||||
}
|
||||
|
||||
buf[numOfBytes - 1] = SM2135_ReadByte(true); //Give NACK on last byte read
|
||||
buf[numOfBytes - 1] = Soft_I2C_ReadByte(true); //Give NACK on last byte read
|
||||
}
|
||||
uint8_t SM2135_ReadByte(bool nack)
|
||||
uint8_t Soft_I2C_ReadByte(bool nack)
|
||||
{
|
||||
uint8_t val = 0;
|
||||
|
||||
SM2135_SetHigh(g_i2c_pin_data);
|
||||
Soft_I2C_SetHigh(g_i2c_pin_data);
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
usleep(SM2135_DELAY);
|
||||
SM2135_SetHigh(g_i2c_pin_clk);
|
||||
Soft_I2C_SetHigh(g_i2c_pin_clk);
|
||||
val <<= 1;
|
||||
if (HAL_PIN_ReadDigitalInput(g_i2c_pin_data))
|
||||
{
|
||||
val |= 1;
|
||||
}
|
||||
SM2135_SetLow(g_i2c_pin_clk);
|
||||
Soft_I2C_SetLow(g_i2c_pin_clk);
|
||||
}
|
||||
if (nack)
|
||||
{
|
||||
SM2135_SetHigh(g_i2c_pin_data);
|
||||
Soft_I2C_SetHigh(g_i2c_pin_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
SM2135_SetLow(g_i2c_pin_data);
|
||||
Soft_I2C_SetLow(g_i2c_pin_data);
|
||||
}
|
||||
SM2135_SetHigh(g_i2c_pin_clk);
|
||||
Soft_I2C_SetHigh(g_i2c_pin_clk);
|
||||
usleep(SM2135_DELAY);
|
||||
SM2135_SetLow(g_i2c_pin_clk);
|
||||
Soft_I2C_SetLow(g_i2c_pin_clk);
|
||||
usleep(SM2135_DELAY);
|
||||
SM2135_SetLow(g_i2c_pin_data);
|
||||
Soft_I2C_SetLow(g_i2c_pin_data);
|
||||
|
||||
return val;
|
||||
}
|
||||
@@ -155,36 +155,36 @@ void SM2135_Write(float *rgbcw) {
|
||||
}
|
||||
}
|
||||
if(bRGB) {
|
||||
SM2135_Start(SM2135_ADDR_MC);
|
||||
SM2135_WriteByte(g_current_setting_rgb);
|
||||
SM2135_WriteByte(SM2135_RGB);
|
||||
SM2135_WriteByte(rgbcw[g_channelOrder[0]]);
|
||||
SM2135_WriteByte(rgbcw[g_channelOrder[1]]);
|
||||
SM2135_WriteByte(rgbcw[g_channelOrder[2]]);
|
||||
SM2135_Stop();
|
||||
Soft_I2C_Start(SM2135_ADDR_MC);
|
||||
Soft_I2C_WriteByte(g_current_setting_rgb);
|
||||
Soft_I2C_WriteByte(SM2135_RGB);
|
||||
Soft_I2C_WriteByte(rgbcw[g_channelOrder[0]]);
|
||||
Soft_I2C_WriteByte(rgbcw[g_channelOrder[1]]);
|
||||
Soft_I2C_WriteByte(rgbcw[g_channelOrder[2]]);
|
||||
Soft_I2C_Stop();
|
||||
} else {
|
||||
SM2135_Start(SM2135_ADDR_MC);
|
||||
SM2135_WriteByte(g_current_setting_cw);
|
||||
SM2135_WriteByte(SM2135_CW);
|
||||
SM2135_Stop();
|
||||
Soft_I2C_Start(SM2135_ADDR_MC);
|
||||
Soft_I2C_WriteByte(g_current_setting_cw);
|
||||
Soft_I2C_WriteByte(SM2135_CW);
|
||||
Soft_I2C_Stop();
|
||||
usleep(SM2135_DELAY);
|
||||
|
||||
SM2135_Start(SM2135_ADDR_C);
|
||||
SM2135_WriteByte(rgbcw[g_channelOrder[3]]);
|
||||
SM2135_WriteByte(rgbcw[g_channelOrder[4]]);
|
||||
SM2135_Stop();
|
||||
Soft_I2C_Start(SM2135_ADDR_C);
|
||||
Soft_I2C_WriteByte(rgbcw[g_channelOrder[3]]);
|
||||
Soft_I2C_WriteByte(rgbcw[g_channelOrder[4]]);
|
||||
Soft_I2C_Stop();
|
||||
|
||||
}
|
||||
} else {
|
||||
SM2135_Start(SM2135_ADDR_MC);
|
||||
SM2135_WriteByte(g_current_setting_rgb);
|
||||
SM2135_WriteByte(SM2135_RGB);
|
||||
SM2135_WriteByte(rgbcw[g_channelOrder[0]]);
|
||||
SM2135_WriteByte(rgbcw[g_channelOrder[1]]);
|
||||
SM2135_WriteByte(rgbcw[g_channelOrder[2]]);
|
||||
SM2135_WriteByte(rgbcw[g_channelOrder[3]]);
|
||||
SM2135_WriteByte(rgbcw[g_channelOrder[4]]);
|
||||
SM2135_Stop();
|
||||
Soft_I2C_Start(SM2135_ADDR_MC);
|
||||
Soft_I2C_WriteByte(g_current_setting_rgb);
|
||||
Soft_I2C_WriteByte(SM2135_RGB);
|
||||
Soft_I2C_WriteByte(rgbcw[g_channelOrder[0]]);
|
||||
Soft_I2C_WriteByte(rgbcw[g_channelOrder[1]]);
|
||||
Soft_I2C_WriteByte(rgbcw[g_channelOrder[2]]);
|
||||
Soft_I2C_WriteByte(rgbcw[g_channelOrder[3]]);
|
||||
Soft_I2C_WriteByte(rgbcw[g_channelOrder[4]]);
|
||||
Soft_I2C_Stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,11 +281,12 @@ static commandResult_t SM2135_Current(const void *context, const char *cmd, cons
|
||||
// SM2135_RGBCW FF00000000
|
||||
void SM2135_Init() {
|
||||
|
||||
SM2135_PreInit();
|
||||
|
||||
g_i2c_pin_clk = PIN_FindPinIndexForRole(IOR_SM2135_CLK,g_i2c_pin_clk);
|
||||
g_i2c_pin_data = PIN_FindPinIndexForRole(IOR_SM2135_DAT,g_i2c_pin_data);
|
||||
|
||||
|
||||
Soft_I2C_PreInit();
|
||||
|
||||
//cmddetail:{"name":"SM2135_RGBCW","args":"[HexColor]",
|
||||
//cmddetail:"descr":"Don't use it. It's for direct access of SM2135 driver. You don't need it because LED driver automatically calls it, so just use led_basecolor_rgb",
|
||||
//cmddetail:"fn":"SM2135_RGBCW","file":"driver/drv_sm2135.c","requires":"",
|
||||
|
||||
@@ -28,30 +28,30 @@ void SM2235_Write(float *rgbcw) {
|
||||
#define SM2235_SECOND_BYTE(x) (x & 0xFF)
|
||||
|
||||
// Byte 0
|
||||
SM2135_Start(SM2235_BYTE_0);
|
||||
Soft_I2C_Start(SM2235_BYTE_0);
|
||||
// Byte 1
|
||||
SM2135_WriteByte(SM2235_BYTE_1);
|
||||
Soft_I2C_WriteByte(SM2235_BYTE_1);
|
||||
// Byte 2
|
||||
SM2135_WriteByte((uint8_t)(SM2235_FIRST_BYTE(cur_col_10[0]))); //Red
|
||||
Soft_I2C_WriteByte((uint8_t)(SM2235_FIRST_BYTE(cur_col_10[0]))); //Red
|
||||
// Byte 3
|
||||
SM2135_WriteByte((uint8_t)(SM2235_SECOND_BYTE(cur_col_10[0])));
|
||||
Soft_I2C_WriteByte((uint8_t)(SM2235_SECOND_BYTE(cur_col_10[0])));
|
||||
// Byte 4
|
||||
SM2135_WriteByte((uint8_t)(SM2235_FIRST_BYTE(cur_col_10[1]))); //Green
|
||||
Soft_I2C_WriteByte((uint8_t)(SM2235_FIRST_BYTE(cur_col_10[1]))); //Green
|
||||
// Byte 5
|
||||
SM2135_WriteByte((uint8_t)(SM2235_SECOND_BYTE(cur_col_10[1])));
|
||||
Soft_I2C_WriteByte((uint8_t)(SM2235_SECOND_BYTE(cur_col_10[1])));
|
||||
// Byte 6
|
||||
SM2135_WriteByte((uint8_t)(SM2235_FIRST_BYTE(cur_col_10[2]))); //Blue
|
||||
Soft_I2C_WriteByte((uint8_t)(SM2235_FIRST_BYTE(cur_col_10[2]))); //Blue
|
||||
// Byte 7
|
||||
SM2135_WriteByte((uint8_t)(SM2235_SECOND_BYTE(cur_col_10[2])));
|
||||
Soft_I2C_WriteByte((uint8_t)(SM2235_SECOND_BYTE(cur_col_10[2])));
|
||||
// Byte 8
|
||||
SM2135_WriteByte((uint8_t)(SM2235_FIRST_BYTE(cur_col_10[4]))); //Cold
|
||||
Soft_I2C_WriteByte((uint8_t)(SM2235_FIRST_BYTE(cur_col_10[4]))); //Cold
|
||||
// Byte 9
|
||||
SM2135_WriteByte((uint8_t)(SM2235_SECOND_BYTE(cur_col_10[4])));
|
||||
Soft_I2C_WriteByte((uint8_t)(SM2235_SECOND_BYTE(cur_col_10[4])));
|
||||
// Byte 10
|
||||
SM2135_WriteByte((uint8_t)(SM2235_FIRST_BYTE(cur_col_10[3]))); //Warm
|
||||
Soft_I2C_WriteByte((uint8_t)(SM2235_FIRST_BYTE(cur_col_10[3]))); //Warm
|
||||
// Byte 11
|
||||
SM2135_WriteByte((uint8_t)(SM2235_SECOND_BYTE(cur_col_10[3])));
|
||||
SM2135_Stop();
|
||||
Soft_I2C_WriteByte((uint8_t)(SM2235_SECOND_BYTE(cur_col_10[3])));
|
||||
Soft_I2C_Stop();
|
||||
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ void SM2235_Init() {
|
||||
g_i2c_pin_clk = PIN_FindPinIndexForRole(IOR_SM2235_CLK,g_i2c_pin_clk);
|
||||
g_i2c_pin_data = PIN_FindPinIndexForRole(IOR_SM2235_DAT,g_i2c_pin_data);
|
||||
|
||||
SM2135_PreInit();
|
||||
Soft_I2C_PreInit();
|
||||
|
||||
|
||||
//cmddetail:{"name":"SM2235_RGBCW","args":"[HexColor]",
|
||||
|
||||
@@ -2,128 +2,13 @@
|
||||
#include "../new_pins.h"
|
||||
#include "../new_cfg.h"
|
||||
#include "../logging/logging.h"
|
||||
#include "../driver/drv_local.h"
|
||||
#include "drv_i2c_local.h"
|
||||
#include "drv_i2c_public.h"
|
||||
// Commands register, execution API and cmd tokenizer
|
||||
#include "../cmnds/cmd_public.h"
|
||||
#include "../hal/hal_pins.h"
|
||||
|
||||
static int g_pin_clk = 20;
|
||||
static int g_pin_data = 21;
|
||||
|
||||
static const int Soft_I2C_DELAY = 1; //delay*10 --> nops
|
||||
static void Soft_I2C_SetLow(uint8_t pin) {
|
||||
HAL_PIN_Setup_Output(pin);
|
||||
HAL_PIN_SetOutputValue(pin, 0);
|
||||
}
|
||||
|
||||
static void Soft_I2C_SetHigh(uint8_t pin) {
|
||||
HAL_PIN_Setup_Input_Pullup(pin);
|
||||
}
|
||||
|
||||
static bool Soft_I2C_PreInit(void) {
|
||||
|
||||
g_pin_clk = PIN_FindPinIndexForRole(IOR_SOFT_SCL, g_pin_clk);
|
||||
g_pin_data = PIN_FindPinIndexForRole(IOR_SOFT_SDA, g_pin_data);
|
||||
|
||||
HAL_PIN_SetOutputValue(g_pin_data, 0);
|
||||
HAL_PIN_SetOutputValue(g_pin_clk, 0);
|
||||
Soft_I2C_SetHigh(g_pin_data);
|
||||
Soft_I2C_SetHigh(g_pin_clk);
|
||||
return (!((HAL_PIN_ReadDigitalInput(g_pin_data) == 0 || HAL_PIN_ReadDigitalInput(g_pin_clk) == 0)));
|
||||
}
|
||||
|
||||
static bool Soft_I2C_WriteByte(uint8_t value) {
|
||||
uint8_t curr;
|
||||
uint8_t ack;
|
||||
|
||||
for (curr = 0x80; curr != 0; curr >>= 1)
|
||||
{
|
||||
if (curr & value)
|
||||
{
|
||||
Soft_I2C_SetHigh(g_pin_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
Soft_I2C_SetLow(g_pin_data);
|
||||
}
|
||||
Soft_I2C_SetHigh(g_pin_clk);
|
||||
usleep(Soft_I2C_DELAY);
|
||||
Soft_I2C_SetLow(g_pin_clk);
|
||||
}
|
||||
// get Ack or Nak
|
||||
Soft_I2C_SetHigh(g_pin_data);
|
||||
Soft_I2C_SetHigh(g_pin_clk);
|
||||
usleep(Soft_I2C_DELAY / 2);
|
||||
ack = HAL_PIN_ReadDigitalInput(g_pin_data);
|
||||
Soft_I2C_SetLow(g_pin_clk);
|
||||
usleep(Soft_I2C_DELAY / 2);
|
||||
Soft_I2C_SetLow(g_pin_data);
|
||||
return (0 == ack);
|
||||
}
|
||||
|
||||
static bool Soft_I2C_Start(uint8_t addr) {
|
||||
Soft_I2C_SetLow(g_pin_data);
|
||||
usleep(Soft_I2C_DELAY);
|
||||
Soft_I2C_SetLow(g_pin_clk);
|
||||
return Soft_I2C_WriteByte(addr);
|
||||
}
|
||||
|
||||
static void Soft_I2C_Stop(void) {
|
||||
Soft_I2C_SetLow(g_pin_data);
|
||||
usleep(Soft_I2C_DELAY);
|
||||
Soft_I2C_SetHigh(g_pin_clk);
|
||||
usleep(Soft_I2C_DELAY);
|
||||
Soft_I2C_SetHigh(g_pin_data);
|
||||
usleep(Soft_I2C_DELAY);
|
||||
}
|
||||
|
||||
static uint8_t Soft_I2C_ReadByte(bool nack)
|
||||
{
|
||||
uint8_t val = 0;
|
||||
|
||||
Soft_I2C_SetHigh(g_pin_data);
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
usleep(Soft_I2C_DELAY);
|
||||
Soft_I2C_SetHigh(g_pin_clk);
|
||||
val <<= 1;
|
||||
if (HAL_PIN_ReadDigitalInput(g_pin_data))
|
||||
{
|
||||
val |= 1;
|
||||
}
|
||||
Soft_I2C_SetLow(g_pin_clk);
|
||||
}
|
||||
if (nack)
|
||||
{
|
||||
Soft_I2C_SetHigh(g_pin_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
Soft_I2C_SetLow(g_pin_data);
|
||||
}
|
||||
Soft_I2C_SetHigh(g_pin_clk);
|
||||
usleep(Soft_I2C_DELAY);
|
||||
Soft_I2C_SetLow(g_pin_clk);
|
||||
usleep(Soft_I2C_DELAY);
|
||||
Soft_I2C_SetLow(g_pin_data);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
static void Soft_I2C_ReadBytes(uint8_t* buf, int numOfBytes)
|
||||
{
|
||||
|
||||
for (int i = 0; i < numOfBytes - 1; i++)
|
||||
{
|
||||
|
||||
buf[i] = Soft_I2C_ReadByte(false);
|
||||
|
||||
}
|
||||
|
||||
buf[numOfBytes - 1] = Soft_I2C_ReadByte(true); //Give NACK on last byte read
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -199,6 +84,8 @@ int DRV_I2C_Begin(int dev_adr, int busID) {
|
||||
tg_addr = dev_adr;
|
||||
|
||||
if (busID == I2C_BUS_SOFT) {
|
||||
g_i2c_pin_clk = PIN_FindPinIndexForRole(IOR_SOFT_SCL, g_i2c_pin_clk);
|
||||
g_i2c_pin_data = PIN_FindPinIndexForRole(IOR_SOFT_SDA, g_i2c_pin_data);
|
||||
Soft_I2C_PreInit();
|
||||
return 0;
|
||||
}
|
||||
@@ -235,26 +122,6 @@ void DRV_I2C_Close() {
|
||||
#endif
|
||||
}
|
||||
|
||||
//void DRV_I2C_Write(byte addr, byte data)
|
||||
//{
|
||||
//}
|
||||
//void DRV_I2C_WriteBytes(byte addr, byte *data, int len) {
|
||||
//
|
||||
//}
|
||||
//
|
||||
//void DRV_I2C_Read(byte addr, byte *data)
|
||||
//{
|
||||
//}
|
||||
//int DRV_I2C_Begin(int dev_adr, int busID) {
|
||||
//
|
||||
// return 1; // error
|
||||
//}
|
||||
//void DRV_I2C_Close() {
|
||||
//
|
||||
//}
|
||||
|
||||
|
||||
|
||||
i2cDevice_t *g_i2c_devices = 0;
|
||||
|
||||
i2cBusType_t DRV_I2C_ParseBusType(const char *s) {
|
||||
|
||||
Reference in New Issue
Block a user