STM32G0 MCAL 0.0.1
Tiny MCAL for educational purpose.
Loading...
Searching...
No Matches
Nvic.c File Reference

Complex Device Driver (CDD). More...

#include "Std_Types.h"
#include "Registers.h"
#include "Nvic.h"
#include "Bfx.h"

Macros

#define Det_ReportError(ModuleId, InstanceId, ApiId, ErrorId)
 
#define BIT_SHIFT(irq)
 
#define IP_IDX(irq)
 
#define NVIC_MIN_IRQ   16u
 
#define NVIC_MAX_IRQ   30u
 
#define NVIC_MAX_PRIORITY   3u
 
#define IRQ_MASK   0x1FUL
 
#define IRQ_NOT_PENDING   0UL
 
#define INVALID_PRIORITY   0xFFU
 
#define FIRST_INDEX   0U
 

Functions

void CDD_Nvic_SetPriority (Nvic_IrqType Irq, uint32 Priority)
 Sets the priority for a specific peripheral interrupt in the NVIC.
 
uint32 CDD_Nvic_GetPriority (Nvic_IrqType Irq)
 Return the priority of a specific peripheral interrupt from the NVIC.
 
void CDD_Nvic_EnableIrq (Nvic_IrqType Irq)
 Enables a specific peripheral interrupt in the NVIC.
 
void CDD_Nvic_DisableIrq (Nvic_IrqType Irq)
 Disables a specific peripheral interrupt in the NVIC.
 
uint32 CDD_Nvic_GetPendingIrq (Nvic_IrqType Irq)
 Return the pending status of a specific peripheral interrupt in the NVIC.
 
void CDD_Nvic_SetPendingIrq (Nvic_IrqType Irq)
 Sets a specific peripheral interrupt as pending in the NVIC.
 
void CDD_Nvic_ClearPendingIrq (Nvic_IrqType Irq)
 Clears the pending status of a specific peripheral interrupt in the NVIC.
 

Detailed Description

Complex Device Driver (CDD).

Complex Nvic Driver controls the NVIC (Nested Vectored Interrupt Controller) functionality. It specifically controls the activation of interrupts in ARM microcontrollers via the NVIC peripheral, providing functionalities including setting priorities, enabling/disabling interrupts, and handling interrupt pending statuses.

Macro Definition Documentation

◆ Det_ReportError

#define Det_ReportError ( ModuleId,
InstanceId,
ApiId,
ErrorId )
Value:
(void)0
Parameters
ModuleIdmodule id number
InstanceIdInstance Id
ApiIdPai id
ErrorIdError code

◆ FIRST_INDEX

#define FIRST_INDEX   0U

Starting index for NVIC register

Function Documentation

◆ CDD_Nvic_ClearPendingIrq()

void CDD_Nvic_ClearPendingIrq ( Nvic_IrqType Irq)

Clears the pending status of a specific peripheral interrupt in the NVIC.

The function checks if the interrupt number belongs to the microcontroller's peripherals. If the number is valid, it uses the Bfx_PutBit_u32u8u8 function to clear the pending status of that interrupt in the NVIC's ICPR register.

Parameters
IrqInterrupt number whose pending status is to be cleared.

< Minimum IQR value

< Maximum IRQ value

< Starting index for NVIC register

< Mask to obtain bits from an IRQ value

◆ CDD_Nvic_DisableIrq()

void CDD_Nvic_DisableIrq ( Nvic_IrqType Irq)

Disables a specific peripheral interrupt in the NVIC.

The function checks if the interrupt number belongs to the microcontroller's peripherals. If the number is valid, it uses the Bfx_PutBit_u32u8u8 function to disable the interrupt in the NVIC's ICER register.

Parameters
IrqInterrupt number to be disabled.

< Minimum IQR value

< Maximum IRQ value

< Starting index for NVIC register

< Mask to obtain bits from an IRQ value

◆ CDD_Nvic_EnableIrq()

void CDD_Nvic_EnableIrq ( Nvic_IrqType Irq)

Enables a specific peripheral interrupt in the NVIC.

The function checks if the interrupt number belongs to the microcontroller's peripherals. If the number is valid, it uses the Bfx_SetBit_u32u8 function to enable the interrupt in the NVIC's ISER register.

Parameters
IrqInterrupt number to be enabled.

< Minimum IQR value

< Maximum IRQ value

< Starting index for NVIC register

< Mask to obtain bits from an IRQ value

◆ CDD_Nvic_GetPendingIrq()

uint32 CDD_Nvic_GetPendingIrq ( Nvic_IrqType Irq)

Return the pending status of a specific peripheral interrupt in the NVIC.

The function checks if the interrupt number belongs to the microcontroller's peripherals. If the number is valid, it uses the Bfx_GetBit_u32u8_u8 function to determine if the interrupt is pending in the NVIC's ISPR register.

Parameters
IrqInterrupt number whose pending status is to be checked.
Returns
Returns TRUE if the interrupt is pending, otherwise returns IRQ_NOT_PENDING.

< Value to specifie IRQ is not pending

< Minimum IQR value

< Maximum IRQ value

< Starting index for NVIC register

< Mask to obtain bits from an IRQ value

◆ CDD_Nvic_GetPriority()

uint32 CDD_Nvic_GetPriority ( Nvic_IrqType Irq)

Return the priority of a specific peripheral interrupt from the NVIC.

The function checks if the interrupt number belongs to the microcontroller's peripherals. If the number is valid, it uses the Bfx_GetBits_u32u8u8_u32 function to extract the priority from the NVIC's IP register. Otherwise, it returns an INVALID_PRIORITY value.

Parameters
IrqInterrupt number whose priority is to be retrieved.
Return values
Priorityvalue of the interrupt. Returns INVALID_PRIORITY if the interrupt number is not a valid peripheral interrupt.

< Invalid priority indicator

< Minimum IQR value

< Maximum IRQ value

< Calculate the index for IRQ priority register

< Calculate the bit shift for IRQ priority

◆ CDD_Nvic_SetPendingIrq()

void CDD_Nvic_SetPendingIrq ( Nvic_IrqType Irq)

Sets a specific peripheral interrupt as pending in the NVIC.

The function checks if the interrupt number belongs to the microcontroller's peripherals. If the number is valid, it utilizes the Bfx_SetBit_u32u8 function to set the interrupt as pending in the NVIC's ISPR register.

Parameters
IrqInterrupt number to set as pending.

< Minimum IQR value

< Maximum IRQ value

< Starting index for NVIC register

< Mask to obtain bits from an IRQ value

◆ CDD_Nvic_SetPriority()

void CDD_Nvic_SetPriority ( Nvic_IrqType Irq,
uint32 Priority )

Sets the priority for a specific peripheral interrupt in the NVIC.

The function checks if the interrupt number belongs to the microcontroller's peripherals. If valid, it utilizes the Bfx_PutBitsMask_u32u32u32 function to update the NVIC's IP register with the desired priority.

Parameters
IrqInterrupt number to set.
PriorityPriority value to assign to the interrupt.

< Minimum IQR value

< Maximum IRQ value

< Maximum priority value

< Calculate the index for IRQ priority register

< Calculate the bit shift for IRQ priority

< Calculate the index for IRQ priority register

< Calculate the bit shift for IRQ priority