STM32 Sequencer v1.6.0

Functions
SEQUENCER exported functions
sequencer utilities

## Functions
void | UTIL_SEQ_Init (void)
| This function initializes the sequencer resources. More...
void | UTIL_SEQ_DeInit (void)
| This function un-initializes the sequencer resources. More...
void | UTIL_SEQ_Run (UTIL_SEQ_bm_t Mask_bm)
| This function requests the sequencer to execute all pending tasks using round robin mechanism. When no task are pending, it calls UTIL_SEQ_Idle(); This function should be called in a while loop in the application. More...
void | UTIL_SEQ_RegTask (UTIL_SEQ_bm_t TaskId_bm, uint32_t Flags, void(*Task)(void))
| This function registers a task in the sequencer. More...
void | UTIL_SEQ_SetTask (UTIL_SEQ_bm_t TaskId_bm, uint32_t Task_Prio)
| This function requests a task to be executed. More...
uint32_t | UTIL_SEQ_IsSchedulableTask (UTIL_SEQ_bm_t TaskId_bm)
| This function checks if a task could be scheduled. More...
void | UTIL_SEQ_PauseTask (UTIL_SEQ_bm_t TaskId_bm)
| This function prevents a task to be called by the sequencer even when set with UTIL_SEQ_SetTask() By default, all tasks are executed by the sequencer when set with UTIL_SEQ_SetTask() When a task is paused, it is moved out from the sequencer list. More...
uint32_t | UTIL_SEQ_IsPauseTask (UTIL_SEQ_bm_t TaskId_bm)
| This function allows to know if the task has been put in pause. By default, all tasks are executed by the sequencer when set with UTIL_SEQ_SetTask() The exit of the pause shall be done by the function UTIL_SEQ_ResumeTask. More...
void | UTIL_SEQ_ResumeTask (UTIL_SEQ_bm_t TaskId_bm)
| This function allows again a task to be called by the sequencer if set with UTIL_SEQ_SetTask() This is used in relation with UTIL_SEQ_PauseTask() More...
void | UTIL_SEQ_SetEvt (UTIL_SEQ_bm_t EvtId_bm)
| This function sets an event that is waited with UTIL_SEQ_WaitEvt() More...
void | UTIL_SEQ_ClrEvt (UTIL_SEQ_bm_t EvtId_bm)
| This function may be used to clear the event before calling UTIL_SEQ_WaitEvt() This API may be useful when the UTIL_SEQ_SetEvt() is called several time to notify the same event. Due to Software Architecture where the timings are hard to control, this may be an unwanted case. More...
void | UTIL_SEQ_WaitEvt (UTIL_SEQ_bm_t EvtId_bm)
| This function waits for a specific event to be set. The sequencer loops UTIL_SEQ_EvtIdle() until the event is set When called recursively, it acts as a First in / Last out mechanism. The sequencer waits for the last event requested to be set even though one of the already requested event has been set. More...
UTIL_SEQ_bm_t | UTIL_SEQ_IsEvtPend (void)
| This function returns whether the waited event is pending or not It is useful only when the UTIL_SEQ_EvtIdle() is overloaded by the application. In that case, when the low power mode needs to be executed, the application shall first check whether the waited event is pending or not. Both the event checking and the low power mode processing should be done in critical section. More...
__WEAK void | UTIL_SEQ_EvtIdle (UTIL_SEQ_bm_t TaskId_bm, UTIL_SEQ_bm_t EvtWaited_bm)
| This function loops until the waited event is set. More...
__WEAK void | UTIL_SEQ_Idle (void)
| This function is called by the sequencer in critical section (PRIMASK bit) when. More...
__WEAK void | UTIL_SEQ_PreIdle (void)
| This function is called by the sequencer outside critical section just before calling UTIL_SEQ_Idle( ) UTIL_SEQ_PreIdle() is considered as the last task executed before calling UTIL_SEQ_Idle( ) In case a task or an event is set from an interrupt handler just after UTIL_SEQ_PreIdle() is called, UTIL_SEQ_Idle() will not be called. More...
__WEAK void | UTIL_SEQ_PostIdle (void)
| This function is called by the sequencer outside critical section either. More...

## Detailed Description

## Function Documentation

## ◆ UTIL_SEQ_ClrEvt()

void UTIL_SEQ_ClrEvt | ( | UTIL_SEQ_bm_t | EvtId_bm | ) |

This function may be used to clear the event before calling UTIL_SEQ_WaitEvt() This API may be useful when the UTIL_SEQ_SetEvt() is called several time to notify the same event. Due to Software Architecture where the timings are hard to control, this may be an unwanted case.

Parameters

  EvtId_bm | event id bm It shall be a bit mapping where only 1 bit is set

Note
  It may be called from an ISR.

Definition at line 407 of file stm32_seq.c.

## ◆ UTIL_SEQ_DeInit()

void UTIL_SEQ_DeInit | ( | void |  | ) |

This function un-initializes the sequencer resources.

Note
  It shall not be called from an ISR

Definition at line 199 of file stm32_seq.c.

## ◆ UTIL_SEQ_EvtIdle()

void UTIL_SEQ_EvtIdle | ( | UTIL_SEQ_bm_t | TaskId_bm,
|  | UTIL_SEQ_bm_t | EvtWaited_bm
| ) |  |

This function loops until the waited event is set.

Parameters

  TaskId_bm | The task id that is currently running. When task_id_bm = 0, it means UTIL_SEQ_WaitEvt( ) has been called outside a registered task (ie at startup before UTIL_SEQ_Run( ) has been called
  EvtWaited_bm | The event id that is waited.

Note
  When not implemented by the application, it calls UTIL_SEQ_Run(~TaskId_bm) which means the waited task is suspended until the waited event and the other tasks are running or the application enter low power mode. Else the user can redefine his own function for example call sequencer UTIL_SEQ_Run(0) to suspend all the task and let the sequencer enter the low power mode. It shall be called only by the sequencer.

Definition at line 477 of file stm32_seq.c.

References UTIL_SEQ_Run().

## ◆ UTIL_SEQ_Idle()

void UTIL_SEQ_Idle | ( | void |  | ) |

This function is called by the sequencer in critical section (PRIMASK bit) when.

- there are no more tasks to be executed AND
- there are no pending event or the pending event is still not set
  Note
    The application should enter low power mode in this function When this function is not implemented by the application, the sequencer keeps running a while loop (RUN MODE). It shall be called only by the sequencer.

Definition at line 484 of file stm32_seq.c.

## ◆ UTIL_SEQ_Init()

void UTIL_SEQ_Init | ( | void |  | ) |

This function initializes the sequencer resources.

Note
  It shall not be called from an ISR.

Definition at line 182 of file stm32_seq.c.

## ◆ UTIL_SEQ_IsEvtPend()

UTIL_SEQ_bm_t UTIL_SEQ_IsEvtPend | ( | void |  | ) |

This function returns whether the waited event is pending or not It is useful only when the UTIL_SEQ_EvtIdle() is overloaded by the application. In that case, when the low power mode needs to be executed, the application shall first check whether the waited event is pending or not. Both the event checking and the low power mode processing should be done in critical section.

Return values

  0 | when the waited event is not there or the evt_id when the waited event is pending

Note
  It may be called from an ISR.

Definition at line 471 of file stm32_seq.c.

## ◆ UTIL_SEQ_IsPauseTask()

uint32_t UTIL_SEQ_IsPauseTask | ( | UTIL_SEQ_bm_t | TaskId_bm | ) |

This function allows to know if the task has been put in pause. By default, all tasks are executed by the sequencer when set with UTIL_SEQ_SetTask() The exit of the pause shall be done by the function UTIL_SEQ_ResumeTask.

Parameters

  TaskId_bm | The Id of the task It shall be (1<<task_id) where task_id is the number assigned when the task has been registered

Note
  It may be called from an ISR.

Definition at line 374 of file stm32_seq.c.

## ◆ UTIL_SEQ_IsSchedulableTask()

uint32_t UTIL_SEQ_IsSchedulableTask | ( | UTIL_SEQ_bm_t | TaskId_bm | ) |

This function checks if a task could be scheduled.

Parameters

  TaskId_bm | The Id of the task It shall be (1<<task_id) where task_id is the number assigned when the task has been registered

Return values

  0 | if not 1 if true

Note
  It may be called from an ISR.

Definition at line 349 of file stm32_seq.c.

## ◆ UTIL_SEQ_PauseTask()

void UTIL_SEQ_PauseTask | ( | UTIL_SEQ_bm_t | TaskId_bm | ) |

This function prevents a task to be called by the sequencer even when set with UTIL_SEQ_SetTask() By default, all tasks are executed by the sequencer when set with UTIL_SEQ_SetTask() When a task is paused, it is moved out from the sequencer list.

Parameters

  TaskId_bm | The Id of the task It shall be (1<<task_id) where task_id is the number assigned when the task has been registered

Note
  It may be called from an ISR.

Definition at line 363 of file stm32_seq.c.

## ◆ UTIL_SEQ_PostIdle()

void UTIL_SEQ_PostIdle | ( | void |  | ) |

This function is called by the sequencer outside critical section either.

- after calling UTIL_SEQ_Idle( ) OR
- after calling UTIL_SEQ_PreIdle( ) without call to UTIL_SEQ_Idle() due to an incoming task set or event requested after UTIL_SEQ_PreIdle() has been called.

Note
  UTIL_SEQ_PostIdle() is always called if UTIL_SEQ_PreIdle() has been called and never called otherwise. It shall be called only by the sequencer.

Definition at line 497 of file stm32_seq.c.

## ◆ UTIL_SEQ_PreIdle()

void UTIL_SEQ_PreIdle | ( | void |  | ) |

This function is called by the sequencer outside critical section just before calling UTIL_SEQ_Idle( ) UTIL_SEQ_PreIdle() is considered as the last task executed before calling UTIL_SEQ_Idle( ) In case a task or an event is set from an interrupt handler just after UTIL_SEQ_PreIdle() is called, UTIL_SEQ_Idle() will not be called.

Note
  It shall be called only by the sequencer.

Definition at line 489 of file stm32_seq.c.

## ◆ UTIL_SEQ_RegTask()

void UTIL_SEQ_RegTask | ( | UTIL_SEQ_bm_t | TaskId_bm,
|  | uint32_t | Flags,
|  | void(*)(void) | Task
| ) |  |

This function registers a task in the sequencer.

Parameters

  TaskId_bm | The Id of the task
  Flags | Flags are reserved param for future use
  Task | Reference of the function to be executed

Note
  It may be called from an ISR.

Definition at line 325 of file stm32_seq.c.

## ◆ UTIL_SEQ_ResumeTask()

void UTIL_SEQ_ResumeTask | ( | UTIL_SEQ_bm_t | TaskId_bm | ) |

This function allows again a task to be called by the sequencer if set with UTIL_SEQ_SetTask() This is used in relation with UTIL_SEQ_PauseTask()

Parameters

  TaskId_bm | The Id of the task It shall be (1<<task_id) where task_id is the number assigned when the task has been registered

Note
  It may be called from an ISR.

Definition at line 385 of file stm32_seq.c.

## ◆ UTIL_SEQ_Run()

void UTIL_SEQ_Run | ( | UTIL_SEQ_bm_t | Mask_bm | ) |

This function requests the sequencer to execute all pending tasks using round robin mechanism. When no task are pending, it calls UTIL_SEQ_Idle(); This function should be called in a while loop in the application.

This function can be nested. That is the reason why many variables that are used only in that function are declared static. Note: These variables could have been declared static in the function.

Parameters

  Mask_bm | list of task (bit mapping) that is be kept in the sequencer list.

Note
  It shall not be called from an ISR.
  The construction of the task must take into account the fact that there is no counting / protection on the activation of the task. Thus, when the task is running, it must perform all the operations in progress programmed before its call or manage a reprogramming of the task.

Definition at line 209 of file stm32_seq.c.

Referenced by UTIL_SEQ_EvtIdle().

## ◆ UTIL_SEQ_SetEvt()

void UTIL_SEQ_SetEvt | ( | UTIL_SEQ_bm_t | EvtId_bm | ) |

This function sets an event that is waited with UTIL_SEQ_WaitEvt()

Parameters

  EvtId_bm | event id bit mask

Note
  An event shall be a 32 bit mapping where only 1 bit is set It may be called from an ISR.

Definition at line 396 of file stm32_seq.c.

## ◆ UTIL_SEQ_SetTask()

void UTIL_SEQ_SetTask | ( | UTIL_SEQ_bm_t | TaskId_bm,
|  | uint32_t | Task_Prio
| ) |  |

This function requests a task to be executed.

Parameters

  TaskId_bm | The Id of the task It shall be (1<<task_id) where task_id is the number assigned when the task has been registered
  Task_Prio | The priority of the task It shall a number from 0 (high priority) to 31 (low priority) The priority is checked each time the sequencer needs to select a new task to execute It does not permit to preempt a running task with lower priority

Note
  It may be called from an ISR

Definition at line 337 of file stm32_seq.c.

## ◆ UTIL_SEQ_WaitEvt()

void UTIL_SEQ_WaitEvt | ( | UTIL_SEQ_bm_t | EvtId_bm | ) |

This function waits for a specific event to be set. The sequencer loops UTIL_SEQ_EvtIdle() until the event is set When called recursively, it acts as a First in / Last out mechanism. The sequencer waits for the last event requested to be set even though one of the already requested event has been set.

Parameters

  EvtId_bm | event id bit mask It shall be a bit mapping where only 1 bit is set

Note
  It shall not be called from an ISR.
  The construction of the task must take into account the fact that there is no counting / protection on the event. Thus, when the task is running, it must perform all the operations in progress programmed before its call or manage a reprogramming of the task.

Definition at line 418 of file stm32_seq.c.