mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Beginnings of the shuffle
This commit is contained in:
35
workspace/TS100/Core/Inc/Buttons.hpp
Normal file
35
workspace/TS100/Core/Inc/Buttons.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Buttons.h
|
||||
*
|
||||
* Created on: 29 May 2020
|
||||
* Author: Ralim
|
||||
*/
|
||||
#include "BSP.h"
|
||||
#ifndef INC_BUTTONS_H_
|
||||
#define INC_BUTTONS_H_
|
||||
|
||||
extern uint32_t lastButtonTime;
|
||||
|
||||
enum ButtonState {
|
||||
BUTTON_NONE = 0, /* No buttons pressed / < filter time*/
|
||||
BUTTON_F_SHORT = 1, /* User has pressed the front button*/
|
||||
BUTTON_B_SHORT = 2, /* User has pressed the back button*/
|
||||
BUTTON_F_LONG = 4, /* User is holding the front button*/
|
||||
BUTTON_B_LONG = 8, /* User is holding the back button*/
|
||||
BUTTON_BOTH = 16, /* User has pressed both buttons*/
|
||||
|
||||
/*
|
||||
* Note:
|
||||
* Pressed means press + release, we trigger on a full \__/ pulse
|
||||
* holding means it has gone low, and been low for longer than filter time
|
||||
*/
|
||||
};
|
||||
|
||||
//Returns what buttons are pressed (if any)
|
||||
ButtonState getButtonState();
|
||||
//Helpers
|
||||
void waitForButtonPressOrTimeout(uint32_t timeout);
|
||||
void waitForButtonPress();
|
||||
|
||||
|
||||
#endif /* INC_BUTTONS_H_ */
|
||||
@@ -1,44 +1,46 @@
|
||||
/*
|
||||
* FRToSI2C.hpp
|
||||
*
|
||||
* Created on: 14Apr.,2018
|
||||
* Author: Ralim
|
||||
*/
|
||||
|
||||
#ifndef FRTOSI2C_HPP_
|
||||
#define FRTOSI2C_HPP_
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "cmsis_os.h"
|
||||
|
||||
class FRToSI2C {
|
||||
public:
|
||||
|
||||
static void init(I2C_HandleTypeDef *i2chandle) {
|
||||
i2c = i2chandle;
|
||||
I2CSemaphore = nullptr;
|
||||
}
|
||||
|
||||
static void FRToSInit() {
|
||||
I2CSemaphore = xSemaphoreCreateBinaryStatic(&xSemaphoreBuffer);
|
||||
xSemaphoreGive(I2CSemaphore);
|
||||
}
|
||||
|
||||
static void CpltCallback(); //Normal Tx Callback
|
||||
|
||||
static void Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
|
||||
uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
|
||||
static void Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
|
||||
uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
|
||||
|
||||
static void Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size);
|
||||
static void I2C_RegisterWrite(uint8_t address, uint8_t reg, uint8_t data);
|
||||
static uint8_t I2C_RegisterRead(uint8_t address, uint8_t reg);
|
||||
|
||||
private:
|
||||
static I2C_HandleTypeDef *i2c;
|
||||
static void I2C1_ClearBusyFlagErratum();
|
||||
static SemaphoreHandle_t I2CSemaphore;
|
||||
static StaticSemaphore_t xSemaphoreBuffer;
|
||||
};
|
||||
|
||||
#endif /* FRTOSI2C_HPP_ */
|
||||
/*
|
||||
* FRToSI2C.hpp
|
||||
*
|
||||
* Created on: 14Apr.,2018
|
||||
* Author: Ralim
|
||||
*/
|
||||
|
||||
#ifndef FRTOSI2C_HPP_
|
||||
#define FRTOSI2C_HPP_
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "cmsis_os.h"
|
||||
|
||||
class FRToSI2C {
|
||||
public:
|
||||
|
||||
static void init(I2C_HandleTypeDef *i2chandle) {
|
||||
i2c = i2chandle;
|
||||
I2CSemaphore = nullptr;
|
||||
}
|
||||
|
||||
static void FRToSInit() {
|
||||
I2CSemaphore = xSemaphoreCreateBinaryStatic(&xSemaphoreBuffer);
|
||||
xSemaphoreGive(I2CSemaphore);
|
||||
}
|
||||
|
||||
static void CpltCallback(); //Normal Tx Callback
|
||||
|
||||
static bool Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
|
||||
uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
|
||||
static void Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
|
||||
uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
|
||||
//Returns true if device ACK's being addressed
|
||||
static bool probe(uint16_t DevAddress);
|
||||
|
||||
static void Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size);
|
||||
static void I2C_RegisterWrite(uint8_t address, uint8_t reg, uint8_t data);
|
||||
static uint8_t I2C_RegisterRead(uint8_t address, uint8_t reg);
|
||||
|
||||
private:
|
||||
static I2C_HandleTypeDef *i2c;
|
||||
static void I2C1_ClearBusyFlagErratum();
|
||||
static SemaphoreHandle_t I2CSemaphore;
|
||||
static StaticSemaphore_t xSemaphoreBuffer;
|
||||
};
|
||||
|
||||
#endif /* FRTOSI2C_HPP_ */
|
||||
|
||||
28
workspace/TS100/Core/Inc/FreeRTOSHooks.h
Normal file
28
workspace/TS100/Core/Inc/FreeRTOSHooks.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* FreeRTOSHooks.h
|
||||
*
|
||||
* Created on: 29 May 2020
|
||||
* Author: Ralim
|
||||
*/
|
||||
|
||||
#ifndef INC_FREERTOSHOOKS_H_
|
||||
#define INC_FREERTOSHOOKS_H_
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "cmsis_os.h"
|
||||
#include "unit.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// RToS
|
||||
void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,
|
||||
StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize);
|
||||
void vApplicationIdleHook(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* INC_FREERTOSHOOKS_H_ */
|
||||
@@ -10,11 +10,8 @@
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "FRToSI2C.hpp"
|
||||
#include "LIS2DH12_defines.hpp"
|
||||
#include "hardware.h"
|
||||
#include "BSP.h"
|
||||
|
||||
#ifdef MODEL_TS80
|
||||
#define LIS_ORI_FLIP
|
||||
#endif
|
||||
class LIS2DH12 {
|
||||
public:
|
||||
static bool detect();
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "MMA8652FC_defines.h"
|
||||
#include "FRToSI2C.hpp"
|
||||
#include "hardware.h"
|
||||
#include "BSP.h"
|
||||
|
||||
class MMA8652FC {
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#ifndef OLED_HPP_
|
||||
#define OLED_HPP_
|
||||
#include <hardware.h>
|
||||
#include <BSP.h>
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
21
workspace/TS100/Core/Inc/QC3.h
Normal file
21
workspace/TS100/Core/Inc/QC3.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* QC3.h
|
||||
*
|
||||
* Created on: 29 May 2020
|
||||
* Author: Ralim
|
||||
*/
|
||||
|
||||
#ifndef INC_QC3_H_
|
||||
#define INC_QC3_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void seekQC(int16_t Vx10, uint16_t divisor);
|
||||
void startQC(uint16_t divisor); // Tries to negotiate QC for highest voltage, must be run after
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* INC_QC3_H_ */
|
||||
42
workspace/TS100/Core/Inc/TipThermoModel.h
Normal file
42
workspace/TS100/Core/Inc/TipThermoModel.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* TipThermoModel.h
|
||||
*
|
||||
* Created on: 7 Oct 2019
|
||||
* Author: ralim
|
||||
*/
|
||||
|
||||
#ifndef SRC_TIPTHERMOMODEL_H_
|
||||
#define SRC_TIPTHERMOMODEL_H_
|
||||
#include "stdint.h"
|
||||
#include "BSP.h"
|
||||
#include "unit.h"
|
||||
class TipThermoModel {
|
||||
public:
|
||||
//These are the main two functions
|
||||
static uint32_t getTipInC(bool sampleNow = false);
|
||||
#ifdef ENABLED_FAHRENHEIT_SUPPORT
|
||||
static uint32_t getTipInF(bool sampleNow = false);
|
||||
#endif
|
||||
|
||||
//Calculates the maximum temperature can can be read by the ADC range
|
||||
static uint32_t getTipMaxInC();
|
||||
|
||||
static uint32_t convertTipRawADCToDegC(uint16_t rawADC);
|
||||
#ifdef ENABLED_FAHRENHEIT_SUPPORT
|
||||
static uint32_t convertTipRawADCToDegF(uint16_t rawADC);
|
||||
#endif
|
||||
//Returns the uV of the tip reading before the op-amp compensating for pullups
|
||||
static uint32_t convertTipRawADCTouV(uint16_t rawADC);
|
||||
#ifdef ENABLED_FAHRENHEIT_SUPPORT
|
||||
static uint32_t convertCtoF(uint32_t degC);
|
||||
static uint32_t convertFtoC(uint32_t degF);
|
||||
#endif
|
||||
|
||||
private:
|
||||
static uint32_t convertuVToDegC(uint32_t tipuVDelta);
|
||||
#ifdef ENABLED_FAHRENHEIT_SUPPORT
|
||||
static uint32_t convertuVToDegF(uint32_t tipuVDelta);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* SRC_TIPTHERMOMODEL_H_ */
|
||||
@@ -1,38 +1,38 @@
|
||||
/*
|
||||
* gui.h
|
||||
*
|
||||
* Created on: 3Sep.,2017
|
||||
* Author: Ben V. Brown
|
||||
*/
|
||||
|
||||
#ifndef GUI_HPP_
|
||||
#define GUI_HPP_
|
||||
#include "Translation.h"
|
||||
#include "Settings.h"
|
||||
#include "hardware.h"
|
||||
|
||||
#define PRESS_ACCEL_STEP 3
|
||||
#define PRESS_ACCEL_INTERVAL_MIN 10
|
||||
#define PRESS_ACCEL_INTERVAL_MAX 30
|
||||
|
||||
|
||||
//GUI holds the menu structure and all its methods for the menu itself
|
||||
|
||||
//Declarations for all the methods for the settings menu (at end of this file)
|
||||
|
||||
//Wrapper for holding a function pointer
|
||||
typedef struct state_func_t {
|
||||
void (*func)(void);
|
||||
} state_func;
|
||||
|
||||
//Struct for holding the function pointers and descriptions
|
||||
typedef struct {
|
||||
const char *description;
|
||||
const state_func incrementHandler;
|
||||
const state_func draw;
|
||||
} menuitem;
|
||||
|
||||
void enterSettingsMenu();
|
||||
extern const menuitem rootSettingsMenu[];
|
||||
|
||||
#endif /* GUI_HPP_ */
|
||||
/*
|
||||
* gui.h
|
||||
*
|
||||
* Created on: 3Sep.,2017
|
||||
* Author: Ben V. Brown
|
||||
*/
|
||||
|
||||
#ifndef GUI_HPP_
|
||||
#define GUI_HPP_
|
||||
#include "Translation.h"
|
||||
#include "Settings.h"
|
||||
#include "BSP.h"
|
||||
|
||||
#define PRESS_ACCEL_STEP 3
|
||||
#define PRESS_ACCEL_INTERVAL_MIN 10
|
||||
#define PRESS_ACCEL_INTERVAL_MAX 30
|
||||
|
||||
//GUI holds the menu structure and all its methods for the menu itself
|
||||
|
||||
//Declarations for all the methods for the settings menu (at end of this file)
|
||||
|
||||
//Wrapper for holding a function pointer
|
||||
typedef struct state_func_t {
|
||||
void (*func)(void);
|
||||
} state_func;
|
||||
|
||||
//Struct for holding the function pointers and descriptions
|
||||
typedef struct {
|
||||
const char *description;
|
||||
const state_func incrementHandler;
|
||||
const state_func draw;
|
||||
} menuitem;
|
||||
|
||||
void enterSettingsMenu();
|
||||
void GUIDelay();
|
||||
extern const menuitem rootSettingsMenu[];
|
||||
|
||||
#endif /* GUI_HPP_ */
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
/*
|
||||
* Hardware.h
|
||||
*
|
||||
* Created on: 29Aug.,2017
|
||||
* Author: Ben V. Brown
|
||||
*/
|
||||
|
||||
#ifndef HARDWARE_H_
|
||||
#define HARDWARE_H_
|
||||
#include "Setup.h"
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "cmsis_os.h"
|
||||
#include "unit.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum Orientation {
|
||||
ORIENTATION_LEFT_HAND = 0, ORIENTATION_RIGHT_HAND = 1, ORIENTATION_FLAT = 3
|
||||
};
|
||||
#define PID_TIM_HZ (8)
|
||||
#if defined(MODEL_TS100) + defined(MODEL_TS80) > 1
|
||||
#error "Multiple models defined!"
|
||||
#elif defined(MODEL_TS100) + defined(MODEL_TS80) == 0
|
||||
#error "No model defined!"
|
||||
#endif
|
||||
|
||||
#ifdef MODEL_TS100
|
||||
|
||||
#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 TMP36_ADC1_CHANNEL ADC_CHANNEL_7
|
||||
#define TIP_TEMP_Pin GPIO_PIN_0
|
||||
#define TIP_TEMP_GPIO_Port GPIOB
|
||||
#define TIP_TEMP_ADC1_CHANNEL ADC_CHANNEL_8
|
||||
#define TIP_TEMP_ADC2_CHANNEL ADC_CHANNEL_8
|
||||
#define VIN_Pin GPIO_PIN_1
|
||||
#define VIN_GPIO_Port GPIOB
|
||||
#define VIN_ADC1_CHANNEL ADC_CHANNEL_9
|
||||
#define VIN_ADC2_CHANNEL ADC_CHANNEL_9
|
||||
#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 PWM_Out_CHANNEL TIM_CHANNEL_1
|
||||
#define PWM_Out_CCR
|
||||
#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
|
||||
|
||||
#else
|
||||
// TS80 pin map
|
||||
#define KEY_B_Pin GPIO_PIN_0
|
||||
#define KEY_B_GPIO_Port GPIOB
|
||||
#define TMP36_INPUT_Pin GPIO_PIN_4
|
||||
#define TMP36_INPUT_GPIO_Port GPIOA
|
||||
#define TMP36_ADC1_CHANNEL ADC_CHANNEL_4
|
||||
#define TIP_TEMP_Pin GPIO_PIN_3
|
||||
#define TIP_TEMP_GPIO_Port GPIOA
|
||||
#define TIP_TEMP_ADC1_CHANNEL ADC_CHANNEL_3
|
||||
#define TIP_TEMP_ADC2_CHANNEL ADC_CHANNEL_3
|
||||
|
||||
#define VIN_Pin GPIO_PIN_2
|
||||
#define VIN_GPIO_Port GPIOA
|
||||
#define VIN_ADC1_CHANNEL ADC_CHANNEL_2
|
||||
#define VIN_ADC2_CHANNEL ADC_CHANNEL_2
|
||||
#define OLED_RESET_Pin GPIO_PIN_15
|
||||
#define OLED_RESET_GPIO_Port GPIOA
|
||||
#define KEY_A_Pin GPIO_PIN_1
|
||||
#define KEY_A_GPIO_Port GPIOB
|
||||
#define INT_Orientation_Pin GPIO_PIN_4
|
||||
#define INT_Orientation_GPIO_Port GPIOB
|
||||
#define PWM_Out_Pin GPIO_PIN_6
|
||||
#define PWM_Out_GPIO_Port GPIOA
|
||||
#define PWM_Out_CHANNEL TIM_CHANNEL_1
|
||||
#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
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Keep in a uint8_t range for the ID's
|
||||
*/
|
||||
#ifdef MODEL_TS100
|
||||
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,
|
||||
};
|
||||
#endif
|
||||
#ifdef MODEL_TS80
|
||||
enum TipType {
|
||||
TS_B02 = 0, TS_D25 = 1, Tip_MiniWare = 2, Tip_Custom = 3,
|
||||
};
|
||||
#endif
|
||||
extern uint16_t tipGainCalValue ;
|
||||
|
||||
uint16_t lookupTipDefaultCalValue(enum TipType tipID);
|
||||
uint16_t getHandleTemperature();
|
||||
uint16_t getTipRawTemp(uint8_t refresh);
|
||||
uint16_t getInputVoltageX10(uint16_t divisor,uint8_t sample);
|
||||
|
||||
void setTipPWM(uint8_t pulse);
|
||||
uint16_t ctoTipMeasurement(uint16_t temp);
|
||||
uint16_t tipMeasurementToC(uint16_t raw);
|
||||
uint16_t ftoTipMeasurement(uint16_t temp);
|
||||
#ifdef ENABLED_FAHRENHEIT_SUPPORT
|
||||
uint16_t tipMeasurementToF(uint16_t raw);
|
||||
#endif
|
||||
void seekQC(int16_t Vx10, uint16_t divisor);
|
||||
void setCalibrationOffset(int16_t offSet);
|
||||
void setTipType(enum TipType tipType, uint8_t manualCalGain);
|
||||
uint32_t calculateTipR();
|
||||
int16_t calculateMaxVoltage(uint8_t useHP);
|
||||
void startQC(uint16_t divisor); // Tries to negotiate QC for highest voltage, must be run after
|
||||
// RToS
|
||||
// This will try for 12V, failing that 9V, failing that 5V
|
||||
// If input is over 12V returns -1
|
||||
// If the input is [5-12] Will return the value.
|
||||
void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,
|
||||
StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize) ;
|
||||
void vApplicationIdleHook(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HARDWARE_H_ */
|
||||
@@ -7,25 +7,7 @@
|
||||
extern uint8_t PCBVersion;
|
||||
extern uint32_t currentTempTargetDegC;
|
||||
extern bool settingsWereReset;
|
||||
enum ButtonState {
|
||||
BUTTON_NONE = 0, /* No buttons pressed / < filter time*/
|
||||
BUTTON_F_SHORT = 1, /* User has pressed the front button*/
|
||||
BUTTON_B_SHORT = 2, /* User has pressed the back button*/
|
||||
BUTTON_F_LONG = 4, /* User is holding the front button*/
|
||||
BUTTON_B_LONG = 8, /* User is holding the back button*/
|
||||
BUTTON_BOTH = 16, /* User has pressed both buttons*/
|
||||
|
||||
/*
|
||||
* Note:
|
||||
* Pressed means press + release, we trigger on a full \__/ pulse
|
||||
* holding means it has gone low, and been low for longer than filter time
|
||||
*/
|
||||
};
|
||||
|
||||
ButtonState getButtonState();
|
||||
void waitForButtonPressOrTimeout(uint32_t timeout);
|
||||
void waitForButtonPress();
|
||||
void GUIDelay();
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "stdint.h"
|
||||
#include <history.hpp>
|
||||
#include "hardware.h"
|
||||
#include "BSP.h"
|
||||
#include "expMovingAverage.h"
|
||||
#ifndef POWER_HPP_
|
||||
#define POWER_HPP_
|
||||
|
||||
Reference in New Issue
Block a user