115 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			115 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /**
 | |
|  * @file		hal_system.h
 | |
|  * @copyright  	Nehemis SARL reserves all rights even in the event of industrial
 | |
|  *             	property rights. We reserve all rights of disposal such as
 | |
|  *             	copying and passing on to third parties.
 | |
|  *
 | |
|  *
 | |
|  * @brief      	Header file for HAL layer for the SYSTEM module.
 | |
|  *
 | |
|  */
 | |
| 
 | |
| #ifndef INCLUDED_HAL_SYSTEM_H
 | |
| #define INCLUDED_HAL_SYSTEM_H
 | |
| 
 | |
| /******************************************************************************
 | |
|  * Include Header Files
 | |
|  ******************************************************************************/
 | |
| #include "nms_types.h"
 | |
| 
 | |
| /******************************************************************************
 | |
|  * Macros Constant Declarations
 | |
|  ******************************************************************************/
 | |
| #define SERIAL_ID_BUFFER_SIZE       12
 | |
| 
 | |
| /******************************************************************************
 | |
|  * Types Declarations
 | |
|  ******************************************************************************/
 | |
| typedef enum
 | |
| {
 | |
| 	HAL_SYSTEM_RESET_CAUSE_OPTION_BYTE_LOADER,
 | |
| 	HAL_SYSTEM_RESET_CAUSE_EXTERNAL_PIN_RESET,
 | |
| 	HAL_SYSTEM_RESET_CAUSE_BROWNOUT_RESET,
 | |
| 	HAL_SYSTEM_RESET_CAUSE_SOFTWARE_RESET,
 | |
| 	HAL_SYSTEM_RESET_CAUSE_WATCH_DOG_TIMER,
 | |
| 	HAL_SYSTEM_RESET_CAUSE_WINDOW_WATCH_DOG,
 | |
| 	HAL_SYSTEM_RESET_CAUSE_LOW_POWER,
 | |
|     HAL_SYSTEM_RESET_CAUSE_ALL_CAUSES
 | |
| } HalSystemResetCauseEn; /**< Enumeration used to analyze the reset cause location. */
 | |
| 
 | |
| /******************************************************************************
 | |
|  * Global Variables Declarations
 | |
|  ******************************************************************************/
 | |
| 
 | |
| /******************************************************************************
 | |
|  * Extern Functions Declarations
 | |
|  ******************************************************************************/
 | |
| 
 | |
| /**
 | |
|  * @brief   Initializes the system HAL.
 | |
|  *
 | |
|  * @note    CAUTION: This function must be called immediately after
 | |
|  *          SystemClock_Config() in the main function to ensure correct
 | |
|  *          operation and prevent potential software issues.
 | |
|  *
 | |
|  * @return  Error code: 0 if successful, nonzero otherwise.
 | |
|  */
 | |
| uint32 HalSystemInit(void);
 | |
| 
 | |
| /**
 | |
|  * @brief   Retrieves the system runtime in microseconds.
 | |
|  *
 | |
|  * @param   resultUs_pu64  Pointer to store the system runtime in microseconds.
 | |
|  *
 | |
|  * @note    The tick resolution depends on the system tick frequency.
 | |
|  *
 | |
|  * @return  Error code: 0 if successful, nonzero otherwise.
 | |
|  */
 | |
| uint32 HalSystemGetRunTimeUs(uint64 *resultUs_pu64);
 | |
| 
 | |
| /**
 | |
|  * @brief   Retrieves the system runtime in milliseconds.
 | |
|  *
 | |
|  * @param   resultMs_pu64  Pointer to store the system runtime in milliseconds.
 | |
|  *
 | |
|  * @note    The tick resolution depends on the system tick frequency.
 | |
|  *
 | |
|  * @return  Error code: 0 if successful, nonzero otherwise.
 | |
|  */
 | |
| uint32 HalSystemGetRunTimeMs(uint64 *resultMs_pu64);
 | |
| 
 | |
| /**
 | |
|  * @brief   Disables all system interrupts.
 | |
|  */
 | |
| void HalSystemDisableInterrupts(void);
 | |
| 
 | |
| /**
 | |
|  * @brief   Enables all system interrupts.
 | |
|  */
 | |
| void HalSystemEnableInterrupts(void);
 | |
| 
 | |
| /**
 | |
|  * @brief   Retrieves the cause of the last system reset from the MCU registers.
 | |
|  *
 | |
|  * @param   resetCauseSelector_en  Enum specifying the reset cause type.
 | |
|  *			causes_pu32            Pointer to store the corresponding bitmask value.
 | |
|  *
 | |
|  * @return  Error code: 0 if successful, nonzero otherwise.
 | |
|  */
 | |
| uint32 HalSystemGetResetCause(HalSystemResetCauseEn resetCauseSelector_en, uint32 *causes_pu32);
 | |
| 
 | |
| /**
 | |
|  * @brief   Retrieves the system's unique serial ID.
 | |
|  *
 | |
|  * @param   serialIdBuffer_pu8  Pointer to the buffer where the serial ID will be stored.
 | |
|  */
 | |
| void HalSystemGetSerialId(uint8 *serialIdBuffer_pu8);
 | |
| 
 | |
| /**
 | |
|  * @brief   Performs a software reset of the system.
 | |
|  */
 | |
| void HalSystemReset(void);
 | |
| 
 | |
| 
 | |
| #endif /* INCLUDED_HAL_SYSTEM_H */
 |