This repository was archived by the owner on Jun 8, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 1515 * limitations under the License.
1616 */
1717#include " mbed-drivers/mbed.h"
18+ #include " minar/minar.h"
1819#include " uvisor-lib/uvisor-lib.h"
1920#include " btn.h"
2021#include " main-hw.h"
2122#include " box-challenge.h"
2223
24+ using mbed::util::FunctionPointer0;
25+
2326InterruptIn btn (MAIN_BTN);
2427extern Serial pc;
2528
@@ -33,10 +36,26 @@ static void btn_onpress(void)
3336 pc.printf (" done\n\r " );
3437}
3538
39+ static void btn_set_fall (void )
40+ {
41+ btn.fall (&btn_onpress);
42+ }
43+
3644void btn_init (void )
3745{
3846 /* configure pushbutton */
3947 btn.mode (MAIN_BTN_PUPD);
40- wait (.01 );
41- btn.fall (&btn_onpress);
48+
49+ /* Register the button fall handler after a short delay. */
50+ minar::Scheduler::postCallback (FunctionPointer0<void >(btn_set_fall).bind ())
51+ .delay (minar::milliseconds (10 ))
52+ .tolerance (minar::milliseconds (1 ));
53+
54+ /* Set a callback to do the equivalent of pushing the button for us. Every
55+ * period, press the button automatically. Pressing the button
56+ * automatically after a certain period of time allows us to trigger button
57+ * presses even for platforms without physically pressable buttons. */
58+ minar::Scheduler::postCallback (FunctionPointer0<void >(btn_onpress).bind ())
59+ .period (minar::milliseconds (10000 ))
60+ .tolerance (minar::milliseconds (100 ));
4261}
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ MAIN_ACL(g_main_acl);
3131UVISOR_SET_MODE_ACL (UVISOR_ENABLED, g_main_acl);
3232
3333DigitalOut led (MAIN_LED);
34- Serial pc (USBTX, USBRX );
34+ Serial pc (STDIO_UART_TX, STDIO_UART_RX );
3535
3636uint8_t g_challenge[CHALLENGE_SIZE];
3737minar::Scheduler *g_scheduler;
You can’t perform that action at this time.
0 commit comments