diff options
author | Damien George <damien.p.george@gmail.com> | 2014-03-30 00:00:15 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-03-30 00:00:15 +0000 |
commit | 038df4318362325b5b6b77f7582fb6373a240f3c (patch) | |
tree | 412143786f23fc67681f44f0673ee72f2a6a7f0d /stmhal/usrsw.c | |
parent | d40d8f1e168c5bc3cf52f51d9592425574e7e6a9 (diff) | |
download | micropython-038df4318362325b5b6b77f7582fb6373a240f3c.tar.gz micropython-038df4318362325b5b6b77f7582fb6373a240f3c.zip |
stmhal: Implement selector for USB device mode; improve boot up.
Can now choose at boot up whether the USB device is CDC+MSC or CDC+HID.
Choice is made by an option in boot.py, with default being CDC+MSC.
HID+MSC is not currently supported, but should be easy to implement.
Boot up now has ability to change the reset mode: hold down USR switch
while booting and LEDs will count from 1 to 7 to indicate the boot mode.
Release USR when correct mode is selected. Current modes are 1 (normal
boot), 2 (safe mode), 3 (reset FS mode).
Diffstat (limited to 'stmhal/usrsw.c')
-rw-r--r-- | stmhal/usrsw.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/stmhal/usrsw.c b/stmhal/usrsw.c index 69a03b2cc3..60032c4ecb 100644 --- a/stmhal/usrsw.c +++ b/stmhal/usrsw.c @@ -39,6 +39,17 @@ static mp_obj_t switch_callback(mp_obj_t line) { } static MP_DEFINE_CONST_FUN_OBJ_1(switch_callback_obj, switch_callback); +// this function inits the switch GPIO so that it can be used +void switch_init0(void) { + GPIO_InitTypeDef init; + init.Pin = USRSW_PIN.pin_mask; + init.Mode = GPIO_MODE_INPUT; + init.Pull = USRSW_PULL; + init.Speed = GPIO_SPEED_FAST; + HAL_GPIO_Init(USRSW_PIN.gpio, &init); +} + +// this function inits the callback and EXTI function of the switch void switch_init(void) { switch_user_callback_obj = mp_const_none; exti_register((mp_obj_t)&USRSW_PIN, |