I'm struggling with the concept of how to schedule my tasks.
My Setup: STM32F103 hooked up on CAN. Taking measurements with a Lidar V3 module comms via I2C, then distributing that measurement on the CAN
Interrupt 1 is a 1ms timer interrupt to initiate message send on CAN
interrupt 2 is active upon receiving CAN message
I also have to poll a register via I2C on the LIDAR unit to ensure that measurement has finished before I can then use I2C to read the distance register, code snippet shown below
status = CheckLidarStatus();
while ((status & LIDAR_BUSY) == LIDAR_BUSY)
{
status = CheckLidarStatus();
}
What I believe is the correct flow that my program should take is shown below:
My main concerns are:
Does the flow seem a logical way in which to approach this?
If I prioritise the timer interrupt (rather than RX int) for CAN transmission, will this affect the CAN network negatively i.e. not dealing with the received CAN messages promptly enough?
If either of the interrupts are active during I2C comms, will it cause the I2C comms to "fall over"?
Is it acceptable to sit in a while loop waiting for the Checklidar status to come back as not busy, or is there a better way to do this?