File tree Expand file tree Collapse file tree 5 files changed +23
-4
lines changed Expand file tree Collapse file tree 5 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,11 @@ STATIC twim_peripheral_t twim_peripherals[] = {
54
54
#endif
55
55
};
56
56
57
- #define INST_NO 0
57
+ void i2c_reset (void ) {
58
+ for (size_t i = 0 ; i < MP_ARRAY_SIZE (twim_peripherals ); i ++ ) {
59
+ twim_peripherals [i ].in_use = false;
60
+ }
61
+ }
58
62
59
63
static uint8_t twi_error_to_mp (const nrfx_err_t err ) {
60
64
switch (err ) {
Original file line number Diff line number Diff line change @@ -45,4 +45,6 @@ typedef struct {
45
45
uint8_t sda_pin_number ;
46
46
} busio_i2c_obj_t ;
47
47
48
+ void i2c_reset (void );
49
+
48
50
#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BUSIO_I2C_H
Original file line number Diff line number Diff line change @@ -59,6 +59,12 @@ STATIC spim_peripheral_t spim_peripherals[] = {
59
59
#endif
60
60
};
61
61
62
+ void spi_reset (void ) {
63
+ for (size_t i = 0 ; i < MP_ARRAY_SIZE (spim_peripherals ); i ++ ) {
64
+ nrfx_spim_uninit (& spim_peripherals [i ].spim );
65
+ }
66
+ }
67
+
62
68
// Convert frequency to clock-speed-dependent value
63
69
static nrf_spim_frequency_t baudrate_to_spim_frequency (const uint32_t baudrate ) {
64
70
if (baudrate <= 125000 ) {
Original file line number Diff line number Diff line change @@ -45,4 +45,6 @@ typedef struct {
45
45
uint8_t MISO_pin_number ;
46
46
} busio_spi_obj_t ;
47
47
48
+ void spi_reset (void );
49
+
48
50
#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BUSIO_SPI_H
Original file line number Diff line number Diff line change 34
34
35
35
#include "shared-module/gamepad/__init__.h"
36
36
#include "common-hal/microcontroller/Pin.h"
37
+ #include "common-hal/busio/I2C.h"
38
+ #include "common-hal/busio/SPI.h"
37
39
#include "common-hal/pulseio/PWMOut.h"
38
40
#include "tick.h"
39
41
@@ -72,11 +74,14 @@ safe_mode_t port_init(void) {
72
74
}
73
75
74
76
void reset_port (void ) {
75
- #ifdef CIRCUITPY_GAMEPAD_TICKS
76
- gamepad_reset ();
77
- #endif
77
+ #ifdef CIRCUITPY_GAMEPAD_TICKS
78
+ gamepad_reset ();
79
+ #endif
78
80
81
+ i2c_reset ();
82
+ spi_reset ();
79
83
pwmout_reset ();
84
+
80
85
reset_all_pins ();
81
86
}
82
87
You can’t perform that action at this time.
0 commit comments