智能車學習(十六)——K60單片機EXIT外部中斷

來源:互聯網
上載者:User

標籤:

一、標頭檔:
#ifndef _EXTI_H_#define _EXTI_H_typedef enum exti_cfg{    zero_down     = 0x08u,     //低電平觸發,內部下拉    rising_down   = 0x09u,     //上升沿觸發,內部下拉    falling_down  = 0x0Au,     //下降沿觸發,內部下拉    either_down   = 0x0Bu,     //跳變沿觸發,內部下拉    one_down      = 0x0Cu,     //高電平觸發,內部下拉    //用最高位標誌上拉和下拉    zero_up       = 0x88u,     //低電平觸發,內部上拉    rising_up     = 0x89u,     //上升沿觸發,內部上拉    falling_up    = 0x8Au,     //下降沿觸發,內部上拉    either_up     = 0x8Bu,     //跳變沿觸發,內部上拉    one_up        = 0x8Cu      //高電平觸發,內部上拉} exti_cfg;//外部中斷初始化void  exti_init(PORTx, u8 n, exti_cfg);#endif

 

二、源檔案
#include "common.h"#include "gpio.h"#include "exti.h"/**************************************************************************  函數名稱:exti_init*  功能說明:EXTI外部GPIO中斷初始化*  參數說明:PORTx       連接埠號碼(PORTA,PORTB,PORTC,PORTD,PORTE)*            n           連接埠引腳*            exti_cfg    觸發選項和上拉下拉選項*  函數返回:無*************************************************************************/void  exti_init(PORTx portx, u8 n, exti_cfg cfg){    SIM_SCGC5 |= (SIM_SCGC5_PORTA_MASK << portx);    //開啟PORTx連接埠    PORT_PCR_REG(PORTX[portx], n) = PORT_PCR_MUX(1) | PORT_PCR_IRQC(cfg & 0x7f ) | PORT_PCR_PE_MASK | ((cfg & 0x80 ) >> 7); // 複用GPIO , 確定觸發模式 ,開啟上拉或下拉電阻    GPIO_PDDR_REG(GPIOx[portx]) &= ~(1 << n);       //輸入模式    enable_irq(portx + 87);                         //使能PORT中斷,PORTA的ISR中斷號為87}

 

 

三、小結

       這部分的API不能指定中斷函數= =,所以暫時擱置不用。

智能車學習(十六)——K60單片機EXIT外部中斷

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.