I used two PIOs as sda and scl for I2c communicates with a lumen sensor. I used PIO9 as SDA and PIO10 as SCL. they are pulled-up to 3.3v with a 10k resister.I have init the I2c as follow, but i get none response when i tried to send command to sensor to config. I tried to check I2C status and I2cready() always returns false;
I2c Init code:
PioSetModes( ((0x01L << CSR_LUMEN_PIO_SDA) | (0x01L << CSR_LUMEN_PIO_SCL)),
pio_mode_user);
/* Configure the PIOs as Input */
PioSetDirs( ((0x01L << CSR_LUMEN_PIO_SDA) | (0x01L << CSR_LUMEN_PIO_SCL)),
FALSE);
PioSetPullModes(((0x01L << CSR_LUMEN_PIO_SDA) | (0x01L << CSR_LUMEN_PIO_SCL)),
pio_mode_strong_pull_down);
PioSetEventMask(((0x01L << CSR_LUMEN_PIO_SDA) | (0x01L << CSR_LUMEN_PIO_SCL)),
pio_event_mode_disable);
/* Configure the I2C controller */
I2cInit(CSR_LUMEN_PIO_SDA,
CSR_LUMEN_PIO_SCL,
I2C_POWER_PIO_UNDEFINED,
pio_i2c_pull_mode_strong_pull_up);
/* Configure pull mode of the I2C pins */
PioSetI2CPullMode(pio_i2c_pull_mode_strong_pull_up);
/* Configure the I2C clock */
I2cConfigClock(I2C_SCL_100KBPS_HIGH_PERIOD, I2C_SCL_100KBPS_LOW_PERIOD);
/* Enable the I2C controller */
I2cEnable(TRUE);
after init , I tried to config the sensor
I2CWriteRegister(AL3010_ADDR,REG_SYS_CONFIG,TRUE);
and operation failed.
does anybody can help me ?
This is an error "PioSetModes( ((0x01L << CSR_LUMEN_PIO_SDA) | (0x01L << CSR_LUMEN_PIO_SCL)), pio_mode_user);"
The PIO has to be defined as I2C no user mode. see pio.h
See I2C.h for demo.