Hilscher netX microcontroller driver  V0.0.5.0
Documentation of the netX driver package
netx_drv_cortex.c
Go to the documentation of this file.
1 /*!************************************************************************/
24 #include "netx_drv.h"
25 #ifdef DRV_CORTEX_MODULE_ENABLED
26 
41 void DRV_NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
42 {
43  /* Set the PRIGROUP[10:8] bits according to the PriorityGroup parameter value */
44  NVIC_SetPriorityGrouping(PriorityGroup);
45 }
46 
52 void DRV_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority)
53 {
54  uint32_t prioritygroup = 0x00U;
55 
56  prioritygroup = NVIC_GetPriorityGrouping();
57 
58  NVIC_SetPriority(IRQn, NVIC_EncodePriority(prioritygroup, PreemptPriority, SubPriority));
59 }
60 
65 {
66  /* Enable interrupt */
67  NVIC_EnableIRQ(IRQn);
68 }
69 
74 {
75  /* Disable interrupt */
76  NVIC_DisableIRQ(IRQn);
77 }
78 
83 
88 {
89  /* System Reset */
91 }
92 
96 uint32_t DRV_SYSTICK_Config(uint32_t TicksNumb)
97 {
98  return SysTick_Config(TicksNumb);
99 }
100 
105 {
106  /* Get the PRIGROUP[10:8] field value */
107  return NVIC_GetPriorityGrouping();
108 }
109 
116 void DRV_NVIC_GetPriority(IRQn_Type IRQn, uint32_t PriorityGroup, uint32_t *pPreemptPriority, uint32_t *pSubPriority)
117 {
118  /* Get priority for Cortex-M system or device specific interrupts */
119  NVIC_DecodePriority(NVIC_GetPriority(IRQn), PriorityGroup, pPreemptPriority, pSubPriority);
120 }
121 
126 {
127  /* Set interrupt pending */
128  NVIC_SetPendingIRQ(IRQn);
129 }
130 
135 {
136  /* Return 1 if pending else 0 */
137  return NVIC_GetPendingIRQ(IRQn);
138 }
139 
144 {
145  /* Clear pending interrupt */
146  NVIC_ClearPendingIRQ(IRQn);
147 }
148 
153 {
154  /* Return 1 if active else 0 */
155  return NVIC_GetActive(IRQn);
156 }
157 
162 {
163  /* Return 1 if active else 0 */
164  return NVIC_GetEnableIRQ(IRQn);
165 }
166 
170 void DRV_NVIC_AttachIRQ(IRQn_Type IRQn, void* pfIRQHandler)
171 {
172 #ifdef NVIC_SOFT_VECTOR
173  g_avpfVTOR[IRQn + 16] = pfIRQHandler;
174 #else
175 #endif
176 }
177 
182 {
183  return ((void**) SCB->VTOR)[IRQn + 16];
184 }
185 
191 int32_t DRV_ITM_ReceiveChar(void)
192 {
193  return ITM_ReceiveChar();
194 }
200 int32_t DRV_ITM_CheckChar(void)
201 {
202  return ITM_CheckChar();
203 }
211 uint32_t DRV_ITM_SendChar(uint32_t ch)
212 {
213  return DRV_ITM_SendChar(ch);
214 }
215 /* End of group CORTEX */
217 
218 #endif /* DRV_CORTEX_MODULE_DISABLED */
void * DRV_NVIC_GetIRQ(IRQn_Type IRQn)
This function may be used to get the pointer of an interrupt.
uint32_t DRV_NVIC_GetActive(IRQn_Type IRQn)
This function returns the active state of a given interrupt.
uint32_t DRV_SYSTICK_Config(uint32_t TicksNumb)
IRQn_Type
Definition: netx90_app.h:57
void DRV_NVIC_GetPriority(IRQn_Type IRQn, uint32_t PriorityGroup, uint32_t *pPreemptPriority, uint32_t *pSubPriority)
This method stores the priority of a given interrupt and group into the given locations.
void DRV_NVIC_DisableIRQ(IRQn_Type IRQn)
This method disables a given interrupt.
uint32_t DRV_NVIC_GetEnableIRQ(IRQn_Type IRQn)
This function returns the enable state of a given interrupt.
void DRV_NVIC_EnableIRQ(IRQn_Type IRQn)
This method enables a given interrupt.
void DRV_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority)
This method sets the priority of a given interrupt.
#define NVIC_SystemReset
Definition: core_cm4.h:1620
#define NVIC_SetPendingIRQ
Definition: core_cm4.h:1615
uint32_t DRV_NVIC_GetPendingIRQ(IRQn_Type IRQn)
This funciton returns the pending state of a given interrupt.
__STATIC_INLINE int32_t ITM_ReceiveChar(void)
ITM Receive Character.
Definition: core_cm4.h:2074
#define NVIC_EnableIRQ
Definition: core_cm4.h:1611
uint32_t DRV_NVIC_GetPriorityGrouping(void)
This function returns the priority grouping.
#define NVIC_DisableIRQ
Definition: core_cm4.h:1613
#define NVIC_GetPendingIRQ
Definition: core_cm4.h:1614
#define NVIC_GetPriorityGrouping
Definition: core_cm4.h:1610
__STATIC_INLINE int32_t ITM_CheckChar(void)
ITM Check Character.
Definition: core_cm4.h:2094
int32_t DRV_ITM_CheckChar(void)
Driver wrapper for ITM Check Character.
__STATIC_INLINE void NVIC_DecodePriority(uint32_t Priority, uint32_t PriorityGroup, uint32_t *const pPreemptPriority, uint32_t *const pSubPriority)
Decode Priority.
Definition: core_cm4.h:1879
#define NVIC_ClearPendingIRQ
Definition: core_cm4.h:1616
void DRV_NVIC_SetPendingIRQ(IRQn_Type IRQn)
This method sets a given interrupt pending.
This file contains all the functions prototypes for the peripheral module driver. ...
#define SCB
Definition: core_cm4.h:1561
int32_t DRV_ITM_ReceiveChar(void)
Driver wrapper for ITM Receive Character.
void DRV_NVIC_AttachIRQ(IRQn_Type IRQn, void *pfIRQHandler)
This function may be used to attach or detach an interrupt to the software vector if it is used...
int ulIrqSemaphore
Semaphore value for nested enabling/disabling of all interrupts.
#define NVIC_GetEnableIRQ
Definition: core_cm4.h:1612
#define NVIC_GetActive
Definition: core_cm4.h:1617
#define NVIC_SetPriority
Definition: core_cm4.h:1618
void DRV_NVIC_ClearPendingIRQ(IRQn_Type IRQn)
This method clears the pending state of a given interrupt.
uint32_t DRV_ITM_SendChar(uint32_t ch)
Driver wrapper for ITM Send Character.
#define NVIC_SetPriorityGrouping
Definition: core_cm4.h:1609
#define NVIC_GetPriority
Definition: core_cm4.h:1619
__STATIC_INLINE uint32_t NVIC_EncodePriority(uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority)
Encode Priority.
Definition: core_cm4.h:1852
void DRV_NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
This method sets the priority grouping.
void DRV_NVIC_SystemReset(void)
This method resets the NVIC and the Cortex M4 internal registers and restarts the PC at 0...