本文整理汇总了C++中NVIC_EncodePriority函数的典型用法代码示例。如果您正苦于以下问题:C++ NVIC_EncodePriority函数的具体用法?C++ NVIC_EncodePriority怎么用?C++ NVIC_EncodePriority使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NVIC_EncodePriority函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(void)
{
DelayInit();
GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
/* 设置PORTE PORTA 中断 */
GPIO_QuickInit(HW_GPIOE,26, kGPIO_Mode_IPU);
GPIO_QuickInit(HW_GPIOA, 4, kGPIO_Mode_IPU);
GPIO_CallbackInstall(HW_GPIOE, PORTE_ISR);
GPIO_CallbackInstall(HW_GPIOA, PORTA_ISR);
GPIO_ITDMAConfig(HW_GPIOE, 26, kGPIO_IT_RisingEdge, true);
GPIO_ITDMAConfig(HW_GPIOA, 4, kGPIO_IT_RisingEdge, true);
printf("NVIC test connect E26&A04\r\n");
/* 将系统 中断优先级分组 可以配置 16个 抢占优先级 和16个 子优先级 */
NVIC_SetPriorityGrouping(NVIC_PriorityGroup_2); //中断优先级分成2组
NVIC_SetPriority(PORTE_IRQn, NVIC_EncodePriority(NVIC_PriorityGroup_2, 2, 2)); //设置PTE端口的抢占优先级的子优先级
NVIC_SetPriority(PORTA_IRQn, NVIC_EncodePriority(NVIC_PriorityGroup_2, 2, 2));
while(1)
{
GPIO_ToggleBit(HW_GPIOE, 6);
DelayMs(500);
}
}
示例2: init_Priority
void init_Priority(void){
uint32_t priority, PG = 5, PP, SP; // priority grouping, pre-empt priority, subpriority
NVIC_SetPriorityGrouping(5);
PP = 0, SP = 0;
priority = NVIC_EncodePriority(PG,PP,SP);
NVIC_SetPriority(SysTick_IRQn, priority);
PP = 1, SP = 0;
priority = NVIC_EncodePriority(PG,PP,SP);
NVIC_SetPriority(EINT3_IRQn, priority); // light sensor and SW3
// interrupt with smallest time interval is given higher priority
PP = 2, SP = 0;
priority = NVIC_EncodePriority(PG,PP,SP);
NVIC_SetPriority(TIMER1_IRQn, priority); // pca9532 led (250ms)
PP = 2, SP = 1;
priority = NVIC_EncodePriority(PG,PP,SP);
NVIC_SetPriority(TIMER2_IRQn, priority); // rgb (1s)
PP = 2, SP = 2;
priority = NVIC_EncodePriority(PG,PP,SP);
NVIC_SetPriority(TIMER3_IRQn, priority); // sampling (2s)
// clear pending status before enabling
NVIC_ClearPendingIRQ(EINT3_IRQn);
NVIC_ClearPendingIRQ(TIMER1_IRQn);
NVIC_ClearPendingIRQ(TIMER2_IRQn);
NVIC_ClearPendingIRQ(TIMER3_IRQn);
NVIC_EnableIRQ(EINT3_IRQn);
NVIC_EnableIRQ(TIMER1_IRQn);
NVIC_EnableIRQ(TIMER2_IRQn);
NVIC_EnableIRQ(TIMER3_IRQn);
}
示例3: Timerx_Init
void Timerx_Init(GPTM_TypeDef* GPTMx,u16 arr,u16 psc)
{
GPTM_TimeBaseInitTypeDef GPTM_TimeBaseStructure;
//NVIC_InitTypeDef NVIC_InitStructure;
Assert_Param(IS_GPTM(GPTMx));
if(GPTMx==GPTM0)
{
CKCU_APBPerip1ClockConfig(CKCU_APBEN1_GPTM0,ENABLE);
}
else if(GPTMx==GPTM1)
{
CKCU_APBPerip1ClockConfig(CKCU_APBEN1_GPTM1,ENABLE);
}
GPTM_DeInit(GPTMx);
GPTM_TimeBaseStructure.CounterReload = arr; //设置在下一个更新事件装入活动的自动重装载寄存器周期的值 计数到5000为500ms
GPTM_TimeBaseStructure.Prescaler =(7200-1); //设置用来作为TIMx时钟频率除数的预分频值 10Khz的计数频率
GPTM_TimeBaseStructure.PSCReloadTime = GPTM_PSC_RLD_UPDATE;//无事件发生,等待下一次重载//TIM 中断源
GPTM_TimeBaseStructure.CounterMode = GPTM_CNT_MODE_UP; //TIM向上计数模式
GPTM_TimeBaseInit(GPTMx, &GPTM_TimeBaseStructure); //根据TIM_TimeBaseInitStruct中指定的参数初始化TIMx的时间基数单位
/* TIM IT enable */
GPTM_IntConfig( //使能或者失能指定的TIM中断
GPTMx, //TIMx
TIM_IT_Update | //TIM 中断源
TIM_IT_Trigger, //TIM 触发中断源
ENABLE //使能
);
/* Enable the TIMx global Interrupt */
if(GPTMx==GPTM0)
{
NVIC_SetPriority(GPTM0_IRQn,NVIC_EncodePriority(5,0,3));
NVIC_EnableIRQ(GPTM0_IRQn);
GPTM_IntConfig(GPTM0,GPTM_INT_UEV,ENABLE);
}
else
if(GPTMx==GPTM1)
{
NVIC_SetPriority(GPTM1_IRQn,NVIC_EncodePriority(5,0,3));
NVIC_EnableIRQ(GPTM1_IRQn);
GPTM_IntConfig(GPTM1,GPTM_INT_UEV,ENABLE);
}
/*
NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn; //TIM3中断
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; //先占优先级0级
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //从优先级3级
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ通道被使能
NVIC_Init(&NVIC_InitStructure); //根据NVIC_InitStruct中指定的参数初始化外设NVIC寄存器
*/
GPTM_Cmd(GPTMx, ENABLE); //使能TIMx外设
}
示例4: Config_SystemClock_Priority
/*******************************************************************************
* @function_name: Config_SystemClock_Priority
* @function_file: BT.c
* @描述:配置各中断优先级
* @入口参数:
* @出口参数: 无
* @Attention:
*---------------------------------------------------------
* @修改人:
******************************************************************************/
void Config_SystemClock_Priority(void)
{
//开启系统定时器,重装载值(时间)为1ms
//SysTick_Config(SystemCoreClock/1000);
//设置优先级组:抢占式优级(0~3),子优先级(0~3)
NVIC_SetPriorityGrouping(5);
//设置FRTIM_IRQn抢占优先级为1
NVIC_SetPriority(FRTIM_IRQn,NVIC_EncodePriority(5,0,0));
//设置系统定时器中断抢占优先级为2
NVIC_SetPriority(SysTick_IRQn,NVIC_EncodePriority(5,1,0));
//设置基本定时器7中断抢占优先级为3
NVIC_SetPriority(BTIM0_7_IRQn,NVIC_EncodePriority(5,0,0));
}
示例5: _BSP_NvicInit
/**
* @brief .
* @param None
* @retval None
*/
void _BSP_NvicInit (void)
{
#ifdef VECT_TAB_RAM
SCB->VTOR = 0X1FFF0000;
#else /* VECT_TAB_FLASH */
SCB->VTOR = 0x4000;
#endif
NVIC_SetPriorityGrouping (5);//抢占式优先级(0~3),亚优先级(0~3)
//NVIC_SetPriority(PORTA_IRQn,NVIC_EncodePriority(5,1,0));
NVIC_SetPriority(PIT0_IRQn,NVIC_EncodePriority(5,1,1));
NVIC_SetPriority(UART3_RX_TX_IRQn,NVIC_EncodePriority(5,1,2));
NVIC_SetPriority(SysTick_IRQn,NVIC_EncodePriority(5,1,3));
}
示例6: SYSTM002_Init
/*
* Initialization function which initializes the App internal data
* structures to default values.
*/
void SYSTM002_Init( void)
{
volatile uint32_t Timer_Status = SYSTM002_TIMER_CONFIGURATION_SUCCESS;
/* <<<DD_SYSTM002 _API_1>>> */
/** Initialize the header of the list */
TimerList = NULL;
/** Initialize timer tracker */
Timer_Status = SysTick_Config((uint32_t)(SYSTM002_SysTickMicroSec( \
SYSTM002_SYSTICK_INTERVAL)));
if(SYSTM002_TIMER_CONFIGURATION_FAILURE == Timer_Status)
{
DBG002_INFO(APP_GID, DBG002_MESSAGEID_LITERAL, \
sizeof("SYSTM002_Init: Timer reload value out of range"), \
"SYSTM002_Init: Timer reload value out of range");
}
else
{
/** setting of Priority and subpriority value for XMC4000 devices */
#if ((__TARGET_DEVICE__ == XMC44) || (__TARGET_DEVICE__ == XMC42) || \
(__TARGET_DEVICE__ == XMC41) || (__TARGET_DEVICE__ == XMC45))
NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority( \
NVIC_GetPriorityGrouping(),SYSTM002_PRIORITY,SYSTM002_SUBPRIORITY));
/** setting of Priority value for XMC1000 devices */
#elif ((__TARGET_DEVICE__ == XMC11) || (__TARGET_DEVICE__ == XMC12) \
|| (__TARGET_DEVICE__ == XMC13))
NVIC_SetPriority(SysTick_IRQn, SYSTM002_PRIORITY);
#endif
TimerTracker = 0UL;
}
}
示例7: PIN_INTERRUPT_Init
/*
* API to initialize the PIN_INTERRUPT APP ERU Event Trigger Logic, Output Gating Unit Hardware initialization
* and NVIC node configuration.
*/
PIN_INTERRUPT_STATUS_t PIN_INTERRUPT_Init(const PIN_INTERRUPT_t *const handle)
{
XMC_ASSERT("PIN_INTERRUPT_Init: PIN_INTERRUPT APP handle function pointer uninitialized", (handle != NULL));
/* Initializes input pin characteristics */
XMC_GPIO_Init(handle->port, handle->pin, &handle->gpio_config);
/* ERU Event Trigger Logic Hardware initialization based on UI */
XMC_ERU_ETL_Init(handle->eru, handle->etl, &handle->etl_config);
/* OGU is configured to generate event on configured trigger edge */
XMC_ERU_OGU_SetServiceRequestMode(handle->eru, handle->ogu, XMC_ERU_OGU_SERVICE_REQUEST_ON_TRIGGER);
#if (UC_FAMILY == XMC1)
/* Configure NVIC node and priority */
NVIC_SetPriority((IRQn_Type)handle->IRQn, handle->irq_priority);
#else
/* Configure NVIC node, priority and subpriority */
NVIC_SetPriority((IRQn_Type)handle->IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),
handle->irq_priority, handle->irq_subpriority));
#endif
#if (UC_SERIES == XMC14)
XMC_SCU_SetInterruptControl((IRQn_Type)handle->IRQn, (XMC_SCU_IRQCTRL_t)handle->irqctrl);
#endif
if (true == handle->enable_at_init)
{
/* Clear pending interrupt before enabling it */
NVIC_ClearPendingIRQ((IRQn_Type)handle->IRQn);
/* Enable NVIC node */
NVIC_EnableIRQ((IRQn_Type)handle->IRQn);
}
return (PIN_INTERRUPT_STATUS_SUCCESS);
}
示例8: extIntInit
error_t extIntInit(void)
{
volatile uint32_t status;
//Enable PIO peripheral clock
PMC->PMC_PCER0 = (1 << ID_PIOD);
//Enable pull-up resistor on PHY IRQ pin
PIOD->PIO_PUER = PIO_PD28;
//Configure the corresponding pin as an input
PIOD->PIO_ODR = PIO_PD28;
PIOD->PIO_PER = PIO_PD28;
//Enable interrupts-on-change
PIOD->PIO_IDR = 0xFFFFFFFF;
PIOD->PIO_IER = PIO_PD28;
//Reset PHY transceiver by asserting NRST pin
//RSTC->RSTC_MR = RSTC_MR_KEY(0xA5) | RSTC_MR_ERSTL(4);
//RSTC->RSTC_CR = RSTC_CR_KEY(0xA5) | RSTC_CR_EXTRST;
//Wait for the reset to complete
//while(!(RSTC->RSTC_SR & RSTC_SR_NRSTL));
//Delay before accessing PHY transceiver
sleep(10);
//Read PIO ISR register to clear any pending interrupt
status = PIOD->PIO_ISR;
//Configure PIOD interrupt priority
NVIC_SetPriority(PIOD_IRQn, NVIC_EncodePriority(3, 15, 0));
//Successful processing
return NO_ERROR;
}
示例9: INTERRUPT_Init
/*
* API to initialize the INTERRUPT APP
*/
INTERRUPT_STATUS_t INTERRUPT_Init(const INTERRUPT_t *const handler)
{
XMC_ASSERT("INTERRUPT_Init:HandlePtr NULL", (handler != NULL));
#if(UC_FAMILY == XMC4)
NVIC_SetPriority(handler->node,
NVIC_EncodePriority(NVIC_GetPriorityGrouping(),
handler->priority,
handler->subpriority));
if (handler->enable_at_init == true)
{
INTERRUPT_Enable(handler);
}
#endif
#if(UC_FAMILY == XMC1)
NVIC_SetPriority(handler->node, handler->priority);
#if (UC_SERIES == XMC14)
XMC_SCU_SetInterruptControl((uint8_t)handler->node, (XMC_SCU_IRQCTRL_t)((handler->node << 8) | handler->irqctrl));
#endif
/* Enable the interrupt if enable_at_init is enabled */
if (handler->enable_at_init == true)
{
INTERRUPT_Enable(handler);
}
#endif
return (INTERRUPT_STATUS_SUCCESS);
}
示例10: NVIC_SCU001_Init
/* Function to configure SCU Interrupts based on user configuration.
*
*/
void NVIC_SCU001_Init()
{
FUNCTION_ENTRY(GID_NVIC_SCU001,NVIC_SCU001_FUNC_ENTRY);
NVIC_SetPriority(64, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),63,0));
/* Enable Interrupt */
NVIC_EnableIRQ(64);
FUNCTION_EXIT(GID_NVIC_SCU001,NVIC_SCU001_FUNC_EXIT);
}
示例11: clock_init
void clock_init( )
{
u_long nirq_Priority = 0;
current_clock = 0;
/* Setup SysTick Timer for 1 msec interrupts */
if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000)) while (1) ;
nirq_Priority = NVIC_EncodePriority(INT_SYSTICK_nIRQ_GROUP, INT_SYSTICK_nIRQ_PREP, INT_SYSTICK_nIRQ_SUBP);
NVIC_SetPriority(SysTick_IRQn, nirq_Priority);
}
示例12: NVIC002_Init
/** Function to initialize the NVIC node parameters based on
* UI configuration.
*/
void NVIC002_Init(void)
{
/*<<<DD_NVIC002_API_1>>>*/
FUNCTION_ENTRY(GID_NVIC002,NVIC002_FUNC_ENTRY);
// Set Interrupt Priority for NVIC 5 Node App Instance 0
NVIC_SetPriority(5, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),63,0));
/* Enable Interrupt */
NVIC_EnableIRQ(5);
FUNCTION_EXIT(GID_NVIC002,NVIC002_FUNC_EXIT);
}
示例13: main
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f10x_xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f10x.c file
*/
/* Initialize LED1..LED4, Key and Wakeup Buttons mounted on STM3210X-EVAL
board */
STM_EVAL_LEDInit(LED1);
STM_EVAL_LEDInit(LED2);
STM_EVAL_LEDInit(LED3);
STM_EVAL_LEDInit(LED4);
STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_EXTI);
STM_EVAL_PBInit(BUTTON_WAKEUP, BUTTON_MODE_EXTI);
/* Configure one bit for preemption priority */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
/* Enable the WAKEUP_BUTTON_EXTI_IRQn Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = WAKEUP_BUTTON_EXTI_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = PreemptionPriorityValue;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Enable the KEY_BUTTON_EXTI_IRQn Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = KEY_BUTTON_EXTI_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Configure the SysTick Handler Priority: Preemption priority and subpriority */
NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), !PreemptionPriorityValue, 0));
while (1)
{
if(PreemptionOccured != FALSE)
{
STM_EVAL_LEDToggle(LED1);
Delay(0x5FFFF);
STM_EVAL_LEDToggle(LED2);
Delay(0x5FFFF);
STM_EVAL_LEDToggle(LED3);
Delay(0x5FFFF);
STM_EVAL_LEDToggle(LED4);
Delay(0x5FFFF);
}
}
}
示例14: HAL_NVIC_SetPriority
/**
* @brief Sets the priority of an interrupt.
* @param IRQn: External interrupt number.
* This parameter can be an enumerator of IRQn_Type enumeration
* (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32f4xxxx.h))
* @param PreemptPriority: The preemption priority for the IRQn channel.
* This parameter can be a value between 0 and 15
* A lower priority value indicates a higher priority
* @param SubPriority: the subpriority level for the IRQ channel.
* This parameter can be a value between 0 and 15
* A lower priority value indicates a higher priority.
* @retval None
*/
void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority)
{
uint32_t prioritygroup = 0x00;
/* Check the parameters */
assert_param(IS_NVIC_SUB_PRIORITY(SubPriority));
assert_param(IS_NVIC_PREEMPTION_PRIORITY(PreemptPriority));
prioritygroup = NVIC_GetPriorityGrouping();
NVIC_SetPriority(IRQn, NVIC_EncodePriority(prioritygroup, PreemptPriority, SubPriority));
}
示例15: main
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
files (startup_stm32f40_41xxx.s/startup_stm32f427_437xx.s/startup_stm32f429_439xx.s)
before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f4xx.c file
*/
/* NVIC configuration ------------------------------------------------------*/
NVIC_Config();
/* Initialize LEDs mounted on EVAL board */
STM_EVAL_LEDInit(LED1);
STM_EVAL_LEDInit(LED2);
STM_EVAL_LEDInit(LED3);
STM_EVAL_LEDInit(LED4);
/* Initialize the KEY/Tamper and Wakeup buttons mounted on EVAL board */
STM_EVAL_PBInit(BUTTON_KEY_TAMPER, BUTTON_MODE_EXTI);
STM_EVAL_PBInit(BUTTON_WAKEUP, BUTTON_MODE_EXTI);
/* Configure the SysTick Handler Priority: Preemption priority and subpriority */
NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), !ubPreemptionPriorityValue, 0));
while (1)
{
if(ubPreemptionOccurred != 0)
{
/* Toggle LED1 */
STM_EVAL_LEDToggle(LED1);
/* Insert delay Time */
Delay(0x5FFFF);
/* Toggle LED2 */
STM_EVAL_LEDToggle(LED2);
Delay(0x5FFFF);
/* Toggle LED3 */
STM_EVAL_LEDToggle(LED3);
Delay(0x5FFFF);
/* Toggle LED4 */
STM_EVAL_LEDToggle(LED4);
Delay(0x5FFFF);
}
}
}