- as anyone successfully used I2C with an STM32F7 ? I haven't found tests or demos of it and have tried to debug my try for hours now. Here's a condensed version of it :
Code: Select all
int main(void) {
halInit();
chSysInit();
palSetPadMode(GPIOB, 8, PAL_MODE_ALTERNATE(4) | PAL_MODE_OUTPUT_OPENDRAIN);
palSetPadMode(GPIOB, 9, PAL_MODE_ALTERNATE(4) | PAL_MODE_OUTPUT_OPENDRAIN);
i2cInit();
const I2CConfig i2cd1_cfg = {
.timingr = 0x40912732,
.cr1 = 0,
.cr2 = 0
};
i2cStart(&I2CD1, &i2cd1_cfg);
msg_t i2c_result;
i2cflags_t i2c_errors;
uint8_t i2c_rxbuf[129],
i2c_txbuf[129];
memset(i2c_txbuf, 0, sizeof(i2c_txbuf));
i2cAcquireBus(&I2CD1);
i2c_result = i2cMasterTransmitTimeout(&I2CD1, 0x37, i2c_txbuf, sizeof(i2c_txbuf), i2c_rxbuf, sizeof(i2c_rxbuf), MS2ST(1000));
if(i2c_result != MSG_OK)
i2c_errors = i2cGetErrors(&I2CD1);
(void) i2c_errors;
i2cReleaseBus(&I2CD1);
i2cStop(&I2CD1);
while (true) {
chThdSleepMilliseconds(500);
}
}
Defines modified from defaults :
Code: Select all
#define HAL_USE_I2C TRUE
#define STM32_I2C_USE_I2C1 TRUE
#define STM32_I2C_USE_DMA FALSEResults :
Code: Select all
i2c_result = -1 / MSG_RESET,
i2c_errors = 0Is there anything obviously wrong ? I wrote the equivalent with STM32CubeHAL to make sure the hardware isn't at fault and it works.
Koen