usb not working...

This commit is contained in:
Hierophect 2019-12-12 17:53:04 -05:00
parent e4fb414b91
commit 99c02b5afb
2 changed files with 29 additions and 12 deletions

View File

@ -2,6 +2,15 @@
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_PB04) },
{ MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_PB05) }
{ MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_PB05) },
// { MP_ROM_QSTR(MP_QSTR_LED_DISP_SCK), MP_ROM_PTR(&pin_PB13) },
// { MP_ROM_QSTR(MP_QSTR_LED_DISP_MISO), MP_ROM_PTR(&pin_PB14) },
// { MP_ROM_QSTR(MP_QSTR_LED_DISP_MOSI), MP_ROM_PTR(&pin_PB15) },
// { MP_ROM_QSTR(MP_QSTR_LED_DISP_CS), MP_ROM_PTR(&pin_PB12) },
// { MP_ROM_QSTR(MP_QSTR_LED_DISP_DC), MP_ROM_PTR(&pin_PA08) },
// { MP_ROM_QSTR(MP_QSTR_LED_DISP_RST), MP_ROM_PTR(&pin_PB10) },
// { MP_ROM_QSTR(MP_QSTR_LED_DISP_BL), MP_ROM_PTR(&pin_PB03) }
};
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

View File

@ -36,15 +36,15 @@
#include "common-hal/microcontroller/Pin.h"
STATIC void disable_usb_vbus(void) {
#ifdef USB_OTG_GCCFG_VBDEN
USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN;
#else
USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS;
USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN;
USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN;
#endif
}
// STATIC void disable_usb_vbus(void) {
// #ifdef USB_OTG_GCCFG_VBDEN
// USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN;
// #else
// USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS;
// USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN;
// USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN;
// #endif
// }
void init_usb_hardware(void) {
//TODO: if future chips overload this with options, move to peripherals management.
@ -92,8 +92,16 @@ void init_usb_hardware(void) {
never_reset_pin_number(0, 8);
#endif
#ifdef BOARD_NO_VBUS
disable_usb_vbus();
// #ifdef BOARD_NO_VBUS
// disable_usb_vbus();
// #endif
#ifdef USB_OTG_GCCFG_VBDEN
USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN;
#else
USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS;
USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN;
USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN;
#endif
/* Peripheral clock enable */