exposes `DigitalInOutPin` instances on the board, initialized and reserved.
This commit is contained in:
parent
78e4b9446b
commit
019a160983
|
@ -30,11 +30,27 @@
|
|||
#include "stm32l4xx.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) {
|
||||
|
||||
/* Initialize the 3V3 discharge to be OFF and the output power to be ON */
|
||||
__HAL_RCC_GPIOE_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;
|
||||
/* Set the DISCHARGE pin and the USB_DETECT pin to FLOAT */
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
|
@ -49,6 +65,7 @@ void initialize_discharge_pin(void) {
|
|||
GPIO_InitStruct.Pin = GPIO_PIN_4;
|
||||
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_4, GPIO_PIN_SET);
|
||||
|
||||
}
|
||||
|
||||
void board_init(void) {
|
||||
|
|
|
@ -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_
|
|
@ -1,5 +1,6 @@
|
|||
#include "py/objtuple.h"
|
||||
#include "shared-bindings/board/__init__.h"
|
||||
#include "board.h"
|
||||
|
||||
// extended pins
|
||||
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_ENABLE_3V3), MP_ROM_PTR(SWAN_R5_ENABLE_3V3) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_DISCHARGE_3V3), MP_ROM_PTR(SWAN_R5_DISCHARGE_3V3) },
|
||||
{ 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_ENABLE_3V3), &power_pin },
|
||||
{ MP_ROM_QSTR(MP_QSTR_DISCHARGE_3V3), &discharge_pin },
|
||||
|
||||
{ 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
|
||||
|
|
Loading…
Reference in New Issue