Merge pull request #6458 from blues/swan_r5_3v3_enable
fix(swan_r5): 3v3 was enabled but then immediately reset.
This commit is contained in:
commit
562c73bcc7
@ -30,11 +30,27 @@
|
|||||||
#include "stm32l4xx.h"
|
#include "stm32l4xx.h"
|
||||||
#include "stm32l4r5xx.h"
|
#include "stm32l4r5xx.h"
|
||||||
|
|
||||||
|
#include "shared-bindings/microcontroller/Pin.h"
|
||||||
|
#include "shared-bindings/digitalio/DigitalInOut.h"
|
||||||
|
#include "shared-bindings/digitalio/Direction.h"
|
||||||
|
#include "shared-bindings/digitalio/DriveMode.h"
|
||||||
|
#include "board.h"
|
||||||
|
|
||||||
|
digitalio_digitalinout_obj_t power_pin = { .base.type = &digitalio_digitalinout_type };
|
||||||
|
digitalio_digitalinout_obj_t discharge_pin = { .base.type = &digitalio_digitalinout_type };
|
||||||
|
|
||||||
void initialize_discharge_pin(void) {
|
void initialize_discharge_pin(void) {
|
||||||
|
|
||||||
/* Initialize the 3V3 discharge to be OFF and the output power to be ON */
|
/* Initialize the 3V3 discharge to be OFF and the output power to be ON */
|
||||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||||
|
|
||||||
|
|
||||||
|
common_hal_digitalio_digitalinout_construct(&power_pin, &pin_PE04);
|
||||||
|
common_hal_digitalio_digitalinout_construct(&discharge_pin, &pin_PE06);
|
||||||
|
common_hal_digitalio_digitalinout_never_reset(&power_pin);
|
||||||
|
common_hal_digitalio_digitalinout_never_reset(&discharge_pin);
|
||||||
|
|
||||||
GPIO_InitTypeDef GPIO_InitStruct;
|
GPIO_InitTypeDef GPIO_InitStruct;
|
||||||
/* Set the DISCHARGE pin and the USB_DETECT pin to FLOAT */
|
/* Set the DISCHARGE pin and the USB_DETECT pin to FLOAT */
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||||
@ -49,6 +65,7 @@ void initialize_discharge_pin(void) {
|
|||||||
GPIO_InitStruct.Pin = GPIO_PIN_4;
|
GPIO_InitStruct.Pin = GPIO_PIN_4;
|
||||||
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||||
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_4, GPIO_PIN_SET);
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_4, GPIO_PIN_SET);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void board_init(void) {
|
void board_init(void) {
|
||||||
@ -59,8 +76,6 @@ void board_init(void) {
|
|||||||
// Without this, USB does not function.
|
// Without this, USB does not function.
|
||||||
HAL_InitTick((1UL << __NVIC_PRIO_BITS) - 1UL);
|
HAL_InitTick((1UL << __NVIC_PRIO_BITS) - 1UL);
|
||||||
|
|
||||||
initialize_discharge_pin();
|
|
||||||
|
|
||||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||||
GPIO_InitTypeDef GPIO_InitStruct;
|
GPIO_InitTypeDef GPIO_InitStruct;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
@ -78,6 +93,7 @@ bool board_requests_safe_mode(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void reset_board(void) {
|
void reset_board(void) {
|
||||||
|
initialize_discharge_pin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void board_deinit(void) {
|
void board_deinit(void) {
|
||||||
|
10
ports/stm/boards/swan_r5/board.h
Normal file
10
ports/stm/boards/swan_r5/board.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef _BOARDS_SWAN_R5_BOARD_H_
|
||||||
|
#define _BOARDS_SWAN_R5_BOARD_H_
|
||||||
|
|
||||||
|
#include "common-hal/digitalio/DigitalInOut.h"
|
||||||
|
|
||||||
|
extern digitalio_digitalinout_obj_t power_pin;
|
||||||
|
extern digitalio_digitalinout_obj_t discharge_pin;
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _BOARDS_SWAN_R5_BOARD_H_
|
@ -64,3 +64,6 @@
|
|||||||
|
|
||||||
#define DEFAULT_UART_BUS_RX (&pin_PA10)
|
#define DEFAULT_UART_BUS_RX (&pin_PA10)
|
||||||
#define DEFAULT_UART_BUS_TX (&pin_PA09)
|
#define DEFAULT_UART_BUS_TX (&pin_PA09)
|
||||||
|
|
||||||
|
#define SWAN_R5_DISCHARGE_3V3 (&pin_PE06)
|
||||||
|
#define SWAN_R5_ENABLE_3V3 (&pin_PE04)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "py/objtuple.h"
|
#include "py/objtuple.h"
|
||||||
#include "shared-bindings/board/__init__.h"
|
#include "shared-bindings/board/__init__.h"
|
||||||
|
#include "board.h"
|
||||||
|
|
||||||
// extended pins
|
// extended pins
|
||||||
STATIC const mp_rom_map_elem_t board_module_carrier_table[] = {
|
STATIC const mp_rom_map_elem_t board_module_carrier_table[] = {
|
||||||
@ -86,10 +87,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
|
|||||||
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_ext), MP_ROM_PTR(&carrier_type) },
|
{ MP_ROM_QSTR(MP_QSTR_ext), MP_ROM_PTR(&carrier_type) },
|
||||||
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_ENABLE_3V3), MP_ROM_PTR(&pin_PE04) },
|
{ MP_ROM_QSTR(MP_QSTR_ENABLE_3V3), &power_pin },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_DISCHARGE_3V3), MP_ROM_PTR(&pin_PE06) },
|
{ MP_ROM_QSTR(MP_QSTR_DISCHARGE_3V3), &discharge_pin },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_DISABLE_DISCHARGING), MP_ROM_TRUE },
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_ENABLE_DISCHARGING), MP_ROM_FALSE },
|
|
||||||
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA03) }, // PWM, ADC
|
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA03) }, // PWM, ADC
|
||||||
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA01) }, // PWM, ADC
|
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA01) }, // PWM, ADC
|
||||||
|
Loading…
x
Reference in New Issue
Block a user