1
0
forked from me/IronOS

Migrate all Miniware devices to use Bit-Bang I2C (#1838)

* MHP30 move to I2C Bit Banging

* Fixup Accelerometer drivers so all can use I2CBB

* No STM32 I2C driver anymore

* TS100 on I2CBB

* Miniware on BB

* Fixup S60 build

* format

format
This commit is contained in:
Ben V. Brown
2023-11-16 21:32:56 +11:00
committed by GitHub
parent c308fe8cc2
commit e3bad2adae
46 changed files with 144 additions and 8044 deletions

View File

@@ -14,10 +14,6 @@ ADC_HandleTypeDef hadc1;
ADC_HandleTypeDef hadc2;
DMA_HandleTypeDef hdma_adc1;
I2C_HandleTypeDef hi2c1;
DMA_HandleTypeDef hdma_i2c1_rx;
DMA_HandleTypeDef hdma_i2c1_tx;
IWDG_HandleTypeDef hiwdg;
TIM_HandleTypeDef htim4; // Tip control
TIM_HandleTypeDef htim2; // ADC Scheduling
@@ -28,7 +24,6 @@ uint16_t ADCReadings[ADC_SAMPLES]; // Used to store the adc readings for the han
// Functions
static void SystemClock_Config(void);
static void MX_ADC1_Init(void);
static void MX_I2C1_Init(void);
static void MX_IWDG_Init(void);
static void MX_TIM4_Init(void); // Tip control
static void MX_TIM2_Init(void); // ADC Scheduling
@@ -44,9 +39,6 @@ void Setup_HAL() {
// These are not shared so no harm enabling
__HAL_AFIO_REMAP_SWJ_NOJTAG();
#ifdef SCL_Pin
MX_I2C1_Init();
#endif
MX_GPIO_Init();
MX_DMA_Init();
MX_ADC1_Init();
@@ -249,33 +241,6 @@ static void MX_ADC2_Init(void) {
;
}
}
/* I2C1 init function */
static void MX_I2C1_Init(void) {
hi2c1.Instance = I2C1;
hi2c1.Init.ClockSpeed = 200000;
// OLED doesnt handle >100k when its asleep (off).
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_16_9;
hi2c1.Init.OwnAddress1 = 0;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
__HAL_I2C_DISABLE(&hi2c1);
__HAL_RCC_I2C1_CLK_ENABLE();
// 13. Set SWRST bit in I2Cx_CR1 register.
hi2c1.Instance->CR1 |= 0x8000;
asm("nop");
// 14. Clear SWRST bit in I2Cx_CR1 register.
hi2c1.Instance->CR1 &= ~0x8000;
HAL_I2C_Init(&hi2c1);
unstick_I2C();
}
/* IWDG init function */
static void MX_IWDG_Init(void) {