📄 stm32f10x_nvic.lst
字号:
493
494 /*******************************************************************************
495 * Function Name : NVIC_SystemHandlerPriorityConfig
496 * Description : Configures the specified System Handlers priority.
497 * Input : - SystemHandler: specifies the system handler to be
498 * enabled or disabled.
499 * This parameter can be one of the following values:
500 * - SystemHandler_MemoryManage
501 * - SystemHandler_BusFault
502 * - SystemHandler_UsageFault
503 * - SystemHandler_SVCall
504 * - SystemHandler_DebugMonitor
505 * - SystemHandler_PSV
506 * - SystemHandler_SysTick
507 * - SystemHandlerPreemptionPriority: new priority group of the
508 * specified system handlers.
509 * - SystemHandlerSubPriority: new sub priority of the specified
510 * system handlers.
511 * Output : None
512 * Return : None
513 *******************************************************************************/
514 void NVIC_SystemHandlerPriorityConfig(u32 SystemHandler, u8 SystemHandlerPreemptionPriority,
515 u8 SystemHandlerSubPriority)
516 {
517 u32 tmp1 = 0x00, tmp2 = 0xFF, handlermask = 0x00;
518 u32 tmppriority = 0x00;
519
520 /* Check the parameters */
521 assert(IS_PRIORITY_SYSTEM_HANDLER(SystemHandler));
522 assert(IS_NVIC_PREEMPTION_PRIORITY(SystemHandlerPreemptionPriority));
523 assert(IS_NVIC_SUB_PRIORITY(SystemHandlerSubPriority));
524
525 tmppriority = (0x700 - (SCB->AIRC & (u32)0x700))>> 0x08;
526 tmp1 = (0x4 - tmppriority);
527 tmp2 = tmp2 >> tmppriority;
528
529 tmppriority = (u32)SystemHandlerPreemptionPriority << tmp1;
530 tmppriority |= SystemHandlerSubPriority & tmp2;
531
532 tmppriority = tmppriority << 0x04;
533 tmp1 = SystemHandler & (u32)0xC0;
534 tmp1 = tmp1 >> 0x06;
535 tmp2 = (SystemHandler >> 0x08) & (u32)0x03;
536 tmppriority = tmppriority << (tmp2 * 0x08);
537 handlermask = (u32)0xFF << (tmp2 * 0x08);
538
539 SCB->SystemPriority[tmp1] &= ~handlermask;
540 SCB->SystemPriority[tmp1] |= tmppriority;
541 }
542
543 /*******************************************************************************
544 * Function Name : NVIC_GetSystemHandlerPendingBitStatus
545 * Description : Checks whether the specified System handlers pending bit is
546 * set or not.
547 * Input : - SystemHandler: specifies the system handler pending bit to
548 * check.
549 * This parameter can be one of the following values:
550 * - SystemHandler_MemoryManage
551 * - SystemHandler_BusFault
552 * - SystemHandler_SVCall
553 * Output : None
554 * Return : The new state of System Handler pending bit(SET or RESET).
555 *******************************************************************************/
556 ITStatus NVIC_GetSystemHandlerPendingBitStatus(u32 SystemHandler)
557 {
558 ITStatus bitstatus = RESET;
559 u32 tmp = 0x00, tmppos = 0x00;
560
561 /* Check the parameters */
562 assert(IS_GET_PENDING_SYSTEM_HANDLER(SystemHandler));
563
564 tmppos = (SystemHandler >> 0x0A);
565 tmppos &= (u32)0x0F;
566
567 tmppos = (u32)0x01 << tmppos;
568
569 tmp = SCB->SysHandlerCtrl & tmppos;
570
571 if (tmp == tmppos)
572 {
573 bitstatus = SET;
574 }
575 else
576 {
577 bitstatus = RESET;
578 }
579 return bitstatus;
580 }
581
582 /*******************************************************************************
583 * Function Name : NVIC_SetSystemHandlerPendingBit
584 * Description : Sets System Handler pending bit.
585 * Input : - SystemHandler: specifies the system handler pending bit
586 * to be set.
587 * This parameter can be one of the following values:
588 * - SystemHandler_NMI
589 * - SystemHandler_PSV
590 * - SystemHandler_SysTick
591 * Output : None
592 * Return : None
593 *******************************************************************************/
594 void NVIC_SetSystemHandlerPendingBit(u32 SystemHandler)
595 {
596 u32 tmp = 0x00;
597
598 /* Check the parameters */
599 assert(IS_SET_PENDING_SYSTEM_HANDLER(SystemHandler));
600
601 /* Get the System Handler pending bit position */
602 tmp = SystemHandler & (u32)0x1F;
603 /* Set the corresponding System Handler pending bit */
604 SCB->IRQControlState |= ((u32)0x01 << tmp);
605 }
606
607 /*******************************************************************************
608 * Function Name : NVIC_ClearSystemHandlerPendingBit
609 * Description : Clears System Handler pending bit.
610 * Input : - SystemHandler: specifies the system handler pending bit to
611 * be clear.
612 * This parameter can be one of the following values:
613 * - SystemHandler_PSV
614 * - SystemHandler_SysTick
615 * Output : None
616 * Return : None
617 *******************************************************************************/
618 void NVIC_ClearSystemHandlerPendingBit(u32 SystemHandler)
619 {
620 u32 tmp = 0x00;
621
622 /* Check the parameters */
623 assert(IS_CLEAR_SYSTEM_HANDLER(SystemHandler));
624
625 /* Get the System Handler pending bit position */
626 tmp = SystemHandler & (u32)0x1F;
627 /* Clear the corresponding System Handler pending bit */
628 SCB->IRQControlState |= ((u32)0x01 << (tmp - 0x01));
629 }
630
631 /*******************************************************************************
632 * Function Name : NVIC_GetSystemHandlerActiveBitStatus
633 * Description : Checks whether the specified System handlers active bit is
634 * set or not.
635 * Input : - SystemHandler: specifies the system handler active bit to
636 * check.
637 * This parameter can be one of the following values:
638 * - SystemHandler_MemoryManage
639 * - SystemHandler_BusFault
640 * - SystemHandler_UsageFault
641 * - SystemHandler_SVCall
642 * - SystemHandler_DebugMonitor
643 * - SystemHandler_PSV
644 * - SystemHandler_SysTick
645 * Output : None
646 * Return : The new state of System Handler active bit(SET or RESET).
647 *******************************************************************************/
648 ITStatus NVIC_GetSystemHandlerActiveBitStatus(u32 SystemHandler)
649 {
650 ITStatus bitstatus = RESET;
651
652 u32 tmp = 0x00, tmppos = 0x00;
653
654 /* Check the parameters */
655 assert(IS_GET_ACTIVE_SYSTEM_HANDLER(SystemHandler));
656
657 tmppos = (SystemHandler >> 0x0E) & (u32)0x0F;
658
659 tmppos = (u32)0x01 << tmppos;
660
661 tmp = SCB->SysHandlerCtrl & tmppos;
662
663 if (tmp == tmppos)
664 {
665 bitstatus = SET;
666 }
667 else
668 {
669 bitstatus = RESET;
670 }
671 return bitstatus;
672 }
673
674 /*******************************************************************************
675 * Function Name : NVIC_GetFaultHandlerSources
676 * Description : Returns the system fault handlers sources.
677 * Input : - SystemHandler: specifies the system handler to get its fault
678 * sources.
679 * This parameter can be one of the following values:
680 * - SystemHandler_HardFault
681 * - SystemHandler_MemoryManage
682 * - SystemHandler_BusFault
683 * - SystemHandler_UsageFault
684 * - SystemHandler_DebugMonitor
685 * Output : None
686 * Return : Source of the fault handler.
687 *******************************************************************************/
688 u32 NVIC_GetFaultHandlerSources(u32 SystemHandler)
689 {
690 u32 faultsources = 0x00;
691 u32 tmpreg = 0x00, tmppos = 0x00;
692
693 /* Check the parameters */
694 assert(IS_FAULT_SOURCE_SYSTEM_HANDLER(SystemHandler));
695
696 tmpreg = (SystemHandler >> 0x12) & (u32)0x03;
697 tmppos = (SystemHandler >> 0x14) & (u32)0x03;
698
699 if (tmpreg == 0x00)
700 {
701 faultsources = SCB->HardFaultStatus;
702 }
703 else if (tmpreg == 0x01)
704 {
705 faultsources = SCB->ConfigFaultStatus >> (tmppos * 0x08);
706 if (tmppos != 0x02)
707 {
708 faultsources &= (u32)0x0F;
709 }
710 else
711 {
712 faultsources &= (u32)0xFF;
713 }
714 }
715 else
716 {
717 faultsources = SCB->DebugFaultStatus;
718 }
719 return faultsources;
720 }
721
722 /*******************************************************************************
723 * Function Name : NVIC_GetFaultAddress
724 * Description : Returns the address of the location that generated a fault
725 * handler.
726 * Input : - SystemHandler: specifies the system handler to get its
727 * fault address.
728 * This parameter can be one of the following values:
729 * - SystemHandler_MemoryManage
730 * - SystemHandler_BusFault
731 * Output : None
732 * Return : Fault address.
733 *******************************************************************************/
734 u32 NVIC_GetFaultAddress(u32 SystemHandler)
735 {
736 u32 faultaddress = 0x00;
737 u32 tmp = 0x00;
738
739 /* Check the parameters */
740 assert(IS_FAULT_ADDRESS_SYSTEM_HANDLER(SystemHandler));
741
742 tmp = (SystemHandler >> 0x16) & (u32)0x01;
743
744 if (tmp == 0x00)
745 {
746 faultaddress = SCB->MemoryManageFaultAddr;
747 }
748 else
749 {
750 faultaddress = SCB->BusFaultAddr;
751 }
752 return faultaddress;
753 }
754
755 /******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/
Errors: 1
Warnings: none
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -