the code equivalent of smacking something really hard with a wrench

This commit is contained in:
Hierophect 2019-09-19 16:10:26 -04:00
parent b325eadc33
commit c12860ff7d

View File

@ -35,21 +35,6 @@
#include "common-hal/microcontroller/Pin.h" #include "common-hal/microcontroller/Pin.h"
void i2c_reset(void) { void i2c_reset(void) {
#ifdef I2C1
__HAL_RCC_I2C1_FORCE_RESET();
HAL_Delay(2);
__HAL_RCC_I2C1_RELEASE_RESET();
#endif
#ifdef I2C2
__HAL_RCC_I2C2_FORCE_RESET();
HAL_Delay(2);
__HAL_RCC_I2C2_RELEASE_RESET();
#endif
#ifdef I2C3
__HAL_RCC_I2C3_FORCE_RESET();
HAL_Delay(2);
__HAL_RCC_I2C3_RELEASE_RESET();
#endif
} }
void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
@ -100,6 +85,22 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
GPIO_InitStruct.Alternate = self->scl->altfn_index; GPIO_InitStruct.Alternate = self->scl->altfn_index;
HAL_GPIO_Init(pin_port(scl->port), &GPIO_InitStruct); HAL_GPIO_Init(pin_port(scl->port), &GPIO_InitStruct);
#ifdef I2C1
__HAL_RCC_I2C1_FORCE_RESET();
HAL_Delay(2);
__HAL_RCC_I2C1_RELEASE_RESET();
#endif
#ifdef I2C2
__HAL_RCC_I2C2_FORCE_RESET();
HAL_Delay(2);
__HAL_RCC_I2C2_RELEASE_RESET();
#endif
#ifdef I2C3
__HAL_RCC_I2C3_FORCE_RESET();
HAL_Delay(2);
__HAL_RCC_I2C3_RELEASE_RESET();
#endif
#ifdef I2C1 #ifdef I2C1
if(I2Cx==I2C1) __HAL_RCC_I2C1_CLK_ENABLE(); if(I2Cx==I2C1) __HAL_RCC_I2C1_CLK_ENABLE();
#endif #endif