2025-04-26 16:03:23 +08:00

152 lines
4.4 KiB
C
Raw Permalink Blame History

/** ##########################################################################
** Filename :
** Project :
** Module :
** Processor :
** Version :
** Compiler :
** Date/Time :
** Abstract :
** Contents :
** Note :
** (c) Copyright dmdz Co.,Ltd
** --------------------------------------------------------------------------
** R E V I S I O N H I S T O R Y
** --------------------------------------------------------------------------
** Date Ver Author Description
** -20191106- --V01-- --LYJ--- --<2D><><EFBFBD><EFBFBD>--
** -20230602- --V1.0-- --mingyea--- --<2D>޸<EFBFBD>--
** #########################################################################*/
/*---------------------------------------------------------------------------
- I N C L U D E F I L E S
----------------------------------------------------------------------------*/
#include "cpu.h"
#include "common_types.h"
#include "common_cfg.h"
/*---------------------------------------------------------------------------
- D E F I N E S / M A C R O S
----------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
- T Y P E D E F I N I T I O N S
----------------------------------------------------------------------------*/
typedef struct
{
u32 low;
u32 high;
u8 iwdtslp;
u8 iwdtslp_f;
}cpu_opt_bytes_t;
cpu_opt_bytes_t g_cpu_opt_bytes;
/*---------------------------------------------------------------------------
- S T A T I C V A R I A B L E S
----------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
* G L O B A L V A R I A B L E S
----------------------------------------------------------------------------*/
static uint32_t ulInterruptDisableCount = 0;
/*---------------------------------------------------------------------------
- C O N S T A N T S
----------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
- F U N C T I O N P R O T O T Y P E
----------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
|Prototype : HardFault_Handler
|Called by : None
|Preconditions : None
|Input parameters : None
|Output parameters : None
|Return value : None
|Description : TBD Cpu configuration will be generated here
----------------------------------------------------------------------------*/
void HardFault_Handler(void)
{
SystemSoftwareReset();
}
/*---------------------------------------------------------------------------
|Prototype : cpu_get_opt_bytes
|Called by : None
|Preconditions : None
|Input parameters : None
|Output parameters : None
|Return value : None
|Description :
----------------------------------------------------------------------------*/
void cpu_get_opt_bytes(void)
{
g_cpu_opt_bytes.low = *(u32*)0x1ffffc00;
g_cpu_opt_bytes.high = *(u32*)0x1ffffc04;
g_cpu_opt_bytes.iwdtslp = (g_cpu_opt_bytes.high >> 4) & 0x0f;
g_cpu_opt_bytes.iwdtslp_f = (g_cpu_opt_bytes.high >> 20) & 0x0f;
}
/*---------------------------------------------------------------------------
|Prototype : System_EnableIrqGlobal
|Called by : None
|Preconditions : None
|Input parameters : None
|Output parameters : None
|Return value : None
|Description :
----------------------------------------------------------------------------*/
void System_EnableIrqGlobal(void)
{
if(ulInterruptDisableCount > 0ul)
{
ulInterruptDisableCount --;
if(ulInterruptDisableCount == 0ul)
{
__enable_irq();
}
}
}
/*---------------------------------------------------------------------------
|Prototype : System_DisableIrqGlobal
|Called by : None
|Preconditions : None
|Input parameters : None
|Output parameters : None
|Return value : None
|Description :
----------------------------------------------------------------------------*/
void System_DisableIrqGlobal(void)
{
if(ulInterruptDisableCount < 0xfffffffful)
{
__disable_irq();
ulInterruptDisableCount ++;
}
else
{
SystemSoftwareReset();
}
}
/* END Cpu. */