mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Faster I2C BB | slow down ADC
This commit is contained in:
@@ -95,7 +95,7 @@ void SystemClock_Config(void) {
|
||||
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
|
||||
|
||||
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC;
|
||||
PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6; // 6 or 8 are the only non overclocked options
|
||||
PeriphClkInit.AdcClockSelection = RCC_CFGR_ADCPRE_DIV8; // 6 or 8 are the only non overclocked options
|
||||
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit);
|
||||
|
||||
/**Configure the Systick interrupt time
|
||||
@@ -128,14 +128,14 @@ static void MX_ADC1_Init(void) {
|
||||
|
||||
/**Configure the ADC multi-mode
|
||||
*/
|
||||
multimode.Mode = ADC_DUALMODE_REGSIMULT_INJECSIMULT;
|
||||
multimode.Mode = ADC_DUALMODE_REGSIMULT;
|
||||
HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode);
|
||||
|
||||
/**Configure Regular Channel
|
||||
*/
|
||||
sConfig.Channel = TMP36_ADC1_CHANNEL;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_1;
|
||||
sConfig.SamplingTime = ADC_SAMPLETIME_71CYCLES_5;
|
||||
sConfig.SamplingTime = ADC_SAMPLETIME_239CYCLES_5;
|
||||
HAL_ADC_ConfigChannel(&hadc1, &sConfig);
|
||||
|
||||
/**Configure Regular Channel
|
||||
@@ -144,7 +144,7 @@ static void MX_ADC1_Init(void) {
|
||||
sConfig.Rank = ADC_REGULAR_RANK_2;
|
||||
HAL_ADC_ConfigChannel(&hadc1, &sConfig);
|
||||
sConfig.Channel = TIP_TEMP_ADC1_CHANNEL;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_2;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_3;
|
||||
HAL_ADC_ConfigChannel(&hadc1, &sConfig);
|
||||
|
||||
SET_BIT(hadc1.Instance->CR1, (ADC_CR1_EOSIE)); // Enable end of Normal
|
||||
@@ -172,7 +172,7 @@ static void MX_ADC2_Init(void) {
|
||||
*/
|
||||
sConfig.Channel = TMP36_ADC2_CHANNEL;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_1;
|
||||
sConfig.SamplingTime = ADC_SAMPLETIME_71CYCLES_5;
|
||||
sConfig.SamplingTime = ADC_SAMPLETIME_239CYCLES_5;
|
||||
HAL_ADC_ConfigChannel(&hadc2, &sConfig);
|
||||
|
||||
sConfig.Channel = VIN_ADC2_CHANNEL;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#define SOFT_SCL_READ() (HAL_GPIO_ReadPin(SCL2_GPIO_Port, SCL2_Pin) == GPIO_PIN_SET ? 1 : 0)
|
||||
#define SOFT_I2C_DELAY() \
|
||||
{ \
|
||||
for (int xx = 0; xx < 40; xx++) { \
|
||||
for (int xx = 0; xx < 20; xx++) { \
|
||||
asm("nop"); \
|
||||
} \
|
||||
}
|
||||
|
||||
@@ -4,31 +4,39 @@
|
||||
#include "cmsis_os.h"
|
||||
#include "stm32f1xx.h"
|
||||
#include "stm32f1xx_hal.h"
|
||||
|
||||
#include "Pins.h"
|
||||
extern TIM_HandleTypeDef htim1; // used for the systick
|
||||
|
||||
/******************************************************************************/
|
||||
/* Cortex-M3 Processor Interruption and Exception Handlers */
|
||||
/******************************************************************************/
|
||||
|
||||
void NMI_Handler(void) {}
|
||||
void NMI_Handler(void) {
|
||||
}
|
||||
|
||||
// We have the assembly for a breakpoint trigger here to halt the system when a debugger is connected
|
||||
// Hardfault handler, often a screwup in the code
|
||||
void HardFault_Handler(void) {}
|
||||
void HardFault_Handler(void) {
|
||||
}
|
||||
|
||||
// Memory management unit had an error
|
||||
void MemManage_Handler(void) {}
|
||||
void MemManage_Handler(void) {
|
||||
}
|
||||
|
||||
// Prefetcher or busfault occured
|
||||
void BusFault_Handler(void) {}
|
||||
void BusFault_Handler(void) {
|
||||
}
|
||||
|
||||
void UsageFault_Handler(void) {}
|
||||
void UsageFault_Handler(void) {
|
||||
}
|
||||
|
||||
void DebugMon_Handler(void) {}
|
||||
void DebugMon_Handler(void) {
|
||||
}
|
||||
|
||||
// Systick is used by FreeRTOS tick
|
||||
void SysTick_Handler(void) { osSystickHandler(); }
|
||||
void SysTick_Handler(void) {
|
||||
osSystickHandler();
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* STM32F1xx Peripheral Interrupt Handlers */
|
||||
@@ -38,18 +46,33 @@ void SysTick_Handler(void) { osSystickHandler(); }
|
||||
/******************************************************************************/
|
||||
|
||||
// DMA used to move the ADC readings into system ram
|
||||
void DMA1_Channel1_IRQHandler(void) { HAL_DMA_IRQHandler(&hdma_adc1); }
|
||||
void DMA1_Channel1_IRQHandler(void) {
|
||||
HAL_DMA_IRQHandler(&hdma_adc1);
|
||||
}
|
||||
// ADC interrupt used for DMA
|
||||
void ADC1_2_IRQHandler(void) { HAL_ADC_IRQHandler(&hadc1); }
|
||||
void ADC1_2_IRQHandler(void) {
|
||||
HAL_ADC_IRQHandler(&hadc1);
|
||||
}
|
||||
|
||||
// Timer 1 has overflowed, used for HAL ticks
|
||||
void TIM1_UP_IRQHandler(void) { HAL_TIM_IRQHandler(&htim1); }
|
||||
void TIM1_UP_IRQHandler(void) {
|
||||
HAL_TIM_IRQHandler(&htim1);
|
||||
}
|
||||
|
||||
void I2C1_EV_IRQHandler(void) {
|
||||
HAL_I2C_EV_IRQHandler(&hi2c1);
|
||||
}
|
||||
void I2C1_ER_IRQHandler(void) {
|
||||
HAL_I2C_ER_IRQHandler(&hi2c1);
|
||||
}
|
||||
|
||||
void I2C1_EV_IRQHandler(void) { HAL_I2C_EV_IRQHandler(&hi2c1); }
|
||||
void I2C1_ER_IRQHandler(void) { HAL_I2C_ER_IRQHandler(&hi2c1); }
|
||||
void DMA1_Channel6_IRQHandler(void) {
|
||||
HAL_DMA_IRQHandler(&hdma_i2c1_tx);
|
||||
}
|
||||
|
||||
void DMA1_Channel6_IRQHandler(void) { HAL_DMA_IRQHandler(&hdma_i2c1_tx); }
|
||||
|
||||
void DMA1_Channel7_IRQHandler(void) { HAL_DMA_IRQHandler(&hdma_i2c1_rx); }
|
||||
void EXTI9_5_IRQHandler(void) { HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9); }
|
||||
void DMA1_Channel7_IRQHandler(void) {
|
||||
HAL_DMA_IRQHandler(&hdma_i2c1_rx);
|
||||
}
|
||||
void EXTI9_5_IRQHandler(void) {
|
||||
HAL_GPIO_EXTI_IRQHandler(INT_PD_Pin);
|
||||
}
|
||||
|
||||
@@ -198,6 +198,6 @@ const uint8_t tipResistance = 45; // x10 ohms, 4.5 typical for ts80 tips
|
||||
|
||||
#ifdef MODEL_MHP30
|
||||
const uint32_t tipMass = 80;//TODO
|
||||
const uint8_t tipResistance = 60; // x10 ohms, 6 typical
|
||||
const uint8_t tipResistance = 65; // x10 ohms, 6 typical
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user