STM32WL5M I2C and the Sequencer Utility
Hello.
Recently I received an B-WL5M-SUBG1 board and started to develop a LoRa application
based on the LoRaWAN_End_Node example that I got from STM32Cube_FW_WL_V1.3.0 archive.
I managed to get the example running and sending LoRa packets.
My objective now is to integrate the on-board ISM330DHCX accelerometer to the application.
For that, I've created a file with the functions AccelApp_Init() AccelApp_Run(), platform_write() and platform_read().
In the same file I also declared two other functions "OnAccelData" and "ProcessAccelData"
I followed this file as an example on how to integrate the ISM330DHCX: ism330dhcx_STdC/examples/ism330dhcx_read_data_polling.c
I'm able to retrieve the ISM330DHCX ID by reading the WHO_AM_I register of the device, and to set-up other registers by calling the ISM330 driver functions from AccelApp_Init().
To create a new task, I first changed "utilities_def.h" and created "CFG_SEQ_Task_ProcessAccelData" Id.
"OnAccelData" is a callback for a UTIL_TIMER, that expires every 5 seconds. From the callback, I set the task "CFG_SEQ_Task_ProcessAccelData" to be run.
"ProcessAccelData" is the callback for the "CFG_SEQ_Task_ProcessAccelData" task. In this callback, I then call the I2C functions to check for new data on the ISM330DHCX and retrieve it.
From the "main.c" file, in the main function, I'm calling AccelApp_Init() and AccelApp_Run() like:
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_LoRaWAN_Init();
/* USER CODE BEGIN 2 */
AccelApp_Init();
AccelApp_Run();
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
MX_LoRaWAN_Process();
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
Unfortnatly, every call from within the "ProcessAccelData" to the I2C bus returns with a HAL_I2C_ERROR_TIMEOUT error.
I have attached the complete code for the accel_app.c file.
The idea is to have the LoRa lmhadler task running together with the accelerometer task, polling for new data.
Is there any other example where I2C communication is performed using the sequencer utility?
Should this be working? Am I missing any other detail?
Thanks in advance!
C. Scherma.
