I have to admit I'm a newbie to Chibios but hope someone may be able to assist with debugging a project I am working on.
There are several threads within the project and some of them configured to communicate via I2C. I am debugging with a GDB debug configuration in STM32CubeIDE. Following the Debug Guide I have set CH_DBG_SYSTEM_STATE_CHECK and CH_DBG_ENABLE_CHECKS. CH_CFG_USE_MUTEXES is also set to TRUE.
The main thread calls some setup functions for the I2C and other devices and then should enter the main loop.
However it looks as though main gets stuck in state "WTMTX" from within setup functions I have traced the code to be waiting on a mutex for one of the I2C buses but I'm uncertain of how to work out why a mutex isn't gained.
All my calls to send or receive on I2C are as follows:
i2cAcquireBus(&m_driver);
auto status = i2cMasterTransmitTimeout(&m_driver,
m_mux_addr,
buf,
sizeof(buf),
rxbuf, //need this non zero otherwise assert.
0,
TIME_MS2I(5));
i2cReleaseBus(&m_driver);
There's no other threads running on i2c during setup so why would Acquire be failing? Interestingly when I switch to -02 in compiler options the code appears to get past setup and into the main loop.. Does anyone have any suggestions as to why I can't get the Mutex on the i2c and how I might find out what is preventing access. Could this be due to an ISR?