#include "drv_clk.h"
#include "drv_misc.h"
#include "kit_debug.h"


#define EXTI_Line16      		  ((uint32_t)0x10000)
#define PWR_FLAG_PVDO             ((uint32_t)0x00000004)
#define PWR_CR_PVDE_POS           ((uint32_t)0x00000010)
#define PWR_PVDLevel_2V9          ((uint32_t)0x000000E0)


void drv_misc_set_nvic(int8_t irq_channel, uint8_t priority)
{
    KIT_ASSERT_PARAM((irq_channel > -15) && (irq_channel < 90) && (priority < 16));
    
    priority = (priority & 0x0F) << 4;
    if(irq_channel > 0)
    {
        NVIC->IP[irq_channel] = priority;
        /* Enable the Selected IRQ Channels */
        NVIC->ISER[irq_channel >> 0x05] = (uint32_t)0x01 << (irq_channel & (uint8_t)0x1F);
    }
    else
    {
        SCB->SHP[((uint32_t)(irq_channel) & 0xF)-4] = priority;
    }
}