📄 stm32f10x_nvic.lst
字号:
418 /*******************************************************************************
419 * Function Name : NVIC_GenerateCoreReset
420 * Description : Generates a Core (Core + NVIC) reset.
421 * Input : None
422 * Output : None
423 * Return : None
424 *******************************************************************************/
425 void NVIC_GenerateCoreReset(void)
426 {
427 SCB->AIRC = AIRC_VECTKEY_MASK | (u32)0x01;
428 }
429
430 /*******************************************************************************
431 * Function Name : NVIC_SystemLPConfig
432 * Description : Selects the condition for the system to enter low power mode.
433 * Input : - LowPowerMode: Specifies the new mode for the system to enter
434 * low power mode.
435 * This parameter can be one of the following values:
436 * - NVIC_LP_SEVONPEND
437 * - NVIC_LP_SLEEPDEEP
438 * - NVIC_LP_SLEEPONEXIT
439 * - NewState: new state of LP condition.
440 * This parameter can be: ENABLE or DISABLE.
441 * Output : None
442 * Return : None
443 *******************************************************************************/
444 void NVIC_SystemLPConfig(u8 LowPowerMode, FunctionalState NewState)
445 {
446 /* Check the parameters */
447 assert(IS_NVIC_LP(LowPowerMode));
448 assert(IS_FUNCTIONAL_STATE(NewState));
449
450 if (NewState != DISABLE)
451 {
452 SCB->SysCtrl |= LowPowerMode;
453 }
454 else
455 {
456 SCB->SysCtrl &= (u32)(~(u32)LowPowerMode);
457 }
458 }
459
460 /*******************************************************************************
461 * Function Name : NVIC_SystemHandlerConfig
462 * Description : Enables or disables the specified System Handlers.
463 * Input : - SystemHandler: specifies the system handler to be enabled
464 * or disabled.
465 * This parameter can be one of the following values:
466 * - SystemHandler_MemoryManage
467 * - SystemHandler_BusFault
468 * - SystemHandler_UsageFault
469 * - NewState: new state of specified System Handlers.
470 * This parameter can be: ENABLE or DISABLE.
471 * Output : None
472 * Return : None
473 *******************************************************************************/
474 void NVIC_SystemHandlerConfig(u32 SystemHandler, FunctionalState NewState)
475 {
476 u32 tmpreg = 0x00;
477
478 /* Check the parameters */
479 assert(IS_CONFIG_SYSTEM_HANDLER(SystemHandler));
480 assert(IS_FUNCTIONAL_STATE(NewState));
481
482 tmpreg = (u32)0x01 << (SystemHandler & (u32)0x1F);
483
484 if (NewState != DISABLE)
485 {
486 SCB->SysHandlerCtrl |= tmpreg;
487 }
488 else
489 {
490 SCB->SysHandlerCtrl &= ~tmpreg;
491 }
492 }
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)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -