You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
3.0 KiB

4 years ago
  1. /*********************************************************
  2. *Copyright (C), 2015, Shanghai Eastsoft Microelectronics Co., Ltd.
  3. *: lib_scs.c
  4. * : AE Team
  5. * : V1.01
  6. * : 2021/06/09
  7. * : SCS模块库函数
  8. * :
  9. 使
  10. **********************************************************/
  11. #include "lib_scs.h"
  12. /***************************************************************
  13. NVIC_Init
  14. NVIC初始化配置
  15. Channel Priority Cmd使
  16. ***************************************************************/
  17. void NVIC_Init(NVIC_IRQChannel Channel, NVIC_IRQPriority Priority,
  18. TYPE_FUNCEN Cmd) {
  19. uint32_t tmppriority = 0x00;
  20. if (Cmd != Disable) {
  21. /* Compute the Corresponding IRQ Priority */
  22. tmppriority = NVIC->IP[Channel >> 0x02];
  23. tmppriority &= (uint32_t)(~(((uint32_t)0xFF) << ((Channel & 0x03) * 8)));
  24. tmppriority |= (uint32_t)((((uint32_t)Priority << 6) & 0xFF)
  25. << ((Channel & 0x03) * 8));
  26. NVIC->IP[Channel >> 0x02] = tmppriority;
  27. /* Enable the Selected IRQ Channels */
  28. NVIC->ISER[0] = (uint32_t)0x01 << (Channel & (uint8_t)0x1F);
  29. } else {
  30. /* Disable the Selected IRQ Channels */
  31. NVIC->ICER[0] = (uint32_t)0x01 << (Channel & (uint8_t)0x1F);
  32. }
  33. return;
  34. }
  35. /***************************************************************
  36. SCB_SystemLPConfig
  37. LowPowerMode NewState使使
  38. ***************************************************************/
  39. void SCB_SystemLPConfig(SCB_TYPE_SCR LowPowerMode, TYPE_FUNCEN NewState) {
  40. if (NewState != Disable)
  41. SCB->SCR |= LowPowerMode;
  42. else
  43. SCB->SCR &= (uint32_t)(~(uint32_t)LowPowerMode);
  44. return;
  45. }
  46. /***************************************************************
  47. SCB_GetCpuID
  48. CPUID
  49. 32ID值
  50. ***************************************************************/
  51. uint32_t SCB_GetCpuID(void) { return (SCB->CPUID); }
  52. /***************************************************************
  53. SysTick_Init
  54. SysTick初始化配置
  55. ***************************************************************/
  56. void SysTick_Init(SYSTICK_InitStruType *SysT_InitStruct) {
  57. uint32_t temp32 = 0;
  58. //重装载值寄存器
  59. SysTick->LOAD = SysT_InitStruct->SysTick_Value;//4800
  60. //当前值寄存器
  61. SysTick->VAL = (uint32_t)0;
  62. if (SysT_InitStruct->SysTick_ClkSource != SysTick_ClkS_Base)
  63. temp32 |= 0x00000004;
  64. else
  65. temp32 &= 0xFFFFFFFB;
  66. if (SysT_InitStruct->SysTick_ITEnable != Disable)
  67. temp32 |= 0x00000002;
  68. else
  69. temp32 &= 0xFFFFFFFD;
  70. SysTick->CTRL = temp32;
  71. return;
  72. }