zoukankan      html  css  js  c++  java
  • arm_cm4.c关于kinetis的修改

    /***********************************************************************/
    /*
     * Initialize the NVIC to enable the specified IRQ.
     * 
     * NOTE: The function only initializes the NVIC to enable a single IRQ. 
     * Interrupts will also need to be enabled in the ARM core. This can be 
     * done using the EnableInterrupts macro.
     *
     * Parameters:
     * irq    irq number to be enabled (the irq number NOT the vector number)
     */
    
    void enable_irq (int irq)
    {
        int div;
        
        /* Make sure that the IRQ is an allowable number. Right now up to 91 is 
         * used.
         */
        if (irq > 91)
            printf("
    ERR! Invalid IRQ value passed to enable irq function!
    ");
        
        /* Determine which of the NVICISERs corresponds to the irq */
        div = irq/32;
        
        switch (div)
        {
        	case 0x0:
                  NVICICPR0 = 1 << (irq%32);
                  NVICISER0 = 1 << (irq%32);
                  break;
        	case 0x1:
                  NVICICPR1 = 1 << (irq%32);
                  NVICISER1 = 1 << (irq%32);
                  break;
        	case 0x2:
                  NVICICPR2 = 1 << (irq%32);
                  NVICISER2 = 1 << (irq%32);
                  break;
        }              
    }
    /***********************************************************************/
    /*
     * Initialize the NVIC to disable the specified IRQ.
     * 
     * NOTE: The function only initializes the NVIC to disable a single IRQ. 
     * If you want to disable all interrupts, then use the DisableInterrupts
     * macro instead. 
     *
     * Parameters:
     * irq    irq number to be disabled (the irq number NOT the vector number)
     */
    
    void disable_irq (int irq)
    {
        int div;
        
        /* Make sure that the IRQ is an allowable number. Right now up to 91 is 
         * used.
         */
        if (irq > 91)
            printf("
    ERR! Invalid IRQ value passed to disable irq function!
    ");
        
        /* Determine which of the NVICICERs corresponds to the irq */
        div = irq/32;
        
        switch (div)
        {
        	case 0x0:
                   NVICICER0 = 1 << (irq%32);
                  break;
        	case 0x1:
                  NVICICER1 = 1 << (irq%32);
                  break;
        	case 0x2:
                  NVICICER2 = 1 << (irq%32);
                  break;
        }              
    }


    由于kinetis的寄存器的特殊性 ,arm_cm4.c文件中作相应修改如下:

    NVIC????|= 1<<(irq%32)  改为 NVIC????= 1<<(irq%32) 

    不然第二次操作中断,会清除第一次的设置


    
    
  • 相关阅读:
    分布式锁_00_资源帖
    JVM_总结_03_Java发展史
    JVM_总结_02_Java技术体系
    JVM_总结_00_资源帖
    分布式事务_03_2PC框架raincat源码解析-事务提交过程
    Java企业微信开发_15_查询企业微信域名对应的所有ip
    分布式事务_02_2PC框架raincat源码解析-启动过程
    Disruptor_学习_00_资源帖
    Git_学习_09_Commit message 和 Change log 编写指南
    分布式_事务_01_2PC框架raincat快速体验1
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/3239015.html
Copyright © 2011-2022 走看看