/**
******************************************************************************
* @file stm32_seq.h
* @author MCD Application Team
* @brief sequencer interface
******************************************************************************
* @attention
*
*
© Copyright (c) 2019 STMicroelectronics.
* All rights reserved.
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef STM32_SEQ_H
#define STM32_SEQ_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stdint.h"
/** @defgroup SEQUENCER sequencer utilities
* @{
*/
/* Exported types ------------------------------------------------------------*/
/** @defgroup SEQUENCER_Exported_type SEQUENCER exported types
* @{
*/
/**
* @brief bit mapping of the task.
* this value is used to represent a list of task (each corresponds to a task).
*/
typedef uint32_t UTIL_SEQ_bm_t;
/**
* @}
*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup SEQUENCER_Exported_const SEQUENCER exported constants
* @{
*/
/**
* @brief This provides a default value for unused parameter
*
*/
#define UTIL_SEQ_RFU 0
/**
* @brief Default value used to start the scheduling.
*
* This informs the sequencer that all tasks registered shall be considered
*
* @note
* This should be used in the application\n
* while(1)\n
* {\n
* UTIL_SEQ_Run( UTIL_SEQ_DEFAULT );\n
* }\n
*
*/
#define UTIL_SEQ_DEFAULT (~0U)
/**
* @}
*/
/* External variables --------------------------------------------------------*/
/* Exported macros -----------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
/** @defgroup SEQUENCER_Exported_function SEQUENCER exported functions
* @{
*/
/**
* @brief This function initializes the sequencer resources.
*
*/
void UTIL_SEQ_Init( void );
/**
* @brief This function un-initializes the sequencer resources.
*
*/
void UTIL_SEQ_DeInit( void );
/**
* @brief 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)
*
*/
void UTIL_SEQ_Idle( void );
/**
* @brief 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.
*
*/
void UTIL_SEQ_PreIdle( void );
/**
* @brief 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
*
*/
void UTIL_SEQ_PostIdle( void );
/**
* @brief 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
*
* @param Mask_bm list of task (bit mapping) that is be kept in the sequencer list.
*
*/
void UTIL_SEQ_Run( UTIL_SEQ_bm_t Mask_bm );
/**
* @brief This function registers a task in the sequencer.
*
* @param TaskId_bm The Id of the task
* @param Flags Flags are reserved param for future use
* @param Task Reference of the function to be executed
*
*/
void UTIL_SEQ_RegTask( UTIL_SEQ_bm_t TaskId_bm, uint32_t Flags, void (*Task)( void ) );
/**
* @brief This function requests a task to be executed
*
* @param TaskId_bm The Id of the task
* It shall be (1<