Smart Car Learning (16)--K60 single-chip computer exit external interrupt

Source: Internet
Author: User

First, the header file:
#ifndef _exti_h_#define_exti_h_typedefenumexti_cfg{Zero_down=0x08u,//low-level trigger, internal pull- downRising_down =0x09u,//rising edge trigger, internal pull- downFalling_down =0x0au,//Falling edge trigger, internal pull- downEither_down =0x0bu,//Jump edge trigger, internal pull- downOne_down =0X0CU,//high-level triggering, internal pull- down//pull up and pull down with the highest flagZERO_UP =0x88u,//low-level trigger, internal pull-upRISING_UP =0x89u,//rising edge trigger, internal pull-upFALLING_UP =0x8au,//Falling edge trigger, internal pull-upEITHER_UP =0x8bu,//Jump edge trigger, internal pull-upONE_UP =0X8CU      //high-level triggering, internal pull-up} exti_cfg;//External Interrupt InitializationvoidExti_init (Portx, U8 N, exti_cfg);#endif

Second, the source file
#include"Common.h"#include"gpio.h"#include"exti.h"/************************************************************************** function Name: exti_init* Function Description: Exti external GPIO Interrupt Initialization * Parameter description: Portx port number (porta,portb,portc,portd,porte) * N Port Pin * Exti_c FG trigger options and pull-down options * function return: no *************************************************************************/voidExti_init (portx portx, U8 N, exti_cfg cfg) {sim_scgc5|= (Sim_scgc5_porta_mask << portx);//turn on the portx portPort_pcr_reg (Portx[portx], N)= Port_pcr_mux (1) | PORT_PCR_IRQC (CFG &0x7f) | Port_pcr_pe_mask | (CFG &0x80) >>7);//re-use GPIO, determine trigger mode, turn on pull-up or pull-down resistorsGpio_pddr_reg (Gpiox[portx]) &= ~ (1<< N);//Input ModeENABLE_IRQ (Portx + the);//enable port interrupt, Porta's ISR interrupt number is}

Third, summary

This part of the API cannot specify the interrupt function = =, so the temporary shelving is not necessary.

Smart Car Learning (16)--K60 single-chip computer exit external interrupt

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.