updated cdc_enabled; now more dynamic status return

This commit is contained in:
sommersoft 2018-03-24 03:42:58 +00:00
parent 8c9cc6b7c0
commit 6205ed9a0c

View File

@ -227,17 +227,17 @@ void init_usb(void) {
} }
static bool cdc_enabled(void) { static bool cdc_enabled(void) {
if (mp_cdc_enabled) {
return true;
}
if (!cdcdf_acm_is_enabled()) { if (!cdcdf_acm_is_enabled()) {
mp_cdc_enabled = false;
return false; return false;
} }
if (!mp_cdc_enabled) {
cdcdf_acm_register_callback(CDCDF_ACM_CB_READ, (FUNC_PTR)read_complete); cdcdf_acm_register_callback(CDCDF_ACM_CB_READ, (FUNC_PTR)read_complete);
cdcdf_acm_register_callback(CDCDF_ACM_CB_WRITE, (FUNC_PTR)write_complete); cdcdf_acm_register_callback(CDCDF_ACM_CB_WRITE, (FUNC_PTR)write_complete);
cdcdf_acm_register_callback(CDCDF_ACM_CB_STATE_C, (FUNC_PTR)usb_device_cb_state_c); cdcdf_acm_register_callback(CDCDF_ACM_CB_STATE_C, (FUNC_PTR)usb_device_cb_state_c);
cdcdf_acm_register_callback(CDCDF_ACM_CB_LINE_CODING_C, (FUNC_PTR)usb_device_cb_line_coding_c); cdcdf_acm_register_callback(CDCDF_ACM_CB_LINE_CODING_C, (FUNC_PTR)usb_device_cb_line_coding_c);
mp_cdc_enabled = true; mp_cdc_enabled = true;
}
return true; return true;
} }