Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
00001 /** Dragonfly InterruptIn Example Program 00002 * 00003 * This program demonstrates how to handle external interrupts using the 00004 * MultiTech Dragonfly and MultiTech UDK2 hardware. The only 00005 * additional hardware required is a jumper wire. 00006 * 00007 * Pins are active low, so 0V = 0 and 5V/3.3V = 1. 00008 * 00009 * This program configures interrupt handlers for rising and falling edges 00010 * on pin D9. 00011 */ 00012 00013 #include "mbed.h" 00014 00015 // This line controls the regulator's battery charger. 00016 // BC_NCE = 0 enables the battery charger 00017 // BC_NCE = 1 disables the battery charger 00018 DigitalOut bc_nce(PB_2); 00019 00020 bool rise_flag = false; 00021 bool fall_flag = false; 00022 00023 void rise_handler(void) { 00024 rise_flag = true; 00025 } 00026 00027 void fall_handler(void) { 00028 fall_flag = true; 00029 } 00030 00031 int main() { 00032 // Disable the battery charger unless a battery is attached. 00033 bc_nce = 1; 00034 00035 InterruptIn in(D9); 00036 in.rise(&rise_handler); 00037 in.fall(&fall_handler); 00038 00039 while (true) { 00040 if (rise_flag) { 00041 printf("rising edge\r\n"); 00042 rise_flag = false; 00043 } 00044 if (fall_flag) { 00045 printf("falling edge\r\n"); 00046 fall_flag = false; 00047 } 00048 00049 wait_ms(100); 00050 } 00051 }
Generated on Mon Jul 18 2022 19:58:34 by
1.7.2