Fromatting + setup adc pin explicitly
This commit is contained in:
@@ -48,8 +48,8 @@ void Setup_HAL() {
|
||||
HAL_ADC_Start(&hadc2);
|
||||
HAL_ADCEx_MultiModeStart_DMA(&hadc1, ADCReadings,
|
||||
(ADC_SAMPLES * ADC_CHANNELS)); // start DMA of normal readings
|
||||
// HAL_ADCEx_InjectedStart(&hadc1); // enable injected readings
|
||||
// HAL_ADCEx_InjectedStart(&hadc2); // enable injected readings
|
||||
// HAL_ADCEx_InjectedStart(&hadc1); // enable injected readings
|
||||
// HAL_ADCEx_InjectedStart(&hadc2); // enable injected readings
|
||||
}
|
||||
|
||||
// channel 0 -> temperature sensor, 1-> VIN, 2-> tip
|
||||
@@ -73,8 +73,7 @@ void SystemClock_Config(void) {
|
||||
|
||||
/**Initializes the CPU, AHB and APB busses clocks
|
||||
*/
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI
|
||||
| RCC_OSCILLATORTYPE_LSI;
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_LSI;
|
||||
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||
RCC_OscInitStruct.HSICalibrationValue = 16;
|
||||
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
|
||||
@@ -85,8 +84,7 @@ void SystemClock_Config(void) {
|
||||
|
||||
/**Initializes the CPU, AHB and APB busses clocks
|
||||
*/
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
|
||||
| RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV16; // TIM
|
||||
@@ -326,7 +324,7 @@ static void MX_DMA_Init(void) {
|
||||
|
||||
static void MX_GPIO_Init(void) {
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
memset(&GPIO_InitStruct,0,sizeof(GPIO_InitStruct));
|
||||
memset(&GPIO_InitStruct, 0, sizeof(GPIO_InitStruct));
|
||||
|
||||
/* GPIO Ports Clock Enable */
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
@@ -347,15 +345,11 @@ static void MX_GPIO_Init(void) {
|
||||
/*
|
||||
* Configure All pins as analog by default
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3
|
||||
| GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8
|
||||
| GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_15;
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_15;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3
|
||||
| GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8
|
||||
| GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13
|
||||
| GPIO_PIN_14 | GPIO_PIN_15;
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12
|
||||
| GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : KEY_B_Pin KEY_A_Pin */
|
||||
|
||||
@@ -41,7 +41,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc) {
|
||||
hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
|
||||
hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
|
||||
hdma_adc1.Init.Mode = DMA_CIRCULAR;
|
||||
hdma_adc1.Init.Priority = DMA_PRIORITY_MEDIUM;
|
||||
hdma_adc1.Init.Priority = DMA_PRIORITY_LOW;
|
||||
HAL_DMA_Init(&hdma_adc1);
|
||||
|
||||
__HAL_LINKDMA(hadc, DMA_Handle, hdma_adc1);
|
||||
@@ -65,6 +65,9 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc) {
|
||||
GPIO_InitStruct.Pin = VIN_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
HAL_GPIO_Init(VIN_GPIO_Port, &GPIO_InitStruct);
|
||||
GPIO_InitStruct.Pin = PLATE_SENSOR_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
HAL_GPIO_Init(PLATE_SENSOR_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/* ADC2 interrupt Init */
|
||||
HAL_NVIC_SetPriority(ADC1_2_IRQn, 15, 0);
|
||||
|
||||
@@ -69,10 +69,8 @@ uint32_t TipThermoModel::convertFtoC(uint32_t degF) {
|
||||
}
|
||||
return ((degF - 32) * 5) / 9;
|
||||
}
|
||||
volatile uint32_t lastTemp = 0;
|
||||
uint32_t TipThermoModel::getTipInC(bool sampleNow) {
|
||||
int32_t currentTipTempInC = TipThermoModel::convertTipRawADCToDegC(getTipRawTemp(sampleNow));
|
||||
lastTemp = currentTipTempInC;
|
||||
currentTipTempInC += getHandleTemperature() / 10; // Add handle offset
|
||||
// Power usage indicates that our tip temp is lower than our thermocouple temp.
|
||||
// I found a number that doesn't unbalance the existing PID, causing overshoot.
|
||||
|
||||
Reference in New Issue
Block a user