Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions hw/usb/tinyusb/stm32_fsdev/src/stm32_fsdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,44 @@ USB_IRQHandler(void)
tud_int_handler(0);
}

#define IS_PIN_MODE(m) MYNEWT_VAL_CHOICE(USB_DP_PULLUP_CONTROL_PIN_MODE, m)

void
dcd_disconnect(uint8_t rhport)
{
(void)rhport;

if (MYNEWT_VAL_USB_DP_PULLUP_CONTROL_PIN >= 0) {
if (IS_PIN_MODE(enable_1_disable_0) || IS_PIN_MODE(enable_input_disable_0)) {
hal_gpio_init_out(MYNEWT_VAL_USB_DP_PULLUP_CONTROL_PIN, 0);
} else if (IS_PIN_MODE(enable_0_disable_1) ||
IS_PIN_MODE(enable_input_disable_1)) {
hal_gpio_init_out(MYNEWT_VAL_USB_DP_PULLUP_CONTROL_PIN, 1);
} else if (IS_PIN_MODE(enable_0_disable_input) ||
IS_PIN_MODE(enable_1_disable_input)) {
hal_gpio_deinit(MYNEWT_VAL_USB_DP_PULLUP_CONTROL_PIN);
}
}
}

void
dcd_connect(uint8_t rhport)
{
(void)rhport;

if (MYNEWT_VAL_USB_DP_PULLUP_CONTROL_PIN >= 0) {
if (IS_PIN_MODE(enable_1_disable_0) || IS_PIN_MODE(enable_1_disable_input)) {
hal_gpio_init_out(MYNEWT_VAL(USB_DP_PULLUP_CONTROL_PIN), 1);
} else if (IS_PIN_MODE(enable_0_disable_1) ||
IS_PIN_MODE(enable_0_disable_input)) {
hal_gpio_init_out(MYNEWT_VAL(USB_DP_PULLUP_CONTROL_PIN), 0);
} else if (IS_PIN_MODE(enable_input_disable_0) ||
IS_PIN_MODE(enable_input_disable_1)) {
hal_gpio_deinit(MYNEWT_VAL(USB_DP_PULLUP_CONTROL_PIN));
}
}
}

void
tinyusb_hardware_init(void)
{
Expand All @@ -43,6 +81,7 @@ tinyusb_hardware_init(void)
NVIC_SetVector(USBWakeUp_IRQn, (uint32_t)USB_IRQHandler);
NVIC_SetPriority(USBWakeUp_IRQn, 2);

dcd_disconnect(0);
/*
* USB Pin Init
* PA11- DM, PA12- DP
Expand Down
27 changes: 0 additions & 27 deletions hw/usb/tinyusb/stm32_fsdev/stm32f3/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,3 @@
# under the License.
#

syscfg.defs:
USB_DP_PULLUP_CONTROL_PIN:
description: >
Set pin number (other then PA11) that connects 1.5k resistor to D+
value: -1

syscfg.defs.(USB_DP_PULLUP_CONTROL_PIN!=-1):
USB_DP_PULLUP_CONTROL_PIN_MODE:
description: >
1.5 kOhm Resistor can be connected directly to one of the output pins,
or it can use additional switch to connect resistor.
choices:
# Following two cases are used when 1.5k is connected when MCU is down
# and needs some control pin value to be shorted to ground
- enable_input_disable_0
- enable_input_disable_1
# This is rare case when both disable and enable requires control pin
# to be connected and set to certain value
- enable_1_disable_0
- enable_0_disable_1
# Current can be drawn directly from control PIN it there is not additional
# switching hardware element.
- enable_1_disable_input
# Case when resistor is connected from MCU pin via inverting transistor
# current is not drawn from MCU pin.
- enable_0_disable_input
value:
25 changes: 25 additions & 0 deletions hw/usb/tinyusb/stm32_fsdev/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,28 @@ syscfg.defs:
then device is discovered by host.
value: 1

USB_DP_PULLUP_CONTROL_PIN:
description: >
Set pin number (other then PA11) that connects 1.5k resistor to D+
value: -1

USB_DP_PULLUP_CONTROL_PIN_MODE:
description: >
1.5 kOhm Resistor can be connected directly to one of the output pins,
or it can use additional switch to connect resistor.
choices:
# Following two cases are used when 1.5k is connected when MCU is down
# and needs some control pin value to be shorted to ground
- enable_input_disable_0
- enable_input_disable_1
# This is rare case when both disable and enable requires control pin
# to be connected and set to certain value
- enable_1_disable_0
- enable_0_disable_1
# Current can be drawn directly from control PIN it there is not additional
# switching hardware element.
- enable_1_disable_input
# Case when resistor is connected from MCU pin via inverting transistor
# current is not drawn from MCU pin.
- enable_0_disable_input
value: enable_1_disable_0
Loading