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.
Homepage
This code can be used as a template to create a library where a single pin can be set to either InterruptIn or DigitalOut.
There are 3 ways to instantiate the library (example using the KL25Z board):
// 2 parameters : Only SDA and SCL are declared. DemoClass sensor(PTE0, PTE1); // 3 parameters : SDA, SCL and a DigitalOut are declared. DemoClass sensor(PTE0, PTE1, PTD7); // SDA, SCL // 4 parameters : SDA, SCL, InterruptIn and a user function pointer are declared. DemoClass sensor(PTE0, PTE1, PTD7, &sensor_irq); // ISR mode
Notice that the 3rd pin declaration switches from DigitalOut to InterruptIn when the user function pointer is added.