File tree Expand file tree Collapse file tree 3 files changed +30
-4
lines changed Expand file tree Collapse file tree 3 files changed +30
-4
lines changed Original file line number Diff line number Diff line change 30
30
#include "stm32l4xx.h"
31
31
#include "stm32l4r5xx.h"
32
32
33
+ #include "shared-bindings/microcontroller/Pin.h"
34
+ #include "shared-bindings/digitalio/DigitalInOut.h"
35
+ #include "shared-bindings/digitalio/Direction.h"
36
+ #include "shared-bindings/digitalio/DriveMode.h"
37
+ #include "board.h"
38
+
39
+ digitalio_digitalinout_obj_t power_pin = { .base .type = & digitalio_digitalinout_type };
40
+ digitalio_digitalinout_obj_t discharge_pin = { .base .type = & digitalio_digitalinout_type };
41
+
33
42
void initialize_discharge_pin (void ) {
43
+
34
44
/* Initialize the 3V3 discharge to be OFF and the output power to be ON */
35
45
__HAL_RCC_GPIOE_CLK_ENABLE ();
36
46
__HAL_RCC_GPIOC_CLK_ENABLE ();
37
47
48
+
49
+ common_hal_digitalio_digitalinout_construct (& power_pin , & pin_PE04 );
50
+ common_hal_digitalio_digitalinout_construct (& discharge_pin , & pin_PE06 );
51
+ common_hal_digitalio_digitalinout_never_reset (& power_pin );
52
+ common_hal_digitalio_digitalinout_never_reset (& discharge_pin );
53
+
38
54
GPIO_InitTypeDef GPIO_InitStruct ;
39
55
/* Set the DISCHARGE pin and the USB_DETECT pin to FLOAT */
40
56
GPIO_InitStruct .Mode = GPIO_MODE_ANALOG ;
@@ -49,6 +65,7 @@ void initialize_discharge_pin(void) {
49
65
GPIO_InitStruct .Pin = GPIO_PIN_4 ;
50
66
HAL_GPIO_Init (GPIOE , & GPIO_InitStruct );
51
67
HAL_GPIO_WritePin (GPIOE , GPIO_PIN_4 , GPIO_PIN_SET );
68
+
52
69
}
53
70
54
71
void board_init (void ) {
Original file line number Diff line number Diff line change
1
+ #ifndef _BOARDS_SWAN_R5_BOARD_H_
2
+ #define _BOARDS_SWAN_R5_BOARD_H_
3
+
4
+ #include "common-hal/digitalio/DigitalInOut.h"
5
+
6
+ extern digitalio_digitalinout_obj_t power_pin ;
7
+ extern digitalio_digitalinout_obj_t discharge_pin ;
8
+
9
+
10
+ #endif // _BOARDS_SWAN_R5_BOARD_H_
Original file line number Diff line number Diff line change 1
1
#include "py/objtuple.h"
2
2
#include "shared-bindings/board/__init__.h"
3
+ #include "board.h"
3
4
4
5
// extended pins
5
6
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[] = {
86
87
87
88
{ MP_ROM_QSTR (MP_QSTR_ext ), MP_ROM_PTR (& carrier_type ) },
88
89
89
- { MP_ROM_QSTR (MP_QSTR_ENABLE_3V3 ), MP_ROM_PTR (SWAN_R5_ENABLE_3V3 ) },
90
- { MP_ROM_QSTR (MP_QSTR_DISCHARGE_3V3 ), MP_ROM_PTR (SWAN_R5_DISCHARGE_3V3 ) },
91
- { MP_ROM_QSTR (MP_QSTR_DISABLE_DISCHARGING ), MP_ROM_TRUE },
92
- { MP_ROM_QSTR (MP_QSTR_ENABLE_DISCHARGING ), MP_ROM_FALSE },
90
+ { MP_ROM_QSTR (MP_QSTR_ENABLE_3V3 ), & power_pin },
91
+ { MP_ROM_QSTR (MP_QSTR_DISCHARGE_3V3 ), & discharge_pin },
93
92
94
93
{ MP_ROM_QSTR (MP_QSTR_A0 ), MP_ROM_PTR (& pin_PA03 ) }, // PWM, ADC
95
94
{ MP_ROM_QSTR (MP_QSTR_A1 ), MP_ROM_PTR (& pin_PA01 ) }, // PWM, ADC
You can’t perform that action at this time.
0 commit comments