📄 stm32f10x_nvic.lst
字号:
418 * Return : None
419 *******************************************************************************/
420 void NVIC_GenerateCoreReset(void)
421 {
422 SCB->AIRCR = AIRCR_VECTKEY_MASK | (u32)0x01;
423 }
424
425 /*******************************************************************************
426 * Function Name : NVIC_SystemLPConfig
427 * Description : Selects the condition for the system to enter low power mode.
428 * Input : - LowPowerMode: Specifies the new mode for the system to enter
429 * low power mode.
430 * This parameter can be one of the following values:
431 * - NVIC_LP_SEVONPEND
432 * - NVIC_LP_SLEEPDEEP
433 * - NVIC_LP_SLEEPONEXIT
434 * - NewState: new state of LP condition.
435 * This parameter can be: ENABLE or DISABLE.
436 * Output : None
437 * Return : None
438 *******************************************************************************/
439 void NVIC_SystemLPConfig(u8 LowPowerMode, FunctionalState NewState)
440 {
441 /* Check the parameters */
442 assert_param(IS_NVIC_LP(LowPowerMode));
443 assert_param(IS_FUNCTIONAL_STATE(NewState));
444
445 if (NewState != DISABLE)
446 {
447 SCB->SCR |= LowPowerMode;
448 }
449 else
450 {
451 SCB->SCR &= (u32)(~(u32)LowPowerMode);
452 }
453 }
454
455 /*******************************************************************************
456 * Function Name : NVIC_SystemHandlerConfig
457 * Description : Enables or disables the specified System Handlers.
458 * Input : - SystemHandler: specifies the system handler to be enabled
459 * or disabled.
460 * This parameter can be one of the following values:
461 * - SystemHandler_MemoryManage
462 * - SystemHandler_BusFault
463 * - SystemHandler_UsageFault
464 * - NewState: new state of specified System Handlers.
465 * This parameter can be: ENABLE or DISABLE.
466 * Output : None
467 * Return : None
468 *******************************************************************************/
469 void NVIC_SystemHandlerConfig(u32 SystemHandler, FunctionalState NewState)
470 {
471 u32 tmpreg = 0x00;
472
473 /* Check the parameters */
474 assert_param(IS_CONFIG_SYSTEM_HANDLER(SystemHandler));
475 assert_param(IS_FUNCTIONAL_STATE(NewState));
476
477 tmpreg = (u32)0x01 << (SystemHandler & (u32)0x1F);
478
479 if (NewState != DISABLE)
480 {
481 SCB->SHCSR |= tmpreg;
482 }
483 else
484 {
485 SCB->SHCSR &= ~tmpreg;
486 }
487 }
488
489 /*******************************************************************************
490 * Function Name : NVIC_SystemHandlerPriorityConfig
491 * Description : Configures the specified System Handlers priority.
492 * Input : - SystemHandler: specifies the system handler to be
493 * enabled or disabled.
494 * This parameter can be one of the following values:
495 * - SystemHandler_MemoryManage
496 * - SystemHandler_BusFault
497 * - SystemHandler_UsageFault
498 * - SystemHandler_SVCall
499 * - SystemHandler_DebugMonitor
500 * - SystemHandler_PSV
501 * - SystemHandler_SysTick
502 * - SystemHandlerPreemptionPriority: new priority group of the
503 * specified system handlers.
504 * - SystemHandlerSubPriority: new sub priority of the specified
505 * system handlers.
506 * Output : None
507 * Return : None
508 *******************************************************************************/
509 void NVIC_SystemHandlerPriorityConfig(u32 SystemHandler, u8 SystemHandlerPreemptionPriority,
510 u8 SystemHandlerSubPriority)
511 {
512 u32 tmp1 = 0x00, tmp2 = 0xFF, handlermask = 0x00;
513 u32 tmppriority = 0x00;
514
515 /* Check the parameters */
516 assert_param(IS_PRIORITY_SYSTEM_HANDLER(SystemHandler));
517 assert_param(IS_NVIC_PREEMPTION_PRIORITY(SystemHandlerPreemptionPriority));
518 assert_param(IS_NVIC_SUB_PRIORITY(SystemHandlerSubPriority));
519
520 tmppriority = (0x700 - (SCB->AIRCR & (u32)0x700))>> 0x08;
521 tmp1 = (0x4 - tmppriority);
522 tmp2 = tmp2 >> tmppriority;
523
524 tmppriority = (u32)SystemHandlerPreemptionPriority << tmp1;
525 tmppriority |= SystemHandlerSubPriority & tmp2;
526
527 tmppriority = tmppriority << 0x04;
528 tmp1 = SystemHandler & (u32)0xC0;
529 tmp1 = tmp1 >> 0x06;
530 tmp2 = (SystemHandler >> 0x08) & (u32)0x03;
531 tmppriority = tmppriority << (tmp2 * 0x08);
532 handlermask = (u32)0xFF << (tmp2 * 0x08);
533
534 SCB->SHPR[tmp1] &= ~handlermask;
535 SCB->SHPR[tmp1] |= tmppriority;
536 }
537
538 /*******************************************************************************
539 * Function Name : NVIC_GetSystemHandlerPendingBitStatus
540 * Description : Checks whether the specified System handlers pending bit is
541 * set or not.
542 * Input : - SystemHandler: specifies the system handler pending bit to
543 * check.
544 * This parameter can be one of the following values:
545 * - SystemHandler_MemoryManage
546 * - SystemHandler_BusFault
547 * - SystemHandler_SVCall
548 * Output : None
549 * Return : The new state of System Handler pending bit(SET or RESET).
550 *******************************************************************************/
551 ITStatus NVIC_GetSystemHandlerPendingBitStatus(u32 SystemHandler)
552 {
553 ITStatus bitstatus = RESET;
554 u32 tmp = 0x00, tmppos = 0x00;
555
556 /* Check the parameters */
557 assert_param(IS_GET_PENDING_SYSTEM_HANDLER(SystemHandler));
558
559 tmppos = (SystemHandler >> 0x0A);
560 tmppos &= (u32)0x0F;
561
562 tmppos = (u32)0x01 << tmppos;
563
564 tmp = SCB->SHCSR & tmppos;
565
566 if (tmp == tmppos)
567 {
568 bitstatus = SET;
569 }
570 else
571 {
572 bitstatus = RESET;
573 }
574 return bitstatus;
575 }
576
577 /*******************************************************************************
578 * Function Name : NVIC_SetSystemHandlerPendingBit
579 * Description : Sets System Handler pending bit.
580 * Input : - SystemHandler: specifies the system handler pending bit
581 * to be set.
582 * This parameter can be one of the following values:
583 * - SystemHandler_NMI
584 * - SystemHandler_PSV
585 * - SystemHandler_SysTick
586 * Output : None
587 * Return : None
588 *******************************************************************************/
589 void NVIC_SetSystemHandlerPendingBit(u32 SystemHandler)
590 {
591 u32 tmp = 0x00;
592
593 /* Check the parameters */
594 assert_param(IS_SET_PENDING_SYSTEM_HANDLER(SystemHandler));
595
596 /* Get the System Handler pending bit position */
597 tmp = SystemHandler & (u32)0x1F;
598 /* Set the corresponding System Handler pending bit */
599 SCB->ICSR |= ((u32)0x01 << tmp);
600 }
601
602 /*******************************************************************************
603 * Function Name : NVIC_ClearSystemHandlerPendingBit
604 * Description : Clears System Handler pending bit.
605 * Input : - SystemHandler: specifies the system handler pending bit to
606 * be clear.
607 * This parameter can be one of the following values:
608 * - SystemHandler_PSV
609 * - SystemHandler_SysTick
610 * Output : None
611 * Return : None
612 *******************************************************************************/
613 void NVIC_ClearSystemHandlerPendingBit(u32 SystemHandler)
614 {
615 u32 tmp = 0x00;
616
617 /* Check the parameters */
618 assert_param(IS_CLEAR_SYSTEM_HANDLER(SystemHandler));
619
620 /* Get the System Handler pending bit position */
621 tmp = SystemHandler & (u32)0x1F;
622 /* Clear the corresponding System Handler pending bit */
623 SCB->ICSR |= ((u32)0x01 << (tmp - 0x01));
624 }
625
626 /*******************************************************************************
627 * Function Name : NVIC_GetSystemHandlerActiveBitStatus
628 * Description : Checks whether the specified System handlers active bit is
629 * set or not.
630 * Input : - SystemHandler: specifies the system handler active bit to
631 * check.
632 * This parameter can be one of the following values:
633 * - SystemHandler_MemoryManage
634 * - SystemHandler_BusFault
635 * - SystemHandler_UsageFault
636 * - SystemHandler_SVCall
637 * - SystemHandler_DebugMonitor
638 * - SystemHandler_PSV
639 * - SystemHandler_SysTick
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -