Files
IronOS/workspace/TS100/inc/hardware.h
Kyle Repinski 0c7be326e5 Allow more precise input voltage divider calibration. (#359)
Finer input voltage calibration

Settings divisor is stored as uint16_t, not uint8_t.

* Allow more precise input voltage divider calibration.

The existing code changed the input voltage by multiple
tenths of a volt per adjustment, which is way too coarse.

This commit simply multiplies the ADC value (and its divisor)
by 4, which allows for finer calibration adjustments.

Unfortunately, for safety reasons this requires a settings
version bump. While old stored divider values can be detected
and multiplied by 4 on startup to update them, if the user
downgrades firmware it will happily read the new higher value
and cause all sorts of problems (which could be either reading
higher *or* lower depending on how getInputVoltageX10's
parameter wraps around in old firmware due to incorrect type.
2018-09-20 16:35:33 +10:00

73 lines
1.7 KiB
C

/*
* Hardware.h
*
* Created on: 29Aug.,2017
* Author: Ben V. Brown
*/
#ifndef HARDWARE_H_
#define HARDWARE_H_
#include "stm32f1xx_hal.h"
#include "Setup.h"
#ifdef __cplusplus
extern "C" {
#endif
enum Orientation {
ORIENTATION_LEFT_HAND = 0, ORIENTATION_RIGHT_HAND = 1, ORIENTATION_FLAT = 3
};
/*
* Keep in a uint8_t range for the ID's
*/
enum TipType {
TS_B2 = 0,
TS_D24 = 1,
TS_BC2 = 2,
TS_C1 = 3,
Tip_MiniWare=4,
HAKKO_BC2=4,
Tip_Hakko=5,
Tip_Custom=5,
};
#define KEY_B_Pin GPIO_PIN_6
#define KEY_B_GPIO_Port GPIOA
#define TMP36_INPUT_Pin GPIO_PIN_7
#define TMP36_INPUT_GPIO_Port GPIOA
#define TIP_TEMP_Pin GPIO_PIN_0
#define TIP_TEMP_GPIO_Port GPIOB
#define VIN_Pin GPIO_PIN_1
#define VIN_GPIO_Port GPIOB
#define OLED_RESET_Pin GPIO_PIN_8
#define OLED_RESET_GPIO_Port GPIOA
#define KEY_A_Pin GPIO_PIN_9
#define KEY_A_GPIO_Port GPIOA
#define INT_Orientation_Pin GPIO_PIN_3
#define INT_Orientation_GPIO_Port GPIOB
#define PWM_Out_Pin GPIO_PIN_4
#define PWM_Out_GPIO_Port GPIOB
#define INT_Movement_Pin GPIO_PIN_5
#define INT_Movement_GPIO_Port GPIOB
#define SCL_Pin GPIO_PIN_6
#define SCL_GPIO_Port GPIOB
#define SDA_Pin GPIO_PIN_7
#define SDA_GPIO_Port GPIOB
uint16_t getHandleTemperature();
uint16_t getTipRawTemp(uint8_t instant);
uint16_t getInputVoltageX10(uint16_t divisor);
uint16_t getTipInstantTemperature();
uint8_t getTipPWM();
void setTipPWM(uint8_t pulse);
uint16_t ctoTipMeasurement(uint16_t temp);
uint16_t tipMeasurementToC(uint16_t raw);
uint16_t ftoTipMeasurement(uint16_t temp);
uint16_t tipMeasurementToF(uint16_t raw);
void setCalibrationOffset(int16_t offSet);
void setTipType(enum TipType tipType, uint8_t manualCalGain);
#ifdef __cplusplus
}
#endif
#endif /* HARDWARE_H_ */