feat(swan_r5): blink the LED on startup. set VUSB_SELECT and DISCHARGE to floating to avoid any potential issues with them being outputs.

This commit is contained in:
Matthew McGowan 2022-05-25 14:22:19 -07:00
parent 65a5ad09ab
commit 321163da1a

View File

@ -33,14 +33,19 @@
void initialize_discharge_pin(void) {
/* Initialize the 3V3 discharge to be OFF and the output power to be ON */
__HAL_RCC_GPIOE_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
/* Set the DISCHARGE pin and the USB_DETECT pin to FLOAT */
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
GPIO_InitStruct.Pin = GPIO_PIN_6;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_6, GPIO_PIN_SET);
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); /* PE6 DISCHRG */
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /* PC6 is USB_DETECT */
/* Turn on the 3V3 regulator */
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
GPIO_InitStruct.Pin = GPIO_PIN_4;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_4, GPIO_PIN_SET);
@ -53,6 +58,19 @@ void board_init(void) {
// Set tick interrupt priority, default HAL value is intentionally invalid
// Without this, USB does not function.
HAL_InitTick((1UL << __NVIC_PRIO_BITS) - 1UL);
initialize_discharge_pin();
__HAL_RCC_GPIOE_CLK_ENABLE();
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
GPIO_InitStruct.Pin = GPIO_PIN_2;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2, GPIO_PIN_SET);
HAL_Delay(50);
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2, GPIO_PIN_RESET);
}
bool board_requests_safe_mode(void) {
@ -60,7 +78,6 @@ bool board_requests_safe_mode(void) {
}
void reset_board(void) {
initialize_discharge_pin();
}
void board_deinit(void) {