2021-11-01 11:45 AM
I am currently attempting to port a product's older firmware that used the Standard Peripheral Driver libraries over to using the HAL libraries for greater portability between different MCUs. I a currently using the STM32L151QEHx.
In the older firmware the I2C is initialized using the following initialization structure:
/* Configure I2C settings within custom init function */
I2cConfig.I2C_ClockSpeed = I2cClockSpeed; //passed into init function
I2cConfig.I2C_Mode = I2C_Mode_I2C;
I2cConfig.I2C_DutyCycle = I2C_DutyCycle_2;
I2cConfig.I2C_OwnAddress1 = 0;
I2cConfig.I2C_Ack = I2C_Ack_Enable;
I2cConfig.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
Of interest is the code on line 6 where the I2C_Ack value is set. The ability to set this option does not appear to be available in STM32CubeMX or in the HAL libraries, but something similar does appear in the LL drivers included with the HAL libraries.
Am I missing a HAL defined way to set the I2C_CR1 ACK bit, or is this simply not available via HAL APIs?
Thank you for your time,
Brian C.
Solved! Go to Solution.
2021-11-01 12:23 PM
It is set within HAL appropriately based on how many bytes you're sending and where you are in the transaction. See:
It's not something that should be set during initialization of the peripheral, but rather at the start and during a transaction.
2021-11-01 12:23 PM
It is set within HAL appropriately based on how many bytes you're sending and where you are in the transaction. See:
It's not something that should be set during initialization of the peripheral, but rather at the start and during a transaction.
2021-11-01 12:27 PM
Thank you very much, this answers it. I assumed there was a very good reason it was no longer included as a parameter to initialize, I just couldn't find out why.