misc.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Copyright (c) 2022 OpenLuat & AirM2M
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  5. * this software and associated documentation files (the "Software"), to deal in
  6. * the Software without restriction, including without limitation the rights to
  7. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  8. * the Software, and to permit persons to whom the Software is furnished to do so,
  9. * subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in all
  12. * copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  16. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  17. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  18. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  19. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. */
  21. #ifndef __MISC_H
  22. #define __MISC_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "air105.h"
  28. typedef struct
  29. {
  30. uint32_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled.
  31. This parameter can be a value of @ref IRQn_Type
  32. (For the complete SCPU Devices IRQ Channels list, please
  33. refer to cpu.h file) */
  34. uint32_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the IRQ channel
  35. specified in NVIC_IRQChannel. This parameter can be a value
  36. between 0 and 15 as described in the table @ref NVIC_Priority_Table */
  37. uint32_t NVIC_IRQChannelSubPriority; /*!< Specifies the subpriority level for the IRQ channel specified
  38. in NVIC_IRQChannel. This parameter can be a value
  39. between 0 and 15 as described in the table @ref NVIC_Priority_Table */
  40. FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel
  41. will be enabled or disabled.
  42. This parameter can be set either to ENABLE or DISABLE */
  43. } NVIC_InitTypeDef;
  44. #define NVIC_VectTab_RAM ((uint32_t)0x20000000)
  45. #define NVIC_VectTab_FLASH ((uint32_t)0x01000000)
  46. #define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \
  47. ((VECTTAB) == NVIC_VectTab_FLASH))
  48. #define NVIC_PriorityGroup_0 ((uint32_t)0x07) /*!< 0 bits for pre-emption priority
  49. 3 bits for subpriority */
  50. #define NVIC_PriorityGroup_1 ((uint32_t)0x06) /*!< 1 bits for pre-emption priority
  51. 2 bits for subpriority */
  52. #define NVIC_PriorityGroup_2 ((uint32_t)0x05) /*!< 2 bits for pre-emption priority
  53. 1 bits for subpriority */
  54. #define NVIC_PriorityGroup_3 ((uint32_t)0x04) /*!< 3 bits for pre-emption priority
  55. 0 bits for subpriority */
  56. #define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \
  57. ((GROUP) == NVIC_PriorityGroup_1) || \
  58. ((GROUP) == NVIC_PriorityGroup_2) || \
  59. ((GROUP) == NVIC_PriorityGroup_3))
  60. #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
  61. #define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
  62. #define IS_NVIC_OFFSET(OFFSET) ((OFFSET) < 0x000FFFFF)
  63. /** @defgroup MISC_SysTick_clock_source
  64. * @{
  65. */
  66. #define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB)
  67. #define SysTick_CLKSource_HCLK ((uint32_t)0x00000004)
  68. #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \
  69. ((SOURCE) == SysTick_CLKSource_HCLK_Div8))
  70. //void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup);
  71. void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct);
  72. void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset);
  73. void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource);
  74. #ifdef __cplusplus
  75. }
  76. #endif
  77. #endif /* __MISC_H */
  78. /**
  79. * @}
  80. */
  81. /**
  82. * @}
  83. */
  84. /**
  85. * @}
  86. */
  87. /******************* (C) COPYRIGHT MEGAHUNT *****END OF FILE****/