1.2. GPIO interrupt - Button detection
This demo is based on GPIO external interrupt mode.
1.2.1. Hardware Connection
This demo is based on BL706_IOT, add the button circuit by yourself, the connection method is as follows
GPIO function GPIO pin
----------------------------------
SW1 <--> GPIO11
1.2.2. Software Implementation
See
examples/gpio/gpio_int
for the software code
1static void gpio11_int_callback(uint32_t pin)
2{
3 MSG("gpio rising trigger !\r\n");
4}
5
6gpio_set_mode(GPIO_PIN_11,GPIO_SYNC_RISING_TRIGER_INT_MODE);
7gpio_attach_irq(GPIO_PIN_11,gpio11_int_callback);
8gpio_irq_enable(GPIO_PIN_11,ENABLE);
Use the above code to configure
GPIO11
as the GPIO rising edge interrupt trigger mode, and register the interrupt callback function.
1.2.3. Compile and Program
CDK compilation
Open project:gpio_int.cdkproj
Refer to the steps of Guide to using CDK (like MDK Keil) under Windows to compile and download
Command compilation
1 $ cd <sdk_path>/bl_mcu_sdk
2 $ make BOARD=bl706_iot APP=gpio_int
Program
1.2.4. Experimental Phenomena
When the button is pressed, the serial port will print "gpio rising trigger !"