本文整理汇总了C++中NVIC_EncodePriority函数的典型用法代码示例。如果您正苦于以下问题:C++ NVIC_EncodePriority函数的具体用法?C++ NVIC_EncodePriority怎么用?C++ NVIC_EncodePriority使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NVIC_EncodePriority函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:Wangwenxue,项目名称:K64_PN532,代码行数:26,代码来源:main.c
示例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);
}
开发者ID:kaiyisg,项目名称:martian-explorer-hope,代码行数:32,代码来源:main.c
示例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外设
}
开发者ID:CyanoBeta,项目名称:Holtek-Example,代码行数:54,代码来源:timer.c
示例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));
}
开发者ID:bearxiong99,项目名称:XXOO_000,代码行数:23,代码来源:Drv_BT.c
示例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));
}
开发者ID:qiurenguo2014,项目名称:qdj-01,代码行数:18,代码来源:BSP.C
示例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;
}
}
开发者ID:ArthurMLago,项目名称:Controle-e-Telemetria,代码行数:37,代码来源:SYSTM002.c
示例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);
}
开发者ID:JackTheEngineer,项目名称:Drone,代码行数:34,代码来源:pin_interrupt.c
示例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;
}
开发者ID:nandojve,项目名称:embedded,代码行数:34,代码来源:ext_int_driver.c
示例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);
}
开发者ID:XMC-CAN,项目名称:UsbCanNode,代码行数:35,代码来源:interrupt.c
示例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);
}
开发者ID:uSasha,项目名称:Webserver_XMC4500_RelaxKit,代码行数:12,代码来源:NVIC_SCU001.c
示例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);
}
开发者ID:zoulincheng,项目名称:stm32chip_project,代码行数:9,代码来源:clock.c
示例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);
}
开发者ID:uSasha,项目名称:Webserver_XMC4500_RelaxKit,代码行数:13,代码来源:NVIC002.c
示例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);
}
}
}
开发者ID:ngocthanhtnt,项目名称:ledshow,代码行数:58,代码来源:main.c
示例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));
}
开发者ID:CSRedRat,项目名称:MobilECG-II,代码行数:25,代码来源:stm32f4xx_hal_cortex.c
示例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);
}
}
}
开发者ID:XDeca,项目名称:LED_POV,代码行数:58,代码来源:main.c
示例16: ConfigZeroCross_NVIC
void ConfigZeroCross_NVIC()
{
//NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
ZeroCross_VectorPrior.NVIC_IRQChannel = EXTI15_10_IRQn;
ZeroCross_VectorPrior.NVIC_IRQChannelPreemptionPriority = 15;
ZeroCross_VectorPrior.NVIC_IRQChannelSubPriority = 0;
ZeroCross_VectorPrior.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&ZeroCross_VectorPrior);
NVIC_SetPriority(EXTI15_10_IRQn, NVIC_EncodePriority(4,15,0));
}
开发者ID:doebbertt,项目名称:stm32-f103-CortexM3-ESP8266-Dimmer,代码行数:12,代码来源:main.c
示例17: setISRPriorities
void setISRPriorities() {
__disable_irq();
// set two bits for preemptive data, two bits for priority as the
// structure for the IPRs. Grouping is global withing the IPRs so
// this value should only be changed here.
NVIC_SetPriorityGrouping(5);
uint32_t priorityGrouping = NVIC_GetPriorityGrouping();
// set preemptive priority default to 2 (0..3)
// set priority default to 1 (0..3)
uint32_t defaultPriority = NVIC_EncodePriority(priorityGrouping, 2, 1);
// When the kernel initialzes the PNVIC, all ISRs are set to the
// highest priority, making it impossible to elevate a few over
// the rest, so the default priority is lowered globally for the
// table first.
//
// Consult LPC17xx.h under IRQn_Type for PNVIC ranges, this is LPC1768
// specific
for (uint32_t IRQn = TIMER0_IRQn; IRQn <= CANActivity_IRQn; IRQn++)
NVIC_SetPriority((IRQn_Type)IRQn, defaultPriority);
// reestablish watchdog
NVIC_SetPriority(WDT_IRQn, NVIC_EncodePriority(priorityGrouping, 0, 0));
// make TIMER #2 2nd in line t the watchdog timer
NVIC_SetPriority(TIMER2_IRQn, NVIC_EncodePriority(priorityGrouping, 0, 1));
// this is the timer used in the mbed Ticker library
NVIC_SetPriority(TIMER3_IRQn, NVIC_EncodePriority(priorityGrouping, 0, 2));
// Brown-Out Detect
NVIC_SetPriority(BOD_IRQn, NVIC_EncodePriority(priorityGrouping, 0, 4));
// The I2C interface that's in use
NVIC_SetPriority(I2C2_IRQn, NVIC_EncodePriority(priorityGrouping, 1, 1));
// The SPI interface that's in use.
NVIC_SetPriority(SPI_IRQn, NVIC_EncodePriority(priorityGrouping, 1, 2));
// set UART (console) interrupts to minimal priority
// when debugging radio and other time sensitive operations, this
// interrupt will need to be deferred.
NVIC_SetPriority(UART0_IRQn, NVIC_EncodePriority(priorityGrouping, 1, 4));
__enable_irq();
}
开发者ID:dtbinh,项目名称:robocup-software,代码行数:48,代码来源:helper-funcs.cpp
示例18: a2fxxxm3EthInit
error_t a2fxxxm3EthInit(NetInterface *interface)
{
error_t error;
//Debug message
TRACE_INFO("Initializing A2FxxxM3 Ethernet MAC...\r\n");
//Save underlying network interface
nicDriverInterface = interface;
//Perform a software reset
MAC->CSR0 |= CSR0_SWR_MASK;
//Wait for the reset to complete
while(MAC->CSR0 & CSR0_SWR_MASK);
//PHY transceiver initialization
error = interface->phyDriver->init(interface);
//Failed to initialize PHY transceiver?
if(error) return error;
//Enable store and forward mode
MAC->CSR6 |= CSR6_SF_MASK;
//Initialize DMA descriptor lists
a2fxxxm3EthInitDmaDesc(interface);
//Enable the desired Ethernet interrupts
MAC->CSR7 |= CSR7_NIE_MASK | CSR7_RIE_MASK | CSR7_TIE_MASK;
//Set priority grouping (5 bits for pre-emption priority, no bits for subpriority)
NVIC_SetPriorityGrouping(A2FXXXM3_ETH_IRQ_PRIORITY_GROUPING);
//Configure Ethernet interrupt priority
NVIC_SetPriority(EthernetMAC_IRQn, NVIC_EncodePriority(A2FXXXM3_ETH_IRQ_PRIORITY_GROUPING,
A2FXXXM3_ETH_IRQ_GROUP_PRIORITY, A2FXXXM3_ETH_IRQ_SUB_PRIORITY));
//Enable transmission and reception
MAC->CSR6 |= CSR6_ST_MASK | CSR6_SR_MASK;
//Set MAC address
error = a2fxxxm3EthSendSetup(interface);
//Any error to report?
if(error) return error;
//Accept any packets from the upper layer
osSetEvent(&interface->nicTxEvent);
//Successful initialization
return NO_ERROR;
}
开发者ID:woo2,项目名称:gatekeeper-v2,代码行数:50,代码来源:a2fxxxm3_eth.c
示例19: SYSTIMER_Init
/*
* Initialization function which initializes the SYSTIMER APP, configures SysTick timer and SysTick exception.
*/
SYSTIMER_STATUS_t SYSTIMER_Init(SYSTIMER_t *handle)
{
SYSTIMER_STATUS_t status = SYSTIMER_STATUS_SUCCESS;
XMC_ASSERT("SYSTIMER_Init: SYSTIMER APP handle pointer uninitialized", (handle != NULL));
/* Check APP initialization status to ensure whether SYSTIMER_Init called or not, initialize SYSTIMER if
* SYSTIMER_Init called first time.
*/
if (false == handle->init_status)
{
#if (UC_FAMILY == XMC4)
/* Initialization of CPU_CTRL_XMC4 APP */
status = (SYSTIMER_STATUS_t)CPU_CTRL_XMC4_Init(CPU_CTRL_HANDLE);
#else
/* Initialization of CPU_CTRL_XMC1 APP */
status = (SYSTIMER_STATUS_t)CPU_CTRL_XMC1_Init(CPU_CTRL_HANDLE);
#endif
if (SYSTIMER_STATUS_FAILURE != status)
{
/* Initialize the header of the list */
g_timer_list = NULL;
/* Initialize SysTick timer */
status = (SYSTIMER_STATUS_t)SysTick_Config((uint32_t)(SYSTIMER_SYSTICK_CLOCK * SYSTIMER_TICK_PERIOD));
if (SYSTIMER_STATUS_FAILURE == status)
{
XMC_DEBUG("SYSTIMER_Init: Timer reload value out of range");
}
else
{
#if (UC_FAMILY == XMC4)
/* setting of First SW Timer period is always and subpriority value for XMC4000 devices */
NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(
NVIC_GetPriorityGrouping(), SYSTIMER_PRIORITY, SYSTIMER_SUBPRIORITY));
#elif (UC_FAMILY == XMC1)
/* setting of priority value for XMC1000 devices */
NVIC_SetPriority(SysTick_IRQn, SYSTIMER_PRIORITY);
#endif
g_timer_tracker = 0U;
/* Update the Initialization status of the SYSTIMER APP instance */
handle->init_status = true;
status = SYSTIMER_STATUS_SUCCESS;
}
}
}
return (status);
}
开发者ID:innot,项目名称:xmctests,代码行数:52,代码来源:systimer.c
示例20: TempUart_init
/*Channel initialization function*/
UART_STATUS_t TempUart_init()
{
UART_STATUS_t status = UART_STATUS_SUCCESS;
/*Configure Receive pin*/
XMC_GPIO_Init((XMC_GPIO_PORT_t *)PORT5_BASE, 0U, &TempUart_rx_pin_config);
/* Initialize USIC channel in UART mode*/
XMC_UART_CH_Init(XMC_UART0_CH0, &TempUart_channel_config);
/*Set input source path*/
XMC_USIC_CH_SetInputSource(XMC_UART0_CH0, XMC_USIC_CH_INPUT_DX0, 3U);
/* Start UART */
XMC_UART_CH_Start(XMC_UART0_CH0);
/* Initialize UART TX pin */
XMC_GPIO_Init((XMC_GPIO_PORT_t *)PORT5_BASE, 1U, &TempUart_tx_pin_config);
/*Set service request for transmit interrupt*/
XMC_USIC_CH_SetInterruptNodePointer(XMC_UART0_CH0, XMC_USIC_CH_INTERRUPT_NODE_POINTER_TRANSMIT_BUFFER,
3U);
/*Set service request for receive interrupt*/
XMC_USIC_CH_SetInterruptNodePointer(XMC_UART0_CH0, XMC_USIC_CH_INTERRUPT_NODE_POINTER_RECEIVE,
5U);
XMC_USIC_CH_SetInterruptNodePointer(XMC_UART0_CH0, XMC_USIC_CH_INTERRUPT_NODE_POINTER_ALTERNATE_RECEIVE,
5U);
/*Set service request for UART protocol events*/
XMC_USIC_CH_SetInterruptNodePointer(XMC_UART0_CH0, XMC_USIC_CH_INTERRUPT_NODE_POINTER_PROTOCOL,
0U);
/*Set priority and enable NVIC node for transmit interrupt*/
NVIC_SetPriority((IRQn_Type)87, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),
18U, 0U));
NVIC_EnableIRQ((IRQn_Type)87);
/*Set priority and enable NVIC node for receive interrupt*/
NVIC_SetPriority((IRQn_Type)89, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),
18U, 0U));
NVIC_EnableIRQ((IRQn_Type)89);
return status;
}
开发者ID:BHTes16,项目名称:ecarui,代码行数:37,代码来源:uart_conf.c
注:本文中的NVIC_EncodePriority函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论