File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,7 +54,11 @@ STATIC twim_peripheral_t twim_peripherals[] = {
5454#endif
5555};
5656
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+ }
5862
5963static uint8_t twi_error_to_mp (const nrfx_err_t err ) {
6064 switch (err ) {
Original file line number Diff line number Diff line change @@ -45,4 +45,6 @@ typedef struct {
4545 uint8_t sda_pin_number ;
4646} busio_i2c_obj_t ;
4747
48+ void i2c_reset (void );
49+
4850#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[] = {
5959#endif
6060};
6161
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+
6268// Convert frequency to clock-speed-dependent value
6369static nrf_spim_frequency_t baudrate_to_spim_frequency (const uint32_t baudrate ) {
6470 if (baudrate <= 125000 ) {
Original file line number Diff line number Diff line change @@ -45,4 +45,6 @@ typedef struct {
4545 uint8_t MISO_pin_number ;
4646} busio_spi_obj_t ;
4747
48+ void spi_reset (void );
49+
4850#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BUSIO_SPI_H
Original file line number Diff line number Diff line change 3434
3535#include "shared-module/gamepad/__init__.h"
3636#include "common-hal/microcontroller/Pin.h"
37+ #include "common-hal/busio/I2C.h"
38+ #include "common-hal/busio/SPI.h"
3739#include "common-hal/pulseio/PWMOut.h"
3840#include "tick.h"
3941
@@ -72,11 +74,14 @@ safe_mode_t port_init(void) {
7274}
7375
7476void reset_port (void ) {
75- #ifdef CIRCUITPY_GAMEPAD_TICKS
76- gamepad_reset ();
77- #endif
77+ #ifdef CIRCUITPY_GAMEPAD_TICKS
78+ gamepad_reset ();
79+ #endif
7880
81+ i2c_reset ();
82+ spi_reset ();
7983 pwmout_reset ();
84+
8085 reset_all_pins ();
8186}
8287
You can’t perform that action at this time.
0 commit comments