aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBen V. Brown <[email protected]>2020-05-30 13:04:45 +1000
committerGitHub <[email protected]>2020-05-30 13:04:45 +1000
commit1207f65ba9ac3756544f66439998dbdce6644d4f (patch)
treeaf81a2ae8d37e2ad26afddf0e8f87201a1a3aaa1
parent45614ff39721d95db07b705540d6228931949902 (diff)
parent7cff1cdf3bea0e443bd75bd78cef6574194cb3f9 (diff)
downloadIronOS-1207f65ba9ac3756544f66439998dbdce6644d4f.tar.gz
IronOS-1207f65ba9ac3756544f66439998dbdce6644d4f.zip
Merge pull request #634 from Ralim/feat/BSP
Feature: Move board dependant code to be separate
-rw-r--r--Dockerfile2
-rw-r--r--workspace/TS100/Core/BSP/BSP.h55
-rw-r--r--workspace/TS100/Core/BSP/BSP_Flash.h26
-rw-r--r--workspace/TS100/Core/BSP/BSP_Power.h27
-rw-r--r--workspace/TS100/Core/BSP/BSP_QC.h42
-rw-r--r--workspace/TS100/Core/BSP/Defines.h19
-rw-r--r--workspace/TS100/Core/BSP/Miniware/BSP.cpp256
-rw-r--r--workspace/TS100/Core/BSP/Miniware/I2C_Wrapper.cpp142
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Pins.h (renamed from workspace/TS100/Core/Inc/hardware.h)231
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Power.cpp21
-rw-r--r--workspace/TS100/Core/BSP/Miniware/QC_GPIO.cpp74
-rw-r--r--workspace/TS100/Core/BSP/Miniware/README.md12
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Setup.c (renamed from workspace/TS100/Core/Src/Setup.c)11
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Setup.h (renamed from workspace/TS100/Core/Inc/Setup.h)76
-rw-r--r--workspace/TS100/Core/BSP/Miniware/UnitSettings.h18
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h (renamed from workspace/TS100/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h (renamed from workspace/TS100/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h (renamed from workspace/TS100/Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/arm_common_tables.h (renamed from workspace/TS100/Drivers/CMSIS/Include/arm_common_tables.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/arm_const_structs.h (renamed from workspace/TS100/Drivers/CMSIS/Include/arm_const_structs.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/arm_math.h (renamed from workspace/TS100/Drivers/CMSIS/Include/arm_math.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/cmsis_armcc.h (renamed from workspace/TS100/Drivers/CMSIS/Include/cmsis_armcc.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/cmsis_armcc_V6.h (renamed from workspace/TS100/Drivers/CMSIS/Include/cmsis_armcc_V6.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/cmsis_gcc.h (renamed from workspace/TS100/Drivers/CMSIS/Include/cmsis_gcc.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cm0.h (renamed from workspace/TS100/Drivers/CMSIS/Include/core_cm0.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cm0plus.h (renamed from workspace/TS100/Drivers/CMSIS/Include/core_cm0plus.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cm3.h (renamed from workspace/TS100/Drivers/CMSIS/Include/core_cm3.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cm4.h (renamed from workspace/TS100/Drivers/CMSIS/Include/core_cm4.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cm7.h (renamed from workspace/TS100/Drivers/CMSIS/Include/core_cm7.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cmFunc.h (renamed from workspace/TS100/Drivers/CMSIS/Include/core_cmFunc.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cmInstr.h (renamed from workspace/TS100/Drivers/CMSIS/Include/core_cmInstr.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cmSimd.h (renamed from workspace/TS100/Drivers/CMSIS/Include/core_cmSimd.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_sc000.h (renamed from workspace/TS100/Drivers/CMSIS/Include/core_sc000.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_sc300.h (renamed from workspace/TS100/Drivers/CMSIS/Include/core_sc300.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc.h (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc_ex.h (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc_ex.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_i2c.h (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_i2c.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_iwdg.h (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_iwdg.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_iwdg.c (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_iwdg.c)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c (renamed from workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c)0
-rw-r--r--workspace/TS100/Core/BSP/Miniware/flash.c49
-rw-r--r--workspace/TS100/Core/BSP/Miniware/logo.cpp27
-rw-r--r--workspace/TS100/Core/BSP/Miniware/postRTOS.cpp13
-rw-r--r--workspace/TS100/Core/BSP/Miniware/preRTOS.cpp22
-rw-r--r--workspace/TS100/Core/BSP/Miniware/stm32f1xx_hal_msp.c (renamed from workspace/TS100/Core/Src/stm32f1xx_hal_msp.c)272
-rw-r--r--workspace/TS100/Core/BSP/Miniware/stm32f1xx_hal_timebase_TIM.c (renamed from workspace/TS100/Core/Src/stm32f1xx_hal_timebase_TIM.c)316
-rw-r--r--workspace/TS100/Core/BSP/Miniware/stm32f1xx_it.c (renamed from workspace/TS100/Core/Src/stm32f1xx_it.c)168
-rw-r--r--workspace/TS100/Core/BSP/Miniware/system_stm32f1xx.c (renamed from workspace/TS100/Core/Src/system_stm32f1xx.c)634
-rw-r--r--workspace/TS100/Core/Drivers/Buttons.cpp115
-rw-r--r--workspace/TS100/Core/Drivers/Buttons.hpp35
-rw-r--r--workspace/TS100/Core/Drivers/Font.h (renamed from workspace/TS100/Core/Inc/Font.h)384
-rw-r--r--workspace/TS100/Core/Drivers/I2C_Wrapper.hpp (renamed from workspace/TS100/Core/Inc/FRToSI2C.hpp)96
-rw-r--r--workspace/TS100/Core/Drivers/LIS2DH12.cpp52
-rw-r--r--workspace/TS100/Core/Drivers/LIS2DH12.hpp (renamed from workspace/TS100/Core/Inc/LIS2DH12.hpp)84
-rw-r--r--workspace/TS100/Core/Drivers/LIS2DH12_defines.hpp (renamed from workspace/TS100/Core/Inc/LIS2DH12_defines.hpp)56
-rw-r--r--workspace/TS100/Core/Drivers/MMA8652FC.cpp (renamed from workspace/TS100/Core/Src/MMA8652FC.cpp)166
-rw-r--r--workspace/TS100/Core/Drivers/MMA8652FC.hpp27
-rw-r--r--workspace/TS100/Core/Drivers/MMA8652FC_defines.h (renamed from workspace/TS100/Core/Inc/MMA8652FC_defines.h)248
-rw-r--r--workspace/TS100/Core/Drivers/OLED.cpp (renamed from workspace/TS100/Core/Src/OLED.cpp)20
-rw-r--r--workspace/TS100/Core/Drivers/OLED.hpp (renamed from workspace/TS100/Core/Inc/OLED.hpp)35
-rw-r--r--workspace/TS100/Core/Drivers/README.md10
-rw-r--r--workspace/TS100/Core/Drivers/TipThermoModel.cpp (renamed from workspace/TS100/Core/Src/TipThermoModel.cpp)2
-rw-r--r--workspace/TS100/Core/Drivers/TipThermoModel.h (renamed from workspace/TS100/Core/Src/TipThermoModel.h)2
-rw-r--r--workspace/TS100/Core/Inc/FreeRTOSHooks.h28
-rw-r--r--workspace/TS100/Core/Inc/MMA8652FC.hpp27
-rw-r--r--workspace/TS100/Core/Inc/QC3.h21
-rw-r--r--workspace/TS100/Core/Inc/Settings.h6
-rw-r--r--workspace/TS100/Core/Inc/Translation.h2
-rw-r--r--workspace/TS100/Core/Inc/gui.hpp76
-rw-r--r--workspace/TS100/Core/Inc/main.hpp26
-rw-r--r--workspace/TS100/Core/Inc/power.hpp2
-rw-r--r--workspace/TS100/Core/Src/FRToSI2C.cpp189
-rw-r--r--workspace/TS100/Core/Src/FreeRTOSHooks.c32
-rw-r--r--workspace/TS100/Core/Src/GUIThread.cpp915
-rw-r--r--workspace/TS100/Core/Src/LIS2DH12.cpp50
-rw-r--r--workspace/TS100/Core/Src/QC3.c157
-rw-r--r--workspace/TS100/Core/Src/Settings.cpp46
-rw-r--r--workspace/TS100/Core/Src/gui.cpp2
-rw-r--r--workspace/TS100/Core/Src/hardware.cpp393
-rw-r--r--workspace/TS100/Core/Src/main.cpp303
-rw-r--r--workspace/TS100/Core/Src/power.cpp4
-rw-r--r--workspace/TS100/Core/Src/syscalls.c114
-rw-r--r--workspace/TS100/Core/Src/sysmem.c18
-rw-r--r--workspace/TS100/Core/Threads/GUIThread.cpp756
-rw-r--r--workspace/TS100/Core/Threads/MOVThread.cpp93
-rw-r--r--workspace/TS100/Core/Threads/PIDThread.cpp128
-rw-r--r--workspace/TS100/Makefile486
-rw-r--r--workspace/TS100/Src/syscalls.c184
-rw-r--r--workspace/TS100/Src/sysmem.c83
-rwxr-xr-xworkspace/TS100/build.sh105
119 files changed, 4135 insertions, 3956 deletions
diff --git a/Dockerfile b/Dockerfile
index e9e9b6ae..8e07117d 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM ubuntu:rolling
+FROM ubuntu:20.04
LABEL maintainer="Ben V. Brown <[email protected]>"
WORKDIR /build
diff --git a/workspace/TS100/Core/BSP/BSP.h b/workspace/TS100/Core/BSP/BSP.h
new file mode 100644
index 00000000..a558baad
--- /dev/null
+++ b/workspace/TS100/Core/BSP/BSP.h
@@ -0,0 +1,55 @@
+#include "BSP_Flash.h"
+#include "BSP_Power.h"
+#include "BSP_QC.h"
+#include "Defines.h"
+#include "UnitSettings.h"
+#include "stdint.h"
+/*
+ * BSP.h -- Board Support
+ *
+ * This exposes functions that are expected to be implemented to add support for different hardware
+ */
+
+#ifndef BSP_BSP_H_
+#define BSP_BSP_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Called first thing in main() to init the hardware
+void preRToSInit();
+// Called once the RToS has started for any extra work
+void postRToSInit();
+
+// Called to reset the hardware watchdog unit
+void resetWatchdog();
+// Accepts a output level of 0.. to use to control the tip output PWM
+void setTipPWM(uint8_t pulse);
+// Returns the Handle temp in C, X10
+uint16_t getHandleTemperature();
+// Returns the Tip temperature ADC reading in raw units
+uint16_t getTipRawTemp(uint8_t refresh);
+// Returns the main DC input voltage, using the adjustable divisor + sample flag
+uint16_t getInputVoltageX10(uint16_t divisor, uint8_t sample);
+
+// Readers for the two buttons
+// !! Returns 1 if held down, 0 if released
+uint8_t getButtonA();
+uint8_t getButtonB();
+
+// This is a work around that will be called if I2C starts to bug out
+// This should toggle the SCL line until SDA goes high to end the current transaction
+void unstick_I2C();
+
+// Reboot the IC when things go seriously wrong
+void reboot();
+
+// If the user has programmed in a bootup logo, draw it to the screen from flash
+// Returns 1 if the logo was printed so that the unit waits for the timeout or button
+uint8_t showBootLogoIfavailable();
+
+void delay_ms(uint16_t count);
+#ifdef __cplusplus
+}
+#endif
+#endif /* BSP_BSP_H_ */
diff --git a/workspace/TS100/Core/BSP/BSP_Flash.h b/workspace/TS100/Core/BSP/BSP_Flash.h
new file mode 100644
index 00000000..d03ecd33
--- /dev/null
+++ b/workspace/TS100/Core/BSP/BSP_Flash.h
@@ -0,0 +1,26 @@
+/*
+ * BSP_Flash.h
+ *
+ * Created on: 29 May 2020
+ * Author: Ralim
+ */
+#include "stdint.h"
+#ifndef BSP_BSP_FLASH_H_
+#define BSP_BSP_FLASH_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Wrappers to allow read/writing to a sector of flash that we use to store all of the user settings
+ *
+ * Should allow reading and writing to the flash
+ */
+
+//Erase the flash, then save the buffer. Returns 1 if worked
+uint8_t flash_save_buffer(const uint8_t *buffer, const uint16_t length);
+
+void flash_read_buffer(uint8_t *buffer, const uint16_t length);
+#ifdef __cplusplus
+}
+#endif
+#endif /* BSP_BSP_FLASH_H_ */
diff --git a/workspace/TS100/Core/BSP/BSP_Power.h b/workspace/TS100/Core/BSP/BSP_Power.h
new file mode 100644
index 00000000..1ce7f2bf
--- /dev/null
+++ b/workspace/TS100/Core/BSP/BSP_Power.h
@@ -0,0 +1,27 @@
+#include "stdint.h"
+/*
+ * BSP_Power.h -- Board Support for Power control
+ *
+ * These functions are hooks used to allow for power control
+ *
+ */
+
+#ifndef BSP_POWER_H_
+#define BSP_POWER_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Called once at startup, after RToS
+// This can handle negotiations for QC/PD etc
+void power_probe();
+
+// Called periodically in the movement handling thread
+// Can be used to check any details for the power system
+void power_check();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/workspace/TS100/Core/BSP/BSP_QC.h b/workspace/TS100/Core/BSP/BSP_QC.h
new file mode 100644
index 00000000..d1536a09
--- /dev/null
+++ b/workspace/TS100/Core/BSP/BSP_QC.h
@@ -0,0 +1,42 @@
+/*
+ * BSP_QC.h
+ *
+ * Created on: 29 May 2020
+ * Author: Ralim
+ */
+
+#ifndef BSP_BSP_QC_H_
+#define BSP_BSP_QC_H_
+#include "stdint.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Init GPIO for QC neg
+void QC_Init_GPIO();
+// Set the DP pin to 0.6V
+void QC_DPlusZero_Six();
+// Set the DM pin to 0.6V
+void QC_DNegZero_Six();
+// Set the DP pin to 3.3V
+void QC_DPlusThree_Three();
+// Set the DM pin to 3.3V
+void QC_DNegThree_Three();
+// Turn on weak pulldown on the DM pin
+// This is used as a helper for some power banks
+void QC_DM_PullDown();
+// Turn off the pulldown
+void QC_DM_No_PullDown();
+// Turn on output drivers that were initally disabled to prevent spike through QC disable mode
+void QC_Post_Probe_En();
+// Check if DM was pulled down
+// 1=Pulled down, 0 == pulled high
+uint8_t QC_DM_PulledDown();
+
+// Re-sync if required
+void QC_resync();
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BSP_BSP_QC_H_ */
diff --git a/workspace/TS100/Core/BSP/Defines.h b/workspace/TS100/Core/BSP/Defines.h
new file mode 100644
index 00000000..52556f99
--- /dev/null
+++ b/workspace/TS100/Core/BSP/Defines.h
@@ -0,0 +1,19 @@
+/*
+ * Defines.h
+ *
+ * Created on: 29 May 2020
+ * Author: Ralim
+ */
+
+#ifndef BSP_DEFINES_H_
+#define BSP_DEFINES_H_
+
+
+enum Orientation {
+ ORIENTATION_LEFT_HAND = 0, ORIENTATION_RIGHT_HAND = 1, ORIENTATION_FLAT = 3
+};
+
+//It is assumed that all hardware implements an 8Hz update period at this time
+#define PID_TIM_HZ (8)
+
+#endif /* BSP_DEFINES_H_ */
diff --git a/workspace/TS100/Core/BSP/Miniware/BSP.cpp b/workspace/TS100/Core/BSP/Miniware/BSP.cpp
new file mode 100644
index 00000000..591f005c
--- /dev/null
+++ b/workspace/TS100/Core/BSP/Miniware/BSP.cpp
@@ -0,0 +1,256 @@
+//BSP mapping functions
+
+#include "BSP.h"
+#include "Setup.h"
+#include "history.hpp"
+#include "Pins.h"
+#include "main.hpp"
+#include "history.hpp"
+#include "I2C_Wrapper.hpp"
+volatile uint16_t PWMSafetyTimer = 0;
+volatile uint8_t pendingPWM = 0;
+
+//2 second filter (ADC is PID_TIM_HZ Hz)
+history<uint16_t, PID_TIM_HZ> rawTempFilter = { { 0 }, 0, 0 };
+void resetWatchdog() {
+ HAL_IWDG_Refresh(&hiwdg);
+}
+
+uint16_t getHandleTemperature() {
+ // We return the current handle temperature in X10 C
+ // TMP36 in handle, 0.5V offset and then 10mV per deg C (0.75V @ 25C for
+ // example) STM32 = 4096 count @ 3.3V input -> But We oversample by 32/(2^2) =
+ // 8 times oversampling Therefore 32768 is the 3.3V input, so 0.1007080078125
+ // mV per count So we need to subtract an offset of 0.5V to center on 0C
+ // (4964.8 counts)
+ //
+ int32_t result = getADC(0);
+ result -= 4965; // remove 0.5V offset
+ // 10mV per C
+ // 99.29 counts per Deg C above 0C
+ result *= 100;
+ result /= 993;
+ return result;
+}
+
+uint16_t getTipInstantTemperature() {
+ uint16_t sum = 0; // 12 bit readings * 8 -> 15 bits
+ uint16_t readings[8];
+ //Looking to reject the highest outlier readings.
+ //As on some hardware these samples can run into the op-amp recovery time
+ //Once this time is up the signal stabilises quickly, so no need to reject minimums
+ readings[0] = hadc1.Instance->JDR1;
+ readings[1] = hadc1.Instance->JDR2;
+ readings[2] = hadc1.Instance->JDR3;
+ readings[3] = hadc1.Instance->JDR4;
+ readings[4] = hadc2.Instance->JDR1;
+ readings[5] = hadc2.Instance->JDR2;
+ readings[6] = hadc2.Instance->JDR3;
+ readings[7] = hadc2.Instance->JDR4;
+
+ for (int i = 0; i < 8; i++) {
+ sum += readings[i];
+ }
+ return sum; // 8x over sample
+}
+
+uint16_t getTipRawTemp(uint8_t refresh) {
+ if (refresh) {
+ uint16_t lastSample = getTipInstantTemperature();
+ rawTempFilter.update(lastSample);
+ return lastSample;
+ } else {
+ return rawTempFilter.average();
+ }
+}
+
+uint16_t getInputVoltageX10(uint16_t divisor, uint8_t sample) {
+ // ADC maximum is 32767 == 3.3V at input == 28.05V at VIN
+ // Therefore we can divide down from there
+ // Multiplying ADC max by 4 for additional calibration options,
+ // ideal term is 467
+#ifdef MODEL_TS100
+#define BATTFILTERDEPTH 32
+#else
+#define BATTFILTERDEPTH 8
+
+#endif
+ static uint8_t preFillneeded = 10;
+ static uint32_t samples[BATTFILTERDEPTH];
+ static uint8_t index = 0;
+ if (preFillneeded) {
+ for (uint8_t i = 0; i < BATTFILTERDEPTH; i++)
+ samples[i] = getADC(1);
+ preFillneeded--;
+ }
+ if (sample) {
+ samples[index] = getADC(1);
+ index = (index + 1) % BATTFILTERDEPTH;
+ }
+ uint32_t sum = 0;
+
+ for (uint8_t i = 0; i < BATTFILTERDEPTH; i++)
+ sum += samples[i];
+
+ sum /= BATTFILTERDEPTH;
+ return sum * 4 / divisor;
+}
+
+void setTipPWM(uint8_t pulse) {
+ PWMSafetyTimer = 10; // This is decremented in the handler for PWM so that the tip pwm is
+ // disabled if the PID task is not scheduled often enough.
+
+ pendingPWM = pulse;
+}
+
+// These are called by the HAL after the corresponding events from the system
+// timers.
+
+void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
+// Period has elapsed
+ if (htim->Instance == TIM2) {
+ // we want to turn on the output again
+ PWMSafetyTimer--;
+ // We decrement this safety value so that lockups in the
+ // scheduler will not cause the PWM to become locked in an
+ // active driving state.
+ // While we could assume this could never happen, its a small price for
+ // increased safety
+ htim2.Instance->CCR4 = pendingPWM;
+ if (htim2.Instance->CCR4 && PWMSafetyTimer) {
+ HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1);
+ } else {
+ HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_1);
+ }
+ } else if (htim->Instance == TIM1) {
+ // STM uses this for internal functions as a counter for timeouts
+ HAL_IncTick();
+ }
+}
+
+void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim) {
+// This was a when the PWM for the output has timed out
+ if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_4) {
+ HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_1);
+ }
+}
+void unstick_I2C() {
+ GPIO_InitTypeDef GPIO_InitStruct;
+ int timeout = 100;
+ int timeout_cnt = 0;
+
+ // 1. Clear PE bit.
+ hi2c1.Instance->CR1 &= ~(0x0001);
+ /**I2C1 GPIO Configuration
+ PB6 ------> I2C1_SCL
+ PB7 ------> I2C1_SDA
+ */
+ // 2. Configure the SCL and SDA I/Os as General Purpose Output Open-Drain, High level (Write 1 to GPIOx_ODR).
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+
+ GPIO_InitStruct.Pin = SCL_Pin;
+ HAL_GPIO_Init(SCL_GPIO_Port, &GPIO_InitStruct);
+ HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_SET);
+
+ GPIO_InitStruct.Pin = SDA_Pin;
+ HAL_GPIO_Init(SDA_GPIO_Port, &GPIO_InitStruct);
+ HAL_GPIO_WritePin(SDA_GPIO_Port, SDA_Pin, GPIO_PIN_SET);
+
+ while (GPIO_PIN_SET != HAL_GPIO_ReadPin(SDA_GPIO_Port, SDA_Pin)) {
+ //Move clock to release I2C
+ HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_RESET);
+ asm("nop");
+ asm("nop");
+ asm("nop");
+ asm("nop");
+ HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_SET);
+
+ timeout_cnt++;
+ if (timeout_cnt > timeout)
+ return;
+ }
+
+ // 12. Configure the SCL and SDA I/Os as Alternate function Open-Drain.
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+
+ GPIO_InitStruct.Pin = SCL_Pin;
+ HAL_GPIO_Init(SCL_GPIO_Port, &GPIO_InitStruct);
+
+ GPIO_InitStruct.Pin = SDA_Pin;
+ HAL_GPIO_Init(SDA_GPIO_Port, &GPIO_InitStruct);
+
+ HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_SET);
+ HAL_GPIO_WritePin(SDA_GPIO_Port, SDA_Pin, GPIO_PIN_SET);
+
+ // 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;
+
+ asm("nop");
+
+ // 15. Enable the I2C peripheral by setting the PE bit in I2Cx_CR1 register
+ hi2c1.Instance->CR1 |= 0x0001;
+
+ // Call initialization function.
+ HAL_I2C_Init(&hi2c1);
+}
+
+uint8_t getButtonA() {
+ return HAL_GPIO_ReadPin(KEY_A_GPIO_Port, KEY_A_Pin) == GPIO_PIN_RESET ?
+ 1 : 0;
+}
+uint8_t getButtonB() {
+ return HAL_GPIO_ReadPin(KEY_B_GPIO_Port, KEY_B_Pin) == GPIO_PIN_RESET ?
+ 1 : 0;
+}
+
+/*
+ * Catch the IRQ that says that the conversion is done on the temperature
+ * readings coming in Once these have come in we can unblock the PID so that it
+ * runs again
+ */
+void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef *hadc) {
+ BaseType_t xHigherPriorityTaskWoken = pdFALSE;
+ if (hadc == &hadc1) {
+ if (pidTaskNotification) {
+ vTaskNotifyGiveFromISR(pidTaskNotification,
+ &xHigherPriorityTaskWoken);
+ portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
+ }
+ }
+}
+void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
+ FRToSI2C::CpltCallback();
+}
+void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
+ FRToSI2C::CpltCallback();
+}
+void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
+ FRToSI2C::CpltCallback();
+}
+void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c __unused) {
+
+ FRToSI2C::CpltCallback();
+}
+void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
+
+ FRToSI2C::CpltCallback();
+}
+void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
+ FRToSI2C::CpltCallback();
+}
+void reboot() {
+ NVIC_SystemReset();
+}
+
+void delay_ms(uint16_t count) {
+ HAL_Delay(count);
+}
diff --git a/workspace/TS100/Core/BSP/Miniware/I2C_Wrapper.cpp b/workspace/TS100/Core/BSP/Miniware/I2C_Wrapper.cpp
new file mode 100644
index 00000000..ad727723
--- /dev/null
+++ b/workspace/TS100/Core/BSP/Miniware/I2C_Wrapper.cpp
@@ -0,0 +1,142 @@
+/*
+ * FRToSI2C.cpp
+ *
+ * Created on: 14Apr.,2018
+ * Author: Ralim
+ */
+#include <I2C_Wrapper.hpp>
+#include "BSP.h"
+#include "Setup.h"
+#define I2CUSESDMA
+SemaphoreHandle_t FRToSI2C::I2CSemaphore;
+StaticSemaphore_t FRToSI2C::xSemaphoreBuffer;
+
+void FRToSI2C::CpltCallback() {
+ hi2c1.State = HAL_I2C_STATE_READY; // Force state reset (even if tx error)
+ if (I2CSemaphore) {
+ xSemaphoreGiveFromISR(I2CSemaphore, NULL);
+ }
+}
+
+bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
+ uint8_t *pData, uint16_t Size) {
+
+ if (I2CSemaphore == NULL) {
+ // no RToS, run blocking code
+ HAL_I2C_Mem_Read(&hi2c1, DevAddress, MemAddress, I2C_MEMADD_SIZE_8BIT,
+ pData, Size, 5000);
+ return true;
+ } else {
+ // RToS is active, run threading
+ // Get the mutex so we can use the I2C port
+ // Wait up to 1 second for the mutex
+ if (xSemaphoreTake(I2CSemaphore, (TickType_t)50) == pdTRUE) {
+#ifdef I2CUSESDMA
+ if (HAL_I2C_Mem_Read(&hi2c1, DevAddress, MemAddress,
+ I2C_MEMADD_SIZE_8BIT, pData, Size, 500) != HAL_OK) {
+
+ I2C_Unstick();
+ xSemaphoreGive(I2CSemaphore);
+ return false;
+ } else {
+ xSemaphoreGive(I2CSemaphore);
+ return true;
+ }
+#else
+
+ if (HAL_I2C_Mem_Read(&hi2c1, DevAddress, MemAddress, I2C_MEMADD_SIZE_8BIT, pData, Size,
+ 5000)==HAL_OK){
+ xSemaphoreGive(I2CSemaphore);
+ return true;
+ }
+ xSemaphoreGive(I2CSemaphore);
+ return false;
+#endif
+ } else {
+ return false;
+ }
+ }
+
+}
+void FRToSI2C::I2C_RegisterWrite(uint8_t address, uint8_t reg, uint8_t data) {
+ Mem_Write(address, reg, &data, 1);
+}
+
+uint8_t FRToSI2C::I2C_RegisterRead(uint8_t add, uint8_t reg) {
+ uint8_t tx_data[1];
+ Mem_Read(add, reg, tx_data, 1);
+ return tx_data[0];
+}
+void FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
+ uint8_t *pData, uint16_t Size) {
+
+ if (I2CSemaphore == NULL) {
+ // no RToS, run blocking code
+ HAL_I2C_Mem_Write(&hi2c1, DevAddress, MemAddress, I2C_MEMADD_SIZE_8BIT,
+ pData, Size, 5000);
+ } else {
+ // RToS is active, run threading
+ // Get the mutex so we can use the I2C port
+ // Wait up to 1 second for the mutex
+ if (xSemaphoreTake(I2CSemaphore, (TickType_t)50) == pdTRUE) {
+#ifdef I2CUSESDMA
+ if (HAL_I2C_Mem_Write(&hi2c1, DevAddress, MemAddress,
+ I2C_MEMADD_SIZE_8BIT, pData, Size, 500) != HAL_OK) {
+
+ I2C_Unstick();
+ xSemaphoreGive(I2CSemaphore);
+ }
+ xSemaphoreGive(I2CSemaphore);
+#else
+ if (HAL_I2C_Mem_Write(&hi2c1, DevAddress, MemAddress, I2C_MEMADD_SIZE_8BIT, pData,
+ Size, 5000) != HAL_OK) {
+ }
+ xSemaphoreGive(I2CSemaphore);
+#endif
+ } else {
+ }
+ }
+
+}
+
+void FRToSI2C::Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size) {
+ if (I2CSemaphore == NULL) {
+ // no RToS, run blocking code
+ HAL_I2C_Master_Transmit(&hi2c1, DevAddress, pData, Size, 5000);
+ } else {
+ // RToS is active, run threading
+ // Get the mutex so we can use the I2C port
+ // Wait up to 1 second for the mutex
+ if (xSemaphoreTake(I2CSemaphore, (TickType_t)50) == pdTRUE) {
+#ifdef I2CUSESDMA
+
+ if (HAL_I2C_Master_Transmit_DMA(&hi2c1, DevAddress, pData, Size)
+ != HAL_OK) {
+
+ I2C_Unstick();
+ xSemaphoreGive(I2CSemaphore);
+
+ }
+#else
+ HAL_I2C_Master_Transmit(&hi2c1, DevAddress, pData, Size, 5000);
+ xSemaphoreGive(I2CSemaphore);
+#endif
+
+ } else {
+ }
+ }
+
+}
+
+bool FRToSI2C::probe(uint16_t DevAddress) {
+ uint8_t buffer[1];
+ if (Mem_Read(DevAddress, 0, buffer, 1)) {
+ //ACK'd
+ return true;
+ }
+ return false;
+}
+
+void FRToSI2C::I2C_Unstick() {
+ unstick_I2C();
+}
diff --git a/workspace/TS100/Core/Inc/hardware.h b/workspace/TS100/Core/BSP/Miniware/Pins.h
index 87bf69cc..1f0ddfa9 100644
--- a/workspace/TS100/Core/Inc/hardware.h
+++ b/workspace/TS100/Core/BSP/Miniware/Pins.h
@@ -1,148 +1,83 @@
-/*
- * 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_ */
+/*
+ * Pins.h
+ *
+ * Created on: 29 May 2020
+ * Author: Ralim
+ */
+
+#ifndef BSP_MINIWARE_PINS_H_
+#define BSP_MINIWARE_PINS_H_
+
+#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
+
+#endif /* BSP_MINIWARE_PINS_H_ */
diff --git a/workspace/TS100/Core/BSP/Miniware/Power.cpp b/workspace/TS100/Core/BSP/Miniware/Power.cpp
new file mode 100644
index 00000000..30386c83
--- /dev/null
+++ b/workspace/TS100/Core/BSP/Miniware/Power.cpp
@@ -0,0 +1,21 @@
+#include "BSP.h"
+#include "BSP_Power.h"
+#include "QC3.h"
+#include "Settings.h"
+void power_probe() {
+// If TS80 probe for QC
+// If TS100 - noop
+#ifdef MODEL_TS80
+ startQC(systemSettings.voltageDiv);
+
+ seekQC((systemSettings.cutoutSetting) ? 120 : 90,
+ systemSettings.voltageDiv); // this will move the QC output to the preferred voltage to start with
+
+#endif
+}
+
+void power_check() {
+#ifdef MODEL_TS80
+ QC_resync();
+#endif
+} \ No newline at end of file
diff --git a/workspace/TS100/Core/BSP/Miniware/QC_GPIO.cpp b/workspace/TS100/Core/BSP/Miniware/QC_GPIO.cpp
new file mode 100644
index 00000000..bd3841c3
--- /dev/null
+++ b/workspace/TS100/Core/BSP/Miniware/QC_GPIO.cpp
@@ -0,0 +1,74 @@
+/*
+ * QC.c
+ *
+ * Created on: 29 May 2020
+ * Author: Ralim
+ */
+#include "BSP.h"
+#include "Pins.h"
+#include "QC3.h"
+#include "Settings.h"
+#include "stm32f1xx_hal.h"
+void QC_DPlusZero_Six() {
+ HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET); // pull down D+
+}
+void QC_DNegZero_Six() {
+ HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_SET);
+ HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET);
+}
+void QC_DPlusThree_Three() {
+ HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_SET); // pull up D+
+}
+void QC_DNegThree_Three() {
+ HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_SET);
+ HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET);
+}
+void QC_DM_PullDown() {
+ GPIO_InitTypeDef GPIO_InitStruct;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_PULLDOWN;
+ GPIO_InitStruct.Pin = GPIO_PIN_11;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+}
+void QC_DM_No_PullDown() {
+ GPIO_InitTypeDef GPIO_InitStruct;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Pin = GPIO_PIN_11;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+}
+void QC_Init_GPIO() {
+ // Setup any GPIO into the right states for QC
+ GPIO_InitTypeDef GPIO_InitStruct;
+ GPIO_InitStruct.Pin = GPIO_PIN_3;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_10;
+ HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+ // Turn off output mode on pins that we can
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_14 | GPIO_PIN_13;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+}
+void QC_Post_Probe_En() {
+ GPIO_InitTypeDef GPIO_InitStruct;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_10;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+}
+
+uint8_t QC_DM_PulledDown() { return HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_11) == GPIO_PIN_RESET ? 1 : 0; }
+
+void QC_resync() {
+#ifdef MODEL_TS80
+ seekQC((systemSettings.cutoutSetting) ? 120 : 90,
+ systemSettings.voltageDiv); // Run the QC seek again if we have drifted too much
+#endif
+} \ No newline at end of file
diff --git a/workspace/TS100/Core/BSP/Miniware/README.md b/workspace/TS100/Core/BSP/Miniware/README.md
new file mode 100644
index 00000000..bb9de245
--- /dev/null
+++ b/workspace/TS100/Core/BSP/Miniware/README.md
@@ -0,0 +1,12 @@
+# BSP section for STM32F103 based Miniware products
+
+This folder contains the hardware abstractions required for the TS100, TS80 and probably TS80P soldering irons.
+
+## Main abstractions
+
+* Hardware Init
+* -> Should contain all bootstrap to bring the hardware up to an operating point
+* -> Two functions are required, a pre and post FreeRToS call
+* I2C read/write
+* Set PWM for the tip
+* Links between IRQ's on the system and the calls in the rest of the firmware
diff --git a/workspace/TS100/Core/Src/Setup.c b/workspace/TS100/Core/BSP/Miniware/Setup.c
index 88aa1a3c..4b3d1f5b 100644
--- a/workspace/TS100/Core/Src/Setup.c
+++ b/workspace/TS100/Core/BSP/Miniware/Setup.c
@@ -5,6 +5,7 @@
* Author: Ben V. Brown
*/
#include "Setup.h"
+#include "Pins.h"
ADC_HandleTypeDef hadc1;
ADC_HandleTypeDef hadc2;
DMA_HandleTypeDef hdma_adc1;
@@ -32,12 +33,8 @@ static void MX_ADC2_Init(void);
void Setup_HAL() {
SystemClock_Config();
-#ifndef LOCAL_BUILD
__HAL_AFIO_REMAP_SWJ_DISABLE()
;
-#else
- __HAL_AFIO_REMAP_SWJ_NOJTAG();
-#endif
MX_GPIO_Init();
MX_DMA_Init();
@@ -49,8 +46,8 @@ void Setup_HAL() {
MX_IWDG_Init();
HAL_ADC_Start(&hadc2);
HAL_ADCEx_MultiModeStart_DMA(&hadc1, (uint32_t*) ADCReadings, 64); // 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
@@ -336,7 +333,7 @@ static void MX_TIM2_Init(void) {
HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig);
sConfigOC.OCMode = TIM_OCMODE_PWM1;
- sConfigOC.Pulse = 255 + 13;//13 -> Delay of 5ms
+ sConfigOC.Pulse = 255 + 13; //13 -> Delay of 5ms
//255 is the largest time period of the drive signal, and then offset ADC sample to be a bit delayed after this
/*
* It takes 4 milliseconds for output to be stable after PWM turns off.
diff --git a/workspace/TS100/Core/Inc/Setup.h b/workspace/TS100/Core/BSP/Miniware/Setup.h
index 3e8c5f46..c5b80813 100644
--- a/workspace/TS100/Core/Inc/Setup.h
+++ b/workspace/TS100/Core/BSP/Miniware/Setup.h
@@ -1,38 +1,38 @@
-/*
- * Setup.h
- *
- * Created on: 29Aug.,2017
- * Author: Ben V. Brown
- */
-
-#ifndef SETUP_H_
-#define SETUP_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-#include <hardware.h>
-#include "stm32f1xx_hal.h"
-
-extern ADC_HandleTypeDef hadc1;
-extern ADC_HandleTypeDef hadc2;
-extern DMA_HandleTypeDef hdma_adc1;
-
-extern DMA_HandleTypeDef hdma_i2c1_rx;
-extern DMA_HandleTypeDef hdma_i2c1_tx;
-extern I2C_HandleTypeDef hi2c1;
-
-extern IWDG_HandleTypeDef hiwdg;
-
-extern TIM_HandleTypeDef htim2;
-extern TIM_HandleTypeDef htim3;
-void Setup_HAL();
-uint16_t getADC(uint8_t channel);
-
-void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim); //Since the hal header file does not define this one
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* SETUP_H_ */
+/*
+ * Setup.h
+ *
+ * Created on: 29Aug.,2017
+ * Author: Ben V. Brown
+ */
+
+#ifndef SETUP_H_
+#define SETUP_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "stm32f1xx_hal.h"
+
+extern ADC_HandleTypeDef hadc1;
+extern ADC_HandleTypeDef hadc2;
+extern DMA_HandleTypeDef hdma_adc1;
+
+extern DMA_HandleTypeDef hdma_i2c1_rx;
+extern DMA_HandleTypeDef hdma_i2c1_tx;
+extern I2C_HandleTypeDef hi2c1;
+
+extern IWDG_HandleTypeDef hiwdg;
+
+extern TIM_HandleTypeDef htim2;
+extern TIM_HandleTypeDef htim3;
+void Setup_HAL();
+uint16_t getADC(uint8_t channel);
+
+void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); //Since the hal header file does not define this one
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SETUP_H_ */
diff --git a/workspace/TS100/Core/BSP/Miniware/UnitSettings.h b/workspace/TS100/Core/BSP/Miniware/UnitSettings.h
new file mode 100644
index 00000000..f3588b8b
--- /dev/null
+++ b/workspace/TS100/Core/BSP/Miniware/UnitSettings.h
@@ -0,0 +1,18 @@
+/*
+ * UnitSettings.h
+ *
+ * Created on: 29 May 2020
+ * Author: Ralim
+ */
+
+#ifndef BSP_MINIWARE_UNITSETTINGS_H_
+#define BSP_MINIWARE_UNITSETTINGS_H_
+//On the TS80, the LIS accel is mounted backwards
+#ifdef MODEL_TS80
+#define LIS_ORI_FLIP
+#endif
+
+
+
+
+#endif /* BSP_MINIWARE_UNITSETTINGS_H_ */
diff --git a/workspace/TS100/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h
index fdaf5c09..fdaf5c09 100644
--- a/workspace/TS100/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h
diff --git a/workspace/TS100/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h
index 333095ba..333095ba 100644
--- a/workspace/TS100/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h
diff --git a/workspace/TS100/Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h
index 3652ff59..3652ff59 100644
--- a/workspace/TS100/Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h
diff --git a/workspace/TS100/Drivers/CMSIS/Include/arm_common_tables.h b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/arm_common_tables.h
index d5d72417..d5d72417 100644
--- a/workspace/TS100/Drivers/CMSIS/Include/arm_common_tables.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/arm_common_tables.h
diff --git a/workspace/TS100/Drivers/CMSIS/Include/arm_const_structs.h b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/arm_const_structs.h
index 54595f55..54595f55 100644
--- a/workspace/TS100/Drivers/CMSIS/Include/arm_const_structs.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/arm_const_structs.h
diff --git a/workspace/TS100/Drivers/CMSIS/Include/arm_math.h b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/arm_math.h
index 580cbbde..580cbbde 100644
--- a/workspace/TS100/Drivers/CMSIS/Include/arm_math.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/arm_math.h
diff --git a/workspace/TS100/Drivers/CMSIS/Include/cmsis_armcc.h b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/cmsis_armcc.h
index f2bb66a0..f2bb66a0 100644
--- a/workspace/TS100/Drivers/CMSIS/Include/cmsis_armcc.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/cmsis_armcc.h
diff --git a/workspace/TS100/Drivers/CMSIS/Include/cmsis_armcc_V6.h b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/cmsis_armcc_V6.h
index d714e9b0..d714e9b0 100644
--- a/workspace/TS100/Drivers/CMSIS/Include/cmsis_armcc_V6.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/cmsis_armcc_V6.h
diff --git a/workspace/TS100/Drivers/CMSIS/Include/cmsis_gcc.h b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/cmsis_gcc.h
index d868f2e6..d868f2e6 100644
--- a/workspace/TS100/Drivers/CMSIS/Include/cmsis_gcc.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/cmsis_gcc.h
diff --git a/workspace/TS100/Drivers/CMSIS/Include/core_cm0.h b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cm0.h
index fdee521a..fdee521a 100644
--- a/workspace/TS100/Drivers/CMSIS/Include/core_cm0.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cm0.h
diff --git a/workspace/TS100/Drivers/CMSIS/Include/core_cm0plus.h b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cm0plus.h
index 7614450d..7614450d 100644
--- a/workspace/TS100/Drivers/CMSIS/Include/core_cm0plus.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cm0plus.h
diff --git a/workspace/TS100/Drivers/CMSIS/Include/core_cm3.h b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cm3.h
index 34ed84c1..34ed84c1 100644
--- a/workspace/TS100/Drivers/CMSIS/Include/core_cm3.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cm3.h
diff --git a/workspace/TS100/Drivers/CMSIS/Include/core_cm4.h b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cm4.h
index 01cb73bf..01cb73bf 100644
--- a/workspace/TS100/Drivers/CMSIS/Include/core_cm4.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cm4.h
diff --git a/workspace/TS100/Drivers/CMSIS/Include/core_cm7.h b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cm7.h
index 20963c14..20963c14 100644
--- a/workspace/TS100/Drivers/CMSIS/Include/core_cm7.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cm7.h
diff --git a/workspace/TS100/Drivers/CMSIS/Include/core_cmFunc.h b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cmFunc.h
index ca319a55..ca319a55 100644
--- a/workspace/TS100/Drivers/CMSIS/Include/core_cmFunc.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cmFunc.h
diff --git a/workspace/TS100/Drivers/CMSIS/Include/core_cmInstr.h b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cmInstr.h
index a0a50645..a0a50645 100644
--- a/workspace/TS100/Drivers/CMSIS/Include/core_cmInstr.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cmInstr.h
diff --git a/workspace/TS100/Drivers/CMSIS/Include/core_cmSimd.h b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cmSimd.h
index 4d76bf90..4d76bf90 100644
--- a/workspace/TS100/Drivers/CMSIS/Include/core_cmSimd.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_cmSimd.h
diff --git a/workspace/TS100/Drivers/CMSIS/Include/core_sc000.h b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_sc000.h
index ea16bf3e..ea16bf3e 100644
--- a/workspace/TS100/Drivers/CMSIS/Include/core_sc000.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_sc000.h
diff --git a/workspace/TS100/Drivers/CMSIS/Include/core_sc300.h b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_sc300.h
index 820cef4f..820cef4f 100644
--- a/workspace/TS100/Drivers/CMSIS/Include/core_sc300.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/CMSIS/Include/core_sc300.h
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h
index 41666dc4..41666dc4 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h
index 653a094e..653a094e 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc.h b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc.h
index fd79972a..fd79972a 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc.h
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc_ex.h b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc_ex.h
index b923ce41..b923ce41 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc_ex.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc_ex.h
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h
index 9cb0c835..9cb0c835 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h
index 0a0e54fe..0a0e54fe 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h
index 524f61f0..524f61f0 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h
index b5caf9fe..b5caf9fe 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h
index 399076dd..399076dd 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h
index 5ec01638..5ec01638 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h
index 2594a194..2594a194 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h
index ff4b96a4..ff4b96a4 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_i2c.h b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_i2c.h
index f8a68397..f8a68397 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_i2c.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_i2c.h
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_iwdg.h b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_iwdg.h
index 5a6f3955..5a6f3955 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_iwdg.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_iwdg.h
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h
index 8499c7fd..8499c7fd 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h
index 0e3bdfc5..0e3bdfc5 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h
index 0080f335..0080f335 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h
index aa62b797..aa62b797 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h
index 3ad03bfa..3ad03bfa 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c
index a449258b..a449258b 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c
index de1ba752..de1ba752 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c
index 2d539a22..2d539a22 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c
index ba8bb631..ba8bb631 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c
index d3989c2e..d3989c2e 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c
index ea723908..ea723908 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c
index b83fbc6a..b83fbc6a 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c
index 2d569515..2d569515 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c
index 551333bb..551333bb 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c
index 09846a44..09846a44 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_iwdg.c b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_iwdg.c
index 79fef5d9..79fef5d9 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_iwdg.c
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_iwdg.c
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c
index 44d66138..44d66138 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c
index e146d9b6..e146d9b6 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c
index 65db17b7..65db17b7 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c
index 9a42f0ed..9a42f0ed 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c
diff --git a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c
index 8bf99260..8bf99260 100644
--- a/workspace/TS100/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c
+++ b/workspace/TS100/Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c
diff --git a/workspace/TS100/Core/BSP/Miniware/flash.c b/workspace/TS100/Core/BSP/Miniware/flash.c
new file mode 100644
index 00000000..26432da8
--- /dev/null
+++ b/workspace/TS100/Core/BSP/Miniware/flash.c
@@ -0,0 +1,49 @@
+/*
+ * flash.c
+ *
+ * Created on: 29 May 2020
+ * Author: Ralim
+ */
+
+#include "BSP_Flash.h"
+#include "BSP.h"
+#include "string.h"
+#include "stm32f1xx_hal.h"
+/*Flash start OR'ed with the maximum amount of flash - 1024 bytes*/
+/*We use the last 1024 byte page*/
+#define FLASH_ADDR (0x8000000 |0xFC00)
+uint8_t flash_save_buffer(const uint8_t *buffer, const uint16_t length) {
+ FLASH_EraseInitTypeDef pEraseInit;
+ pEraseInit.TypeErase = FLASH_TYPEERASE_PAGES;
+ pEraseInit.Banks = FLASH_BANK_1;
+ pEraseInit.NbPages = 1;
+ pEraseInit.PageAddress = FLASH_ADDR;
+ uint32_t failingAddress = 0;
+ resetWatchdog();
+ __HAL_FLASH_CLEAR_FLAG(
+ FLASH_FLAG_EOP | FLASH_FLAG_WRPERR | FLASH_FLAG_PGERR | FLASH_FLAG_BSY);
+ HAL_FLASH_Unlock();
+ HAL_Delay(10);
+ resetWatchdog();
+ HAL_FLASHEx_Erase(&pEraseInit, &failingAddress);
+ //^ Erase the page of flash (1024 bytes on this stm32)
+ // erased the chunk
+ // now we program it
+ uint16_t *data = (uint16_t*) buffer;
+ HAL_FLASH_Unlock();
+ for (uint8_t i = 0; i < (length / 2); i++) {
+ resetWatchdog();
+ HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, FLASH_ADDR + (i * 2),
+ data[i]);
+ }
+ HAL_FLASH_Lock();
+ return 1;
+}
+
+void flash_read_buffer(uint8_t *buffer, const uint16_t length) {
+
+ uint16_t *data = (uint16_t*) buffer;
+ for (uint8_t i = 0; i < (length / 2); i++) {
+ data[i] = *((uint16_t*) (FLASH_ADDR + (i * 2)));
+ }
+}
diff --git a/workspace/TS100/Core/BSP/Miniware/logo.cpp b/workspace/TS100/Core/BSP/Miniware/logo.cpp
new file mode 100644
index 00000000..f71df93d
--- /dev/null
+++ b/workspace/TS100/Core/BSP/Miniware/logo.cpp
@@ -0,0 +1,27 @@
+/*
+ * logo.c
+ *
+ * Created on: 29 May 2020
+ * Author: Ralim
+ */
+
+#include "BSP.h"
+#include "OLED.hpp"
+// Second last page of flash set aside for logo image.
+#define FLASH_LOGOADDR (0x8000000 | 0xF800)
+
+// Logo header signature.
+#define LOGO_HEADER_VALUE 0xF00DAA55
+
+uint8_t showBootLogoIfavailable() {
+// Do not show logo data if signature is not found.
+ if (LOGO_HEADER_VALUE
+ != *(reinterpret_cast<const uint32_t*>(FLASH_LOGOADDR))) {
+ return 0;
+ }
+
+ OLED::drawAreaSwapped(0, 0, 96, 16, (uint8_t*) (FLASH_LOGOADDR + 4));
+ OLED::refresh();
+ return 1;
+}
+
diff --git a/workspace/TS100/Core/BSP/Miniware/postRTOS.cpp b/workspace/TS100/Core/BSP/Miniware/postRTOS.cpp
new file mode 100644
index 00000000..0c262a95
--- /dev/null
+++ b/workspace/TS100/Core/BSP/Miniware/postRTOS.cpp
@@ -0,0 +1,13 @@
+#include "BSP.h"
+#include "FreeRTOS.h"
+#include "QC3.h"
+#include "Settings.h"
+#include "cmsis_os.h"
+#include "main.hpp"
+#include "power.hpp"
+#include "stdlib.h"
+#include "task.h"
+
+void postRToSInit() {
+ // Any after RTos setup
+}
diff --git a/workspace/TS100/Core/BSP/Miniware/preRTOS.cpp b/workspace/TS100/Core/BSP/Miniware/preRTOS.cpp
new file mode 100644
index 00000000..6a16c44f
--- /dev/null
+++ b/workspace/TS100/Core/BSP/Miniware/preRTOS.cpp
@@ -0,0 +1,22 @@
+/*
+ * preRTOS.c
+ *
+ * Created on: 29 May 2020
+ * Author: Ralim
+ */
+
+#include <I2C_Wrapper.hpp>
+#include "BSP.h"
+#include "Setup.h"
+#include "Pins.h"
+void preRToSInit() {
+ /* Reset of all peripherals, Initializes the Flash interface and the Systick.
+ */
+ HAL_Init();
+ Setup_HAL(); // Setup all the HAL objects
+ FRToSI2C::init();
+ HAL_Delay(50);
+ HAL_GPIO_WritePin(OLED_RESET_GPIO_Port, OLED_RESET_Pin, GPIO_PIN_SET);
+ HAL_Delay(50);
+
+}
diff --git a/workspace/TS100/Core/Src/stm32f1xx_hal_msp.c b/workspace/TS100/Core/BSP/Miniware/stm32f1xx_hal_msp.c
index d0b6cebd..3ccd6413 100644
--- a/workspace/TS100/Core/Src/stm32f1xx_hal_msp.c
+++ b/workspace/TS100/Core/BSP/Miniware/stm32f1xx_hal_msp.c
@@ -1,136 +1,136 @@
-#include <hardware.h>
-#include "stm32f1xx_hal.h"
-#include "Setup.h"
-/**
- * Initializes the Global MSP.
- */
-void HAL_MspInit(void) {
- __HAL_RCC_AFIO_CLK_ENABLE()
- ;
-
- HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
-
- /* System interrupt init*/
- /* MemoryManagement_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0);
- /* BusFault_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0);
- /* UsageFault_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0);
- /* SVCall_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(SVCall_IRQn, 0, 0);
- /* DebugMonitor_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0);
- /* PendSV_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0);
- /* SysTick_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(SysTick_IRQn, 15, 0);
-
-
-}
-
-void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) {
-
- GPIO_InitTypeDef GPIO_InitStruct;
- if (hadc->Instance == ADC1) {
- __HAL_RCC_ADC1_CLK_ENABLE()
- ;
-
- /* ADC1 DMA Init */
- /* ADC1 Init */
- hdma_adc1.Instance = DMA1_Channel1;
- hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY;
- hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE;
- hdma_adc1.Init.MemInc = DMA_MINC_ENABLE;
- hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
- hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
- hdma_adc1.Init.Mode = DMA_CIRCULAR;
- hdma_adc1.Init.Priority = DMA_PRIORITY_VERY_HIGH;
- HAL_DMA_Init(&hdma_adc1);
-
- __HAL_LINKDMA(hadc, DMA_Handle, hdma_adc1);
-
- /* ADC1 interrupt Init */
- HAL_NVIC_SetPriority(ADC1_2_IRQn, 15, 0);
- HAL_NVIC_EnableIRQ(ADC1_2_IRQn);
- } else {
- __HAL_RCC_ADC2_CLK_ENABLE()
- ;
-
- /**ADC2 GPIO Configuration
- PB0 ------> ADC2_IN8
- PB1 ------> ADC2_IN9
- */
- GPIO_InitStruct.Pin = TIP_TEMP_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
- HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
-
- /* ADC2 interrupt Init */
- HAL_NVIC_SetPriority(ADC1_2_IRQn, 15, 0);
- HAL_NVIC_EnableIRQ(ADC1_2_IRQn);
- }
-
-}
-
-void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c) {
-
- GPIO_InitTypeDef GPIO_InitStruct;
- /**I2C1 GPIO Configuration
- PB6 ------> I2C1_SCL
- PB7 ------> I2C1_SDA
- */
- GPIO_InitStruct.Pin = SCL_Pin | SDA_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
- GPIO_InitStruct.Pull = GPIO_PULLUP;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
-
- /* Peripheral clock enable */
- __HAL_RCC_I2C1_CLK_ENABLE()
- ;
- /* I2C1 DMA Init */
- /* I2C1_RX Init */
- hdma_i2c1_rx.Instance = DMA1_Channel7;
- hdma_i2c1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
- hdma_i2c1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
- hdma_i2c1_rx.Init.MemInc = DMA_MINC_ENABLE;
- hdma_i2c1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
- hdma_i2c1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
- hdma_i2c1_rx.Init.Mode = DMA_NORMAL;
- hdma_i2c1_rx.Init.Priority = DMA_PRIORITY_LOW;
- HAL_DMA_Init(&hdma_i2c1_rx);
-
- __HAL_LINKDMA(hi2c, hdmarx, hdma_i2c1_rx);
-
- /* I2C1_TX Init */
- hdma_i2c1_tx.Instance = DMA1_Channel6;
- hdma_i2c1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
- hdma_i2c1_tx.Init.PeriphInc = DMA_PINC_DISABLE;
- hdma_i2c1_tx.Init.MemInc = DMA_MINC_ENABLE;
- hdma_i2c1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
- hdma_i2c1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
- hdma_i2c1_tx.Init.Mode = DMA_NORMAL;
- hdma_i2c1_tx.Init.Priority = DMA_PRIORITY_MEDIUM;
- HAL_DMA_Init(&hdma_i2c1_tx);
-
- __HAL_LINKDMA(hi2c, hdmatx, hdma_i2c1_tx);
-
- /* I2C1 interrupt Init */
- HAL_NVIC_SetPriority(I2C1_EV_IRQn, 15, 0);
- HAL_NVIC_EnableIRQ(I2C1_EV_IRQn);
- HAL_NVIC_SetPriority(I2C1_ER_IRQn, 15, 0);
- HAL_NVIC_EnableIRQ(I2C1_ER_IRQn);
-
-}
-
-void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) {
- if (htim_base->Instance == TIM3) {
- /* Peripheral clock enable */
- __HAL_RCC_TIM3_CLK_ENABLE()
- ;
- } else if (htim_base->Instance == TIM2) {
- /* Peripheral clock enable */
- __HAL_RCC_TIM2_CLK_ENABLE()
- ;
- }
-}
+#include "Pins.h"
+#include "stm32f1xx_hal.h"
+#include "Setup.h"
+/**
+ * Initializes the Global MSP.
+ */
+void HAL_MspInit(void) {
+ __HAL_RCC_AFIO_CLK_ENABLE()
+ ;
+
+ HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
+
+ /* System interrupt init*/
+ /* MemoryManagement_IRQn interrupt configuration */
+ HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0);
+ /* BusFault_IRQn interrupt configuration */
+ HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0);
+ /* UsageFault_IRQn interrupt configuration */
+ HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0);
+ /* SVCall_IRQn interrupt configuration */
+ HAL_NVIC_SetPriority(SVCall_IRQn, 0, 0);
+ /* DebugMonitor_IRQn interrupt configuration */
+ HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0);
+ /* PendSV_IRQn interrupt configuration */
+ HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0);
+ /* SysTick_IRQn interrupt configuration */
+ HAL_NVIC_SetPriority(SysTick_IRQn, 15, 0);
+
+
+}
+
+void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) {
+
+ GPIO_InitTypeDef GPIO_InitStruct;
+ if (hadc->Instance == ADC1) {
+ __HAL_RCC_ADC1_CLK_ENABLE()
+ ;
+
+ /* ADC1 DMA Init */
+ /* ADC1 Init */
+ hdma_adc1.Instance = DMA1_Channel1;
+ hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY;
+ hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE;
+ hdma_adc1.Init.MemInc = DMA_MINC_ENABLE;
+ hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
+ hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
+ hdma_adc1.Init.Mode = DMA_CIRCULAR;
+ hdma_adc1.Init.Priority = DMA_PRIORITY_VERY_HIGH;
+ HAL_DMA_Init(&hdma_adc1);
+
+ __HAL_LINKDMA(hadc, DMA_Handle, hdma_adc1);
+
+ /* ADC1 interrupt Init */
+ HAL_NVIC_SetPriority(ADC1_2_IRQn, 15, 0);
+ HAL_NVIC_EnableIRQ(ADC1_2_IRQn);
+ } else {
+ __HAL_RCC_ADC2_CLK_ENABLE()
+ ;
+
+ /**ADC2 GPIO Configuration
+ PB0 ------> ADC2_IN8
+ PB1 ------> ADC2_IN9
+ */
+ GPIO_InitStruct.Pin = TIP_TEMP_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
+ HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+
+ /* ADC2 interrupt Init */
+ HAL_NVIC_SetPriority(ADC1_2_IRQn, 15, 0);
+ HAL_NVIC_EnableIRQ(ADC1_2_IRQn);
+ }
+
+}
+
+void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c) {
+
+ GPIO_InitTypeDef GPIO_InitStruct;
+ /**I2C1 GPIO Configuration
+ PB6 ------> I2C1_SCL
+ PB7 ------> I2C1_SDA
+ */
+ GPIO_InitStruct.Pin = SCL_Pin | SDA_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+
+ /* Peripheral clock enable */
+ __HAL_RCC_I2C1_CLK_ENABLE()
+ ;
+ /* I2C1 DMA Init */
+ /* I2C1_RX Init */
+ hdma_i2c1_rx.Instance = DMA1_Channel7;
+ hdma_i2c1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
+ hdma_i2c1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
+ hdma_i2c1_rx.Init.MemInc = DMA_MINC_ENABLE;
+ hdma_i2c1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
+ hdma_i2c1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
+ hdma_i2c1_rx.Init.Mode = DMA_NORMAL;
+ hdma_i2c1_rx.Init.Priority = DMA_PRIORITY_LOW;
+ HAL_DMA_Init(&hdma_i2c1_rx);
+
+ __HAL_LINKDMA(hi2c, hdmarx, hdma_i2c1_rx);
+
+ /* I2C1_TX Init */
+ hdma_i2c1_tx.Instance = DMA1_Channel6;
+ hdma_i2c1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
+ hdma_i2c1_tx.Init.PeriphInc = DMA_PINC_DISABLE;
+ hdma_i2c1_tx.Init.MemInc = DMA_MINC_ENABLE;
+ hdma_i2c1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
+ hdma_i2c1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
+ hdma_i2c1_tx.Init.Mode = DMA_NORMAL;
+ hdma_i2c1_tx.Init.Priority = DMA_PRIORITY_MEDIUM;
+ HAL_DMA_Init(&hdma_i2c1_tx);
+
+ __HAL_LINKDMA(hi2c, hdmatx, hdma_i2c1_tx);
+
+ /* I2C1 interrupt Init */
+ HAL_NVIC_SetPriority(I2C1_EV_IRQn, 15, 0);
+ HAL_NVIC_EnableIRQ(I2C1_EV_IRQn);
+ HAL_NVIC_SetPriority(I2C1_ER_IRQn, 15, 0);
+ HAL_NVIC_EnableIRQ(I2C1_ER_IRQn);
+
+}
+
+void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) {
+ if (htim_base->Instance == TIM3) {
+ /* Peripheral clock enable */
+ __HAL_RCC_TIM3_CLK_ENABLE()
+ ;
+ } else if (htim_base->Instance == TIM2) {
+ /* Peripheral clock enable */
+ __HAL_RCC_TIM2_CLK_ENABLE()
+ ;
+ }
+}
diff --git a/workspace/TS100/Core/Src/stm32f1xx_hal_timebase_TIM.c b/workspace/TS100/Core/BSP/Miniware/stm32f1xx_hal_timebase_TIM.c
index 526e0e22..84a8ae55 100644
--- a/workspace/TS100/Core/Src/stm32f1xx_hal_timebase_TIM.c
+++ b/workspace/TS100/Core/BSP/Miniware/stm32f1xx_hal_timebase_TIM.c
@@ -1,158 +1,158 @@
-/**
- ******************************************************************************
- * @file stm32f1xx_hal_timebase_TIM.c
- * @brief HAL time base based on the hardware TIM.
- ******************************************************************************
- * This notice applies to any and all portions of this file
- * that are not between comment pairs USER CODE BEGIN and
- * USER CODE END. Other portions of this file, whether
- * inserted by the user or by software development tools
- * are owned by their respective copyright owners.
- *
- * Copyright (c) 2017 STMicroelectronics International N.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted, provided that the following conditions are met:
- *
- * 1. Redistribution of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of other
- * contributors to this software may be used to endorse or promote products
- * derived from this software without specific written permission.
- * 4. This software, including modifications and/or derivative works of this
- * software, must execute solely and exclusively on microcontroller or
- * microprocessor devices manufactured by or for STMicroelectronics.
- * 5. Redistribution and use of this software other than as permitted under
- * this license is void and will automatically terminate your rights under
- * this license.
- *
- * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
- * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
- * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32f1xx_hal.h"
-#include "stm32f1xx_hal_tim.h"
-/** @addtogroup STM32F7xx_HAL_Examples
- * @{
- */
-
-/** @addtogroup HAL_TimeBase
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-TIM_HandleTypeDef htim1;
-uint32_t uwIncrementState = 0;
-/* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-
-/**
- * @brief This function configures the TIM1 as a time base source.
- * The time source is configured to have 1ms time base with a dedicated
- * Tick interrupt priority.
- * @note This function is called automatically at the beginning of program after
- * reset by HAL_Init() or at any time when clock is configured, by HAL_RCC_ClockConfig().
- * @param TickPriority: Tick interrupt priorty.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
-{
- RCC_ClkInitTypeDef clkconfig;
- uint32_t uwTimclock = 0;
- uint32_t uwPrescalerValue = 0;
- uint32_t pFLatency;
-
- /*Configure the TIM1 IRQ priority */
- HAL_NVIC_SetPriority(TIM1_UP_IRQn, TickPriority ,0);
-
- /* Enable the TIM1 global Interrupt */
- HAL_NVIC_EnableIRQ(TIM1_UP_IRQn);
-
- /* Enable TIM1 clock */
- __HAL_RCC_TIM1_CLK_ENABLE();
-
- /* Get clock configuration */
- HAL_RCC_GetClockConfig(&clkconfig, &pFLatency);
-
- /* Compute TIM1 clock */
- uwTimclock = HAL_RCC_GetPCLK2Freq();
-
- /* Compute the prescaler value to have TIM1 counter clock equal to 1MHz */
- uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000) - 1);
-
- /* Initialize TIM1 */
- htim1.Instance = TIM1;
-
- /* Initialize TIMx peripheral as follow:
- + Period = [(TIM1CLK/1000) - 1]. to have a (1/1000) s time base.
- + Prescaler = (uwTimclock/1000000 - 1) to have a 1MHz counter clock.
- + ClockDivision = 0
- + Counter direction = Up
- */
- htim1.Init.Period = (1000000 / 1000) - 1;
- htim1.Init.Prescaler = uwPrescalerValue;
- htim1.Init.ClockDivision = 0;
- htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
- if(HAL_TIM_Base_Init(&htim1) == HAL_OK)
- {
- /* Start the TIM time Base generation in interrupt mode */
- return HAL_TIM_Base_Start_IT(&htim1);
- }
-
- /* Return function status */
- return HAL_ERROR;
-}
-
-/**
- * @brief Suspend Tick increment.
- * @note Disable the tick increment by disabling TIM1 update interrupt.
- * @param None
- * @retval None
- */
-void HAL_SuspendTick(void)
-{
- /* Disable TIM1 update Interrupt */
- __HAL_TIM_DISABLE_IT(&htim1, TIM_IT_UPDATE);
-}
-
-/**
- * @brief Resume Tick increment.
- * @note Enable the tick increment by Enabling TIM1 update interrupt.
- * @param None
- * @retval None
- */
-void HAL_ResumeTick(void)
-{
- /* Enable TIM1 Update interrupt */
- __HAL_TIM_ENABLE_IT(&htim1, TIM_IT_UPDATE);
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+/**
+ ******************************************************************************
+ * @file stm32f1xx_hal_timebase_TIM.c
+ * @brief HAL time base based on the hardware TIM.
+ ******************************************************************************
+ * This notice applies to any and all portions of this file
+ * that are not between comment pairs USER CODE BEGIN and
+ * USER CODE END. Other portions of this file, whether
+ * inserted by the user or by software development tools
+ * are owned by their respective copyright owners.
+ *
+ * Copyright (c) 2017 STMicroelectronics International N.V.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions are met:
+ *
+ * 1. Redistribution of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of other
+ * contributors to this software may be used to endorse or promote products
+ * derived from this software without specific written permission.
+ * 4. This software, including modifications and/or derivative works of this
+ * software, must execute solely and exclusively on microcontroller or
+ * microprocessor devices manufactured by or for STMicroelectronics.
+ * 5. Redistribution and use of this software other than as permitted under
+ * this license is void and will automatically terminate your rights under
+ * this license.
+ *
+ * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
+ * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
+ * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f1xx_hal.h"
+#include "stm32f1xx_hal_tim.h"
+/** @addtogroup STM32F7xx_HAL_Examples
+ * @{
+ */
+
+/** @addtogroup HAL_TimeBase
+ * @{
+ */
+
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+TIM_HandleTypeDef htim1;
+uint32_t uwIncrementState = 0;
+/* Private function prototypes -----------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+
+/**
+ * @brief This function configures the TIM1 as a time base source.
+ * The time source is configured to have 1ms time base with a dedicated
+ * Tick interrupt priority.
+ * @note This function is called automatically at the beginning of program after
+ * reset by HAL_Init() or at any time when clock is configured, by HAL_RCC_ClockConfig().
+ * @param TickPriority: Tick interrupt priorty.
+ * @retval HAL status
+ */
+HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
+{
+ RCC_ClkInitTypeDef clkconfig;
+ uint32_t uwTimclock = 0;
+ uint32_t uwPrescalerValue = 0;
+ uint32_t pFLatency;
+
+ /*Configure the TIM1 IRQ priority */
+ HAL_NVIC_SetPriority(TIM1_UP_IRQn, TickPriority ,0);
+
+ /* Enable the TIM1 global Interrupt */
+ HAL_NVIC_EnableIRQ(TIM1_UP_IRQn);
+
+ /* Enable TIM1 clock */
+ __HAL_RCC_TIM1_CLK_ENABLE();
+
+ /* Get clock configuration */
+ HAL_RCC_GetClockConfig(&clkconfig, &pFLatency);
+
+ /* Compute TIM1 clock */
+ uwTimclock = HAL_RCC_GetPCLK2Freq();
+
+ /* Compute the prescaler value to have TIM1 counter clock equal to 1MHz */
+ uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000) - 1);
+
+ /* Initialize TIM1 */
+ htim1.Instance = TIM1;
+
+ /* Initialize TIMx peripheral as follow:
+ + Period = [(TIM1CLK/1000) - 1]. to have a (1/1000) s time base.
+ + Prescaler = (uwTimclock/1000000 - 1) to have a 1MHz counter clock.
+ + ClockDivision = 0
+ + Counter direction = Up
+ */
+ htim1.Init.Period = (1000000 / 1000) - 1;
+ htim1.Init.Prescaler = uwPrescalerValue;
+ htim1.Init.ClockDivision = 0;
+ htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
+ if(HAL_TIM_Base_Init(&htim1) == HAL_OK)
+ {
+ /* Start the TIM time Base generation in interrupt mode */
+ return HAL_TIM_Base_Start_IT(&htim1);
+ }
+
+ /* Return function status */
+ return HAL_ERROR;
+}
+
+/**
+ * @brief Suspend Tick increment.
+ * @note Disable the tick increment by disabling TIM1 update interrupt.
+ * @param None
+ * @retval None
+ */
+void HAL_SuspendTick(void)
+{
+ /* Disable TIM1 update Interrupt */
+ __HAL_TIM_DISABLE_IT(&htim1, TIM_IT_UPDATE);
+}
+
+/**
+ * @brief Resume Tick increment.
+ * @note Enable the tick increment by Enabling TIM1 update interrupt.
+ * @param None
+ * @retval None
+ */
+void HAL_ResumeTick(void)
+{
+ /* Enable TIM1 Update interrupt */
+ __HAL_TIM_ENABLE_IT(&htim1, TIM_IT_UPDATE);
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/workspace/TS100/Core/Src/stm32f1xx_it.c b/workspace/TS100/Core/BSP/Miniware/stm32f1xx_it.c
index e0047e08..b411c980 100644
--- a/workspace/TS100/Core/Src/stm32f1xx_it.c
+++ b/workspace/TS100/Core/BSP/Miniware/stm32f1xx_it.c
@@ -1,84 +1,84 @@
-// This is the stock standard STM interrupt file full of handlers
-#include "stm32f1xx_hal.h"
-#include "stm32f1xx.h"
-#include "stm32f1xx_it.h"
-#include "cmsis_os.h"
-#include "Setup.h"
-
-extern TIM_HandleTypeDef htim1; //used for the systick
-
-/******************************************************************************/
-/* Cortex-M3 Processor Interruption and Exception Handlers */
-/******************************************************************************/
-
-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) {
-}
-
-// Memory management unit had an error
-void MemManage_Handler(void) {
-}
-
-// Prefetcher or busfault occured
-void BusFault_Handler(void) {
-}
-
-void UsageFault_Handler(void) {
-}
-
-void DebugMon_Handler(void) {
-}
-
-// Systick is used by FreeRTOS tick
-void SysTick_Handler(void) {
- osSystickHandler();
-}
-
-/******************************************************************************/
-/* STM32F1xx Peripheral Interrupt Handlers */
-/* Add here the Interrupt Handlers for the used peripherals. */
-/* For the available peripheral interrupt handler names, */
-/* please refer to the startup file. */
-/******************************************************************************/
-
-// DMA used to move the ADC readings into system ram
-void DMA1_Channel1_IRQHandler(void) {
- HAL_DMA_IRQHandler(&hdma_adc1);
-}
-//ADC interrupt used for DMA
-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);
-}
-//Timer 3 is used for the PWM output to the tip
-void TIM3_IRQHandler(void) {
- HAL_TIM_IRQHandler(&htim3);
-}
-
-//Timer 2 is used for co-ordination of PWM & ADC
-void TIM2_IRQHandler(void) {
- HAL_TIM_IRQHandler(&htim2);
-}
-
-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_Channel7_IRQHandler(void) {
- HAL_DMA_IRQHandler(&hdma_i2c1_rx);
-}
+// This is the stock standard STM interrupt file full of handlers
+#include "stm32f1xx_hal.h"
+#include "stm32f1xx.h"
+#include "stm32f1xx_it.h"
+#include "cmsis_os.h"
+#include "Setup.h"
+
+extern TIM_HandleTypeDef htim1; //used for the systick
+
+/******************************************************************************/
+/* Cortex-M3 Processor Interruption and Exception Handlers */
+/******************************************************************************/
+
+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) {
+}
+
+// Memory management unit had an error
+void MemManage_Handler(void) {
+}
+
+// Prefetcher or busfault occured
+void BusFault_Handler(void) {
+}
+
+void UsageFault_Handler(void) {
+}
+
+void DebugMon_Handler(void) {
+}
+
+// Systick is used by FreeRTOS tick
+void SysTick_Handler(void) {
+ osSystickHandler();
+}
+
+/******************************************************************************/
+/* STM32F1xx Peripheral Interrupt Handlers */
+/* Add here the Interrupt Handlers for the used peripherals. */
+/* For the available peripheral interrupt handler names, */
+/* please refer to the startup file. */
+/******************************************************************************/
+
+// DMA used to move the ADC readings into system ram
+void DMA1_Channel1_IRQHandler(void) {
+ HAL_DMA_IRQHandler(&hdma_adc1);
+}
+//ADC interrupt used for DMA
+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);
+}
+//Timer 3 is used for the PWM output to the tip
+void TIM3_IRQHandler(void) {
+ HAL_TIM_IRQHandler(&htim3);
+}
+
+//Timer 2 is used for co-ordination of PWM & ADC
+void TIM2_IRQHandler(void) {
+ HAL_TIM_IRQHandler(&htim2);
+}
+
+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_Channel7_IRQHandler(void) {
+ HAL_DMA_IRQHandler(&hdma_i2c1_rx);
+}
diff --git a/workspace/TS100/Core/Src/system_stm32f1xx.c b/workspace/TS100/Core/BSP/Miniware/system_stm32f1xx.c
index 662d38d6..dfff3485 100644
--- a/workspace/TS100/Core/Src/system_stm32f1xx.c
+++ b/workspace/TS100/Core/BSP/Miniware/system_stm32f1xx.c
@@ -1,317 +1,317 @@
-// This file was automatically generated by the STM Cube software
-// And as such, is BSD licneced from STM
-#include "stm32f1xx.h"
-
-#if !defined (HSI_VALUE)
- #define HSI_VALUE 8000000U /*!< Default value of the Internal oscillator in Hz.
- This value can be provided and adapted by the user application. */
-#endif /* HSI_VALUE */
-
-/*!< Uncomment the following line if you need to use external SRAM */
-#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
-/* #define DATA_IN_ExtSRAM */
-#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */
-#ifndef LOCAL_BUILD
-#define VECT_TAB_OFFSET 0x00004000U /*!< Vector Table base offset field.
- This value must be a multiple of 0x200. */
-#else
-#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
- This value must be a multiple of 0x200. */
-#warning LOCAL_BUILD SETUP
- #endif
-//We offset this by 0x4000 to because of the bootloader
-/*******************************************************************************
-* Clock Definitions
-*******************************************************************************/
-#if defined(STM32F100xB) ||defined(STM32F100xE)
- uint32_t SystemCoreClock = 24000000U; /*!< System Clock Frequency (Core Clock) */
-#else /*!< HSI Selected as System Clock source */
- uint32_t SystemCoreClock = 64000000U; /*!< System Clock Frequency (Core Clock) */
-#endif
-
-const uint8_t AHBPrescTable[16U] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
-const uint8_t APBPrescTable[8U] = {0, 0, 0, 0, 1, 2, 3, 4};
-
-
-/**
- * @brief Setup the microcontroller system
- * Initialize the Embedded Flash Interface, the PLL and update the
- * SystemCoreClock variable.
- * @note This function should be used only after reset.
- * @param None
- * @retval None
- */
-void SystemInit (void)
-{
- /* Reset the RCC clock configuration to the default reset state(for debug purpose) */
- /* Set HSION bit */
- RCC->CR |= 0x00000001U;
-
- /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */
-#if !defined(STM32F105xC) && !defined(STM32F107xC)
- RCC->CFGR &= 0xF8FF0000U;
-#else
- RCC->CFGR &= 0xF0FF0000U;
-#endif /* STM32F105xC */
-
- /* Reset HSEON, CSSON and PLLON bits */
- RCC->CR &= 0xFEF6FFFFU;
-
- /* Reset HSEBYP bit */
- RCC->CR &= 0xFFFBFFFFU;
-
- /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */
- RCC->CFGR &= 0xFF80FFFFU;
-
-#if defined(STM32F105xC) || defined(STM32F107xC)
- /* Reset PLL2ON and PLL3ON bits */
- RCC->CR &= 0xEBFFFFFFU;
-
- /* Disable all interrupts and clear pending bits */
- RCC->CIR = 0x00FF0000U;
-
- /* Reset CFGR2 register */
- RCC->CFGR2 = 0x00000000U;
-#elif defined(STM32F100xB) || defined(STM32F100xE)
- /* Disable all interrupts and clear pending bits */
- RCC->CIR = 0x009F0000U;
-
- /* Reset CFGR2 register */
- RCC->CFGR2 = 0x00000000U;
-#else
- /* Disable all interrupts and clear pending bits */
- RCC->CIR = 0x009F0000U;
-#endif /* STM32F105xC */
-
-#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
- #ifdef DATA_IN_ExtSRAM
- SystemInit_ExtMemCtl();
- #endif /* DATA_IN_ExtSRAM */
-#endif
-
-#ifdef VECT_TAB_SRAM
- SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */
-#else
- SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */
-#endif
-}
-
-/**
- * @brief Update SystemCoreClock variable according to Clock Register Values.
- * The SystemCoreClock variable contains the core clock (HCLK), it can
- * be used by the user application to setup the SysTick timer or configure
- * other parameters.
- *
- * @note Each time the core clock (HCLK) changes, this function must be called
- * to update SystemCoreClock variable value. Otherwise, any configuration
- * based on this variable will be incorrect.
- *
- * @note - The system frequency computed by this function is not the real
- * frequency in the chip. It is calculated based on the predefined
- * constant and the selected clock source:
- *
- * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
- *
- * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
- *
- * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
- * or HSI_VALUE(*) multiplied by the PLL factors.
- *
- * (*) HSI_VALUE is a constant defined in stm32f1xx.h file (default value
- * 8 MHz) but the real value may vary depending on the variations
- * in voltage and temperature.
- *
- * (**) HSE_VALUE is a constant defined in stm32f1xx.h file (default value
- * 8 MHz or 25 MHz, depending on the product used), user has to ensure
- * that HSE_VALUE is same as the real frequency of the crystal used.
- * Otherwise, this function may have wrong result.
- *
- * - The result of this function could be not correct when using fractional
- * value for HSE crystal.
- * @param None
- * @retval None
- */
-void SystemCoreClockUpdate (void)
-{
- uint32_t tmp = 0U, pllmull = 0U, pllsource = 0U;
-
-#if defined(STM32F105xC) || defined(STM32F107xC)
- uint32_t prediv1source = 0U, prediv1factor = 0U, prediv2factor = 0U, pll2mull = 0U;
-#endif /* STM32F105xC */
-
-#if defined(STM32F100xB) || defined(STM32F100xE)
- uint32_t prediv1factor = 0U;
-#endif /* STM32F100xB or STM32F100xE */
-
- /* Get SYSCLK source -------------------------------------------------------*/
- tmp = RCC->CFGR & RCC_CFGR_SWS;
-
- switch (tmp)
- {
- case 0x00U: /* HSI used as system clock */
- SystemCoreClock = HSI_VALUE;
- break;
- case 0x04U: /* HSE used as system clock */
- SystemCoreClock = HSE_VALUE;
- break;
- case 0x08U: /* PLL used as system clock */
-
- /* Get PLL clock source and multiplication factor ----------------------*/
- pllmull = RCC->CFGR & RCC_CFGR_PLLMULL;
- pllsource = RCC->CFGR & RCC_CFGR_PLLSRC;
-
-#if !defined(STM32F105xC) && !defined(STM32F107xC)
- pllmull = ( pllmull >> 18U) + 2U;
-
- if (pllsource == 0x00U)
- {
- /* HSI oscillator clock divided by 2 selected as PLL clock entry */
- SystemCoreClock = (HSI_VALUE >> 1U) * pllmull;
- }
- else
- {
- #if defined(STM32F100xB) || defined(STM32F100xE)
- prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1U;
- /* HSE oscillator clock selected as PREDIV1 clock entry */
- SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull;
- #else
- /* HSE selected as PLL clock entry */
- if ((RCC->CFGR & RCC_CFGR_PLLXTPRE) != (uint32_t)RESET)
- {/* HSE oscillator clock divided by 2 */
- SystemCoreClock = (HSE_VALUE >> 1U) * pllmull;
- }
- else
- {
- SystemCoreClock = HSE_VALUE * pllmull;
- }
- #endif
- }
-#else
- pllmull = pllmull >> 18U;
-
- if (pllmull != 0x0DU)
- {
- pllmull += 2U;
- }
- else
- { /* PLL multiplication factor = PLL input clock * 6.5 */
- pllmull = 13U / 2U;
- }
-
- if (pllsource == 0x00U)
- {
- /* HSI oscillator clock divided by 2 selected as PLL clock entry */
- SystemCoreClock = (HSI_VALUE >> 1U) * pllmull;
- }
- else
- {/* PREDIV1 selected as PLL clock entry */
-
- /* Get PREDIV1 clock source and division factor */
- prediv1source = RCC->CFGR2 & RCC_CFGR2_PREDIV1SRC;
- prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1U;
-
- if (prediv1source == 0U)
- {
- /* HSE oscillator clock selected as PREDIV1 clock entry */
- SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull;
- }
- else
- {/* PLL2 clock selected as PREDIV1 clock entry */
-
- /* Get PREDIV2 division factor and PLL2 multiplication factor */
- prediv2factor = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> 4U) + 1U;
- pll2mull = ((RCC->CFGR2 & RCC_CFGR2_PLL2MUL) >> 8U) + 2U;
- SystemCoreClock = (((HSE_VALUE / prediv2factor) * pll2mull) / prediv1factor) * pllmull;
- }
- }
-#endif /* STM32F105xC */
- break;
-
- default:
- SystemCoreClock = HSI_VALUE;
- break;
- }
-
- /* Compute HCLK clock frequency ----------------*/
- /* Get HCLK prescaler */
- tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4U)];
- /* HCLK clock frequency */
- SystemCoreClock >>= tmp;
-}
-
-#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
-/**
- * @brief Setup the external memory controller. Called in startup_stm32f1xx.s
- * before jump to __main
- * @param None
- * @retval None
- */
-#ifdef DATA_IN_ExtSRAM
-/**
- * @brief Setup the external memory controller.
- * Called in startup_stm32f1xx_xx.s/.c before jump to main.
- * This function configures the external SRAM mounted on STM3210E-EVAL
- * board (STM32 High density devices). This SRAM will be used as program
- * data memory (including heap and stack).
- * @param None
- * @retval None
- */
-void SystemInit_ExtMemCtl(void)
-{
- __IO uint32_t tmpreg;
- /*!< FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is
- required, then adjust the Register Addresses */
-
- /* Enable FSMC clock */
- RCC->AHBENR = 0x00000114U;
-
- /* Delay after an RCC peripheral clock enabling */
- tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_FSMCEN);
-
- /* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks */
- RCC->APB2ENR = 0x000001E0U;
-
- /* Delay after an RCC peripheral clock enabling */
- tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPDEN);
-
- (void)(tmpreg);
-
-/* --------------- SRAM Data lines, NOE and NWE configuration ---------------*/
-/*---------------- SRAM Address lines configuration -------------------------*/
-/*---------------- NOE and NWE configuration --------------------------------*/
-/*---------------- NE3 configuration ----------------------------------------*/
-/*---------------- NBL0, NBL1 configuration ---------------------------------*/
-
- GPIOD->CRL = 0x44BB44BBU;
- GPIOD->CRH = 0xBBBBBBBBU;
-
- GPIOE->CRL = 0xB44444BBU;
- GPIOE->CRH = 0xBBBBBBBBU;
-
- GPIOF->CRL = 0x44BBBBBBU;
- GPIOF->CRH = 0xBBBB4444U;
-
- GPIOG->CRL = 0x44BBBBBBU;
- GPIOG->CRH = 0x444B4B44U;
-
-/*---------------- FSMC Configuration ---------------------------------------*/
-/*---------------- Enable FSMC Bank1_SRAM Bank ------------------------------*/
-
- FSMC_Bank1->BTCR[4U] = 0x00001091U;
- FSMC_Bank1->BTCR[5U] = 0x00110212U;
-}
-#endif /* DATA_IN_ExtSRAM */
-#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+// This file was automatically generated by the STM Cube software
+// And as such, is BSD licneced from STM
+#include "stm32f1xx.h"
+
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE 8000000U /*!< Default value of the Internal oscillator in Hz.
+ This value can be provided and adapted by the user application. */
+#endif /* HSI_VALUE */
+
+/*!< Uncomment the following line if you need to use external SRAM */
+#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
+/* #define DATA_IN_ExtSRAM */
+#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */
+#ifndef LOCAL_BUILD
+#define VECT_TAB_OFFSET 0x00004000U /*!< Vector Table base offset field.
+ This value must be a multiple of 0x200. */
+#else
+#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
+ This value must be a multiple of 0x200. */
+#warning LOCAL_BUILD SETUP
+ #endif
+//We offset this by 0x4000 to because of the bootloader
+/*******************************************************************************
+* Clock Definitions
+*******************************************************************************/
+#if defined(STM32F100xB) ||defined(STM32F100xE)
+ uint32_t SystemCoreClock = 24000000U; /*!< System Clock Frequency (Core Clock) */
+#else /*!< HSI Selected as System Clock source */
+ uint32_t SystemCoreClock = 64000000U; /*!< System Clock Frequency (Core Clock) */
+#endif
+
+const uint8_t AHBPrescTable[16U] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
+const uint8_t APBPrescTable[8U] = {0, 0, 0, 0, 1, 2, 3, 4};
+
+
+/**
+ * @brief Setup the microcontroller system
+ * Initialize the Embedded Flash Interface, the PLL and update the
+ * SystemCoreClock variable.
+ * @note This function should be used only after reset.
+ * @param None
+ * @retval None
+ */
+void SystemInit (void)
+{
+ /* Reset the RCC clock configuration to the default reset state(for debug purpose) */
+ /* Set HSION bit */
+ RCC->CR |= 0x00000001U;
+
+ /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */
+#if !defined(STM32F105xC) && !defined(STM32F107xC)
+ RCC->CFGR &= 0xF8FF0000U;
+#else
+ RCC->CFGR &= 0xF0FF0000U;
+#endif /* STM32F105xC */
+
+ /* Reset HSEON, CSSON and PLLON bits */
+ RCC->CR &= 0xFEF6FFFFU;
+
+ /* Reset HSEBYP bit */
+ RCC->CR &= 0xFFFBFFFFU;
+
+ /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */
+ RCC->CFGR &= 0xFF80FFFFU;
+
+#if defined(STM32F105xC) || defined(STM32F107xC)
+ /* Reset PLL2ON and PLL3ON bits */
+ RCC->CR &= 0xEBFFFFFFU;
+
+ /* Disable all interrupts and clear pending bits */
+ RCC->CIR = 0x00FF0000U;
+
+ /* Reset CFGR2 register */
+ RCC->CFGR2 = 0x00000000U;
+#elif defined(STM32F100xB) || defined(STM32F100xE)
+ /* Disable all interrupts and clear pending bits */
+ RCC->CIR = 0x009F0000U;
+
+ /* Reset CFGR2 register */
+ RCC->CFGR2 = 0x00000000U;
+#else
+ /* Disable all interrupts and clear pending bits */
+ RCC->CIR = 0x009F0000U;
+#endif /* STM32F105xC */
+
+#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
+ #ifdef DATA_IN_ExtSRAM
+ SystemInit_ExtMemCtl();
+ #endif /* DATA_IN_ExtSRAM */
+#endif
+
+#ifdef VECT_TAB_SRAM
+ SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */
+#else
+ SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */
+#endif
+}
+
+/**
+ * @brief Update SystemCoreClock variable according to Clock Register Values.
+ * The SystemCoreClock variable contains the core clock (HCLK), it can
+ * be used by the user application to setup the SysTick timer or configure
+ * other parameters.
+ *
+ * @note Each time the core clock (HCLK) changes, this function must be called
+ * to update SystemCoreClock variable value. Otherwise, any configuration
+ * based on this variable will be incorrect.
+ *
+ * @note - The system frequency computed by this function is not the real
+ * frequency in the chip. It is calculated based on the predefined
+ * constant and the selected clock source:
+ *
+ * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
+ *
+ * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
+ *
+ * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
+ * or HSI_VALUE(*) multiplied by the PLL factors.
+ *
+ * (*) HSI_VALUE is a constant defined in stm32f1xx.h file (default value
+ * 8 MHz) but the real value may vary depending on the variations
+ * in voltage and temperature.
+ *
+ * (**) HSE_VALUE is a constant defined in stm32f1xx.h file (default value
+ * 8 MHz or 25 MHz, depending on the product used), user has to ensure
+ * that HSE_VALUE is same as the real frequency of the crystal used.
+ * Otherwise, this function may have wrong result.
+ *
+ * - The result of this function could be not correct when using fractional
+ * value for HSE crystal.
+ * @param None
+ * @retval None
+ */
+void SystemCoreClockUpdate (void)
+{
+ uint32_t tmp = 0U, pllmull = 0U, pllsource = 0U;
+
+#if defined(STM32F105xC) || defined(STM32F107xC)
+ uint32_t prediv1source = 0U, prediv1factor = 0U, prediv2factor = 0U, pll2mull = 0U;
+#endif /* STM32F105xC */
+
+#if defined(STM32F100xB) || defined(STM32F100xE)
+ uint32_t prediv1factor = 0U;
+#endif /* STM32F100xB or STM32F100xE */
+
+ /* Get SYSCLK source -------------------------------------------------------*/
+ tmp = RCC->CFGR & RCC_CFGR_SWS;
+
+ switch (tmp)
+ {
+ case 0x00U: /* HSI used as system clock */
+ SystemCoreClock = HSI_VALUE;
+ break;
+ case 0x04U: /* HSE used as system clock */
+ SystemCoreClock = HSE_VALUE;
+ break;
+ case 0x08U: /* PLL used as system clock */
+
+ /* Get PLL clock source and multiplication factor ----------------------*/
+ pllmull = RCC->CFGR & RCC_CFGR_PLLMULL;
+ pllsource = RCC->CFGR & RCC_CFGR_PLLSRC;
+
+#if !defined(STM32F105xC) && !defined(STM32F107xC)
+ pllmull = ( pllmull >> 18U) + 2U;
+
+ if (pllsource == 0x00U)
+ {
+ /* HSI oscillator clock divided by 2 selected as PLL clock entry */
+ SystemCoreClock = (HSI_VALUE >> 1U) * pllmull;
+ }
+ else
+ {
+ #if defined(STM32F100xB) || defined(STM32F100xE)
+ prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1U;
+ /* HSE oscillator clock selected as PREDIV1 clock entry */
+ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull;
+ #else
+ /* HSE selected as PLL clock entry */
+ if ((RCC->CFGR & RCC_CFGR_PLLXTPRE) != (uint32_t)RESET)
+ {/* HSE oscillator clock divided by 2 */
+ SystemCoreClock = (HSE_VALUE >> 1U) * pllmull;
+ }
+ else
+ {
+ SystemCoreClock = HSE_VALUE * pllmull;
+ }
+ #endif
+ }
+#else
+ pllmull = pllmull >> 18U;
+
+ if (pllmull != 0x0DU)
+ {
+ pllmull += 2U;
+ }
+ else
+ { /* PLL multiplication factor = PLL input clock * 6.5 */
+ pllmull = 13U / 2U;
+ }
+
+ if (pllsource == 0x00U)
+ {
+ /* HSI oscillator clock divided by 2 selected as PLL clock entry */
+ SystemCoreClock = (HSI_VALUE >> 1U) * pllmull;
+ }
+ else
+ {/* PREDIV1 selected as PLL clock entry */
+
+ /* Get PREDIV1 clock source and division factor */
+ prediv1source = RCC->CFGR2 & RCC_CFGR2_PREDIV1SRC;
+ prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1U;
+
+ if (prediv1source == 0U)
+ {
+ /* HSE oscillator clock selected as PREDIV1 clock entry */
+ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull;
+ }
+ else
+ {/* PLL2 clock selected as PREDIV1 clock entry */
+
+ /* Get PREDIV2 division factor and PLL2 multiplication factor */
+ prediv2factor = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> 4U) + 1U;
+ pll2mull = ((RCC->CFGR2 & RCC_CFGR2_PLL2MUL) >> 8U) + 2U;
+ SystemCoreClock = (((HSE_VALUE / prediv2factor) * pll2mull) / prediv1factor) * pllmull;
+ }
+ }
+#endif /* STM32F105xC */
+ break;
+
+ default:
+ SystemCoreClock = HSI_VALUE;
+ break;
+ }
+
+ /* Compute HCLK clock frequency ----------------*/
+ /* Get HCLK prescaler */
+ tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4U)];
+ /* HCLK clock frequency */
+ SystemCoreClock >>= tmp;
+}
+
+#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
+/**
+ * @brief Setup the external memory controller. Called in startup_stm32f1xx.s
+ * before jump to __main
+ * @param None
+ * @retval None
+ */
+#ifdef DATA_IN_ExtSRAM
+/**
+ * @brief Setup the external memory controller.
+ * Called in startup_stm32f1xx_xx.s/.c before jump to main.
+ * This function configures the external SRAM mounted on STM3210E-EVAL
+ * board (STM32 High density devices). This SRAM will be used as program
+ * data memory (including heap and stack).
+ * @param None
+ * @retval None
+ */
+void SystemInit_ExtMemCtl(void)
+{
+ __IO uint32_t tmpreg;
+ /*!< FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is
+ required, then adjust the Register Addresses */
+
+ /* Enable FSMC clock */
+ RCC->AHBENR = 0x00000114U;
+
+ /* Delay after an RCC peripheral clock enabling */
+ tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_FSMCEN);
+
+ /* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks */
+ RCC->APB2ENR = 0x000001E0U;
+
+ /* Delay after an RCC peripheral clock enabling */
+ tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPDEN);
+
+ (void)(tmpreg);
+
+/* --------------- SRAM Data lines, NOE and NWE configuration ---------------*/
+/*---------------- SRAM Address lines configuration -------------------------*/
+/*---------------- NOE and NWE configuration --------------------------------*/
+/*---------------- NE3 configuration ----------------------------------------*/
+/*---------------- NBL0, NBL1 configuration ---------------------------------*/
+
+ GPIOD->CRL = 0x44BB44BBU;
+ GPIOD->CRH = 0xBBBBBBBBU;
+
+ GPIOE->CRL = 0xB44444BBU;
+ GPIOE->CRH = 0xBBBBBBBBU;
+
+ GPIOF->CRL = 0x44BBBBBBU;
+ GPIOF->CRH = 0xBBBB4444U;
+
+ GPIOG->CRL = 0x44BBBBBBU;
+ GPIOG->CRH = 0x444B4B44U;
+
+/*---------------- FSMC Configuration ---------------------------------------*/
+/*---------------- Enable FSMC Bank1_SRAM Bank ------------------------------*/
+
+ FSMC_Bank1->BTCR[4U] = 0x00001091U;
+ FSMC_Bank1->BTCR[5U] = 0x00110212U;
+}
+#endif /* DATA_IN_ExtSRAM */
+#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/workspace/TS100/Core/Drivers/Buttons.cpp b/workspace/TS100/Core/Drivers/Buttons.cpp
new file mode 100644
index 00000000..beca08b1
--- /dev/null
+++ b/workspace/TS100/Core/Drivers/Buttons.cpp
@@ -0,0 +1,115 @@
+/*
+ * Buttons.c
+ *
+ * Created on: 29 May 2020
+ * Author: Ralim
+ */
+#include <Buttons.hpp>
+#include "FreeRTOS.h"
+#include "task.h"
+#include "gui.hpp"
+uint32_t lastButtonTime = 0;
+
+ButtonState getButtonState() {
+ /*
+ * Read in the buttons and then determine if a state change needs to occur
+ */
+
+ /*
+ * If the previous state was 00 Then we want to latch the new state if
+ * different & update time
+ * If the previous state was !00 Then we want to search if we trigger long
+ * press (buttons still down), or if release we trigger press
+ * (downtime>filter)
+ */
+ static uint8_t previousState = 0;
+ static uint32_t previousStateChange = 0;
+ const uint16_t timeout = 40;
+ uint8_t currentState;
+ currentState = (getButtonA()) << 0;
+ currentState |= (getButtonB()) << 1;
+
+ if (currentState)
+ lastButtonTime = xTaskGetTickCount();
+ if (currentState == previousState) {
+ if (currentState == 0)
+ return BUTTON_NONE;
+ if ((xTaskGetTickCount() - previousStateChange) > timeout) {
+ // User has been holding the button down
+ // We want to send a button is held message
+ if (currentState == 0x01)
+ return BUTTON_F_LONG;
+ else if (currentState == 0x02)
+ return BUTTON_B_LONG;
+ else
+ return BUTTON_NONE; // Both being held case, we dont long hold this
+ } else
+ return BUTTON_NONE;
+ } else {
+ // A change in button state has occurred
+ ButtonState retVal = BUTTON_NONE;
+ if (currentState) {
+ // User has pressed a button down (nothing done on down)
+ if (currentState != previousState) {
+ // There has been a change in the button states
+ // If there is a rising edge on one of the buttons from double press we
+ // want to mask that out As users are having issues with not release
+ // both at once
+ if (previousState == 0x03)
+ currentState = 0x03;
+ }
+ } else {
+ // User has released buttons
+ // If they previously had the buttons down we want to check if they were <
+ // long hold and trigger a press
+ if ((xTaskGetTickCount() - previousStateChange) < timeout) {
+ // The user didn't hold the button for long
+ // So we send button press
+
+ if (previousState == 0x01)
+ retVal = BUTTON_F_SHORT;
+ else if (previousState == 0x02)
+ retVal = BUTTON_B_SHORT;
+ else
+ retVal = BUTTON_BOTH; // Both being held case
+ }
+ }
+ previousState = currentState;
+ previousStateChange = xTaskGetTickCount();
+ return retVal;
+ }
+ return BUTTON_NONE;
+}
+
+void waitForButtonPress() {
+ // we are just lazy and sleep until user confirms button press
+ // This also eats the button press event!
+ ButtonState buttons = getButtonState();
+ while (buttons) {
+ buttons = getButtonState();
+ GUIDelay();
+ }
+ while (!buttons) {
+ buttons = getButtonState();
+ GUIDelay();
+ }
+}
+
+void waitForButtonPressOrTimeout(uint32_t timeout) {
+ timeout += xTaskGetTickCount();
+ // calculate the exit point
+
+ ButtonState buttons = getButtonState();
+ while (buttons) {
+ buttons = getButtonState();
+ GUIDelay();
+ if (xTaskGetTickCount() > timeout)
+ return;
+ }
+ while (!buttons) {
+ buttons = getButtonState();
+ GUIDelay();
+ if (xTaskGetTickCount() > timeout)
+ return;
+ }
+}
diff --git a/workspace/TS100/Core/Drivers/Buttons.hpp b/workspace/TS100/Core/Drivers/Buttons.hpp
new file mode 100644
index 00000000..fb4b1991
--- /dev/null
+++ b/workspace/TS100/Core/Drivers/Buttons.hpp
@@ -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_ */
diff --git a/workspace/TS100/Core/Inc/Font.h b/workspace/TS100/Core/Drivers/Font.h
index 07139044..761b2723 100644
--- a/workspace/TS100/Core/Inc/Font.h
+++ b/workspace/TS100/Core/Drivers/Font.h
@@ -1,192 +1,192 @@
-/*
- * Font.h
- *
- * Created on: 17 Sep 2016
- * Author: Ralim
- *
- * ... This file contains the font...
- */
-
-#ifndef FONT_H_
-#define FONT_H_
-#include "Translation.h"
-
-#define FONT_12_WIDTH 12
-// FONTS ARE NO LONGER HERE, MOVED TO PYTHON AUTO GEN
-
-
-const uint8_t ExtraFontChars[] = {
- //width = 12
- //height = 16
- 0x00,0x18,0x24,0x24,0x18,0xC0,0x40,0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x02,0x02,0x02,0x00,0x00,0x00, // Degrees F
- 0x00,0x18,0x24,0x24,0x18,0x80,0x40,0x20,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x08,0x10,0x10,0x10,0x00,0x00, // Degrees C
- 0x00,0x00,0x20,0x30,0x38,0xFC,0xFE,0xFC,0x38,0x30,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x7F,0x7F,0x00,0x00,0x00,0x00, // UP arrow
-
- 0x00,0xF0,0x08,0x0E,0x02,0x02,0x02,0x02,0x0E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x3F,0x00, // Battery Empty
- 0x00,0xF0,0x08,0x0E,0x02,0x02,0x02,0x02,0x0E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x50,0x50,0x50,0x50,0x50,0x50,0x40,0x3F,0x00, // Battery 1*/
- 0x00,0xF0,0x08,0x0E,0x02,0x02,0x02,0x02,0x0E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x58,0x58,0x58,0x58,0x58,0x58,0x40,0x3F,0x00, // Battery 2*/
- 0x00,0xF0,0x08,0x0E,0x02,0x02,0x02,0x02,0x0E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5C,0x5C,0x5C,0x5C,0x5C,0x5C,0x40,0x3F,0x00, // Battery 3*/
- 0x00,0xF0,0x08,0x0E,0x02,0x02,0x02,0x02,0x0E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5E,0x5E,0x5E,0x5E,0x5E,0x5E,0x40,0x3F,0x00, // Battery 4*/
- 0x00,0xF0,0x08,0x0E,0x02,0x02,0x02,0x02,0x0E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5F,0x5F,0x5F,0x5F,0x5F,0x5F,0x40,0x3F,0x00, // Battery 5*/
- 0x00,0xF0,0x08,0x8E,0x82,0x82,0x82,0x82,0x8E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5F,0x5F,0x5F,0x5F,0x5F,0x5F,0x40,0x3F,0x00, // Battery 6*/
- 0x00,0xF0,0x08,0xCE,0xC2,0xC2,0xC2,0xC2,0xCE,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5F,0x5F,0x5F,0x5F,0x5F,0x5F,0x40,0x3F,0x00, // Battery 7*/
- 0x00,0xF0,0x08,0xEE,0xE2,0xE2,0xE2,0xE2,0xEE,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5F,0x5F,0x5F,0x5F,0x5F,0x5F,0x40,0x3F,0x00, // Battery 8*/
- 0x00,0xF0,0x08,0xEE,0xE2,0xF2,0xF2,0xE2,0xEE,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5F,0x5F,0x5F,0x5F,0x5F,0x5F,0x40,0x3F,0x00, // Battery 9*/
- 0x00,0xF0,0x08,0xEE,0xE2,0xFA,0xFA,0xE2,0xEE,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5F,0x5F,0x5F,0x5F,0x5F,0x5F,0x40,0x3F,0x00, // Battery 10*/
-
- 0x00,0x00,0x38,0xC4,0x00,0x38,0xC4,0x00,0x38,0xC4,0x00,0x00,0x00,0x38,0x3A,0x39,0x38,0x3A,0x39,0x38,0x3A,0x39,0x10,0x10, // heating
- 0x00,0x60,0xE0,0xFE,0xE0,0xE0,0xE0,0xE0,0xFE,0xE0,0x60,0x00,0x00,0x00,0x00,0x01,0x03,0xFF,0xFF,0x03,0x01,0x00,0x00,0x00, // AC
-
- 0xFC,0x02,0x02,0x02,0x02,0x02,0x02,0x82,0x62,0x1A,0x02,0xFC,0x3F,0x40,0x42,0x46,0x4C,0x58,0x46,0x41,0x40,0x40,0x40,0x3F, // ☑ (check box on, menu true)
- 0xFC,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0xFC,0x3F,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x3F, // ☐ (check box off, menu false)
-
- /*
- 0x00,0x00,0x00,0x80,0x80,0xFE,0xFF,0x83,0x87,0x06,0x00,0x00,0x00,0x00,0x30,0x70,0x60,0x7F,0x3F,0x00,0x00,0x00,0x00,0x00, // Function?
- 0x00,0x70,0xFA,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xFF,0xFE,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x00, // a_
- 0x00,0x3C,0x7E,0xE7,0xC3,0xC3,0xC3,0xC3,0xE7,0x7E,0x3C,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x00, // 0_
- 0x55,0x00,0xAA,0x00,0x55,0x00,0xAA,0x00,0x55,0x00,0xAA,0x00,0x55,0x00,0xAA,0x00,0x55,0x00,0xAA,0x00,0x55,0x00,0xAA,0x00, // 25% block
- 0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55, // 50% pipe
- 0xAA,0xFF,0x55,0xFF,0xAA,0xFF,0x55,0xFF,0xAA,0xFF,0x55,0xFF,0xAA,0xFF,0x55,0xFF,0xAA,0xFF,0x55,0xFF,0xAA,0xFF,0x55,0xFF, // 75% block
- 0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00, // | pipe
- 0x80,0x80,0x80,0x80,0x80,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00, // T pipe ,|
- 0xC0,0xC0,0xFF,0xFF,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0xFE,0xFE,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00, // ,| double pipe
- 0x00,0x00,0xFF,0xFF,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00, // || double pipe
- 0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0xFE,0xFE,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00, // #NAME?//#NAME?
- 0xC0,0xC0,0xFF,0xFF,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x07,0x07,0x00,0x00,0x00,0x00,0x00, // ,^ double pupe
- 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00, // #NAME?//#NAME?
- 0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01, // ,> pipe
- 0x80,0x80,0x80,0x80,0x80,0xFF,0xFF,0x80,0x80,0x80,0x80,0x80,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, // _|_ pipe
- 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x01,0x01,0x01,0x01,0x01,0xFF,0xFF,0x01,0x01,0x01,0x01,0x01, // ,|, pipe
- 0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x01,0x01,0x01,0x01,0x01, // |, pipe
- 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, // #NAME?//#NAME?
- 0x80,0x80,0x80,0x80,0x80,0xFF,0xFF,0x80,0x80,0x80,0x80,0x80,0x01,0x01,0x01,0x01,0x01,0xFF,0xFF,0x01,0x01,0x01,0x01,0x01, // #NAME?//#NAME?
- 0x00,0x00,0xFF,0xFF,0x00,0xFF,0xFF,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x07,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, // ,> double pipe
- 0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0xFF,0xFF,0x00,0xFE,0xFE,0x06,0x06,0x06,0x06,0x06, // ^, double pipe
- 0xC0,0xC0,0xFF,0xFF,0x00,0xFF,0xFF,0xC0,0xC0,0xC0,0xC0,0xC0,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, // _|_ double pipe
- 0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x06,0x06,0xFE,0xFE,0x00,0xFE,0xFE,0x06,0x06,0x06,0x06,0x06, // ,|, double pipe
- 0x00,0x00,0xFF,0xFF,0x00,0xFF,0xFF,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0xFF,0xFF,0x00,0xFE,0xFE,0x06,0x06,0x06,0x06,0x06, // |, double pipe
- 0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, // == double pipe
- 0xC0,0xC0,0xFF,0xFF,0x00,0xFF,0xFF,0xC0,0xC0,0xC0,0xC0,0xC0,0x06,0x06,0xFE,0xFE,0x00,0xFE,0xFE,0x06,0x06,0x06,0x06,0x06, // #NAME?//#NAME?
- 0x00,0x00,0x00,0x78,0xFC,0xCC,0x8C,0x0C,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x3E,0x33,0x33,0x3F,0x1E,0x00,0x00,0x00, // Delta lowercase
- 0x00,0x00,0x00,0x00,0x00,0x7E,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 27 (')
- 0x80,0x80,0x80,0x80,0x80,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00, // ,^ pipe
- 0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x01,0x01,0x01,0x01,0x01, // | , pipe
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, // solid block
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, // half block bottom
- 0x00,0x00,0x00,0x00,0x00,0xBF,0xBF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x3F,0x00,0x00,0x00,0x00,0x00, // 7C (|)
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // top half solid block
- 0x00,0x00,0x0C,0xFC,0xFC,0x6C,0x60,0x60,0xE0,0xC0,0x00,0x00,0x00,0x00,0x30,0x3F,0x3F,0x36,0x06,0x06,0x07,0x03,0x00,0x00, // DE small
- 0x00,0x00,0x03,0xFF,0xFF,0x1B,0x18,0x18,0xF8,0xF0,0x00,0x00,0x00,0x00,0x30,0x3F,0x3F,0x36,0x06,0x06,0x07,0x03,0x00,0x00, // DE large
- 0x00,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ? (,)
- 0x00,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x00, // =
- 0x00,0x00,0x00,0x40,0x80,0x80,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // sideways comma
- 0x00,0x00,0x80,0xC0,0x80,0x00,0x00,0x80,0xC0,0x80,0x00,0x00,0x00,0x00,0x01,0x03,0x01,0x00,0x00,0x01,0x03,0x01,0x00,0x00, // ..
- 0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x01,0x00,0x00,0x00,0x00, // .
- 0x00,0x00,0x02,0x1F,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // tiny 1
- 0x00,0x00,0x00,0x00,0xF0,0xF0,0xF0,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x00, // small block
- */
-};
-
-const uint8_t FontSymbols[] = {
- 0x00,0x00,0x00,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00, // Right block
- 0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0F,0x1F,0x00,0x00,0x00, // left block
- 0x00,0x00,0x00,0x10,0x18,0x1C,0xFE,0x1C,0x18,0x10,0x00,0x00,0x00,0x00,0x00,0x04,0x0C,0x1C,0x3F,0x1C,0x0C,0x04,0x00,0x00, // UD arrow
- 0x00,0x00,0x00,0xFE,0xFE,0x00,0x00,0xFE,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x37,0x00,0x00,0x37,0x37,0x00,0x00,0x00, // !!
- 0x00,0x38,0x7C,0xC6,0x82,0xFE,0xFE,0x02,0xFE,0xFE,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x3F,0x00,0x3F,0x3F,0x00,0x00, // paragraph
- 0x00,0x00,0xDC,0xFE,0x22,0x22,0x22,0x22,0xE6,0xC4,0x00,0x00,0x00,0x00,0x08,0x19,0x11,0x11,0x11,0x11,0x1F,0x0E,0x00,0x00, // section
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x00, // cursor
- 0x00,0x00,0x00,0x08,0x0C,0x0E,0xFF,0x0E,0x0C,0x08,0x00,0x00,0x00,0x00,0x00,0x44,0x4C,0x5C,0x7F,0x5C,0x4C,0x44,0x00,0x00, // UD arrow
- 0x00,0x00,0x00,0x10,0x18,0x1C,0xFE,0x1C,0x18,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,0x00, // UP arrow
- 0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x0C,0x1C,0x3F,0x1C,0x0C,0x04,0x00,0x00, // Down arrow
- 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x03,0x01,0x00,0x00, // right arrow
- 0x00,0x00,0x80,0xC0,0xE0,0xF0,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x00,0x00,0x00,0x00,0x00,0x00, // left arrow
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
- 0x00,0x80,0xC0,0xE0,0xF0,0x80,0x80,0x80,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x01,0x03,0x07,0x00,0x00,0x00,0x07,0x03,0x01,0x00, // LR arrow
- 0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x04,0x06,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x06,0x04, // UP block
- 0x00,0x20,0x60,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0x60,0x20,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x03,0x01,0x00,0x00,0x00 // Down block
-};
-
-const uint8_t WarningBlock24[] = {
- //width = 24
- //height = 16
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x30,0x0C,0x02,0xF1,0xF1,0xF1,0x02,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0xC0,0xB0,0x8C,0x83,0x80,0x80,0x80,0x80,0xB3,0xB3,0xB3,0x80,0x80,0x80,0x80,0x83,0x8C,0xB0,0xC0,0x00,0x00
-};
-
-const uint8_t idleScreenBG[] = {
- //width = 84
- //height = 16
- 0x00,0xE0,0x18,0x04,0x02,0x02,0x01,0x41,0x61,0x61,0x61,0xE1,0xC1,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,
- 0x81,0x81,0x81,0x81,0xC1,0xE1,0x61,0x61,0x61,0x41,0x01,0x01,0x02,0x02,0x04,0x18,0xE0,0x00,0x00,0xE0,0x18,0x04,0x02,0x02,
- 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
- 0x99,0x65,0x01,0x01,0x81,0x41,0x01,0x02,0x02,0x04,0x18,0xE0,
- 0x00,0x07,0x18,0x20,0x40,0x40,0x80,0x82,0x86,0x86,0x86,0x87,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,
- 0x81,0x81,0x81,0x81,0x83,0x87,0x86,0x86,0x86,0x82,0x80,0x80,0x40,0x40,0x20,0x18,0x07,0x00,0x00,0x07,0x18,0x20,0x40,0x40,
- 0x80,0x82,0x87,0x85,0x85,0x85,0x85,0x87,0x87,0x85,0x87,0x85,0x87,0x87,0x82,0x82,0x82,0x80,0x82,0x80,0x82,0x82,0x82,0x92,
- 0x8A,0x84,0x82,0x81,0x80,0x80,0x80,0x40,0x40,0x20,0x18,0x07
-};
-
-const uint8_t idleScreenBGF[] = {
- //width = 84
- //height = 16
- 0xE0,0x18,0x04,0x02,0x02,0x01,0x41,0x81,0x01,0x01,0x65,0x99,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
- 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x04,0x18,0xE0,0x00,0x00,0xE0,0x18,0x04,0x02,0x02,
- 0x01,0x01,0x41,0x61,0x61,0x61,0xE1,0xC1,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xC1,
- 0xE1,0x61,0x61,0x61,0x41,0x01,0x02,0x02,0x04,0x18,0xE0,0x00,
- 0x07,0x18,0x20,0x40,0x40,0x80,0x80,0x80,0x81,0x82,0x84,0x8A,0x92,0x82,0x82,0x82,0x80,0x82,0x80,0x82,0x82,0x82,0x87,0x87,
- 0x85,0x87,0x85,0x87,0x87,0x85,0x85,0x85,0x85,0x87,0x82,0x80,0x40,0x40,0x20,0x18,0x07,0x00,0x00,0x07,0x18,0x20,0x40,0x40,
- 0x80,0x80,0x82,0x86,0x86,0x86,0x87,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x83,
- 0x87,0x86,0x86,0x86,0x82,0x80,0x40,0x40,0x20,0x18,0x07,0x00
-};
-
-/*
- * 16x16 icons
- * */
-const uint8_t SettingsMenuIcons[] = {
-
- // Soldering
- //width = 16
- //height = 16
- 0x00, 0x02, 0x04, 0x08, 0x12, 0x24, 0xC4, 0x42, 0x82, 0x04,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01, 0x02, 0x07, 0x0A, 0x14, 0x28, 0x50,
- 0x60, 0x00,
-
-
-
- //Sleep
- //width = 16
- //height = 16
- 0x00, 0xC6, 0xE6, 0xF6, 0xBE, 0x9E, 0x8E, 0x86, 0x00, 0x00,
- 0x40, 0x40, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x01, 0x01, 0x01,
- 0x45, 0x65, 0x75, 0x5D, 0x4C, 0x00, 0x06, 0x07, 0x07, 0x05,
- 0x04, 0x00,
-
-
-
- //Menu
- //width = 16
- //height = 16
- 0x00,0x80,0x06,0x86,0x46,0x06,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x00,
- 0x00,0x00,0x61,0x60,0x00,0x00,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x00,
-
- //Wrench
- ///width = 16
- //height = 16
- 0x00, 0x18, 0x30, 0x32, 0x7E, 0x7C, 0xF0, 0xC0, 0x80, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01, 0x03, 0x0F, 0x3E, 0x7E, 0x4C, 0x0C,
- 0x18, 0x00,
- #ifdef NOTUSED
- //Calibration (Not used, kept for future menu layouts)
- //width = 16
- //height = 16
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE8, 0x70,
- 0x7A, 0x5E, 0x8E, 0x1C, 0x30, 0x00, 0x00, 0x10, 0x38, 0x1C,
- 0x0E, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00,
- #endif
-};
-
-
-#endif /* FONT_H_ */
+/*
+ * Font.h
+ *
+ * Created on: 17 Sep 2016
+ * Author: Ralim
+ *
+ * ... This file contains the font...
+ */
+
+#ifndef FONT_H_
+#define FONT_H_
+#include "Translation.h"
+
+#define FONT_12_WIDTH 12
+// THE MAIN FONTS ARE NO LONGER HERE, MOVED TO PYTHON AUTO GEN
+// THESE ARE ONLY THE SYMBOL FONTS
+
+const uint8_t ExtraFontChars[] = {
+ //width = 12
+ //height = 16
+ 0x00,0x18,0x24,0x24,0x18,0xC0,0x40,0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x02,0x02,0x02,0x00,0x00,0x00, // Degrees F
+ 0x00,0x18,0x24,0x24,0x18,0x80,0x40,0x20,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x08,0x10,0x10,0x10,0x00,0x00, // Degrees C
+ 0x00,0x00,0x20,0x30,0x38,0xFC,0xFE,0xFC,0x38,0x30,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x7F,0x7F,0x00,0x00,0x00,0x00, // UP arrow
+
+ 0x00,0xF0,0x08,0x0E,0x02,0x02,0x02,0x02,0x0E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x3F,0x00, // Battery Empty
+ 0x00,0xF0,0x08,0x0E,0x02,0x02,0x02,0x02,0x0E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x50,0x50,0x50,0x50,0x50,0x50,0x40,0x3F,0x00, // Battery 1*/
+ 0x00,0xF0,0x08,0x0E,0x02,0x02,0x02,0x02,0x0E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x58,0x58,0x58,0x58,0x58,0x58,0x40,0x3F,0x00, // Battery 2*/
+ 0x00,0xF0,0x08,0x0E,0x02,0x02,0x02,0x02,0x0E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5C,0x5C,0x5C,0x5C,0x5C,0x5C,0x40,0x3F,0x00, // Battery 3*/
+ 0x00,0xF0,0x08,0x0E,0x02,0x02,0x02,0x02,0x0E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5E,0x5E,0x5E,0x5E,0x5E,0x5E,0x40,0x3F,0x00, // Battery 4*/
+ 0x00,0xF0,0x08,0x0E,0x02,0x02,0x02,0x02,0x0E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5F,0x5F,0x5F,0x5F,0x5F,0x5F,0x40,0x3F,0x00, // Battery 5*/
+ 0x00,0xF0,0x08,0x8E,0x82,0x82,0x82,0x82,0x8E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5F,0x5F,0x5F,0x5F,0x5F,0x5F,0x40,0x3F,0x00, // Battery 6*/
+ 0x00,0xF0,0x08,0xCE,0xC2,0xC2,0xC2,0xC2,0xCE,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5F,0x5F,0x5F,0x5F,0x5F,0x5F,0x40,0x3F,0x00, // Battery 7*/
+ 0x00,0xF0,0x08,0xEE,0xE2,0xE2,0xE2,0xE2,0xEE,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5F,0x5F,0x5F,0x5F,0x5F,0x5F,0x40,0x3F,0x00, // Battery 8*/
+ 0x00,0xF0,0x08,0xEE,0xE2,0xF2,0xF2,0xE2,0xEE,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5F,0x5F,0x5F,0x5F,0x5F,0x5F,0x40,0x3F,0x00, // Battery 9*/
+ 0x00,0xF0,0x08,0xEE,0xE2,0xFA,0xFA,0xE2,0xEE,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5F,0x5F,0x5F,0x5F,0x5F,0x5F,0x40,0x3F,0x00, // Battery 10*/
+
+ 0x00,0x00,0x38,0xC4,0x00,0x38,0xC4,0x00,0x38,0xC4,0x00,0x00,0x00,0x38,0x3A,0x39,0x38,0x3A,0x39,0x38,0x3A,0x39,0x10,0x10, // heating
+ 0x00,0x60,0xE0,0xFE,0xE0,0xE0,0xE0,0xE0,0xFE,0xE0,0x60,0x00,0x00,0x00,0x00,0x01,0x03,0xFF,0xFF,0x03,0x01,0x00,0x00,0x00, // AC
+
+ 0xFC,0x02,0x02,0x02,0x02,0x02,0x02,0x82,0x62,0x1A,0x02,0xFC,0x3F,0x40,0x42,0x46,0x4C,0x58,0x46,0x41,0x40,0x40,0x40,0x3F, // ☑ (check box on, menu true)
+ 0xFC,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0xFC,0x3F,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x3F, // ☐ (check box off, menu false)
+
+ /*
+ 0x00,0x00,0x00,0x80,0x80,0xFE,0xFF,0x83,0x87,0x06,0x00,0x00,0x00,0x00,0x30,0x70,0x60,0x7F,0x3F,0x00,0x00,0x00,0x00,0x00, // Function?
+ 0x00,0x70,0xFA,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xFF,0xFE,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x00, // a_
+ 0x00,0x3C,0x7E,0xE7,0xC3,0xC3,0xC3,0xC3,0xE7,0x7E,0x3C,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x00, // 0_
+ 0x55,0x00,0xAA,0x00,0x55,0x00,0xAA,0x00,0x55,0x00,0xAA,0x00,0x55,0x00,0xAA,0x00,0x55,0x00,0xAA,0x00,0x55,0x00,0xAA,0x00, // 25% block
+ 0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55, // 50% pipe
+ 0xAA,0xFF,0x55,0xFF,0xAA,0xFF,0x55,0xFF,0xAA,0xFF,0x55,0xFF,0xAA,0xFF,0x55,0xFF,0xAA,0xFF,0x55,0xFF,0xAA,0xFF,0x55,0xFF, // 75% block
+ 0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00, // | pipe
+ 0x80,0x80,0x80,0x80,0x80,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00, // T pipe ,|
+ 0xC0,0xC0,0xFF,0xFF,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0xFE,0xFE,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00, // ,| double pipe
+ 0x00,0x00,0xFF,0xFF,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00, // || double pipe
+ 0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0xFE,0xFE,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00, // #NAME?//#NAME?
+ 0xC0,0xC0,0xFF,0xFF,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x07,0x07,0x00,0x00,0x00,0x00,0x00, // ,^ double pupe
+ 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00, // #NAME?//#NAME?
+ 0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01, // ,> pipe
+ 0x80,0x80,0x80,0x80,0x80,0xFF,0xFF,0x80,0x80,0x80,0x80,0x80,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, // _|_ pipe
+ 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x01,0x01,0x01,0x01,0x01,0xFF,0xFF,0x01,0x01,0x01,0x01,0x01, // ,|, pipe
+ 0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x01,0x01,0x01,0x01,0x01, // |, pipe
+ 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, // #NAME?//#NAME?
+ 0x80,0x80,0x80,0x80,0x80,0xFF,0xFF,0x80,0x80,0x80,0x80,0x80,0x01,0x01,0x01,0x01,0x01,0xFF,0xFF,0x01,0x01,0x01,0x01,0x01, // #NAME?//#NAME?
+ 0x00,0x00,0xFF,0xFF,0x00,0xFF,0xFF,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x07,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, // ,> double pipe
+ 0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0xFF,0xFF,0x00,0xFE,0xFE,0x06,0x06,0x06,0x06,0x06, // ^, double pipe
+ 0xC0,0xC0,0xFF,0xFF,0x00,0xFF,0xFF,0xC0,0xC0,0xC0,0xC0,0xC0,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, // _|_ double pipe
+ 0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x06,0x06,0xFE,0xFE,0x00,0xFE,0xFE,0x06,0x06,0x06,0x06,0x06, // ,|, double pipe
+ 0x00,0x00,0xFF,0xFF,0x00,0xFF,0xFF,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0xFF,0xFF,0x00,0xFE,0xFE,0x06,0x06,0x06,0x06,0x06, // |, double pipe
+ 0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, // == double pipe
+ 0xC0,0xC0,0xFF,0xFF,0x00,0xFF,0xFF,0xC0,0xC0,0xC0,0xC0,0xC0,0x06,0x06,0xFE,0xFE,0x00,0xFE,0xFE,0x06,0x06,0x06,0x06,0x06, // #NAME?//#NAME?
+ 0x00,0x00,0x00,0x78,0xFC,0xCC,0x8C,0x0C,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x3E,0x33,0x33,0x3F,0x1E,0x00,0x00,0x00, // Delta lowercase
+ 0x00,0x00,0x00,0x00,0x00,0x7E,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 27 (')
+ 0x80,0x80,0x80,0x80,0x80,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00, // ,^ pipe
+ 0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x01,0x01,0x01,0x01,0x01, // | , pipe
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, // solid block
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, // half block bottom
+ 0x00,0x00,0x00,0x00,0x00,0xBF,0xBF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x3F,0x00,0x00,0x00,0x00,0x00, // 7C (|)
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // top half solid block
+ 0x00,0x00,0x0C,0xFC,0xFC,0x6C,0x60,0x60,0xE0,0xC0,0x00,0x00,0x00,0x00,0x30,0x3F,0x3F,0x36,0x06,0x06,0x07,0x03,0x00,0x00, // DE small
+ 0x00,0x00,0x03,0xFF,0xFF,0x1B,0x18,0x18,0xF8,0xF0,0x00,0x00,0x00,0x00,0x30,0x3F,0x3F,0x36,0x06,0x06,0x07,0x03,0x00,0x00, // DE large
+ 0x00,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ? (,)
+ 0x00,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x00, // =
+ 0x00,0x00,0x00,0x40,0x80,0x80,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // sideways comma
+ 0x00,0x00,0x80,0xC0,0x80,0x00,0x00,0x80,0xC0,0x80,0x00,0x00,0x00,0x00,0x01,0x03,0x01,0x00,0x00,0x01,0x03,0x01,0x00,0x00, // ..
+ 0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x01,0x00,0x00,0x00,0x00, // .
+ 0x00,0x00,0x02,0x1F,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // tiny 1
+ 0x00,0x00,0x00,0x00,0xF0,0xF0,0xF0,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x00, // small block
+ */
+};
+
+const uint8_t FontSymbols[] = {
+ 0x00,0x00,0x00,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00, // Right block
+ 0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0F,0x1F,0x00,0x00,0x00, // left block
+ 0x00,0x00,0x00,0x10,0x18,0x1C,0xFE,0x1C,0x18,0x10,0x00,0x00,0x00,0x00,0x00,0x04,0x0C,0x1C,0x3F,0x1C,0x0C,0x04,0x00,0x00, // UD arrow
+ 0x00,0x00,0x00,0xFE,0xFE,0x00,0x00,0xFE,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x37,0x00,0x00,0x37,0x37,0x00,0x00,0x00, // !!
+ 0x00,0x38,0x7C,0xC6,0x82,0xFE,0xFE,0x02,0xFE,0xFE,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x3F,0x00,0x3F,0x3F,0x00,0x00, // paragraph
+ 0x00,0x00,0xDC,0xFE,0x22,0x22,0x22,0x22,0xE6,0xC4,0x00,0x00,0x00,0x00,0x08,0x19,0x11,0x11,0x11,0x11,0x1F,0x0E,0x00,0x00, // section
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x00, // cursor
+ 0x00,0x00,0x00,0x08,0x0C,0x0E,0xFF,0x0E,0x0C,0x08,0x00,0x00,0x00,0x00,0x00,0x44,0x4C,0x5C,0x7F,0x5C,0x4C,0x44,0x00,0x00, // UD arrow
+ 0x00,0x00,0x00,0x10,0x18,0x1C,0xFE,0x1C,0x18,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,0x00, // UP arrow
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x0C,0x1C,0x3F,0x1C,0x0C,0x04,0x00,0x00, // Down arrow
+ 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x03,0x01,0x00,0x00, // right arrow
+ 0x00,0x00,0x80,0xC0,0xE0,0xF0,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x00,0x00,0x00,0x00,0x00,0x00, // left arrow
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
+ 0x00,0x80,0xC0,0xE0,0xF0,0x80,0x80,0x80,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x01,0x03,0x07,0x00,0x00,0x00,0x07,0x03,0x01,0x00, // LR arrow
+ 0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x04,0x06,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x06,0x04, // UP block
+ 0x00,0x20,0x60,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0x60,0x20,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x03,0x01,0x00,0x00,0x00 // Down block
+};
+
+const uint8_t WarningBlock24[] = {
+ //width = 24
+ //height = 16
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x30,0x0C,0x02,0xF1,0xF1,0xF1,0x02,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xC0,0xB0,0x8C,0x83,0x80,0x80,0x80,0x80,0xB3,0xB3,0xB3,0x80,0x80,0x80,0x80,0x83,0x8C,0xB0,0xC0,0x00,0x00
+};
+
+const uint8_t idleScreenBG[] = {
+ //width = 84
+ //height = 16
+ 0x00,0xE0,0x18,0x04,0x02,0x02,0x01,0x41,0x61,0x61,0x61,0xE1,0xC1,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,
+ 0x81,0x81,0x81,0x81,0xC1,0xE1,0x61,0x61,0x61,0x41,0x01,0x01,0x02,0x02,0x04,0x18,0xE0,0x00,0x00,0xE0,0x18,0x04,0x02,0x02,
+ 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+ 0x99,0x65,0x01,0x01,0x81,0x41,0x01,0x02,0x02,0x04,0x18,0xE0,
+ 0x00,0x07,0x18,0x20,0x40,0x40,0x80,0x82,0x86,0x86,0x86,0x87,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,
+ 0x81,0x81,0x81,0x81,0x83,0x87,0x86,0x86,0x86,0x82,0x80,0x80,0x40,0x40,0x20,0x18,0x07,0x00,0x00,0x07,0x18,0x20,0x40,0x40,
+ 0x80,0x82,0x87,0x85,0x85,0x85,0x85,0x87,0x87,0x85,0x87,0x85,0x87,0x87,0x82,0x82,0x82,0x80,0x82,0x80,0x82,0x82,0x82,0x92,
+ 0x8A,0x84,0x82,0x81,0x80,0x80,0x80,0x40,0x40,0x20,0x18,0x07
+};
+
+const uint8_t idleScreenBGF[] = {
+ //width = 84
+ //height = 16
+ 0xE0,0x18,0x04,0x02,0x02,0x01,0x41,0x81,0x01,0x01,0x65,0x99,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+ 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x04,0x18,0xE0,0x00,0x00,0xE0,0x18,0x04,0x02,0x02,
+ 0x01,0x01,0x41,0x61,0x61,0x61,0xE1,0xC1,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xC1,
+ 0xE1,0x61,0x61,0x61,0x41,0x01,0x02,0x02,0x04,0x18,0xE0,0x00,
+ 0x07,0x18,0x20,0x40,0x40,0x80,0x80,0x80,0x81,0x82,0x84,0x8A,0x92,0x82,0x82,0x82,0x80,0x82,0x80,0x82,0x82,0x82,0x87,0x87,
+ 0x85,0x87,0x85,0x87,0x87,0x85,0x85,0x85,0x85,0x87,0x82,0x80,0x40,0x40,0x20,0x18,0x07,0x00,0x00,0x07,0x18,0x20,0x40,0x40,
+ 0x80,0x80,0x82,0x86,0x86,0x86,0x87,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x83,
+ 0x87,0x86,0x86,0x86,0x82,0x80,0x40,0x40,0x20,0x18,0x07,0x00
+};
+
+/*
+ * 16x16 icons
+ * */
+const uint8_t SettingsMenuIcons[] = {
+
+ // Soldering
+ //width = 16
+ //height = 16
+ 0x00, 0x02, 0x04, 0x08, 0x12, 0x24, 0xC4, 0x42, 0x82, 0x04,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01, 0x02, 0x07, 0x0A, 0x14, 0x28, 0x50,
+ 0x60, 0x00,
+
+
+
+ //Sleep
+ //width = 16
+ //height = 16
+ 0x00, 0xC6, 0xE6, 0xF6, 0xBE, 0x9E, 0x8E, 0x86, 0x00, 0x00,
+ 0x40, 0x40, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x01, 0x01, 0x01,
+ 0x45, 0x65, 0x75, 0x5D, 0x4C, 0x00, 0x06, 0x07, 0x07, 0x05,
+ 0x04, 0x00,
+
+
+
+ //Menu
+ //width = 16
+ //height = 16
+ 0x00,0x80,0x06,0x86,0x46,0x06,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x00,
+ 0x00,0x00,0x61,0x60,0x00,0x00,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x00,
+
+ //Wrench
+ ///width = 16
+ //height = 16
+ 0x00, 0x18, 0x30, 0x32, 0x7E, 0x7C, 0xF0, 0xC0, 0x80, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01, 0x03, 0x0F, 0x3E, 0x7E, 0x4C, 0x0C,
+ 0x18, 0x00,
+ #ifdef NOTUSED
+ //Calibration (Not used, kept for future menu layouts)
+ //width = 16
+ //height = 16
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE8, 0x70,
+ 0x7A, 0x5E, 0x8E, 0x1C, 0x30, 0x00, 0x00, 0x10, 0x38, 0x1C,
+ 0x0E, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00,
+ #endif
+};
+
+
+#endif /* FONT_H_ */
diff --git a/workspace/TS100/Core/Inc/FRToSI2C.hpp b/workspace/TS100/Core/Drivers/I2C_Wrapper.hpp
index f1515929..3753a481 100644
--- a/workspace/TS100/Core/Inc/FRToSI2C.hpp
+++ b/workspace/TS100/Core/Drivers/I2C_Wrapper.hpp
@@ -1,44 +1,52 @@
-/*
- * 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 "cmsis_os.h"
+
+/*
+ * Wrapper class to work with the device I2C bus
+ *
+ * This provides mutex protection of the peripheral
+ * Also allows hardware to use DMA should it want to
+ *
+ *
+ */
+class FRToSI2C {
+public:
+
+ static void init() {
+ 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,
+ uint8_t *pData, uint16_t Size);
+ static void Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
+ 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 void I2C_Unstick();
+ static SemaphoreHandle_t I2CSemaphore;
+ static StaticSemaphore_t xSemaphoreBuffer;
+};
+
+#endif /* FRTOSI2C_HPP_ */
diff --git a/workspace/TS100/Core/Drivers/LIS2DH12.cpp b/workspace/TS100/Core/Drivers/LIS2DH12.cpp
new file mode 100644
index 00000000..888e1231
--- /dev/null
+++ b/workspace/TS100/Core/Drivers/LIS2DH12.cpp
@@ -0,0 +1,52 @@
+/*
+ * LIS2DH12.cpp
+ *
+ * Created on: 27Feb.,2018
+ * Author: Ralim
+ */
+
+#include <array>
+
+#include "LIS2DH12.hpp"
+#include "cmsis_os.h"
+
+typedef struct {
+ const uint8_t reg;
+ const uint8_t value;
+} LIS_REG;
+
+static const LIS_REG i2c_registers[] = { { LIS_CTRL_REG1, 0x17 }, // 25Hz
+ { LIS_CTRL_REG2, 0b00001000 }, // Highpass filter off
+ { LIS_CTRL_REG3, 0b01100000 }, // Setup interrupt pins
+ { LIS_CTRL_REG4, 0b00001000 }, // Block update mode off, HR on
+ { LIS_CTRL_REG5, 0b00000010 }, { LIS_CTRL_REG6, 0b01100010 },
+ //Basically setup the unit to run, and enable 4D orientation detection
+ { LIS_INT2_CFG, 0b01111110 }, //setup for movement detection
+ { LIS_INT2_THS, 0x28 }, { LIS_INT2_DURATION, 64 }, {
+ LIS_INT1_CFG, 0b01111110 }, { LIS_INT1_THS, 0x28 }, {
+ LIS_INT1_DURATION, 64 } };
+
+void LIS2DH12::initalize() {
+ for (size_t index = 0;
+ index < (sizeof(i2c_registers) / sizeof(i2c_registers[0]));
+ index++) {
+ FRToSI2C::I2C_RegisterWrite(LIS2DH_I2C_ADDRESS,
+ i2c_registers[index].reg, i2c_registers[index].value);
+ }
+}
+
+void LIS2DH12::getAxisReadings(int16_t &x, int16_t &y, int16_t &z) {
+ std::array<int16_t, 3> sensorData;
+
+ FRToSI2C::Mem_Read(LIS2DH_I2C_ADDRESS, 0xA8,
+ reinterpret_cast<uint8_t*>(sensorData.begin()),
+ sensorData.size() * sizeof(int16_t));
+
+ x = sensorData[0];
+ y = sensorData[1];
+ z = sensorData[2];
+}
+
+bool LIS2DH12::detect() {
+ return FRToSI2C::probe(LIS2DH_I2C_ADDRESS);
+}
diff --git a/workspace/TS100/Core/Inc/LIS2DH12.hpp b/workspace/TS100/Core/Drivers/LIS2DH12.hpp
index 5a30288f..79346e98 100644
--- a/workspace/TS100/Core/Inc/LIS2DH12.hpp
+++ b/workspace/TS100/Core/Drivers/LIS2DH12.hpp
@@ -1,42 +1,42 @@
-/*
- * LIS2DH12.hpp
- *
- * Created on: 27Feb.,2018
- * Author: Ralim
- */
-
-#ifndef LIS2DH12_HPP_
-#define LIS2DH12_HPP_
-#include "stm32f1xx_hal.h"
-#include "FRToSI2C.hpp"
-#include "LIS2DH12_defines.hpp"
-#include "hardware.h"
-
-class LIS2DH12 {
-public:
- static void initalize();
- //1 = rh, 2,=lh, 8=flat
- static Orientation getOrientation() {
-#ifdef MODEL_TS80
- uint8_t val = (FRToSI2C::I2C_RegisterRead(LIS2DH_I2C_ADDRESS,
- LIS_INT2_SRC) >> 2);
- if (val == 8)
- val = 3;
- else if (val == 1)
- val = 1;
- else if (val == 2)
- val = 0;
- else
- val = 3;
- return static_cast<Orientation>(val);
-#endif
-#ifdef MODEL_TS100
- return static_cast<Orientation>((FRToSI2C::I2C_RegisterRead(LIS2DH_I2C_ADDRESS,LIS_INT2_SRC) >> 2) - 1);
-#endif
- }
- static void getAxisReadings(int16_t& x, int16_t& y, int16_t& z);
-
-private:
-};
-
-#endif /* LIS2DH12_HPP_ */
+/*
+ * LIS2DH12.hpp
+ *
+ * Created on: 27Feb.,2018
+ * Author: Ralim
+ */
+
+#ifndef LIS2DH12_HPP_
+#define LIS2DH12_HPP_
+#include "I2C_Wrapper.hpp"
+#include "LIS2DH12_defines.hpp"
+#include "BSP.h"
+
+class LIS2DH12 {
+public:
+ static bool detect();
+ static void initalize();
+ //1 = rh, 2,=lh, 8=flat
+ static Orientation getOrientation() {
+#ifdef LIS_ORI_FLIP
+ uint8_t val = (FRToSI2C::I2C_RegisterRead(LIS2DH_I2C_ADDRESS,
+ LIS_INT2_SRC) >> 2);
+ if (val == 8)
+ val = 3;
+ else if (val == 1)
+ val = 1;
+ else if (val == 2)
+ val = 0;
+ else
+ val = 3;
+ return static_cast<Orientation>(val);
+#endif
+#ifdef MODEL_TS100
+ return static_cast<Orientation>((FRToSI2C::I2C_RegisterRead(LIS2DH_I2C_ADDRESS,LIS_INT2_SRC) >> 2) - 1);
+#endif
+ }
+ static void getAxisReadings(int16_t& x, int16_t& y, int16_t& z);
+
+private:
+};
+
+#endif /* LIS2DH12_HPP_ */
diff --git a/workspace/TS100/Core/Inc/LIS2DH12_defines.hpp b/workspace/TS100/Core/Drivers/LIS2DH12_defines.hpp
index f317fbca..c233aca5 100644
--- a/workspace/TS100/Core/Inc/LIS2DH12_defines.hpp
+++ b/workspace/TS100/Core/Drivers/LIS2DH12_defines.hpp
@@ -1,28 +1,28 @@
-/*
- * LIS2DH12_defines.hpp
- *
- * Created on: 27Feb.,2018
- * Author: Ralim
- */
-
-#ifndef LIS2DH12_DEFINES_HPP_
-#define LIS2DH12_DEFINES_HPP_
-
-
-#define LIS2DH_I2C_ADDRESS (25<<1)
-
-#define LIS_CTRL_REG1 0x20|0x80
-#define LIS_CTRL_REG2 0x21|0x80
-#define LIS_CTRL_REG3 0x22|0x80
-#define LIS_CTRL_REG4 0x23|0x80
-#define LIS_CTRL_REG5 0x24|0x80
-#define LIS_CTRL_REG6 0x25|0x80
-#define LIS_INT1_CFG 0xB0|0x80
-#define LIS_INT2_CFG 0xB4|0x80
-#define LIS_INT1_DURATION 0x33|0x80
-#define LIS_INT1_THS 0x32|0x80
-#define LIS_INT1_SRC 0x31|0x80
-#define LIS_INT2_DURATION 0x37|0x80
-#define LIS_INT2_THS 0x36|0x80
-#define LIS_INT2_SRC 0x35|0x80
-#endif /* LIS2DH12_DEFINES_HPP_ */
+/*
+ * LIS2DH12_defines.hpp
+ *
+ * Created on: 27Feb.,2018
+ * Author: Ralim
+ */
+
+#ifndef LIS2DH12_DEFINES_HPP_
+#define LIS2DH12_DEFINES_HPP_
+
+
+#define LIS2DH_I2C_ADDRESS (25<<1)
+
+#define LIS_CTRL_REG1 0x20|0x80
+#define LIS_CTRL_REG2 0x21|0x80
+#define LIS_CTRL_REG3 0x22|0x80
+#define LIS_CTRL_REG4 0x23|0x80
+#define LIS_CTRL_REG5 0x24|0x80
+#define LIS_CTRL_REG6 0x25|0x80
+#define LIS_INT1_CFG 0xB0|0x80
+#define LIS_INT2_CFG 0xB4|0x80
+#define LIS_INT1_DURATION 0x33|0x80
+#define LIS_INT1_THS 0x32|0x80
+#define LIS_INT1_SRC 0x31|0x80
+#define LIS_INT2_DURATION 0x37|0x80
+#define LIS_INT2_THS 0x36|0x80
+#define LIS_INT2_SRC 0x35|0x80
+#endif /* LIS2DH12_DEFINES_HPP_ */
diff --git a/workspace/TS100/Core/Src/MMA8652FC.cpp b/workspace/TS100/Core/Drivers/MMA8652FC.cpp
index ebe10568..cd41488a 100644
--- a/workspace/TS100/Core/Src/MMA8652FC.cpp
+++ b/workspace/TS100/Core/Drivers/MMA8652FC.cpp
@@ -1,78 +1,88 @@
-/*
- * MMA8652FC.cpp
- *
- * Created on: 31Aug.,2017
- * Author: Ben V. Brown
- */
-
-#include <array>
-
-#include "MMA8652FC.hpp"
-#include "cmsis_os.h"
-
-typedef struct {
- const uint8_t reg;
- const uint8_t val;
-} MMA_REG;
-
-static const MMA_REG i2c_registers[] = { { CTRL_REG2, 0 }, //Normal mode
- { CTRL_REG2, 0x40 }, // Reset all registers to POR values
- { FF_MT_CFG_REG, 0x78 }, // Enable motion detection for X, Y, Z axis, latch disabled
- { PL_CFG_REG, 0x40 }, //Enable the orientation detection
- { PL_COUNT_REG, 200 }, //200 count debounce
- { PL_BF_ZCOMP_REG, 0b01000111 }, //Set the threshold to 42 degrees
- { P_L_THS_REG, 0b10011100 }, //Up the trip angles
- { CTRL_REG4, 0x01 | (1 << 4) }, // Enable dataready interrupt & orientation interrupt
- { CTRL_REG5, 0x01 }, // Route data ready interrupts to INT1 ->PB5 ->EXTI5, leaving orientation routed to INT2
- { CTRL_REG2, 0x12 }, //Set maximum resolution oversampling
- { XYZ_DATA_CFG_REG, (1 << 4) }, //select high pass filtered data
- { HP_FILTER_CUTOFF_REG, 0x03 }, //select high pass filtered data
- { CTRL_REG1, 0x19 } // ODR=12 Hz, Active mode
-};
-
-
-void MMA8652FC::initalize() {
- size_t index = 0;
-
- //send all the init commands to the unit
-
- FRToSI2C::I2C_RegisterWrite(MMA8652FC_I2C_ADDRESS,i2c_registers[index].reg, i2c_registers[index].val);
- index++;
- FRToSI2C::I2C_RegisterWrite(MMA8652FC_I2C_ADDRESS,i2c_registers[index].reg, i2c_registers[index].val);
- index++;
-
- HAL_Delay(2); // ~1ms delay
-
- while (index < (sizeof(i2c_registers) / sizeof(i2c_registers[0]))) {
- FRToSI2C::I2C_RegisterWrite(MMA8652FC_I2C_ADDRESS,i2c_registers[index].reg, i2c_registers[index].val);
- index++;
- }
-}
-
-Orientation MMA8652FC::getOrientation() {
- //First read the PL_STATUS register
- uint8_t plStatus = FRToSI2C::I2C_RegisterRead(MMA8652FC_I2C_ADDRESS,PL_STATUS_REG);
- if ((plStatus & 0b10000000) == 0b10000000) {
- plStatus >>= 1; //We don't need the up/down bit
- plStatus &= 0x03; //mask to the two lower bits
-
- //0 == left handed
- //1 == right handed
-
- return static_cast<Orientation>(plStatus);
- }
-
- return ORIENTATION_FLAT;
-}
-
-void MMA8652FC::getAxisReadings(int16_t& x, int16_t& y, int16_t& z) {
- std::array<int16_t, 3> sensorData;
-
- FRToSI2C::Mem_Read(MMA8652FC_I2C_ADDRESS, OUT_X_MSB_REG, I2C_MEMADD_SIZE_8BIT,
- reinterpret_cast<uint8_t*>(sensorData.begin()),
- sensorData.size() * sizeof(int16_t));
-
- x = static_cast<int16_t>(__builtin_bswap16(*reinterpret_cast<uint16_t*>(&sensorData[0])));
- y = static_cast<int16_t>(__builtin_bswap16(*reinterpret_cast<uint16_t*>(&sensorData[1])));
- z = static_cast<int16_t>(__builtin_bswap16(*reinterpret_cast<uint16_t*>(&sensorData[2])));
-}
+/*
+ * MMA8652FC.cpp
+ *
+ * Created on: 31Aug.,2017
+ * Author: Ben V. Brown
+ */
+
+#include <array>
+
+#include "MMA8652FC.hpp"
+#include "cmsis_os.h"
+
+typedef struct {
+ const uint8_t reg;
+ const uint8_t val;
+} MMA_REG;
+
+static const MMA_REG i2c_registers[] = { { CTRL_REG2, 0 }, //Normal mode
+ { CTRL_REG2, 0x40 }, // Reset all registers to POR values
+ { FF_MT_CFG_REG, 0x78 }, // Enable motion detection for X, Y, Z axis, latch disabled
+ { PL_CFG_REG, 0x40 }, //Enable the orientation detection
+ { PL_COUNT_REG, 200 }, //200 count debounce
+ { PL_BF_ZCOMP_REG, 0b01000111 }, //Set the threshold to 42 degrees
+ { P_L_THS_REG, 0b10011100 }, //Up the trip angles
+ { CTRL_REG4, 0x01 | (1 << 4) }, // Enable dataready interrupt & orientation interrupt
+ { CTRL_REG5, 0x01 }, // Route data ready interrupts to INT1 ->PB5 ->EXTI5, leaving orientation routed to INT2
+ { CTRL_REG2, 0x12 }, //Set maximum resolution oversampling
+ { XYZ_DATA_CFG_REG, (1 << 4) }, //select high pass filtered data
+ { HP_FILTER_CUTOFF_REG, 0x03 }, //select high pass filtered data
+ { CTRL_REG1, 0x19 } // ODR=12 Hz, Active mode
+};
+
+void MMA8652FC::initalize() {
+ size_t index = 0;
+
+ //send all the init commands to the unit
+
+ FRToSI2C::I2C_RegisterWrite(MMA8652FC_I2C_ADDRESS, i2c_registers[index].reg,
+ i2c_registers[index].val);
+ index++;
+ FRToSI2C::I2C_RegisterWrite(MMA8652FC_I2C_ADDRESS, i2c_registers[index].reg,
+ i2c_registers[index].val);
+ index++;
+
+ delay_ms(2); // ~1ms delay
+
+ while (index < (sizeof(i2c_registers) / sizeof(i2c_registers[0]))) {
+ FRToSI2C::I2C_RegisterWrite(MMA8652FC_I2C_ADDRESS,
+ i2c_registers[index].reg, i2c_registers[index].val);
+ index++;
+ }
+}
+
+Orientation MMA8652FC::getOrientation() {
+ //First read the PL_STATUS register
+ uint8_t plStatus = FRToSI2C::I2C_RegisterRead(MMA8652FC_I2C_ADDRESS,
+ PL_STATUS_REG);
+ if ((plStatus & 0b10000000) == 0b10000000) {
+ plStatus >>= 1; //We don't need the up/down bit
+ plStatus &= 0x03; //mask to the two lower bits
+
+ //0 == left handed
+ //1 == right handed
+
+ return static_cast<Orientation>(plStatus);
+ }
+
+ return ORIENTATION_FLAT;
+}
+
+void MMA8652FC::getAxisReadings(int16_t &x, int16_t &y, int16_t &z) {
+ std::array<int16_t, 3> sensorData;
+
+ FRToSI2C::Mem_Read(MMA8652FC_I2C_ADDRESS, OUT_X_MSB_REG,
+ reinterpret_cast<uint8_t*>(sensorData.begin()),
+ sensorData.size() * sizeof(int16_t));
+
+ x = static_cast<int16_t>(__builtin_bswap16(
+ *reinterpret_cast<uint16_t*>(&sensorData[0])));
+ y = static_cast<int16_t>(__builtin_bswap16(
+ *reinterpret_cast<uint16_t*>(&sensorData[1])));
+ z = static_cast<int16_t>(__builtin_bswap16(
+ *reinterpret_cast<uint16_t*>(&sensorData[2])));
+}
+
+bool MMA8652FC::detect() {
+ return FRToSI2C::probe(MMA8652FC_I2C_ADDRESS);
+}
diff --git a/workspace/TS100/Core/Drivers/MMA8652FC.hpp b/workspace/TS100/Core/Drivers/MMA8652FC.hpp
new file mode 100644
index 00000000..ec160ab5
--- /dev/null
+++ b/workspace/TS100/Core/Drivers/MMA8652FC.hpp
@@ -0,0 +1,27 @@
+/*
+ * MMA8652FC.h
+ *
+ * Created on: 31Aug.,2017
+ * Author: Ben V. Brown
+ */
+
+#ifndef MMA8652FC_HPP_
+#define MMA8652FC_HPP_
+#include "MMA8652FC_defines.h"
+#include "I2C_Wrapper.hpp"
+#include "BSP.h"
+
+class MMA8652FC {
+
+public:
+ //Returns true if this accelerometer is detected
+ static bool detect();
+ //Init any internal state
+ static void initalize();
+ static Orientation getOrientation(); // Reads the I2C register and returns the orientation (true == left)
+ static void getAxisReadings(int16_t &x, int16_t &y, int16_t &z);
+
+private:
+};
+
+#endif /* MMA8652FC_HPP_ */
diff --git a/workspace/TS100/Core/Inc/MMA8652FC_defines.h b/workspace/TS100/Core/Drivers/MMA8652FC_defines.h
index af4ef38c..d3526c02 100644
--- a/workspace/TS100/Core/Inc/MMA8652FC_defines.h
+++ b/workspace/TS100/Core/Drivers/MMA8652FC_defines.h
@@ -1,124 +1,124 @@
-/*
- * MMA8652FC_defines.h
- *
- * Created on: 31Aug.,2017
- * Author: Ben V. Brown
- */
-
-#ifndef MMA8652FC_DEFINES_H_
-#define MMA8652FC_DEFINES_H_
-
-//--------------MMA8652 Registers-------------------------------------------//
-
-#define STATUS_REG 0x00 // STATUS Register
-
-#define OUT_X_MSB_REG 0x01 // [7:0] are 8 MSBs of the 14-bit X-axis sample
-#define OUT_X_LSB_REG 0x02 // [7:2] are the 6 LSB of 14-bit X-axis sample
-#define OUT_Y_MSB_REG 0x03 // [7:0] are 8 MSBs of the 14-bit Y-axis sample
-#define OUT_Y_LSB_REG 0x04 // [7:2] are the 6 LSB of 14-bit Y-axis sample
-#define OUT_Z_MSB_REG 0x05 // [7:0] are 8 MSBs of the 14-bit Z-axis sample
-#define OUT_Z_LSB_REG 0x06 // [7:2] are the 6 LSB of 14-bit Z-axis sample
-
-#define F_SETUP_REG 0x09 // F_SETUP FIFO Setup Register
-#define TRIG_CFG_REG 0x0A // TRIG_CFG Map of FIFO data capture events
-#define SYSMOD_REG 0x0B // SYSMOD System Mode Register
-#define INT_SOURCE_REG 0x0C // INT_SOURCE System Interrupt Status Register
-#define WHO_AM_I_REG 0x0D // WHO_AM_I Device ID Register
-#define XYZ_DATA_CFG_REG 0x0E // XYZ_DATA_CFG Sensor Data Configuration Register
-#define HP_FILTER_CUTOFF_REG 0x0F // HP_FILTER_CUTOFF High Pass Filter Register
-
-#define PL_STATUS_REG 0x10 // PL_STATUS Portrait/Landscape Status Register
-#define PL_CFG_REG 0x11 // PL_CFG Portrait/Landscape Configuration Register
-#define PL_COUNT_REG 0x12 // PL_COUNT Portrait/Landscape Debounce Register
-#define PL_BF_ZCOMP_REG 0x13 // PL_BF_ZCOMP Back/Front and Z Compensation Register
-#define P_L_THS_REG 0x14 // P_L_THS Portrait to Landscape Threshold Register
-
-#define FF_MT_CFG_REG 0x15 // FF_MT_CFG Freefall and Motion Configuration Register
-#define FF_MT_SRC_REG 0x16 // FF_MT_SRC Freefall and Motion Source Register
-#define FF_MT_THS_REG 0x17 // FF_MT_THS Freefall and Motion Threshold Register
-#define FF_MT_COUNT_REG 0x18 // FF_MT_COUNT Freefall Motion Count Register
-
-#define TRANSIENT_CFG_REG 0x1D // TRANSIENT_CFG Transient Configuration Register
-#define TRANSIENT_SRC_REG 0x1E // TRANSIENT_SRC Transient Source Register
-#define TRANSIENT_THS_REG 0x1F // TRANSIENT_THS Transient Threshold Register
-#define TRANSIENT_COUNT_REG 0x20 // TRANSIENT_COUNT Transient Debounce Counter Register
-
-#define PULSE_CFG_REG 0x21 // PULSE_CFG Pulse Configuration Register
-#define PULSE_SRC_REG 0x22 // PULSE_SRC Pulse Source Register
-#define PULSE_THSX_REG 0x23 // PULSE_THS XYZ Pulse Threshold Registers
-#define PULSE_THSY_REG 0x24
-#define PULSE_THSZ_REG 0x25
-#define PULSE_TMLT_REG 0x26 // PULSE_TMLT Pulse Time Window Register
-#define PULSE_LTCY_REG 0x27 // PULSE_LTCY Pulse Latency Timer Register
-#define PULSE_WIND_REG 0x28 // PULSE_WIND Second Pulse Time Window Register
-
-#define ASLP_COUNT_REG 0x29 // ASLP_COUNT Auto Sleep Inactivity Timer Register
-
-#define CTRL_REG1 0x2A // CTRL_REG1 System Control 1 Register
-#define CTRL_REG2 0x2B // CTRL_REG2 System Control 2 Register
-#define CTRL_REG3 0x2C // CTRL_REG3 Interrupt Control Register
-#define CTRL_REG4 0x2D // CTRL_REG4 Interrupt Enable Register
-#define CTRL_REG5 0x2E // CTRL_REG5 Interrupt Configuration Register
-
-#define OFF_X_REG 0x2F // XYZ Offset Correction Registers
-#define OFF_Y_REG 0x30
-#define OFF_Z_REG 0x31
-
-//MMA8652FC 7-bit I2C address
-
-#define MMA8652FC_I2C_ADDRESS (0x1D<<1)
-
-//MMA8652FC Sensitivity
-
-#define SENSITIVITY_2G 1024
-#define SENSITIVITY_4G 512
-#define SENSITIVITY_8G 256
-
-#define STATUS_REG 0x00
-#define X_MSB_REG 0X01
-#define X_LSB_REG 0X02
-#define Y_MSB_REG 0X03
-#define Y_LSB_REG 0X04
-#define Z_MSB_REG 0X05
-#define Z_LSB_REG 0X06
-
-#define TRIG_CFG 0X0A
-#define SYSMOD 0X0B
-#define INT_SOURCE 0X0C
-#define DEVICE_ID 0X0D
-
-//-----STATUS_REG(0X00)-----Bit Define----------------------------------------//
-#define ZYXDR_BIT 0X08
-//----XYZ_DATA_CFG_REG(0xE)-Bit Define----------------------------------------//
-#define FS_MASK 0x03
-#define FULL_SCALE_2G 0x00 //2g=0x0,4g=0x1,8g=0x2
-#define FULL_SCALE_4G 0x01
-#define FULL_SCALE_8G 0x02
-//---------CTRL_REG1(0X2A)Bit Define------------------------------------------//
-#define ACTIVE_MASK 1<<0 //bit0
-#define DR_MASK 0x38 //bit D5,D4,D3
-#define FHZ800 0x0 //800hz
-#define FHZ400 0x1 //400hz
-#define FHZ200 0x2 //200hz
-#define FHZ100 0x3 //100hz
-#define FHZ50 0x4 //50hz
-#define FHZ2 0x5 //12.5hz
-#define FHZ1 0x6 //6.25hz
-#define FHZ0 0x7 //1.563hz
-
-//---------CTRL_REG2(0X2B)Bit Define------------------------------------------//
-#define MODS_MASK 0x03 //Oversampling Mode 4
-#define Normal_Mode 0x0 //Normal=0,Low Noise Low Power MODS=1,
-//HI RESOLUTION=2,LOW POWER MODS = 11
-//----CTRL_REG4---Interrupt Enable BIT ---------------------------------------//
-//0 interrupt is disabled (default)
-//1 interrupt is enabled
-#define INT_EN_ASLP 1<<7 //Auto-SLEEP/WAKE Interrupt Enable
-#define INT_EN_FIFO 1<<6 //FIFO Interrupt Enable
-#define INT_EN_TRANS 1<<5 //Transient Interrupt Enable
-#define INT_EN_LNDPRT 1<<4 //Orientation(Landscape/Portrait)Interrupt Enable
-#define INT_EN_PULSE 1<<3 //Pulse Detection Interrupt Enable
-#define INT_EN_FF_MT 1<<2 //Freefall/Motion Interrupt Enable
-#define INT_EN_DRDY 1<<0 //Data Ready Interrupt Enable
-
-#endif /* MMA8652FC_DEFINES_H_ */
+/*
+ * MMA8652FC_defines.h
+ *
+ * Created on: 31Aug.,2017
+ * Author: Ben V. Brown
+ */
+
+#ifndef MMA8652FC_DEFINES_H_
+#define MMA8652FC_DEFINES_H_
+
+//--------------MMA8652 Registers-------------------------------------------//
+
+#define STATUS_REG 0x00 // STATUS Register
+
+#define OUT_X_MSB_REG 0x01 // [7:0] are 8 MSBs of the 14-bit X-axis sample
+#define OUT_X_LSB_REG 0x02 // [7:2] are the 6 LSB of 14-bit X-axis sample
+#define OUT_Y_MSB_REG 0x03 // [7:0] are 8 MSBs of the 14-bit Y-axis sample
+#define OUT_Y_LSB_REG 0x04 // [7:2] are the 6 LSB of 14-bit Y-axis sample
+#define OUT_Z_MSB_REG 0x05 // [7:0] are 8 MSBs of the 14-bit Z-axis sample
+#define OUT_Z_LSB_REG 0x06 // [7:2] are the 6 LSB of 14-bit Z-axis sample
+
+#define F_SETUP_REG 0x09 // F_SETUP FIFO Setup Register
+#define TRIG_CFG_REG 0x0A // TRIG_CFG Map of FIFO data capture events
+#define SYSMOD_REG 0x0B // SYSMOD System Mode Register
+#define INT_SOURCE_REG 0x0C // INT_SOURCE System Interrupt Status Register
+#define WHO_AM_I_REG 0x0D // WHO_AM_I Device ID Register
+#define XYZ_DATA_CFG_REG 0x0E // XYZ_DATA_CFG Sensor Data Configuration Register
+#define HP_FILTER_CUTOFF_REG 0x0F // HP_FILTER_CUTOFF High Pass Filter Register
+
+#define PL_STATUS_REG 0x10 // PL_STATUS Portrait/Landscape Status Register
+#define PL_CFG_REG 0x11 // PL_CFG Portrait/Landscape Configuration Register
+#define PL_COUNT_REG 0x12 // PL_COUNT Portrait/Landscape Debounce Register
+#define PL_BF_ZCOMP_REG 0x13 // PL_BF_ZCOMP Back/Front and Z Compensation Register
+#define P_L_THS_REG 0x14 // P_L_THS Portrait to Landscape Threshold Register
+
+#define FF_MT_CFG_REG 0x15 // FF_MT_CFG Freefall and Motion Configuration Register
+#define FF_MT_SRC_REG 0x16 // FF_MT_SRC Freefall and Motion Source Register
+#define FF_MT_THS_REG 0x17 // FF_MT_THS Freefall and Motion Threshold Register
+#define FF_MT_COUNT_REG 0x18 // FF_MT_COUNT Freefall Motion Count Register
+
+#define TRANSIENT_CFG_REG 0x1D // TRANSIENT_CFG Transient Configuration Register
+#define TRANSIENT_SRC_REG 0x1E // TRANSIENT_SRC Transient Source Register
+#define TRANSIENT_THS_REG 0x1F // TRANSIENT_THS Transient Threshold Register
+#define TRANSIENT_COUNT_REG 0x20 // TRANSIENT_COUNT Transient Debounce Counter Register
+
+#define PULSE_CFG_REG 0x21 // PULSE_CFG Pulse Configuration Register
+#define PULSE_SRC_REG 0x22 // PULSE_SRC Pulse Source Register
+#define PULSE_THSX_REG 0x23 // PULSE_THS XYZ Pulse Threshold Registers
+#define PULSE_THSY_REG 0x24
+#define PULSE_THSZ_REG 0x25
+#define PULSE_TMLT_REG 0x26 // PULSE_TMLT Pulse Time Window Register
+#define PULSE_LTCY_REG 0x27 // PULSE_LTCY Pulse Latency Timer Register
+#define PULSE_WIND_REG 0x28 // PULSE_WIND Second Pulse Time Window Register
+
+#define ASLP_COUNT_REG 0x29 // ASLP_COUNT Auto Sleep Inactivity Timer Register
+
+#define CTRL_REG1 0x2A // CTRL_REG1 System Control 1 Register
+#define CTRL_REG2 0x2B // CTRL_REG2 System Control 2 Register
+#define CTRL_REG3 0x2C // CTRL_REG3 Interrupt Control Register
+#define CTRL_REG4 0x2D // CTRL_REG4 Interrupt Enable Register
+#define CTRL_REG5 0x2E // CTRL_REG5 Interrupt Configuration Register
+
+#define OFF_X_REG 0x2F // XYZ Offset Correction Registers
+#define OFF_Y_REG 0x30
+#define OFF_Z_REG 0x31
+
+//MMA8652FC 7-bit I2C address
+
+#define MMA8652FC_I2C_ADDRESS (0x1D<<1)
+
+//MMA8652FC Sensitivity
+
+#define SENSITIVITY_2G 1024
+#define SENSITIVITY_4G 512
+#define SENSITIVITY_8G 256
+
+#define STATUS_REG 0x00
+#define X_MSB_REG 0X01
+#define X_LSB_REG 0X02
+#define Y_MSB_REG 0X03
+#define Y_LSB_REG 0X04
+#define Z_MSB_REG 0X05
+#define Z_LSB_REG 0X06
+
+#define TRIG_CFG 0X0A
+#define SYSMOD 0X0B
+#define INT_SOURCE 0X0C
+#define DEVICE_ID 0X0D
+
+//-----STATUS_REG(0X00)-----Bit Define----------------------------------------//
+#define ZYXDR_BIT 0X08
+//----XYZ_DATA_CFG_REG(0xE)-Bit Define----------------------------------------//
+#define FS_MASK 0x03
+#define FULL_SCALE_2G 0x00 //2g=0x0,4g=0x1,8g=0x2
+#define FULL_SCALE_4G 0x01
+#define FULL_SCALE_8G 0x02
+//---------CTRL_REG1(0X2A)Bit Define------------------------------------------//
+#define ACTIVE_MASK 1<<0 //bit0
+#define DR_MASK 0x38 //bit D5,D4,D3
+#define FHZ800 0x0 //800hz
+#define FHZ400 0x1 //400hz
+#define FHZ200 0x2 //200hz
+#define FHZ100 0x3 //100hz
+#define FHZ50 0x4 //50hz
+#define FHZ2 0x5 //12.5hz
+#define FHZ1 0x6 //6.25hz
+#define FHZ0 0x7 //1.563hz
+
+//---------CTRL_REG2(0X2B)Bit Define------------------------------------------//
+#define MODS_MASK 0x03 //Oversampling Mode 4
+#define Normal_Mode 0x0 //Normal=0,Low Noise Low Power MODS=1,
+//HI RESOLUTION=2,LOW POWER MODS = 11
+//----CTRL_REG4---Interrupt Enable BIT ---------------------------------------//
+//0 interrupt is disabled (default)
+//1 interrupt is enabled
+#define INT_EN_ASLP 1<<7 //Auto-SLEEP/WAKE Interrupt Enable
+#define INT_EN_FIFO 1<<6 //FIFO Interrupt Enable
+#define INT_EN_TRANS 1<<5 //Transient Interrupt Enable
+#define INT_EN_LNDPRT 1<<4 //Orientation(Landscape/Portrait)Interrupt Enable
+#define INT_EN_PULSE 1<<3 //Pulse Detection Interrupt Enable
+#define INT_EN_FF_MT 1<<2 //Freefall/Motion Interrupt Enable
+#define INT_EN_DRDY 1<<0 //Data Ready Interrupt Enable
+
+#endif /* MMA8652FC_DEFINES_H_ */
diff --git a/workspace/TS100/Core/Src/OLED.cpp b/workspace/TS100/Core/Drivers/OLED.cpp
index 3949b17a..fc9867eb 100644
--- a/workspace/TS100/Core/Src/OLED.cpp
+++ b/workspace/TS100/Core/Drivers/OLED.cpp
@@ -63,7 +63,6 @@ uint8_t OLED_Setup_Array[] = {
const uint8_t REFRESH_COMMANDS[17] = { 0x80, 0xAF, 0x80, 0x21, 0x80, 0x20, 0x80,
0x7F, 0x80, 0xC0, 0x80, 0x22, 0x80, 0x00, 0x80, 0x01, 0x40 };
-
/*
* Animation timing function that follows a bezier curve.
* @param t A given percentage value [0..<100]
@@ -95,10 +94,6 @@ void OLED::initialize() {
displayOffset = 0;
memcpy(&screenBuffer[0], &REFRESH_COMMANDS[0], sizeof(REFRESH_COMMANDS));
- HAL_Delay(50);
- HAL_GPIO_WritePin(OLED_RESET_GPIO_Port, OLED_RESET_Pin, GPIO_PIN_SET);
- HAL_Delay(50);
-
// Set the display to be ON once the settings block is sent and send the
// initialisation data to the OLED.
@@ -148,10 +143,10 @@ void OLED::drawScrollIndicator(uint8_t y, uint8_t height) {
uint16_t whole;
uint8_t strips[2];
} column;
-
+
column.whole = (1 << height) - 1;
column.whole <<= y;
-
+
// Draw a one pixel wide bar to the left with a single pixel as
// the scroll indicator.
fillArea(OLED_WIDTH - 1, 0, 1, 8, column.strips[0]);
@@ -195,11 +190,14 @@ void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) {
offset = progress;
- memmove(&firstStripPtr[oldStart], &firstStripPtr[oldPrevious], OLED_WIDTH - progress);
- memmove(&secondStripPtr[oldStart], &secondStripPtr[oldPrevious], OLED_WIDTH - progress);
+ memmove(&firstStripPtr[oldStart], &firstStripPtr[oldPrevious],
+ OLED_WIDTH - progress);
+ memmove(&secondStripPtr[oldStart], &secondStripPtr[oldPrevious],
+ OLED_WIDTH - progress);
memmove(&firstStripPtr[newStart], &firstBackStripPtr[newEnd], progress);
- memmove(&secondStripPtr[newStart], &secondBackStripPtr[newEnd], progress);
+ memmove(&secondStripPtr[newStart], &secondBackStripPtr[newEnd],
+ progress);
refresh();
osDelay(40);
@@ -275,7 +273,7 @@ uint8_t OLED::getFont() {
inline void stripLeaderZeros(char *buffer, uint8_t places) {
//Removing the leading zero's by swapping them to SymbolSpace
// Stop 1 short so that we dont blank entire number if its zero
- for (int i = 0; i < (places-1); i++) {
+ for (int i = 0; i < (places - 1); i++) {
if (buffer[i] == 2) {
buffer[i] = SymbolSpace[0];
} else {
diff --git a/workspace/TS100/Core/Inc/OLED.hpp b/workspace/TS100/Core/Drivers/OLED.hpp
index 5994e9f6..5e3238a7 100644
--- a/workspace/TS100/Core/Inc/OLED.hpp
+++ b/workspace/TS100/Core/Drivers/OLED.hpp
@@ -9,11 +9,10 @@
#ifndef OLED_HPP_
#define OLED_HPP_
-#include <hardware.h>
-#include "stm32f1xx_hal.h"
+#include <BSP.h>
#include <stdbool.h>
#include <string.h>
-#include "FRToSI2C.hpp"
+#include "I2C_Wrapper.hpp"
#include "Font.h"
#ifdef __cplusplus
extern "C" {
@@ -27,12 +26,11 @@ extern "C" {
#define OLED_HEIGHT 16
#define FRAMEBUFFER_START 17
-class OLED {
+class OLED {
public:
enum DisplayState : bool {
- OFF = false,
- ON = true
+ OFF = false, ON = true
};
static void initialize(); // Startup the I2C coms (brings screen out of reset etc)
@@ -40,7 +38,7 @@ public:
// Draw the buffer out to the LCD using the DMA Channel
static void refresh() {
FRToSI2C::Transmit( DEVICEADDR_OLED, screenBuffer,
- FRAMEBUFFER_START + (OLED_WIDTH * 2));
+ FRAMEBUFFER_START + (OLED_WIDTH * 2));
//DMA tx time is ~ 20mS Ensure after calling this you delay for at least 25ms
//or we need to goto double buffering
}
@@ -49,16 +47,16 @@ public:
displayState = state;
screenBuffer[1] = (state == ON) ? 0xAF : 0xAE;
}
-
+
static void setRotation(bool leftHanded); // Set the rotation for the screen
// Get the current rotation of the LCD
- static bool getRotation() {
+ static bool getRotation() {
return inLeftHandedMode;
}
static int16_t getCursorX() {
return cursor_x;
}
- static void print(const char* string);// Draw a string to the current location, with current font
+ static void print(const char *string);// Draw a string to the current location, with current font
// Set the cursor location by pixels
static void setCursor(int16_t x, int16_t y) {
cursor_x = x;
@@ -71,11 +69,12 @@ public:
}
static void setFont(uint8_t fontNumber); // (Future) Set the font that is being used
static uint8_t getFont();
- static void drawImage(const uint8_t* buffer, uint8_t x, uint8_t width) {
+ static void drawImage(const uint8_t *buffer, uint8_t x, uint8_t width) {
drawArea(x, 0, width, 16, buffer);
}
// Draws an image to the buffer, at x offset from top to bottom (fixed height renders)
- static void printNumber(uint16_t number, uint8_t places,bool noLeaderZeros=true);
+ static void printNumber(uint16_t number, uint8_t places,
+ bool noLeaderZeros = true);
// Draws a number at the current cursor location
// Clears the buffer
static void clearScreen() {
@@ -92,9 +91,9 @@ public:
static void debugNumber(int32_t val);
static void drawSymbol(uint8_t symbolID);//Used for drawing symbols of a predictable width
static void drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height,
- const uint8_t* ptr); //Draw an area, but y must be aligned on 0/8 offset
- static void drawAreaSwapped(int16_t x, int8_t y, uint8_t wide, uint8_t height,
- const uint8_t* ptr); //Draw an area, but y must be aligned on 0/8 offset
+ const uint8_t *ptr); //Draw an area, but y must be aligned on 0/8 offset
+ static void drawAreaSwapped(int16_t x, int8_t y, uint8_t wide,
+ uint8_t height, const uint8_t *ptr); //Draw an area, but y must be aligned on 0/8 offset
static void fillArea(int16_t x, int8_t y, uint8_t wide, uint8_t height,
const uint8_t value); //Fill an area, but y must be aligned on 0/8 offset
static void drawFilledRect(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
@@ -106,9 +105,9 @@ public:
private:
static void drawChar(char c); // Draw a character to a specific location
static void setFramebuffer(uint8_t *buffer);
- static const uint8_t* currentFont;// Pointer to the current font used for rendering to the buffer
- static uint8_t* firstStripPtr; // Pointers to the strips to allow for buffer having extra content
- static uint8_t* secondStripPtr; //Pointers to the strips
+ static const uint8_t *currentFont; // Pointer to the current font used for rendering to the buffer
+ static uint8_t *firstStripPtr; // Pointers to the strips to allow for buffer having extra content
+ static uint8_t *secondStripPtr; //Pointers to the strips
static bool inLeftHandedMode; // Whether the screen is in left or not (used for offsets in GRAM)
static DisplayState displayState;
static uint8_t fontWidth, fontHeight;
diff --git a/workspace/TS100/Core/Drivers/README.md b/workspace/TS100/Core/Drivers/README.md
new file mode 100644
index 00000000..9b5ebf91
--- /dev/null
+++ b/workspace/TS100/Core/Drivers/README.md
@@ -0,0 +1,10 @@
+# Drivers
+
+Drivers are the classes used to represent physical hardware on the board in a more abstract way, that are more complex than just an IO
+
+* OLED Display
+* Accelerometers
+* Button handling logic
+* Tip thermo response modelling
+
+All drivers should be written with minimal hardware assumptions, and defer hardware related logic to the BSP folder where possible \ No newline at end of file
diff --git a/workspace/TS100/Core/Src/TipThermoModel.cpp b/workspace/TS100/Core/Drivers/TipThermoModel.cpp
index e35b2915..ac1c9389 100644
--- a/workspace/TS100/Core/Src/TipThermoModel.cpp
+++ b/workspace/TS100/Core/Drivers/TipThermoModel.cpp
@@ -7,7 +7,7 @@
#include "TipThermoModel.h"
#include "Settings.h"
-#include "hardware.h"
+#include "BSP.h"
#include "../../configuration.h"
/*
diff --git a/workspace/TS100/Core/Src/TipThermoModel.h b/workspace/TS100/Core/Drivers/TipThermoModel.h
index 6c31f6bd..a4b0b368 100644
--- a/workspace/TS100/Core/Src/TipThermoModel.h
+++ b/workspace/TS100/Core/Drivers/TipThermoModel.h
@@ -8,7 +8,7 @@
#ifndef SRC_TIPTHERMOMODEL_H_
#define SRC_TIPTHERMOMODEL_H_
#include "stdint.h"
-#include "hardware.h"
+#include "BSP.h"
#include "unit.h"
class TipThermoModel {
public:
diff --git a/workspace/TS100/Core/Inc/FreeRTOSHooks.h b/workspace/TS100/Core/Inc/FreeRTOSHooks.h
new file mode 100644
index 00000000..8dca47e6
--- /dev/null
+++ b/workspace/TS100/Core/Inc/FreeRTOSHooks.h
@@ -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_ */
diff --git a/workspace/TS100/Core/Inc/MMA8652FC.hpp b/workspace/TS100/Core/Inc/MMA8652FC.hpp
deleted file mode 100644
index b6d2938e..00000000
--- a/workspace/TS100/Core/Inc/MMA8652FC.hpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * MMA8652FC.h
- *
- * Created on: 31Aug.,2017
- * Author: Ben V. Brown
- */
-
-#ifndef MMA8652FC_HPP_
-#define MMA8652FC_HPP_
-#include "stm32f1xx_hal.h"
-#include "MMA8652FC_defines.h"
-#include "FRToSI2C.hpp"
-#include "hardware.h"
-
-class MMA8652FC {
-
-public:
-
-
- static void initalize(); // Initalize the system
- static Orientation getOrientation();// Reads the I2C register and returns the orientation (true == left)
- static void getAxisReadings(int16_t& x, int16_t& y, int16_t& z);
-
-private:
-};
-
-#endif /* MMA8652FC_HPP_ */
diff --git a/workspace/TS100/Core/Inc/QC3.h b/workspace/TS100/Core/Inc/QC3.h
new file mode 100644
index 00000000..0ddf1b0f
--- /dev/null
+++ b/workspace/TS100/Core/Inc/QC3.h
@@ -0,0 +1,21 @@
+/*
+ * QC3.h
+ *
+ * Created on: 29 May 2020
+ * Author: Ralim
+ */
+
+#ifndef INC_QC3_H_
+#define INC_QC3_H_
+#include "stdint.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_ */
diff --git a/workspace/TS100/Core/Inc/Settings.h b/workspace/TS100/Core/Inc/Settings.h
index cde51fc4..21d4b35d 100644
--- a/workspace/TS100/Core/Inc/Settings.h
+++ b/workspace/TS100/Core/Inc/Settings.h
@@ -42,7 +42,7 @@ typedef struct {
uint8_t temperatureInF :1; // Should the temp be in F or C (true is F)
#endif
uint8_t descriptionScrollSpeed :1; // Description scroll speed
- uint8_t KeepAwakePulse; // Keep Awake pulse power in 0.1 watts (10 = 1Watt)
+ uint8_t KeepAwakePulse; // Keep Awake pulse power in 0.1 watts (10 = 1Watt)
uint16_t voltageDiv; // Voltage divisor factor
uint16_t BoostTemp; // Boost mode set point for the iron
@@ -51,7 +51,7 @@ typedef struct {
uint8_t powerLimitEnable; // Allow toggling of power limit without changing value
uint8_t powerLimit; // Maximum power iron allowed to output
-
+
uint16_t TipGain; // uV/C * 10, it can be used to convert tip thermocouple voltage to temperateture TipV/TipGain = TipTemp
uint8_t ReverseButtonTempChangeEnabled; // Change the plus and minus button assigment
@@ -70,5 +70,5 @@ void saveSettings();
bool restoreSettings();
uint8_t lookupVoltageLevel(uint8_t level);
void resetSettings();
-bool showBootLogoIfavailable();
+
#endif /* SETTINGS_H_ */
diff --git a/workspace/TS100/Core/Inc/Translation.h b/workspace/TS100/Core/Inc/Translation.h
index e918ae8a..614ea12f 100644
--- a/workspace/TS100/Core/Inc/Translation.h
+++ b/workspace/TS100/Core/Inc/Translation.h
@@ -7,8 +7,8 @@
#ifndef TRANSLATION_H_
#define TRANSLATION_H_
-#include "stm32f1xx_hal.h"
#include "unit.h"
+#include "stdint.h"
enum ShortNameType {
SHORT_NAME_SINGLE_LINE = 1, SHORT_NAME_DOUBLE_LINE = 2,
};
diff --git a/workspace/TS100/Core/Inc/gui.hpp b/workspace/TS100/Core/Inc/gui.hpp
index d79b71dd..f05d59fb 100644
--- a/workspace/TS100/Core/Inc/gui.hpp
+++ b/workspace/TS100/Core/Inc/gui.hpp
@@ -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_ */
diff --git a/workspace/TS100/Core/Inc/main.hpp b/workspace/TS100/Core/Inc/main.hpp
index fb1809c7..37bc9816 100644
--- a/workspace/TS100/Core/Inc/main.hpp
+++ b/workspace/TS100/Core/Inc/main.hpp
@@ -1,31 +1,12 @@
#ifndef __MAIN_H
#define __MAIN_H
-#include <MMA8652FC.hpp>
#include "OLED.hpp"
#include "Setup.h"
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
@@ -40,6 +21,13 @@ void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c);
void vApplicationStackOverflowHook(xTaskHandle *pxTask,
signed portCHAR *pcTaskName);
+//Threads
+void startGUITask(void const *argument);
+void startPIDTask(void const *argument);
+void startMOVTask(void const *argument);
+extern TaskHandle_t pidTaskNotification;
+extern uint8_t accelInit;
+extern uint32_t lastMovementTime;
#ifdef __cplusplus
}
#endif
diff --git a/workspace/TS100/Core/Inc/power.hpp b/workspace/TS100/Core/Inc/power.hpp
index 9e86752b..c882a99a 100644
--- a/workspace/TS100/Core/Inc/power.hpp
+++ b/workspace/TS100/Core/Inc/power.hpp
@@ -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_
diff --git a/workspace/TS100/Core/Src/FRToSI2C.cpp b/workspace/TS100/Core/Src/FRToSI2C.cpp
deleted file mode 100644
index aabd6906..00000000
--- a/workspace/TS100/Core/Src/FRToSI2C.cpp
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * FRToSI2C.cpp
- *
- * Created on: 14Apr.,2018
- * Author: Ralim
- */
-#include "hardware.h"
-#include "FRToSI2C.hpp"
-#define I2CUSESDMA
-I2C_HandleTypeDef* FRToSI2C::i2c;
-SemaphoreHandle_t FRToSI2C::I2CSemaphore;
-StaticSemaphore_t FRToSI2C::xSemaphoreBuffer;
-
-void FRToSI2C::CpltCallback() {
- i2c->State = HAL_I2C_STATE_READY; // Force state reset (even if tx error)
- if (I2CSemaphore) {
- xSemaphoreGiveFromISR(I2CSemaphore, NULL);
- }
-}
-
-void FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
- uint16_t MemAddSize, uint8_t* pData, uint16_t Size) {
-
- if (I2CSemaphore == NULL) {
- // no RToS, run blocking code
- HAL_I2C_Mem_Read(i2c, DevAddress, MemAddress, MemAddSize, pData, Size,
- 5000);
- } else {
- // RToS is active, run threading
- // Get the mutex so we can use the I2C port
- // Wait up to 1 second for the mutex
- if (xSemaphoreTake(I2CSemaphore, (TickType_t)50) == pdTRUE) {
-#ifdef I2CUSESDMA
- if (HAL_I2C_Mem_Read(i2c, DevAddress, MemAddress, MemAddSize, pData,
- Size, 500) != HAL_OK) {
-
- I2C1_ClearBusyFlagErratum();
- xSemaphoreGive(I2CSemaphore);
- }
- xSemaphoreGive(I2CSemaphore);
-#else
-
- HAL_I2C_Mem_Read(i2c, DevAddress, MemAddress, MemAddSize, pData, Size,
- 5000);
- xSemaphoreGive(I2CSemaphore);
-#endif
- } else {
- }
- }
-
-}
-void FRToSI2C::I2C_RegisterWrite(uint8_t address, uint8_t reg, uint8_t data) {
- Mem_Write(address, reg, I2C_MEMADD_SIZE_8BIT, &data, 1);
-}
-
-uint8_t FRToSI2C::I2C_RegisterRead(uint8_t add, uint8_t reg) {
- uint8_t tx_data[1];
- Mem_Read(add, reg, I2C_MEMADD_SIZE_8BIT, tx_data, 1);
- return tx_data[0];
-}
-void FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
- uint16_t MemAddSize, uint8_t* pData, uint16_t Size) {
-
- if (I2CSemaphore == NULL) {
- // no RToS, run blocking code
- HAL_I2C_Mem_Write(i2c, DevAddress, MemAddress, MemAddSize, pData, Size,
- 5000);
- } else {
- // RToS is active, run threading
- // Get the mutex so we can use the I2C port
- // Wait up to 1 second for the mutex
- if (xSemaphoreTake(I2CSemaphore, (TickType_t)50) == pdTRUE) {
-#ifdef I2CUSESDMA
- if (HAL_I2C_Mem_Write(i2c, DevAddress, MemAddress, MemAddSize,
- pData, Size, 500) != HAL_OK) {
-
- I2C1_ClearBusyFlagErratum();
- xSemaphoreGive(I2CSemaphore);
- }
- xSemaphoreGive(I2CSemaphore);
-#else
- if (HAL_I2C_Mem_Write(i2c, DevAddress, MemAddress, MemAddSize, pData,
- Size, 5000) != HAL_OK) {
- }
- xSemaphoreGive(I2CSemaphore);
-#endif
- } else {
- }
- }
-
-}
-
-void FRToSI2C::Transmit(uint16_t DevAddress, uint8_t* pData, uint16_t Size) {
- if (I2CSemaphore == NULL) {
- // no RToS, run blocking code
- HAL_I2C_Master_Transmit(i2c, DevAddress, pData, Size, 5000);
- } else {
- // RToS is active, run threading
- // Get the mutex so we can use the I2C port
- // Wait up to 1 second for the mutex
- if (xSemaphoreTake(I2CSemaphore, (TickType_t)50) == pdTRUE) {
-#ifdef I2CUSESDMA
-
- if (HAL_I2C_Master_Transmit_DMA(i2c, DevAddress, pData, Size)
- != HAL_OK) {
-
- I2C1_ClearBusyFlagErratum();
- xSemaphoreGive(I2CSemaphore);
-
- }
-#else
- HAL_I2C_Master_Transmit(i2c, DevAddress, pData, Size, 5000);
- xSemaphoreGive(I2CSemaphore);
-#endif
-
- } else {
- }
- }
-
-}
-
-void FRToSI2C::I2C1_ClearBusyFlagErratum() {
- GPIO_InitTypeDef GPIO_InitStruct;
- int timeout = 100;
- int timeout_cnt = 0;
-
- // 1. Clear PE bit.
- i2c->Instance->CR1 &= ~(0x0001);
- /**I2C1 GPIO Configuration
- PB6 ------> I2C1_SCL
- PB7 ------> I2C1_SDA
- */
- // 2. Configure the SCL and SDA I/Os as General Purpose Output Open-Drain, High level (Write 1 to GPIOx_ODR).
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
- GPIO_InitStruct.Pull = GPIO_PULLUP;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-
- GPIO_InitStruct.Pin = SCL_Pin;
- HAL_GPIO_Init(SCL_GPIO_Port, &GPIO_InitStruct);
- HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_SET);
-
- GPIO_InitStruct.Pin = SDA_Pin;
- HAL_GPIO_Init(SDA_GPIO_Port, &GPIO_InitStruct);
- HAL_GPIO_WritePin(SDA_GPIO_Port, SDA_Pin, GPIO_PIN_SET);
-
- while (GPIO_PIN_SET != HAL_GPIO_ReadPin(SDA_GPIO_Port, SDA_Pin)) {
- //Move clock to release I2C
- HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_RESET);
- asm("nop");
- asm("nop");
- asm("nop");
- asm("nop");
- HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_SET);
-
- timeout_cnt++;
- if (timeout_cnt > timeout)
- return;
- }
-
- // 12. Configure the SCL and SDA I/Os as Alternate function Open-Drain.
- GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
- GPIO_InitStruct.Pull = GPIO_PULLUP;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-
- GPIO_InitStruct.Pin = SCL_Pin;
- HAL_GPIO_Init(SCL_GPIO_Port, &GPIO_InitStruct);
-
- GPIO_InitStruct.Pin = SDA_Pin;
- HAL_GPIO_Init(SDA_GPIO_Port, &GPIO_InitStruct);
-
- HAL_GPIO_WritePin(SCL_GPIO_Port, SCL_Pin, GPIO_PIN_SET);
- HAL_GPIO_WritePin(SDA_GPIO_Port, SDA_Pin, GPIO_PIN_SET);
-
- // 13. Set SWRST bit in I2Cx_CR1 register.
- i2c->Instance->CR1 |= 0x8000;
-
- asm("nop");
-
- // 14. Clear SWRST bit in I2Cx_CR1 register.
- i2c->Instance->CR1 &= ~0x8000;
-
- asm("nop");
-
- // 15. Enable the I2C peripheral by setting the PE bit in I2Cx_CR1 register
- i2c->Instance->CR1 |= 0x0001;
-
- // Call initialization function.
- HAL_I2C_Init(i2c);
-}
diff --git a/workspace/TS100/Core/Src/FreeRTOSHooks.c b/workspace/TS100/Core/Src/FreeRTOSHooks.c
new file mode 100644
index 00000000..1e9c3dc6
--- /dev/null
+++ b/workspace/TS100/Core/Src/FreeRTOSHooks.c
@@ -0,0 +1,32 @@
+/*
+ * FreeRTOSHooks.c
+ *
+ * Created on: 29 May 2020
+ * Author: Ralim
+ */
+
+#include "FreeRTOSHooks.h"
+#include "BSP.h"
+void vApplicationIdleHook(void) {
+ resetWatchdog();
+}
+
+/* USER CODE BEGIN GET_IDLE_TASK_MEMORY */
+static StaticTask_t xIdleTaskTCBBuffer;
+static StackType_t xIdleStack[configMINIMAL_STACK_SIZE];
+
+void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,
+ StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize) {
+ *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer;
+ *ppxIdleTaskStackBuffer = &xIdleStack[0];
+ *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
+ /* place for user code */
+}
+
+void vApplicationStackOverflowHook(xTaskHandle *pxTask,
+ signed portCHAR *pcTaskName) {
+ (void) pxTask;
+ (void) pcTaskName;
+// We dont have a good way to handle a stack overflow at this point in time
+ reboot();
+}
diff --git a/workspace/TS100/Core/Src/GUIThread.cpp b/workspace/TS100/Core/Src/GUIThread.cpp
deleted file mode 100644
index 28e0f88b..00000000
--- a/workspace/TS100/Core/Src/GUIThread.cpp
+++ /dev/null
@@ -1,915 +0,0 @@
-/*
- * GUIThread.cpp
- *
- * Created on: 19 Aug 2019
- * Author: ralim
- */
-#include <MMA8652FC.hpp>
-#include <gui.hpp>
-#include <main.hpp>
-#include "LIS2DH12.hpp"
-#include <history.hpp>
-#include <power.hpp>
-#include "Settings.h"
-#include "Translation.h"
-#include "cmsis_os.h"
-#include "stdlib.h"
-#include "stm32f1xx_hal.h"
-#include "string.h"
-#include "TipThermoModel.h"
-#include "unit.h"
-#include "../../configuration.h"
-
-extern uint8_t PCBVersion;
-// File local variables
-extern uint32_t currentTempTargetDegC;
-extern uint8_t accelInit;
-extern uint32_t lastMovementTime;
-extern int16_t idealQCVoltage;
-uint32_t lastButtonTime = 0;
-extern osThreadId GUITaskHandle;
-extern osThreadId MOVTaskHandle;
-extern osThreadId PIDTaskHandle;
-
-// TODO: express time constants in terms of dividends of portTICK_RATE_MS
-
-#define MOVEMENT_INACTIVITY_TIME 6000
-#define BUTTON_INACTIVITY_TIME 6000
-
-static uint16_t min(uint16_t a, uint16_t b) {
- if (a > b)
- return b;
- else
- return a;
-}
-
-void printVoltage() {
- uint32_t volt = getInputVoltageX10(systemSettings.voltageDiv, 0);
- OLED::printNumber(volt / 10, 2);
- OLED::print(SymbolDot);
- OLED::printNumber(volt % 10, 1);
-}
-void GUIDelay() {
- // Called in all UI looping tasks,
- // This limits the re-draw rate to the LCD and also lets the DMA run
- // As the gui task can very easily fill this bus with transactions, which will
- // prevent the movement detection from running
- osDelay(50);
-}
-void gui_drawTipTemp(bool symbol) {
- // Draw tip temp handling unit conversion & tolerance near setpoint
- uint16_t Temp = 0;
- #ifdef ENABLED_FAHRENHEIT_SUPPORT
- if (systemSettings.temperatureInF)
- Temp = TipThermoModel::getTipInF();
- else
- #endif
- Temp = TipThermoModel::getTipInC();
-
- OLED::printNumber(Temp, 3); // Draw the tip temp out finally
- if (symbol) {
- if (OLED::getFont() == 0) {
- //Big font, can draw nice symbols
- #ifdef ENABLED_FAHRENHEIT_SUPPORT
- if (systemSettings.temperatureInF)
- OLED::drawSymbol(0);
- else
- #endif
- OLED::drawSymbol(1);
- } else {
- //Otherwise fall back to chars
- #ifdef ENABLED_FAHRENHEIT_SUPPORT
- if (systemSettings.temperatureInF)
- OLED::print(SymbolDegF);
- else
- #endif
- OLED::print(SymbolDegC);
- }
- }
-}
-ButtonState getButtonState() {
- /*
- * Read in the buttons and then determine if a state change needs to occur
- */
-
- /*
- * If the previous state was 00 Then we want to latch the new state if
- * different & update time
- * If the previous state was !00 Then we want to search if we trigger long
- * press (buttons still down), or if release we trigger press
- * (downtime>filter)
- */
- static uint8_t previousState = 0;
- static uint32_t previousStateChange = 0;
- const uint16_t timeout = 40;
- uint8_t currentState;
- currentState = (
- HAL_GPIO_ReadPin(KEY_A_GPIO_Port, KEY_A_Pin) == GPIO_PIN_RESET ?
- 1 : 0) << 0;
- currentState |= (
- HAL_GPIO_ReadPin(KEY_B_GPIO_Port, KEY_B_Pin) == GPIO_PIN_RESET ?
- 1 : 0) << 1;
-
- if (currentState)
- lastButtonTime = xTaskGetTickCount();
- if (currentState == previousState) {
- if (currentState == 0)
- return BUTTON_NONE;
- if ((xTaskGetTickCount() - previousStateChange) > timeout) {
- // User has been holding the button down
- // We want to send a buttong is held message
- if (currentState == 0x01)
- return BUTTON_F_LONG;
- else if (currentState == 0x02)
- return BUTTON_B_LONG;
- else
- return BUTTON_NONE; // Both being held case, we dont long hold this
- } else
- return BUTTON_NONE;
- } else {
- // A change in button state has occurred
- ButtonState retVal = BUTTON_NONE;
- if (currentState) {
- // User has pressed a button down (nothing done on down)
- if (currentState != previousState) {
- // There has been a change in the button states
- // If there is a rising edge on one of the buttons from double press we
- // want to mask that out As users are having issues with not release
- // both at once
- if (previousState == 0x03)
- currentState = 0x03;
- }
- } else {
- // User has released buttons
- // If they previously had the buttons down we want to check if they were <
- // long hold and trigger a press
- if ((xTaskGetTickCount() - previousStateChange) < timeout) {
- // The user didn't hold the button for long
- // So we send button press
-
- if (previousState == 0x01)
- retVal = BUTTON_F_SHORT;
- else if (previousState == 0x02)
- retVal = BUTTON_B_SHORT;
- else
- retVal = BUTTON_BOTH; // Both being held case
- }
- }
- previousState = currentState;
- previousStateChange = xTaskGetTickCount();
- return retVal;
- }
- return BUTTON_NONE;
-}
-
-void waitForButtonPress() {
- // we are just lazy and sleep until user confirms button press
- // This also eats the button press event!
- ButtonState buttons = getButtonState();
- while (buttons) {
- buttons = getButtonState();
- GUIDelay();
- }
- while (!buttons) {
- buttons = getButtonState();
- GUIDelay();
- }
-}
-
-void waitForButtonPressOrTimeout(uint32_t timeout) {
- timeout += xTaskGetTickCount();
- // calculate the exit point
-
- ButtonState buttons = getButtonState();
- while (buttons) {
- buttons = getButtonState();
- GUIDelay();
- if (xTaskGetTickCount() > timeout)
- return;
- }
- while (!buttons) {
- buttons = getButtonState();
- GUIDelay();
- if (xTaskGetTickCount() > timeout)
- return;
- }
-}
-#ifdef MODEL_TS100
-// returns true if undervoltage has occured
-static bool checkVoltageForExit() {
- uint16_t v = getInputVoltageX10(systemSettings.voltageDiv, 0);
-
- //Dont check for first 1.5 seconds while the ADC stabilizes and the DMA fills the buffer
- if (xTaskGetTickCount() > 150) {
- if ((v < lookupVoltageLevel(systemSettings.cutoutSetting))) {
- GUIDelay();
- OLED::clearScreen();
- OLED::setCursor(0, 0);
- if (systemSettings.detailedSoldering) {
- OLED::setFont(1);
- OLED::print(UndervoltageString);
- OLED::setCursor(0, 8);
- OLED::print(InputVoltageString);
- printVoltage();
- OLED::print(SymbolVolts);
-
- } else {
- OLED::setFont(0);
- OLED::print(UVLOWarningString);
- }
-
- OLED::refresh();
- currentTempTargetDegC = 0;
- waitForButtonPress();
- return true;
- }
- }
- return false;
-}
-#endif
-static void gui_drawBatteryIcon() {
-#ifdef MODEL_TS100
- if (systemSettings.cutoutSetting) {
- // User is on a lithium battery
- // we need to calculate which of the 10 levels they are on
- uint8_t cellCount = systemSettings.cutoutSetting + 2;
- uint32_t cellV = getInputVoltageX10(systemSettings.voltageDiv, 0)
- / cellCount;
- // Should give us approx cell voltage X10
- // Range is 42 -> 33 = 9 steps therefore we will use battery 1-10
- if (cellV < 33)
- cellV = 33;
- cellV -= 33; // Should leave us a number of 0-9
- if (cellV > 9)
- cellV = 9;
- OLED::drawBattery(cellV + 1);
- } else
- OLED::drawSymbol(15); // Draw the DC Logo
-#else
- // On TS80 we replace this symbol with the voltage we are operating on
- // If <9V then show single digit, if not show duals
- uint8_t V = getInputVoltageX10(systemSettings.voltageDiv, 0);
- if (V % 10 >= 5)
- V = V / 10 + 1; // round up
- else
- V = V / 10;
- if (V >= 10) {
- int16_t xPos = OLED::getCursorX();
- OLED::setFont(1);
- OLED::printNumber(1, 1);
- OLED::setCursor(xPos, 8);
- OLED::printNumber(V % 10, 1);
- OLED::setFont(0);
- OLED::setCursor(xPos + 12, 0); // need to reset this as if we drew a wide char
- } else {
- OLED::printNumber(V, 1);
- }
-#endif
-}
-static void gui_solderingTempAdjust() {
- uint32_t lastChange = xTaskGetTickCount();
- currentTempTargetDegC = 0;
- uint32_t autoRepeatTimer = 0;
- uint8_t autoRepeatAcceleration = 0;
- for (;;) {
- OLED::setCursor(0, 0);
- OLED::clearScreen();
- OLED::setFont(0);
- ButtonState buttons = getButtonState();
- if (buttons)
- lastChange = xTaskGetTickCount();
- switch (buttons) {
- case BUTTON_NONE:
- // stay
- break;
- case BUTTON_BOTH:
- // exit
- return;
- break;
-case BUTTON_B_LONG:
- if (xTaskGetTickCount() - autoRepeatTimer
- + autoRepeatAcceleration> PRESS_ACCEL_INTERVAL_MAX) {
- if(systemSettings.ReverseButtonTempChangeEnabled) {
- systemSettings.SolderingTemp += systemSettings.TempChangeLongStep;
- } else systemSettings.SolderingTemp -= systemSettings.TempChangeLongStep;
-
- autoRepeatTimer = xTaskGetTickCount();
- autoRepeatAcceleration += PRESS_ACCEL_STEP;
- }
- break;
- case BUTTON_B_SHORT:
- if(systemSettings.ReverseButtonTempChangeEnabled) {
- systemSettings.SolderingTemp += systemSettings.TempChangeShortStep;
- } else systemSettings.SolderingTemp -= systemSettings.TempChangeShortStep;
- break;
- case BUTTON_F_LONG:
- if (xTaskGetTickCount() - autoRepeatTimer
- + autoRepeatAcceleration> PRESS_ACCEL_INTERVAL_MAX) {
- if(systemSettings.ReverseButtonTempChangeEnabled) {
- systemSettings.SolderingTemp -= systemSettings.TempChangeLongStep;
- } else systemSettings.SolderingTemp += systemSettings.TempChangeLongStep;
- autoRepeatTimer = xTaskGetTickCount();
- autoRepeatAcceleration += PRESS_ACCEL_STEP;
- }
- break;
- case BUTTON_F_SHORT:
- if(systemSettings.ReverseButtonTempChangeEnabled) {
- systemSettings.SolderingTemp -= systemSettings.TempChangeShortStep; // add 10
- } else systemSettings.SolderingTemp += systemSettings.TempChangeShortStep; // add 10
- break;
- default:
- break;
- }
- if ((PRESS_ACCEL_INTERVAL_MAX - autoRepeatAcceleration)
- < PRESS_ACCEL_INTERVAL_MIN) {
- autoRepeatAcceleration = PRESS_ACCEL_INTERVAL_MAX
- - PRESS_ACCEL_INTERVAL_MIN;
- }
- // constrain between 10-450 C
- #ifdef ENABLED_FAHRENHEIT_SUPPORT
- if (systemSettings.temperatureInF) {
- if (systemSettings.SolderingTemp > 850)
- systemSettings.SolderingTemp = 850;
- if (systemSettings.SolderingTemp < 60)
- systemSettings.SolderingTemp = 60;
- }
- else
- #endif
- {
- if (systemSettings.SolderingTemp > 450)
- systemSettings.SolderingTemp = 450;
- if (systemSettings.SolderingTemp < 10)
- systemSettings.SolderingTemp = 10;
- }
-
- if (xTaskGetTickCount() - lastChange > 200)
- return; // exit if user just doesn't press anything for a bit
-
-#ifdef MODEL_TS80
- if (!OLED::getRotation()) {
-#else
- if (OLED::getRotation()) {
-#endif
- OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolPlus:SymbolMinus);
- } else {
- OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolMinus:SymbolPlus);
- }
-
-
- OLED::print(SymbolSpace);
- OLED::printNumber(systemSettings.SolderingTemp, 3);
- #ifdef ENABLED_FAHRENHEIT_SUPPORT
- if (systemSettings.temperatureInF)
- OLED::drawSymbol(0);
- else
- #endif
- {
- OLED::drawSymbol(1);
- }
- OLED::print(SymbolSpace);
-#ifdef MODEL_TS80
- if (!OLED::getRotation()) {
-#else
- if (OLED::getRotation()) {
-#endif
- OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolMinus:SymbolPlus);
- } else {
- OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolPlus:SymbolMinus);
- }
- OLED::refresh();
- GUIDelay();
- }
-}
-
-static int gui_SolderingSleepingMode(bool stayOff) {
- // Drop to sleep temperature and display until movement or button press
-
- for (;;) {
- ButtonState buttons = getButtonState();
- if (buttons)
- return 0;
- if ((xTaskGetTickCount() > 100)
- && ((accelInit && (xTaskGetTickCount() - lastMovementTime < 100))
- || (xTaskGetTickCount() - lastButtonTime < 100)))
- return 0; // user moved or pressed a button, go back to soldering
-#ifdef MODEL_TS100
- if (checkVoltageForExit())
- return 1; // return non-zero on error
-#endif
-#ifdef ENABLED_FAHRENHEIT_SUPPORT
- if (systemSettings.temperatureInF) {
- currentTempTargetDegC = stayOff ? 0 : TipThermoModel::convertFtoC(
- min(systemSettings.SleepTemp,
- systemSettings.SolderingTemp));
- } else
-#endif
- {
- currentTempTargetDegC = stayOff ? 0 : min(systemSettings.SleepTemp,
- systemSettings.SolderingTemp);
- }
- // draw the lcd
- uint16_t tipTemp;
-#ifdef ENABLED_FAHRENHEIT_SUPPORT
- if (systemSettings.temperatureInF)
- tipTemp = TipThermoModel::getTipInF();
- else
-#endif
- {
- tipTemp = TipThermoModel::getTipInC();
- }
-
- OLED::clearScreen();
- OLED::setCursor(0, 0);
- if (systemSettings.detailedSoldering) {
- OLED::setFont(1);
- OLED::print(SleepingAdvancedString);
- OLED::setCursor(0, 8);
- OLED::print(SleepingTipAdvancedString);
- OLED::printNumber(tipTemp, 3);
-#ifdef ENABLED_FAHRENHEIT_SUPPORT
- if (systemSettings.temperatureInF)
- OLED::print(SymbolDegF);
- else
-#endif
- {
- OLED::print(SymbolDegC);
- }
-
- OLED::print(SymbolSpace);
- printVoltage();
- OLED::print(SymbolVolts);
- } else {
- OLED::setFont(0);
- OLED::print(SleepingSimpleString);
- OLED::printNumber(tipTemp, 3);
-#ifdef ENABLED_FAHRENHEIT_SUPPORT
- if (systemSettings.temperatureInF)
- OLED::drawSymbol(0);
- else
-#endif
- {
- OLED::drawSymbol(1);
- }
- }
- if (systemSettings.ShutdownTime) // only allow shutdown exit if time > 0
- if (lastMovementTime)
- if (((uint32_t) (xTaskGetTickCount() - lastMovementTime))
- > (uint32_t) (systemSettings.ShutdownTime * 60 * 100)) {
- // shutdown
- currentTempTargetDegC = 0;
- return 1; // we want to exit soldering mode
- }
- OLED::refresh();
- GUIDelay();
- }
- return 0;
-}
-
-static void display_countdown(int sleepThres) {
- /*
- * Print seconds or minutes (if > 99 seconds) until sleep
- * mode is triggered.
- */
- int lastEventTime =
- lastButtonTime < lastMovementTime ?
- lastMovementTime : lastButtonTime;
- int downCount = sleepThres - xTaskGetTickCount() + lastEventTime;
- if (downCount > 9900) {
- OLED::printNumber(downCount / 6000 + 1, 2);
- OLED::print(SymbolMinutes);
- } else {
- OLED::printNumber(downCount / 100 + 1, 2);
- OLED::print(SymbolSeconds);
- }
-}
-
-static void gui_solderingMode(uint8_t jumpToSleep) {
- /*
- * * Soldering (gui_solderingMode)
- * -> Main loop where we draw temp, and animations
- * --> User presses buttons and they goto the temperature adjust screen
- * ---> Display the current setpoint temperature
- * ---> Use buttons to change forward and back on temperature
- * ---> Both buttons or timeout for exiting
- * --> Long hold front button to enter boost mode
- * ---> Just temporarily sets the system into the alternate temperature for
- * PID control
- * --> Long hold back button to exit
- * --> Double button to exit
- */
- bool boostModeOn = false;
-
- uint32_t sleepThres = 0;
- if (systemSettings.SleepTime < 6)
- sleepThres = systemSettings.SleepTime * 10 * 100;
- else
- sleepThres = (systemSettings.SleepTime - 5) * 60 * 100;
- if (jumpToSleep) {
- if (gui_SolderingSleepingMode(jumpToSleep == 2)) {
- lastButtonTime = xTaskGetTickCount();
- return; // If the function returns non-0 then exit
- }
- }
- for (;;) {
-
- ButtonState buttons = getButtonState();
- switch (buttons) {
- case BUTTON_NONE:
- // stay
- boostModeOn = false;
- break;
- case BUTTON_BOTH:
- // exit
- return;
- break;
- case BUTTON_B_LONG:
- return; // exit on back long hold
- break;
- case BUTTON_F_LONG:
- // if boost mode is enabled turn it on
- if (systemSettings.boostModeEnabled)
- boostModeOn = true;
- break;
- case BUTTON_F_SHORT:
- case BUTTON_B_SHORT: {
- uint16_t oldTemp = systemSettings.SolderingTemp;
- gui_solderingTempAdjust(); // goto adjust temp mode
- if (oldTemp != systemSettings.SolderingTemp) {
- saveSettings(); // only save on change
- }
- }
- break;
- default:
- break;
- }
- // else we update the screen information
- OLED::setCursor(0, 0);
- OLED::clearScreen();
- OLED::setFont(0);
- //Draw in the screen details
- if (systemSettings.detailedSoldering) {
- OLED::setFont(1);
- OLED::print(SolderingAdvancedPowerPrompt); // Power:
- OLED::printNumber(x10WattHistory.average() / 10, 2);
- OLED::print(SymbolDot);
- OLED::printNumber(x10WattHistory.average() % 10, 1);
- OLED::print(SymbolWatts);
-
- if (systemSettings.sensitivity && systemSettings.SleepTime) {
- OLED::print(SymbolSpace);
- display_countdown(sleepThres);
- }
-
- OLED::setCursor(0, 8);
- OLED::print(SleepingTipAdvancedString);
- //OLED::printNumber(
- // TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0)), 5); // Draw the tip temp out finally
-
- gui_drawTipTemp(true);
- OLED::print(SymbolSpace);
- printVoltage();
- OLED::print(SymbolVolts);
- } else {
- // We switch the layout direction depending on the orientation of the
- // OLED::
- if (OLED::getRotation()) {
- // battery
- gui_drawBatteryIcon();
- OLED::print(SymbolSpace); // Space out gap between battery <-> temp
- gui_drawTipTemp(true); // Draw current tip temp
-
- // We draw boost arrow if boosting, or else gap temp <-> heat
- // indicator
- if (boostModeOn)
- OLED::drawSymbol(2);
- else
- OLED::print(SymbolSpace);
-
- // Draw heating/cooling symbols
- OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory.average()));
- } else {
- // Draw heating/cooling symbols
- OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory.average()));
- // We draw boost arrow if boosting, or else gap temp <-> heat
- // indicator
- if (boostModeOn)
- OLED::drawSymbol(2);
- else
- OLED::print(SymbolSpace);
- gui_drawTipTemp(true); // Draw current tip temp
-
- OLED::print(SymbolSpace); // Space out gap between battery <-> temp
-
- gui_drawBatteryIcon();
- }
- }
- OLED::refresh();
-
- // Update the setpoints for the temperature
- if (boostModeOn) {
-#ifdef ENABLED_FAHRENHEIT_SUPPORT
- if (systemSettings.temperatureInF)
- currentTempTargetDegC = TipThermoModel::convertFtoC(
- systemSettings.BoostTemp);
- else
-#endif
- {
- currentTempTargetDegC = (systemSettings.BoostTemp);
- }
- } else {
-#ifdef ENABLED_FAHRENHEIT_SUPPORT
- if (systemSettings.temperatureInF)
- currentTempTargetDegC = TipThermoModel::convertFtoC(
- systemSettings.SolderingTemp);
- else
-#endif
- {
- currentTempTargetDegC = (systemSettings.SolderingTemp);
- }
- }
-
-#ifdef MODEL_TS100
- // Undervoltage test
- if (checkVoltageForExit()) {
- lastButtonTime = xTaskGetTickCount();
- return;
- }
-#else
- // on the TS80 we only want to check for over voltage to prevent tip damage
- /*if (getInputVoltageX10(systemSettings.voltageDiv, 1) > 150) {
- lastButtonTime = xTaskGetTickCount();
- currentlyActiveTemperatureTarget = 0;
- return; // Over voltage
- }*/
-#endif
-
- if (systemSettings.sensitivity && systemSettings.SleepTime)
- if (xTaskGetTickCount() - lastMovementTime > sleepThres
- && xTaskGetTickCount() - lastButtonTime > sleepThres) {
- if (gui_SolderingSleepingMode(false)) {
- return; // If the function returns non-0 then exit
- }
- }
- //slow down ui update rate
- GUIDelay();
- }
-}
-
-void showDebugMenu(void) {
- uint8_t screen = 0;
- ButtonState b;
- for (;;) {
- OLED::clearScreen(); // Ensure the buffer starts clean
- OLED::setCursor(0, 0); // Position the cursor at the 0,0 (top left)
- OLED::setFont(1); // small font
- OLED::print(SymbolVersionNumber); // Print version number
- OLED::setCursor(0, 8); // second line
- OLED::print(DebugMenu[screen]);
- switch (screen) {
- case 0: //Just prints date
- break;
- case 1:
- //High water mark for GUI
- OLED::printNumber(uxTaskGetStackHighWaterMark(GUITaskHandle), 5);
- break;
- case 2:
- //High water mark for the Movement task
- OLED::printNumber(uxTaskGetStackHighWaterMark(MOVTaskHandle), 5);
- break;
- case 3:
- //High water mark for the PID task
- OLED::printNumber(uxTaskGetStackHighWaterMark(PIDTaskHandle), 5);
- break;
- case 4:
- //system up time stamp
- OLED::printNumber(xTaskGetTickCount() / 100, 5);
- break;
- case 5:
- //Movement time stamp
- OLED::printNumber(lastMovementTime / 100, 5);
- break;
- case 6:
- //Raw Tip
- {
- uint32_t temp = systemSettings.CalibrationOffset;
- systemSettings.CalibrationOffset = 0;
- OLED::printNumber(
- TipThermoModel::convertTipRawADCTouV(getTipRawTemp(1)), 6);
- systemSettings.CalibrationOffset = temp;
- }
- break;
- case 7:
- //Temp in C
- OLED::printNumber(TipThermoModel::getTipInC(1), 5);
- break;
- case 8:
- //Handle Temp
- OLED::printNumber(getHandleTemperature(), 3);
- break;
- case 9:
- //Voltage input
- printVoltage();
- break;
- case 10:
- // Print PCB ID number
- OLED::printNumber(PCBVersion, 1);
- break;
- default:
- break;
- }
-
- OLED::refresh();
- b = getButtonState();
- if (b == BUTTON_B_SHORT)
- return;
- else if (b == BUTTON_F_SHORT) {
- screen++;
- screen = screen % 11;
- }
- GUIDelay();
- }
-}
-
-/* StartGUITask function */
-void startGUITask(void const *argument __unused) {
- FRToSI2C::FRToSInit();
- uint8_t tempWarningState = 0;
- bool buttonLockout = false;
- bool tempOnDisplay = false;
- getTipRawTemp(1); // reset filter
- OLED::setRotation(systemSettings.OrientationMode & 1);
- uint32_t ticks = xTaskGetTickCount();
- ticks += 400; // 4 seconds from now
- while (xTaskGetTickCount() < ticks) {
- if (showBootLogoIfavailable() == false)
- ticks = xTaskGetTickCount();
- ButtonState buttons = getButtonState();
- if (buttons)
- ticks = xTaskGetTickCount(); // make timeout now so we will exit
- GUIDelay();
- }
-
- if (settingsWereReset) {
- //Display alert settings were reset
- OLED::clearScreen();
- OLED::setFont(1);
- OLED::setCursor(0, 0);
- OLED::print(SettingsResetMessage);
- OLED::refresh();
- waitForButtonPressOrTimeout(1000);
-
- }
-
- if (systemSettings.autoStartMode) {
- // jump directly to the autostart mode
- if (systemSettings.autoStartMode == 1)
- {
- gui_solderingMode(0);
- buttonLockout = true;
- }
- else if (systemSettings.autoStartMode == 2)
- {
- gui_solderingMode(1);
- buttonLockout = true;
- }
- else if (systemSettings.autoStartMode == 3)
- {
- gui_solderingMode(2);
- buttonLockout = true;
- }
- }
-
-#ifdef ACCELDEBUG
-
- for (;;) {
- HAL_IWDG_Refresh(&hiwdg);
- osDelay(100);
- }
-//^ Kept here for a way to block this thread
-#endif
-
- for (;;) {
- ButtonState buttons = getButtonState();
- if (buttons != BUTTON_NONE) {
- OLED::setDisplayState(OLED::DisplayState::ON);
- OLED::setFont(0);
- }
- if (tempWarningState == 2)
- buttons = BUTTON_F_SHORT;
- if (buttons != BUTTON_NONE && buttonLockout)
- buttons = BUTTON_NONE;
- else
- buttonLockout = false;
-
- switch (buttons) {
- case BUTTON_NONE:
- // Do nothing
- break;
- case BUTTON_BOTH:
- // Not used yet
- // In multi-language this might be used to reset language on a long hold
- // or some such
- break;
-
- case BUTTON_B_LONG:
- // Show the version information
- showDebugMenu();
- break;
- case BUTTON_F_LONG:
- gui_solderingTempAdjust();
- saveSettings();
- break;
- case BUTTON_F_SHORT:
- gui_solderingMode(0); // enter soldering mode
- buttonLockout = true;
- break;
- case BUTTON_B_SHORT:
- enterSettingsMenu(); // enter the settings menu
- buttonLockout = true;
- break;
- default:
- break;
- }
-
- currentTempTargetDegC = 0; // ensure tip is off
- getInputVoltageX10(systemSettings.voltageDiv, 0);
- uint16_t tipTemp = TipThermoModel::getTipInC();
-
- // Preemptively turn the display on. Turn it off if and only if
- // the tip temperature is below 50 degrees C *and* motion sleep
- // detection is enabled *and* there has been no activity (movement or
- // button presses) in a while.
- OLED::setDisplayState(OLED::DisplayState::ON);
-
- if ((tipTemp < 50) && systemSettings.sensitivity
- && (((xTaskGetTickCount() - lastMovementTime)
- > MOVEMENT_INACTIVITY_TIME)
- && ((xTaskGetTickCount() - lastButtonTime)
- > BUTTON_INACTIVITY_TIME))) {
- OLED::setDisplayState(OLED::DisplayState::OFF);
- }
-
- // Clear the lcd buffer
- OLED::clearScreen();
- OLED::setCursor(0, 0);
- if (systemSettings.detailedIDLE) {
- OLED::setFont(1);
- if (tipTemp > 470) {
- OLED::print(TipDisconnectedString);
- } else {
- OLED::print(IdleTipString);
- gui_drawTipTemp(false);
- OLED::print(IdleSetString);
- OLED::printNumber(systemSettings.SolderingTemp, 3);
- }
- OLED::setCursor(0, 8);
-
- OLED::print(InputVoltageString);
- printVoltage();
-
- } else {
- OLED::setFont(0);
-#ifdef MODEL_TS80
- if (!OLED::getRotation()) {
-#else
- if (OLED::getRotation()) {
-#endif
- OLED::drawArea(12, 0, 84, 16, idleScreenBG);
- OLED::setCursor(0, 0);
- gui_drawBatteryIcon();
- } else {
- OLED::drawArea(0, 0, 84, 16, idleScreenBGF); // Needs to be flipped so button ends up
- // on right side of screen
- OLED::setCursor(84, 0);
- gui_drawBatteryIcon();
- }
- if (tipTemp > 55)
- tempOnDisplay = true;
- else if (tipTemp < 45)
- tempOnDisplay = false;
- if (tempOnDisplay) {
- // draw temp over the start soldering button
- // Location changes on screen rotation
-#ifdef MODEL_TS80
- if (!OLED::getRotation()) {
-#else
- if (OLED::getRotation()) {
-#endif
- // in right handed mode we want to draw over the first part
- OLED::fillArea(55, 0, 41, 16, 0); // clear the area for the temp
- OLED::setCursor(56, 0);
-
- } else {
- OLED::fillArea(0, 0, 41, 16, 0); // clear the area
- OLED::setCursor(0, 0);
- }
- // draw in the temp
- if (!(systemSettings.coolingTempBlink
- && (xTaskGetTickCount() % 25 < 16)))
- gui_drawTipTemp(false); // draw in the temp
- }
- }
- OLED::refresh();
- GUIDelay();
- }
-}
diff --git a/workspace/TS100/Core/Src/LIS2DH12.cpp b/workspace/TS100/Core/Src/LIS2DH12.cpp
deleted file mode 100644
index b1d25703..00000000
--- a/workspace/TS100/Core/Src/LIS2DH12.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * LIS2DH12.cpp
- *
- * Created on: 27Feb.,2018
- * Author: Ralim
- */
-
-#include <array>
-
-#include "LIS2DH12.hpp"
-#include "cmsis_os.h"
-
-typedef struct {
- const uint8_t reg;
- const uint8_t value;
-} LIS_REG;
-
-static const LIS_REG i2c_registers[] = {
- {LIS_CTRL_REG1, 0x17}, // 25Hz
- {LIS_CTRL_REG2, 0b00001000}, // Highpass filter off
- {LIS_CTRL_REG3, 0b01100000}, // Setup interrupt pins
- {LIS_CTRL_REG4, 0b00001000}, // Block update mode off, HR on
- {LIS_CTRL_REG5, 0b00000010},
- {LIS_CTRL_REG6, 0b01100010},
- //Basically setup the unit to run, and enable 4D orientation detection
- {LIS_INT2_CFG, 0b01111110}, //setup for movement detection
- {LIS_INT2_THS, 0x28},
- {LIS_INT2_DURATION, 64},
- {LIS_INT1_CFG, 0b01111110},
- {LIS_INT1_THS, 0x28},
- {LIS_INT1_DURATION, 64}
-};
-
-void LIS2DH12::initalize() {
- for (size_t index = 0; index < (sizeof(i2c_registers) / sizeof(i2c_registers[0])); index++) {
- FRToSI2C::I2C_RegisterWrite(LIS2DH_I2C_ADDRESS,i2c_registers[index].reg, i2c_registers[index].value);
- }
-}
-
-void LIS2DH12::getAxisReadings(int16_t& x, int16_t& y, int16_t& z) {
- std::array<int16_t, 3> sensorData;
-
- FRToSI2C::Mem_Read(LIS2DH_I2C_ADDRESS, 0xA8, I2C_MEMADD_SIZE_8BIT,
- reinterpret_cast<uint8_t*>(sensorData.begin()),
- sensorData.size() * sizeof(int16_t));
-
- x = sensorData[0];
- y = sensorData[1];
- z = sensorData[2];
-}
diff --git a/workspace/TS100/Core/Src/QC3.c b/workspace/TS100/Core/Src/QC3.c
new file mode 100644
index 00000000..43cff776
--- /dev/null
+++ b/workspace/TS100/Core/Src/QC3.c
@@ -0,0 +1,157 @@
+/*
+ * QC3.c
+ *
+ * Created on: 29 May 2020
+ * Author: Ralim
+ */
+
+// Quick charge 3.0 supporting functions
+#include "QC3.h"
+
+#include "BSP.h"
+#include "cmsis_os.h"
+#include "stdint.h"
+
+void QC_Seek9V() {
+ QC_DNegZero_Six();
+ QC_DPlusThree_Three();
+}
+void QC_Seek12V() {
+ QC_DNegZero_Six();
+ QC_DPlusZero_Six();
+}
+void QC_Seek20V() {
+ QC_DNegThree_Three();
+ QC_DPlusThree_Three();
+}
+void QC_SeekContMode() {
+ QC_DNegThree_Three();
+ QC_DPlusZero_Six();
+}
+void QC_SeekContPlus() {
+ QC_SeekContMode();
+ vTaskDelay(3);
+ QC_Seek20V();
+ vTaskDelay(1);
+ QC_SeekContMode();
+}
+void QC_SeekContNeg() {
+ QC_SeekContMode();
+ vTaskDelay(3);
+ QC_Seek12V();
+ vTaskDelay(1);
+ QC_SeekContMode();
+}
+uint8_t QCMode = 0;
+uint8_t QCTries = 0;
+void seekQC(int16_t Vx10, uint16_t divisor) {
+ if (QCMode == 5) startQC(divisor);
+ if (QCMode == 0) return; // NOT connected to a QC Charger
+
+ if (Vx10 < 45) return;
+ if (xTaskGetTickCount() < 100) return;
+ if (Vx10 > 130) Vx10 = 130; // Cap max value at 13V
+ // Seek the QC to the Voltage given if this adapter supports continuous mode
+ // try and step towards the wanted value
+
+ // 1. Measure current voltage
+ int16_t vStart = getInputVoltageX10(divisor, 1);
+ int difference = Vx10 - vStart;
+
+ // 2. calculate ideal steps (0.2V changes)
+
+ int steps = difference / 2;
+ if (QCMode == 3) {
+ if (steps > -2 && steps < 2) return; // dont bother with small steps
+ while (steps < 0) {
+ QC_SeekContNeg();
+ vTaskDelay(3);
+ steps++;
+ }
+ while (steps > 0) {
+ QC_SeekContPlus();
+ vTaskDelay(3);
+ steps--;
+ }
+ vTaskDelay(10);
+ }
+#ifdef ENABLE_QC2
+ // Re-measure
+ /* Disabled due to nothing to test and code space of around 1k*/
+ steps = vStart - getInputVoltageX10(divisor, 1);
+ if (steps < 0) steps = -steps;
+ if (steps > 4) {
+ // No continuous mode, so QC2
+ QCMode = 2;
+ // Goto nearest
+ if (Vx10 > 110) {
+ // request 12V
+ // D- = 0.6V, D+ = 0.6V
+ // Clamp PB3
+ QC_Seek12V();
+
+ } else {
+ // request 9V
+ QC_Seek9V();
+ }
+ }
+#endif
+}
+// Must be called after FreeRToS Starts
+void startQC(uint16_t divisor) {
+ // Pre check that the input could be >5V already, and if so, dont both
+ // negotiating as someone is feeding in hv
+ uint16_t vin = getInputVoltageX10(divisor, 1);
+ if (vin > 100) {
+ QCMode = 1; // Already at 12V, user has probably over-ridden this
+ return;
+ }
+ QC_Init_GPIO();
+
+ // Tries to negotiate QC for 9V
+ // This is a multiple step process.
+ // 1. Set around 0.6V on D+ for 1.25 Seconds or so
+ // 2. After this It should un-short D+->D- and instead add a 20k pulldown on
+ // D-
+ QC_DPlusZero_Six();
+
+ // Delay 1.25 seconds
+ uint8_t enteredQC = 0;
+ for (uint16_t i = 0; i < 200 && enteredQC == 0; i++) {
+ vTaskDelay(1); // 10mS pause
+ if (i > 130) {
+ if (QC_DM_PulledDown()) {
+ enteredQC = 1;
+ }
+ if (i == 140) {
+ // For some marginal QC chargers, we try adding a pulldown
+ QC_DM_PullDown();
+ }
+ }
+ }
+ QC_DM_No_PullDown();
+ if (enteredQC) {
+ // We have a QC capable charger
+ QC_Seek9V();
+ QC_Post_Probe_En();
+ QC_Seek9V();
+ // Wait for frontend ADC to stabilise
+ QCMode = 4;
+ for (uint8_t i = 0; i < 10; i++) {
+ if (getInputVoltageX10(divisor, 1) > 80) {
+ // yay we have at least QC2.0 or QC3.0
+ QCMode = 3; // We have at least QC2, pray for 3
+ return;
+ }
+ vTaskDelay(10); // 100mS
+ }
+ QCMode = 5;
+ QCTries++;
+ if (QCTries > 10) // 10 goes to get it going
+ QCMode = 0;
+ } else {
+ // no QC
+ QCMode = 0;
+ }
+ if (QCTries > 10) QCMode = 0;
+}
diff --git a/workspace/TS100/Core/Src/Settings.cpp b/workspace/TS100/Core/Src/Settings.cpp
index 70bb74eb..716d7c9c 100644
--- a/workspace/TS100/Core/Src/Settings.cpp
+++ b/workspace/TS100/Core/Src/Settings.cpp
@@ -11,6 +11,7 @@
#include "Settings.h"
#include "Setup.h"
#include "../../configuration.h"
+#include "BSP.h"
#define FLASH_ADDR \
(0x8000000 | \
0xFC00) /*Flash start OR'ed with the maximum amount of flash - 1024 bytes*/
@@ -19,39 +20,12 @@ volatile systemSettingsType systemSettings;
void saveSettings() {
// First we erase the flash
- FLASH_EraseInitTypeDef pEraseInit;
- pEraseInit.TypeErase = FLASH_TYPEERASE_PAGES;
- pEraseInit.Banks = FLASH_BANK_1;
- pEraseInit.NbPages = 1;
- pEraseInit.PageAddress = FLASH_ADDR;
- uint32_t failingAddress = 0;
- HAL_IWDG_Refresh(&hiwdg);
- __HAL_FLASH_CLEAR_FLAG(
- FLASH_FLAG_EOP | FLASH_FLAG_WRPERR | FLASH_FLAG_PGERR | FLASH_FLAG_BSY);
- HAL_FLASH_Unlock();
- HAL_Delay(10);
- HAL_IWDG_Refresh(&hiwdg);
- HAL_FLASHEx_Erase(&pEraseInit, &failingAddress);
- //^ Erase the page of flash (1024 bytes on this stm32)
- // erased the chunk
- // now we program it
- uint16_t *data = (uint16_t*) &systemSettings;
- HAL_FLASH_Unlock();
-
- for (uint8_t i = 0; i < (sizeof(systemSettingsType) / 2); i++) {
- HAL_IWDG_Refresh(&hiwdg);
- HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, FLASH_ADDR + (i * 2),
- data[i]);
- }
- HAL_FLASH_Lock();
+ flash_save_buffer((uint8_t*) &systemSettings, sizeof(systemSettingsType));
}
bool restoreSettings() {
// We read the flash
- uint16_t *data = (uint16_t*) &systemSettings;
- for (uint8_t i = 0; i < (sizeof(systemSettingsType) / 2); i++) {
- data[i] = *((uint16_t*) (FLASH_ADDR + (i * 2)));
- }
+ flash_read_buffer((uint8_t*) &systemSettings, sizeof(systemSettingsType));
// if the version is correct were done
// if not we reset and save
@@ -80,12 +54,12 @@ void resetSettings() {
memset((void*) &systemSettings, 0, sizeof(systemSettingsType));
systemSettings.SleepTemp = SLEEP_TEMP; // Temperature the iron sleeps at - default 150.0 C
systemSettings.SleepTime = SLEEP_TIME; // How many seconds/minutes we wait until going
- // to sleep - default 1 min
- systemSettings.SolderingTemp = SOLDERING_TEMP; // Default soldering temp is 320.0 C
+ // to sleep - default 1 min
+ systemSettings.SolderingTemp = SOLDERING_TEMP; // Default soldering temp is 320.0 C
systemSettings.cutoutSetting = CUT_OUT_SETTING; // default to no cut-off voltage (or 18W for TS80)
systemSettings.version =
SETTINGSVERSION; // Store the version number to allow for easier upgrades
- systemSettings.detailedSoldering = DETAILED_SOLDERING; // Detailed soldering screen
+ systemSettings.detailedSoldering = DETAILED_SOLDERING; // Detailed soldering screen
systemSettings.detailedIDLE = DETAILED_IDLE; // Detailed idle screen (off for first time users)
systemSettings.OrientationMode = ORIENTATION_MODE; // Default to automatic
systemSettings.sensitivity = SENSITIVITY; // Default high sensitivity
@@ -93,19 +67,19 @@ void resetSettings() {
systemSettings.ShutdownTime = SHUTDOWN_TIME; // How many minutes until the unit turns itself off
systemSettings.boostModeEnabled = BOOST_MODE_ENABLED; // Default to having boost mode on as most people prefer it
systemSettings.BoostTemp = BOOST_TEMP; // default to 400C
- systemSettings.autoStartMode = AUTO_START_MODE; // Auto start off for safety
+ systemSettings.autoStartMode = AUTO_START_MODE; // Auto start off for safety
systemSettings.coolingTempBlink = COOLING_TEMP_BLINK; // Blink the temperature on the cooling screen when its > 50C
#ifdef ENABLED_FAHRENHEIT_SUPPORT
systemSettings.temperatureInF = TEMPERATURE_INF; // default to 0
#endif
- systemSettings.descriptionScrollSpeed = DESCRIPTION_SCROLL_SPEED; // default to slow
+ systemSettings.descriptionScrollSpeed = DESCRIPTION_SCROLL_SPEED; // default to slow
systemSettings.powerLimitEnable = POWER_LIMIT_ENABLE; // Default to no power limit
- systemSettings.CalibrationOffset = CALIBRATION_OFFSET; // the adc offset in uV
+ systemSettings.CalibrationOffset = CALIBRATION_OFFSET; // the adc offset in uV
systemSettings.powerLimit = POWER_LIMIT; // 30 watts default limit
systemSettings.ReverseButtonTempChangeEnabled = REVERSE_BUTTON_TEMP_CHANGE; //
systemSettings.TempChangeShortStep = TEMP_CHANGE_SHORT_STEP; //
systemSettings.TempChangeLongStep = TEMP_CHANGE_LONG_STEP; //
- systemSettings.KeepAwakePulse= POWER_PULSE_DEFAULT;
+ systemSettings.KeepAwakePulse = POWER_PULSE_DEFAULT;
systemSettings.TipGain = TIP_GAIN;
saveSettings(); // Save defaults
}
diff --git a/workspace/TS100/Core/Src/gui.cpp b/workspace/TS100/Core/Src/gui.cpp
index ca4e92c1..2fe91a24 100644
--- a/workspace/TS100/Core/Src/gui.cpp
+++ b/workspace/TS100/Core/Src/gui.cpp
@@ -13,8 +13,8 @@
#include "string.h"
#include "unit.h"
#include "../../configuration.h"
+#include "Buttons.hpp"
-extern uint32_t lastButtonTime;
void gui_Menu(const menuitem *menu);
#ifdef MODEL_TS100
diff --git a/workspace/TS100/Core/Src/hardware.cpp b/workspace/TS100/Core/Src/hardware.cpp
deleted file mode 100644
index 7deb1380..00000000
--- a/workspace/TS100/Core/Src/hardware.cpp
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
- * hardware.c
- *
- * Created on: 2Sep.,2017
- * Author: Ben V. Brown
- */
-
-// These are all the functions for interacting with the hardware
-#include "hardware.h"
-#include "history.hpp"
-volatile uint16_t PWMSafetyTimer = 0;
-
-uint16_t getHandleTemperature() {
- // We return the current handle temperature in X10 C
- // TMP36 in handle, 0.5V offset and then 10mV per deg C (0.75V @ 25C for
- // example) STM32 = 4096 count @ 3.3V input -> But We oversample by 32/(2^2) =
- // 8 times oversampling Therefore 32768 is the 3.3V input, so 0.1007080078125
- // mV per count So we need to subtract an offset of 0.5V to center on 0C
- // (4964.8 counts)
- //
- int32_t result = getADC(0);
- result -= 4965; // remove 0.5V offset
- // 10mV per C
- // 99.29 counts per Deg C above 0C
- result *= 100;
- result /= 993;
- return result;
-}
-
-uint16_t getTipInstantTemperature() {
- uint16_t sum = 0; // 12 bit readings * 8 -> 15 bits
- uint16_t readings[8];
- //Looking to reject the highest outlier readings.
- //As on some hardware these samples can run into the op-amp recovery time
- //Once this time is up the signal stabilises quickly, so no need to reject minimums
- readings[0] = hadc1.Instance->JDR1;
- readings[1] = hadc1.Instance->JDR2;
- readings[2] = hadc1.Instance->JDR3;
- readings[3] = hadc1.Instance->JDR4;
- readings[4] = hadc2.Instance->JDR1;
- readings[5] = hadc2.Instance->JDR2;
- readings[6] = hadc2.Instance->JDR3;
- readings[7] = hadc2.Instance->JDR4;
-
- for (int i = 0; i < 8; i++) {
- sum += readings[i];
- }
- return sum; // 8x over sample
-}
-
-//2 second filter (ADC is PID_TIM_HZ Hz)
-history<uint16_t, PID_TIM_HZ> rawTempFilter = { { 0 }, 0, 0 };
-
-uint16_t getTipRawTemp(uint8_t refresh) {
- if (refresh) {
- uint16_t lastSample = getTipInstantTemperature();
- rawTempFilter.update(lastSample);
- return lastSample;
- } else {
- return rawTempFilter.average();
- }
-}
-
-uint16_t getInputVoltageX10(uint16_t divisor, uint8_t sample) {
- // ADC maximum is 32767 == 3.3V at input == 28.05V at VIN
- // Therefore we can divide down from there
- // Multiplying ADC max by 4 for additional calibration options,
- // ideal term is 467
-#ifdef MODEL_TS100
-#define BATTFILTERDEPTH 32
-#else
-#define BATTFILTERDEPTH 8
-
-#endif
- static uint8_t preFillneeded = 10;
- static uint32_t samples[BATTFILTERDEPTH];
- static uint8_t index = 0;
- if (preFillneeded) {
- for (uint8_t i = 0; i < BATTFILTERDEPTH; i++)
- samples[i] = getADC(1);
- preFillneeded--;
- }
- if (sample) {
- samples[index] = getADC(1);
- index = (index + 1) % BATTFILTERDEPTH;
- }
- uint32_t sum = 0;
-
- for (uint8_t i = 0; i < BATTFILTERDEPTH; i++)
- sum += samples[i];
-
- sum /= BATTFILTERDEPTH;
- return sum * 4 / divisor;
-}
-#ifdef MODEL_TS80
-void DPlusZero_Six() {
- HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET); // pull down D+
-}
-void DNegZero_Six() {
- HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_SET);
- HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET);
-}
-void DPlusThree_Three() {
- HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_SET); // pull up D+
-}
-void DNegThree_Three() {
- HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_SET);
- HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET);
-}
-
-void QC_Seek9V() {
- DNegZero_Six();
- DPlusThree_Three();
-}
-void QC_Seek12V() {
- DNegZero_Six();
- DPlusZero_Six();
-}
-void QC_Seek20V() {
- DNegThree_Three();
- DPlusThree_Three();
-}
-void QC_SeekContMode() {
- DNegThree_Three();
- DPlusZero_Six();
-}
-void QC_SeekContPlus() {
- QC_SeekContMode();
- vTaskDelay(3);
- QC_Seek20V();
- vTaskDelay(1);
- QC_SeekContMode();
-}
-void QC_SeekContNeg() {
- QC_SeekContMode();
- vTaskDelay(3);
- QC_Seek12V();
- vTaskDelay(1);
- QC_SeekContMode();
-}
-uint8_t QCMode = 0;
-uint8_t QCTries = 0;
-void seekQC(int16_t Vx10, uint16_t divisor) {
- if (QCMode == 5)
- startQC(divisor);
- if (QCMode == 0)
- return; // NOT connected to a QC Charger
-
- if (Vx10 < 45)
- return;
- if (xTaskGetTickCount() < 100)
- return;
- if (Vx10 > 130)
- Vx10 = 130; //Cap max value at 13V
- // Seek the QC to the Voltage given if this adapter supports continuous mode
- // try and step towards the wanted value
-
- // 1. Measure current voltage
- int16_t vStart = getInputVoltageX10(divisor, 1);
- int difference = Vx10 - vStart;
-
- // 2. calculate ideal steps (0.2V changes)
-
- int steps = difference / 2;
- if (QCMode == 3) {
- if (steps > -2 && steps < 2)
- return; // dont bother with small steps
- while (steps < 0) {
- QC_SeekContNeg();
- vTaskDelay(3);
- steps++;
- }
- while (steps > 0) {
- QC_SeekContPlus();
- vTaskDelay(3);
- steps--;
- }
- vTaskDelay(10);
- }
-#ifdef ENABLE_QC2
- // Re-measure
- /* Disabled due to nothing to test and code space of around 1k*/
- steps = vStart - getInputVoltageX10(divisor, 1);
- if (steps < 0)
- steps = -steps;
- if (steps > 4) {
- // No continuous mode, so QC2
- QCMode = 2;
- // Goto nearest
- if (Vx10 > 110) {
- // request 12V
- // D- = 0.6V, D+ = 0.6V
- // Clamp PB3
- QC_Seek12V();
-
- } else {
- // request 9V
- QC_Seek9V();
- }
- }
-#endif
-}
-// Must be called after FreeRToS Starts
-void startQC(uint16_t divisor) {
- // Pre check that the input could be >5V already, and if so, dont both
- // negotiating as someone is feeding in hv
- uint16_t vin = getInputVoltageX10(divisor, 1);
- if (vin > 100) {
- QCMode = 1; // Already at 12V, user has probably over-ridden this
- return;
- }
- GPIO_InitTypeDef GPIO_InitStruct;
- GPIO_InitStruct.Pin = GPIO_PIN_3;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
- HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
- GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_10;
- HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
- //Turn off output mode on pins that we can
- GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_14 | GPIO_PIN_13;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- // Tries to negotiate QC for 9V
- // This is a multiple step process.
- // 1. Set around 0.6V on D+ for 1.25 Seconds or so
- // 2. After this It should un-short D+->D- and instead add a 20k pulldown on
- // D-
- DPlusZero_Six();
-
- // Delay 1.25 seconds
- uint8_t enteredQC = 0;
- for (uint16_t i = 0; i < 200 && enteredQC == 0; i++) {
- vTaskDelay(1); //10mS pause
- if (i > 130) {
- if (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_11) == GPIO_PIN_RESET) {
- enteredQC = 1;
- }
- if (i == 140) {
- //For some marginal QC chargers, we try adding a pulldown
- GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
- GPIO_InitStruct.Pull = GPIO_PULLDOWN;
- GPIO_InitStruct.Pin = GPIO_PIN_11;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
- }
- }
- }
- GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Pin = GPIO_PIN_11;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
- if (enteredQC) {
- // We have a QC capable charger
- QC_Seek9V();
- GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_10;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
- QC_Seek9V();
- // Wait for frontend ADC to stabilise
- QCMode = 4;
- for (uint8_t i = 0; i < 10; i++) {
- if (getInputVoltageX10(divisor, 1) > 80) {
- // yay we have at least QC2.0 or QC3.0
- QCMode = 3; // We have at least QC2, pray for 3
- return;
- }
- vTaskDelay(10); // 100mS
- }
- QCMode = 5;
- QCTries++;
- if (QCTries > 10) // 10 goes to get it going
- QCMode = 0;
- } else {
- // no QC
- QCMode = 0;
- }
- if (QCTries > 10)
- QCMode = 0;
-}
-
-static unsigned int sqrt32(unsigned long n) {
- unsigned int c = 0x8000;
- unsigned int g = 0x8000;
-
- for (;;) {
- if (g * g > n)
- g ^= c;
- c >>= 1;
- if (c == 0)
- return g;
- g |= c;
- }
-}
-int16_t calculateMaxVoltage(uint8_t useHP) {
-// This measures the tip resistance, then it calculates the appropriate
-// voltage To stay under ~18W. Mosfet is "9A", so no issues there
-// QC3.0 supports up to 18W, which is 2A @9V and 1.5A @12V
- uint32_t milliOhms = 4500;
-// Check no tip
- if (milliOhms > 10000)
- return -1;
-//Because of tolerance, if a user has asked for the higher power mode, then just goto 12V and call it a day
- if (useHP)
- return 120;
-//
-// V = sqrt(18W*R)
-// Convert this to sqrt(18W)*sqrt(milli ohms)*sqrt(1/1000)
-
- uint32_t Vx = sqrt32(milliOhms);
- if (useHP)
- Vx *= 1549; //sqrt(24)*sqrt(1/1000)*10000
- else
- Vx *= 1342; // sqrt(18) * sqrt(1/1000)*10000
-
-// Round to nearest 200mV,
-// So divide by 100 to start, to get in Vxx
- Vx /= 100;
- if (Vx % 10 >= 5)
- Vx += 10;
- Vx /= 10;
-// Round to nearest increment of 2
- if (Vx % 2 == 1)
- Vx++;
-//Because of how bad the tolerance is on detecting the tip resistance is
-//Its more functional to bin this
- if (Vx < 90)
- Vx = 90;
- else if (Vx >= 105)
- Vx = 120;
- return Vx;
-}
-
-#endif
-volatile uint8_t pendingPWM = 0;
-
-void setTipPWM(uint8_t pulse) {
- PWMSafetyTimer = 10; // This is decremented in the handler for PWM so that the tip pwm is
- // disabled if the PID task is not scheduled often enough.
-
- pendingPWM = pulse;
-}
-
-// These are called by the HAL after the corresponding events from the system
-// timers.
-
-void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
-// Period has elapsed
- if (htim->Instance == TIM2) {
- // we want to turn on the output again
- PWMSafetyTimer--;
- // We decrement this safety value so that lockups in the
- // scheduler will not cause the PWM to become locked in an
- // active driving state.
- // While we could assume this could never happen, its a small price for
- // increased safety
- htim2.Instance->CCR4 = pendingPWM;
- if (htim2.Instance->CCR4 && PWMSafetyTimer) {
- HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1);
- } else {
- HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_1);
- }
- } else if (htim->Instance == TIM1) {
- // STM uses this for internal functions as a counter for timeouts
- HAL_IncTick();
- }
-}
-
-void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim) {
-// This was a when the PWM for the output has timed out
- if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_4) {
- HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_1);
- }
-}
-
-void vApplicationIdleHook(void) {
- HAL_IWDG_Refresh(&hiwdg);
-}
-
-/* USER CODE BEGIN GET_IDLE_TASK_MEMORY */
-static StaticTask_t xIdleTaskTCBBuffer;
-static StackType_t xIdleStack[configMINIMAL_STACK_SIZE];
-
-void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,
- StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize) {
- *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer;
- *ppxIdleTaskStackBuffer = &xIdleStack[0];
- *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
- /* place for user code */
-}
-/* USER CODE END GET_IDLE_TASK_MEMORY */
diff --git a/workspace/TS100/Core/Src/main.cpp b/workspace/TS100/Core/Src/main.cpp
index ad952611..9d5e19f4 100644
--- a/workspace/TS100/Core/Src/main.cpp
+++ b/workspace/TS100/Core/Src/main.cpp
@@ -1,22 +1,18 @@
// By Ben V. Brown - V2.0 of the TS100 firmware
-#include <MMA8652FC.hpp>
-#include <gui.hpp>
+
+/*
+ * Main.cpp bootstraps the device and then hands over to FreeRTOS and the threads
+ */
+
+#include "BSP.h"
#include <main.hpp>
#include "LIS2DH12.hpp"
-#include <history.hpp>
+#include <MMA8652FC.hpp>
#include <power.hpp>
#include "Settings.h"
-#include "Translation.h"
#include "cmsis_os.h"
-#include "stdlib.h"
-#include "stm32f1xx_hal.h"
-#include "string.h"
-#include "TipThermoModel.h"
uint8_t PCBVersion = 0;
// File local variables
-uint32_t currentTempTargetDegC = 0; // Current temperature target in C
-uint8_t accelInit = 0;
-uint32_t lastMovementTime = 0;
bool settingsWereReset = false;
// FreeRTOS variables
@@ -35,34 +31,23 @@ static const size_t MOVTaskStackSize = 512 / 4;
uint32_t MOVTaskBuffer[MOVTaskStackSize];
osStaticThreadDef_t MOVTaskControlBlock;
-static TaskHandle_t pidTaskNotification = NULL;
-static TickType_t powerPulseRate = 1000;
-static TickType_t powerPulseDuration = 50;
-void startGUITask(void const *argument);
-void startPIDTask(void const *argument);
-void startMOVTask(void const *argument);
// End FreeRTOS
// Main sets up the hardware then hands over to the FreeRTOS kernel
int main(void) {
- /* Reset of all peripherals, Initializes the Flash interface and the Systick.
- */
- HAL_Init();
- Setup_HAL(); // Setup all the HAL objects
- HAL_IWDG_Refresh(&hiwdg);
+ preRToSInit();
+
setTipX10Watts(0); // force tip off
- FRToSI2C::init(&hi2c1);
OLED::initialize(); // start up the LCD
OLED::setFont(0); // default to bigger font
// Testing for which accelerometer is mounted
- uint8_t buffer[1];
- HAL_IWDG_Refresh(&hiwdg);
- if (HAL_I2C_Mem_Read(&hi2c1, 29 << 1, 0x0F, I2C_MEMADD_SIZE_8BIT, buffer, 1,
- 1000) == HAL_OK) {
+ resetWatchdog();
+ resetWatchdog();
+ settingsWereReset = restoreSettings(); // load the settings from flash
+ if (MMA8652FC::detect()) {
PCBVersion = 1;
MMA8652FC::initalize(); // this sets up the I2C registers
- } else if (HAL_I2C_Mem_Read(&hi2c1, 25 << 1, 0x0F, I2C_MEMADD_SIZE_8BIT,
- buffer, 1, 1000) == HAL_OK) {
+ } else if (LIS2DH12::detect()) {
PCBVersion = 2;
// Setup the ST Accelerometer
LIS2DH12::initalize(); // startup the accelerometer
@@ -72,10 +57,8 @@ int main(void) {
systemSettings.ShutdownTime = 0; // No accel -> disable sleep
systemSettings.sensitivity = 0;
}
- HAL_IWDG_Refresh(&hiwdg);
- settingsWereReset = restoreSettings(); // load the settings from flash
- HAL_IWDG_Refresh(&hiwdg);
+ resetWatchdog();
/* Create the thread(s) */
/* definition and creation of GUITask */
@@ -97,263 +80,7 @@ int main(void) {
/* Start scheduler */
osKernelStart();
-
/* We should never get here as control is now taken by the scheduler */
- while (1) {
- }
-}
-
-/* StartPIDTask function */
-void startPIDTask(void const *argument __unused) {
- /*
- * We take the current tip temperature & evaluate the next step for the tip
- * control PWM.
- */
- setTipX10Watts(0); // disable the output driver if the output is set to be off
- TickType_t lastPowerPulseStart = 0;
- TickType_t lastPowerPulseEnd = 0;
-
- history<int32_t, PID_TIM_HZ> tempError = { { 0 }, 0, 0 };
- currentTempTargetDegC = 0; // Force start with no output (off). If in sleep / soldering this will
- // be over-ridden rapidly
- pidTaskNotification = xTaskGetCurrentTaskHandle();
- uint32_t PIDTempTarget = 0;
for (;;) {
-
- if (ulTaskNotifyTake(pdTRUE, 2000)) {
- // This is a call to block this thread until the ADC does its samples
- int32_t x10WattsOut = 0;
- // Do the reading here to keep the temp calculations churning along
- uint32_t currentTipTempInC = TipThermoModel::getTipInC(true);
- PIDTempTarget = currentTempTargetDegC;
- if (PIDTempTarget) {
- // Cap the max set point to 450C
- if (PIDTempTarget > (450)) {
- //Maximum allowed output
- PIDTempTarget = (450);
- }
- //Safety check that not aiming higher than current tip can measure
- if (PIDTempTarget > TipThermoModel::getTipMaxInC()) {
- PIDTempTarget = TipThermoModel::getTipMaxInC();
- }
- // Convert the current tip to degree's C
-
- // As we get close to our target, temp noise causes the system
- // to be unstable. Use a rolling average to dampen it.
- // We overshoot by roughly 1 degree C.
- // This helps stabilize the display.
- int32_t tError = PIDTempTarget - currentTipTempInC + 1;
- tError = tError > INT16_MAX ? INT16_MAX : tError;
- tError = tError < INT16_MIN ? INT16_MIN : tError;
- tempError.update(tError);
-
- // Now for the PID!
-
- // P term - total power needed to hit target temp next cycle.
- // thermal mass = 1690 milliJ/*C for my tip.
- // = Watts*Seconds to raise Temp from room temp to +100*C, divided by 100*C.
- // we divide milliWattsNeeded by 20 to let the I term dominate near the set point.
- // This is necessary because of the temp noise and thermal lag in the system.
- // Once we have feed-forward temp estimation we should be able to better tune this.
-
- int32_t x10WattsNeeded = tempToX10Watts(tError);
-// tempError.average());
- // note that milliWattsNeeded is sometimes negative, this counters overshoot
- // from I term's inertia.
- x10WattsOut += x10WattsNeeded;
-
- // I term - energy needed to compensate for heat loss.
- // We track energy put into the system over some window.
- // Assuming the temp is stable, energy in = energy transfered.
- // (If it isn't, P will dominate).
- x10WattsOut += x10WattHistory.average();
-
- // D term - use sudden temp change to counter fast cooling/heating.
- // In practice, this provides an early boost if temp is dropping
- // and counters extra power if the iron is no longer losing temp.
- // basically: temp - lastTemp
- // Unfortunately, our temp signal is too noisy to really help.
-
- }
- //If the user turns on the option of using an occasional pulse to keep the power bank on
- if (systemSettings.KeepAwakePulse) {
-
- if (xTaskGetTickCount() - lastPowerPulseStart
- > powerPulseRate) {
- lastPowerPulseStart = xTaskGetTickCount();
- lastPowerPulseEnd = lastPowerPulseStart
- + powerPulseDuration;
- }
-
- //If current PID is less than the pulse level, check if we want to constrain to the pulse as the floor
- if (x10WattsOut < systemSettings.KeepAwakePulse
- && xTaskGetTickCount() < lastPowerPulseEnd) {
- x10WattsOut = systemSettings.KeepAwakePulse;
- }
- }
-
- //Secondary safety check to forcefully disable header when within ADC noise of top of ADC
- if (getTipRawTemp(0) > (0x7FFF - 150)) {
- x10WattsOut = 0;
- }
- if (systemSettings.powerLimitEnable
- && x10WattsOut > (systemSettings.powerLimit * 10)) {
- setTipX10Watts(systemSettings.powerLimit * 10);
- } else {
- setTipX10Watts(x10WattsOut);
- }
-
- HAL_IWDG_Refresh(&hiwdg);
- } else {
- //ADC interrupt timeout
- setTipPWM(0);
- }
}
}
-
-#define MOVFilter 8
-void startMOVTask(void const *argument __unused) {
- OLED::setRotation(true);
-
-#ifdef MODEL_TS80
- startQC(systemSettings.voltageDiv);
- while (pidTaskNotification == 0)
- osDelay(30); // To ensure we return after idealQCVoltage/tip resistance
-
- seekQC((systemSettings.cutoutSetting) ? 120 : 90,
- systemSettings.voltageDiv); // this will move the QC output to the preferred voltage to start with
-
-#else
- osDelay(250); // wait for accelerometer to stabilize
-#endif
-
- OLED::setRotation(systemSettings.OrientationMode & 1);
- lastMovementTime = 0;
- int16_t datax[MOVFilter] = { 0 };
- int16_t datay[MOVFilter] = { 0 };
- int16_t dataz[MOVFilter] = { 0 };
- uint8_t currentPointer = 0;
- int16_t tx = 0, ty = 0, tz = 0;
- int32_t avgx = 0, avgy = 0, avgz = 0;
- if (systemSettings.sensitivity > 9)
- systemSettings.sensitivity = 9;
-#ifdef ACCELDEBUG
- uint32_t max = 0;
-#endif
- Orientation rotation = ORIENTATION_FLAT;
- for (;;) {
- int32_t threshold = 1500 + (9 * 200);
- threshold -= systemSettings.sensitivity * 200; // 200 is the step size
-
- if (PCBVersion == 2) {
- LIS2DH12::getAxisReadings(tx, ty, tz);
- rotation = LIS2DH12::getOrientation();
- } else if (PCBVersion == 1) {
- MMA8652FC::getAxisReadings(tx, ty, tz);
- rotation = MMA8652FC::getOrientation();
- }
- if (systemSettings.OrientationMode == 2) {
- if (rotation != ORIENTATION_FLAT) {
- OLED::setRotation(rotation == ORIENTATION_LEFT_HAND); // link the data through
- }
- }
- datax[currentPointer] = (int32_t) tx;
- datay[currentPointer] = (int32_t) ty;
- dataz[currentPointer] = (int32_t) tz;
- if (!accelInit) {
- for (uint8_t i = currentPointer + 1; i < MOVFilter; i++) {
- datax[i] = (int32_t) tx;
- datay[i] = (int32_t) ty;
- dataz[i] = (int32_t) tz;
- }
- accelInit = 1;
- }
- currentPointer = (currentPointer + 1) % MOVFilter;
- avgx = avgy = avgz = 0;
- // calculate averages
- for (uint8_t i = 0; i < MOVFilter; i++) {
- avgx += datax[i];
- avgy += datay[i];
- avgz += dataz[i];
- }
- avgx /= MOVFilter;
- avgy /= MOVFilter;
- avgz /= MOVFilter;
-
- // Sum the deltas
- int32_t error = (abs(avgx - tx) + abs(avgy - ty) + abs(avgz - tz));
- // So now we have averages, we want to look if these are different by more
- // than the threshold
-
- // If error has occurred then we update the tick timer
- if (error > threshold) {
- lastMovementTime = xTaskGetTickCount();
- }
-
- osDelay(100); // Slow down update rate
-#ifdef MODEL_TS80
- seekQC((systemSettings.cutoutSetting) ? 120 : 90,
- systemSettings.voltageDiv); // Run the QC seek again if we have drifted too much
-#endif
- }
-}
-
-// Second last page of flash set aside for logo image.
-#define FLASH_LOGOADDR (0x8000000 | 0xF800)
-
-// Logo header signature.
-#define LOGO_HEADER_VALUE 0xF00DAA55
-
-bool showBootLogoIfavailable() {
-// Do not show logo data if signature is not found.
- if (LOGO_HEADER_VALUE
- != *(reinterpret_cast<const uint32_t*>(FLASH_LOGOADDR))) {
- return false;
- }
-
- OLED::drawAreaSwapped(0, 0, 96, 16, (uint8_t*) (FLASH_LOGOADDR + 4));
- OLED::refresh();
- return true;
-}
-
-/*
- * Catch the IRQ that says that the conversion is done on the temperature
- * readings coming in Once these have come in we can unblock the PID so that it
- * runs again
- */
-void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef *hadc) {
- BaseType_t xHigherPriorityTaskWoken = pdFALSE;
- if (hadc == &hadc1) {
- if (pidTaskNotification) {
- vTaskNotifyGiveFromISR(pidTaskNotification,
- &xHigherPriorityTaskWoken);
- portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
- }
- }
-}
-void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
- FRToSI2C::CpltCallback();
-}
-void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
- FRToSI2C::CpltCallback();
-}
-void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
- FRToSI2C::CpltCallback();
-}
-void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c __unused) {
-
- FRToSI2C::CpltCallback();
-}
-void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
-
- FRToSI2C::CpltCallback();
-}
-void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
- FRToSI2C::CpltCallback();
-}
-void vApplicationStackOverflowHook(xTaskHandle *pxTask __unused,
- signed portCHAR *pcTaskName __unused) {
-
-// We dont have a good way to handle a stack overflow at this point in time
- NVIC_SystemReset();
-}
diff --git a/workspace/TS100/Core/Src/power.cpp b/workspace/TS100/Core/Src/power.cpp
index 99887079..4cceb9c5 100644
--- a/workspace/TS100/Core/Src/power.cpp
+++ b/workspace/TS100/Core/Src/power.cpp
@@ -2,12 +2,12 @@
* power.cpp
*
* Created on: 28 Oct, 2018
- * Authors: Ben V. Brown, David Hilton
+ * Authors: Ben V. Brown, David Hilton <- Mostly David
*/
#include <power.hpp>
#include <Settings.h>
-#include <hardware.h>
+#include <BSP.h>
const uint16_t powerPWM = 255;
const uint16_t totalPWM = 255 + 17; //htim2.Init.Period, the full PWM cycle
diff --git a/workspace/TS100/Core/Src/syscalls.c b/workspace/TS100/Core/Src/syscalls.c
new file mode 100644
index 00000000..1a0f4f8e
--- /dev/null
+++ b/workspace/TS100/Core/Src/syscalls.c
@@ -0,0 +1,114 @@
+/* Includes */
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdio.h>
+#include <signal.h>
+#include <time.h>
+#include <sys/time.h>
+#include <sys/times.h>
+
+/* Variables */
+//#undef errno
+extern int errno;
+extern int __io_putchar(int ch) __attribute__((weak));
+extern int __io_getchar(void) __attribute__((weak));
+
+register char *stack_ptr asm("sp");
+
+char *__env[1] = { 0 };
+char **environ = __env;
+
+/* Functions */
+void initialise_monitor_handles() {
+}
+
+int _getpid(void) {
+ return 1;
+}
+
+int _kill(int pid, int sig) {
+ errno = EINVAL;
+ return -1;
+}
+
+void _exit(int status) {
+ _kill(status, -1);
+ while (1) {
+ } /* Make sure we hang here */
+}
+
+__attribute__((weak)) int _read(int file, char *ptr, int len) {
+ int DataIdx;
+
+ for (DataIdx = 0; DataIdx < len; DataIdx++) {
+ *ptr++ = __io_getchar();
+ }
+
+ return len;
+}
+
+__attribute__((weak)) int _write(int file, char *ptr, int len) {
+ int DataIdx;
+
+ for (DataIdx = 0; DataIdx < len; DataIdx++) {
+ __io_putchar(*ptr++);
+ }
+ return len;
+}
+
+int _close(int file) {
+ return -1;
+}
+
+int _fstat(int file, struct stat *st) {
+ st->st_mode = S_IFCHR;
+ return 0;
+}
+
+int _isatty(int file) {
+ return 1;
+}
+
+int _lseek(int file, int ptr, int dir) {
+ return 0;
+}
+
+int _open(char *path, int flags, ...) {
+ /* Pretend like we always fail */
+ return -1;
+}
+
+int _wait(int *status) {
+ errno = ECHILD;
+ return -1;
+}
+
+int _unlink(char *name) {
+ errno = ENOENT;
+ return -1;
+}
+
+int _times(struct tms *buf) {
+ return -1;
+}
+
+int _stat(char *file, struct stat *st) {
+ st->st_mode = S_IFCHR;
+ return 0;
+}
+
+int _link(char *old, char *new) {
+ errno = EMLINK;
+ return -1;
+}
+
+int _fork(void) {
+ errno = EAGAIN;
+ return -1;
+}
+
+int _execve(char *name, char **argv, char **env) {
+ errno = ENOMEM;
+ return -1;
+}
diff --git a/workspace/TS100/Core/Src/sysmem.c b/workspace/TS100/Core/Src/sysmem.c
new file mode 100644
index 00000000..fc88ed94
--- /dev/null
+++ b/workspace/TS100/Core/Src/sysmem.c
@@ -0,0 +1,18 @@
+/* Includes */
+#include <errno.h>
+#include <stdio.h>
+
+/* Variables */
+extern int errno;
+register char *stack_ptr asm("sp");
+
+/* Functions */
+
+/**
+ _sbrk
+ Increase program data space. Malloc and related functions depend on this
+ **/
+caddr_t _sbrk(int incr) {
+ return (void*) -1;
+}
+
diff --git a/workspace/TS100/Core/Threads/GUIThread.cpp b/workspace/TS100/Core/Threads/GUIThread.cpp
new file mode 100644
index 00000000..668b60b7
--- /dev/null
+++ b/workspace/TS100/Core/Threads/GUIThread.cpp
@@ -0,0 +1,756 @@
+/*
+ * GUIThread.cpp
+ *
+ * Created on: 19 Aug 2019
+ * Author: ralim
+ */
+extern "C" {
+#include "FreeRTOSConfig.h"
+}
+#include <MMA8652FC.hpp>
+#include <gui.hpp>
+#include <history.hpp>
+#include <main.hpp>
+#include <power.hpp>
+
+#include "../../configuration.h"
+#include "Buttons.hpp"
+#include "LIS2DH12.hpp"
+#include "Settings.h"
+#include "TipThermoModel.h"
+#include "Translation.h"
+#include "cmsis_os.h"
+#include "stdlib.h"
+#include "string.h"
+#include "unit.h"
+extern uint8_t PCBVersion;
+// File local variables
+extern uint32_t currentTempTargetDegC;
+extern uint8_t accelInit;
+extern uint32_t lastMovementTime;
+extern int16_t idealQCVoltage;
+extern osThreadId GUITaskHandle;
+extern osThreadId MOVTaskHandle;
+extern osThreadId PIDTaskHandle;
+
+#define MOVEMENT_INACTIVITY_TIME (60 * configTICK_RATE_HZ)
+#define BUTTON_INACTIVITY_TIME (60 * configTICK_RATE_HZ)
+
+static uint16_t min(uint16_t a, uint16_t b) {
+ if (a > b)
+ return b;
+ else
+ return a;
+}
+
+void printVoltage() {
+ uint32_t volt = getInputVoltageX10(systemSettings.voltageDiv, 0);
+ OLED::printNumber(volt / 10, 2);
+ OLED::print(SymbolDot);
+ OLED::printNumber(volt % 10, 1);
+}
+void GUIDelay() {
+ // Called in all UI looping tasks,
+ // This limits the re-draw rate to the LCD and also lets the DMA run
+ // As the gui task can very easily fill this bus with transactions, which will
+ // prevent the movement detection from running
+ osDelay(50);
+}
+void gui_drawTipTemp(bool symbol) {
+ // Draw tip temp handling unit conversion & tolerance near setpoint
+ uint16_t Temp = 0;
+#ifdef ENABLED_FAHRENHEIT_SUPPORT
+ if (systemSettings.temperatureInF)
+ Temp = TipThermoModel::getTipInF();
+ else
+#endif
+ Temp = TipThermoModel::getTipInC();
+
+ OLED::printNumber(Temp, 3); // Draw the tip temp out finally
+ if (symbol) {
+ if (OLED::getFont() == 0) {
+ // Big font, can draw nice symbols
+#ifdef ENABLED_FAHRENHEIT_SUPPORT
+ if (systemSettings.temperatureInF)
+ OLED::drawSymbol(0);
+ else
+#endif
+ OLED::drawSymbol(1);
+ } else {
+ // Otherwise fall back to chars
+#ifdef ENABLED_FAHRENHEIT_SUPPORT
+ if (systemSettings.temperatureInF)
+ OLED::print(SymbolDegF);
+ else
+#endif
+ OLED::print(SymbolDegC);
+ }
+ }
+}
+
+#ifdef MODEL_TS100
+// returns true if undervoltage has occured
+static bool checkVoltageForExit() {
+ uint16_t v = getInputVoltageX10(systemSettings.voltageDiv, 0);
+
+ // Dont check for first 1.5 seconds while the ADC stabilizes and the DMA fills the buffer
+ if (xTaskGetTickCount() > 150) {
+ if ((v < lookupVoltageLevel(systemSettings.cutoutSetting))) {
+ GUIDelay();
+ OLED::clearScreen();
+ OLED::setCursor(0, 0);
+ if (systemSettings.detailedSoldering) {
+ OLED::setFont(1);
+ OLED::print(UndervoltageString);
+ OLED::setCursor(0, 8);
+ OLED::print(InputVoltageString);
+ printVoltage();
+ OLED::print(SymbolVolts);
+
+ } else {
+ OLED::setFont(0);
+ OLED::print(UVLOWarningString);
+ }
+
+ OLED::refresh();
+ currentTempTargetDegC = 0;
+ waitForButtonPress();
+ return true;
+ }
+ }
+ return false;
+}
+#endif
+static void gui_drawBatteryIcon() {
+#ifdef MODEL_TS100
+ if (systemSettings.cutoutSetting) {
+ // User is on a lithium battery
+ // we need to calculate which of the 10 levels they are on
+ uint8_t cellCount = systemSettings.cutoutSetting + 2;
+ uint32_t cellV = getInputVoltageX10(systemSettings.voltageDiv, 0) / cellCount;
+ // Should give us approx cell voltage X10
+ // Range is 42 -> 33 = 9 steps therefore we will use battery 1-10
+ if (cellV < 33) cellV = 33;
+ cellV -= 33; // Should leave us a number of 0-9
+ if (cellV > 9) cellV = 9;
+ OLED::drawBattery(cellV + 1);
+ } else
+ OLED::drawSymbol(15); // Draw the DC Logo
+#else
+ // On TS80 we replace this symbol with the voltage we are operating on
+ // If <9V then show single digit, if not show duals
+ uint8_t V = getInputVoltageX10(systemSettings.voltageDiv, 0);
+ if (V % 10 >= 5)
+ V = V / 10 + 1; // round up
+ else
+ V = V / 10;
+ if (V >= 10) {
+ int16_t xPos = OLED::getCursorX();
+ OLED::setFont(1);
+ OLED::printNumber(1, 1);
+ OLED::setCursor(xPos, 8);
+ OLED::printNumber(V % 10, 1);
+ OLED::setFont(0);
+ OLED::setCursor(xPos + 12, 0); // need to reset this as if we drew a wide char
+ } else {
+ OLED::printNumber(V, 1);
+ }
+#endif
+}
+static void gui_solderingTempAdjust() {
+ uint32_t lastChange = xTaskGetTickCount();
+ currentTempTargetDegC = 0;
+ uint32_t autoRepeatTimer = 0;
+ uint8_t autoRepeatAcceleration = 0;
+ for (;;) {
+ OLED::setCursor(0, 0);
+ OLED::clearScreen();
+ OLED::setFont(0);
+ ButtonState buttons = getButtonState();
+ if (buttons) lastChange = xTaskGetTickCount();
+ switch (buttons) {
+ case BUTTON_NONE:
+ // stay
+ break;
+ case BUTTON_BOTH:
+ // exit
+ return;
+ break;
+ case BUTTON_B_LONG:
+ if (xTaskGetTickCount() - autoRepeatTimer + autoRepeatAcceleration > PRESS_ACCEL_INTERVAL_MAX) {
+ if (systemSettings.ReverseButtonTempChangeEnabled) {
+ systemSettings.SolderingTemp += systemSettings.TempChangeLongStep;
+ } else
+ systemSettings.SolderingTemp -= systemSettings.TempChangeLongStep;
+
+ autoRepeatTimer = xTaskGetTickCount();
+ autoRepeatAcceleration += PRESS_ACCEL_STEP;
+ }
+ break;
+ case BUTTON_B_SHORT:
+ if (systemSettings.ReverseButtonTempChangeEnabled) {
+ systemSettings.SolderingTemp += systemSettings.TempChangeShortStep;
+ } else
+ systemSettings.SolderingTemp -= systemSettings.TempChangeShortStep;
+ break;
+ case BUTTON_F_LONG:
+ if (xTaskGetTickCount() - autoRepeatTimer + autoRepeatAcceleration > PRESS_ACCEL_INTERVAL_MAX) {
+ if (systemSettings.ReverseButtonTempChangeEnabled) {
+ systemSettings.SolderingTemp -= systemSettings.TempChangeLongStep;
+ } else
+ systemSettings.SolderingTemp += systemSettings.TempChangeLongStep;
+ autoRepeatTimer = xTaskGetTickCount();
+ autoRepeatAcceleration += PRESS_ACCEL_STEP;
+ }
+ break;
+ case BUTTON_F_SHORT:
+ if (systemSettings.ReverseButtonTempChangeEnabled) {
+ systemSettings.SolderingTemp -= systemSettings.TempChangeShortStep; // add 10
+ } else
+ systemSettings.SolderingTemp += systemSettings.TempChangeShortStep; // add 10
+ break;
+ default:
+ break;
+ }
+ if ((PRESS_ACCEL_INTERVAL_MAX - autoRepeatAcceleration) < PRESS_ACCEL_INTERVAL_MIN) {
+ autoRepeatAcceleration = PRESS_ACCEL_INTERVAL_MAX - PRESS_ACCEL_INTERVAL_MIN;
+ }
+ // constrain between 10-450 C
+#ifdef ENABLED_FAHRENHEIT_SUPPORT
+ if (systemSettings.temperatureInF) {
+ if (systemSettings.SolderingTemp > 850) systemSettings.SolderingTemp = 850;
+ if (systemSettings.SolderingTemp < 60) systemSettings.SolderingTemp = 60;
+ } else
+#endif
+ {
+ if (systemSettings.SolderingTemp > 450) systemSettings.SolderingTemp = 450;
+ if (systemSettings.SolderingTemp < 10) systemSettings.SolderingTemp = 10;
+ }
+
+ if (xTaskGetTickCount() - lastChange > 200) return; // exit if user just doesn't press anything for a bit
+
+#ifdef MODEL_TS80
+ if (!OLED::getRotation()) {
+#else
+ if (OLED::getRotation()) {
+#endif
+ OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolPlus : SymbolMinus);
+ } else {
+ OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolMinus : SymbolPlus);
+ }
+
+ OLED::print(SymbolSpace);
+ OLED::printNumber(systemSettings.SolderingTemp, 3);
+#ifdef ENABLED_FAHRENHEIT_SUPPORT
+ if (systemSettings.temperatureInF)
+ OLED::drawSymbol(0);
+ else
+#endif
+ {
+ OLED::drawSymbol(1);
+ }
+ OLED::print(SymbolSpace);
+#ifdef MODEL_TS80
+ if (!OLED::getRotation()) {
+#else
+ if (OLED::getRotation()) {
+#endif
+ OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolMinus : SymbolPlus);
+ } else {
+ OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolPlus : SymbolMinus);
+ }
+ OLED::refresh();
+ GUIDelay();
+ }
+}
+
+static int gui_SolderingSleepingMode(bool stayOff) {
+ // Drop to sleep temperature and display until movement or button press
+
+ for (;;) {
+ ButtonState buttons = getButtonState();
+ if (buttons) return 0;
+ if ((xTaskGetTickCount() > 100) && ((accelInit && (xTaskGetTickCount() - lastMovementTime < 100)) || (xTaskGetTickCount() - lastButtonTime < 100))) return 0; // user moved or pressed a button, go back to soldering
+#ifdef MODEL_TS100
+ if (checkVoltageForExit()) return 1; // return non-zero on error
+#endif
+#ifdef ENABLED_FAHRENHEIT_SUPPORT
+ if (systemSettings.temperatureInF) {
+ currentTempTargetDegC = stayOff ? 0 : TipThermoModel::convertFtoC(min(systemSettings.SleepTemp, systemSettings.SolderingTemp));
+ } else
+#endif
+ {
+ currentTempTargetDegC = stayOff ? 0 : min(systemSettings.SleepTemp, systemSettings.SolderingTemp);
+ }
+ // draw the lcd
+ uint16_t tipTemp;
+#ifdef ENABLED_FAHRENHEIT_SUPPORT
+ if (systemSettings.temperatureInF)
+ tipTemp = TipThermoModel::getTipInF();
+ else
+#endif
+ {
+ tipTemp = TipThermoModel::getTipInC();
+ }
+
+ OLED::clearScreen();
+ OLED::setCursor(0, 0);
+ if (systemSettings.detailedSoldering) {
+ OLED::setFont(1);
+ OLED::print(SleepingAdvancedString);
+ OLED::setCursor(0, 8);
+ OLED::print(SleepingTipAdvancedString);
+ OLED::printNumber(tipTemp, 3);
+#ifdef ENABLED_FAHRENHEIT_SUPPORT
+ if (systemSettings.temperatureInF)
+ OLED::print(SymbolDegF);
+ else
+#endif
+ {
+ OLED::print(SymbolDegC);
+ }
+
+ OLED::print(SymbolSpace);
+ printVoltage();
+ OLED::print(SymbolVolts);
+ } else {
+ OLED::setFont(0);
+ OLED::print(SleepingSimpleString);
+ OLED::printNumber(tipTemp, 3);
+#ifdef ENABLED_FAHRENHEIT_SUPPORT
+ if (systemSettings.temperatureInF)
+ OLED::drawSymbol(0);
+ else
+#endif
+ {
+ OLED::drawSymbol(1);
+ }
+ }
+ if (systemSettings.ShutdownTime) // only allow shutdown exit if time > 0
+ if (lastMovementTime)
+ if (((uint32_t)(xTaskGetTickCount() - lastMovementTime)) > (uint32_t)(systemSettings.ShutdownTime * 60 * 100)) {
+ // shutdown
+ currentTempTargetDegC = 0;
+ return 1; // we want to exit soldering mode
+ }
+ OLED::refresh();
+ GUIDelay();
+ }
+ return 0;
+}
+
+static void display_countdown(int sleepThres) {
+ /*
+ * Print seconds or minutes (if > 99 seconds) until sleep
+ * mode is triggered.
+ */
+ int lastEventTime = lastButtonTime < lastMovementTime ? lastMovementTime : lastButtonTime;
+ int downCount = sleepThres - xTaskGetTickCount() + lastEventTime;
+ if (downCount > 9900) {
+ OLED::printNumber(downCount / 6000 + 1, 2);
+ OLED::print(SymbolMinutes);
+ } else {
+ OLED::printNumber(downCount / 100 + 1, 2);
+ OLED::print(SymbolSeconds);
+ }
+}
+
+static void gui_solderingMode(uint8_t jumpToSleep) {
+ /*
+ * * Soldering (gui_solderingMode)
+ * -> Main loop where we draw temp, and animations
+ * --> User presses buttons and they goto the temperature adjust screen
+ * ---> Display the current setpoint temperature
+ * ---> Use buttons to change forward and back on temperature
+ * ---> Both buttons or timeout for exiting
+ * --> Long hold front button to enter boost mode
+ * ---> Just temporarily sets the system into the alternate temperature for
+ * PID control
+ * --> Long hold back button to exit
+ * --> Double button to exit
+ */
+ bool boostModeOn = false;
+
+ uint32_t sleepThres = 0;
+ if (systemSettings.SleepTime < 6)
+ sleepThres = systemSettings.SleepTime * 10 * 100;
+ else
+ sleepThres = (systemSettings.SleepTime - 5) * 60 * 100;
+ if (jumpToSleep) {
+ if (gui_SolderingSleepingMode(jumpToSleep == 2)) {
+ lastButtonTime = xTaskGetTickCount();
+ return; // If the function returns non-0 then exit
+ }
+ }
+ for (;;) {
+ ButtonState buttons = getButtonState();
+ switch (buttons) {
+ case BUTTON_NONE:
+ // stay
+ boostModeOn = false;
+ break;
+ case BUTTON_BOTH:
+ // exit
+ return;
+ break;
+ case BUTTON_B_LONG:
+ return; // exit on back long hold
+ break;
+ case BUTTON_F_LONG:
+ // if boost mode is enabled turn it on
+ if (systemSettings.boostModeEnabled) boostModeOn = true;
+ break;
+ case BUTTON_F_SHORT:
+ case BUTTON_B_SHORT: {
+ uint16_t oldTemp = systemSettings.SolderingTemp;
+ gui_solderingTempAdjust(); // goto adjust temp mode
+ if (oldTemp != systemSettings.SolderingTemp) {
+ saveSettings(); // only save on change
+ }
+ } break;
+ default:
+ break;
+ }
+ // else we update the screen information
+ OLED::setCursor(0, 0);
+ OLED::clearScreen();
+ OLED::setFont(0);
+ // Draw in the screen details
+ if (systemSettings.detailedSoldering) {
+ OLED::setFont(1);
+ OLED::print(SolderingAdvancedPowerPrompt); // Power:
+ OLED::printNumber(x10WattHistory.average() / 10, 2);
+ OLED::print(SymbolDot);
+ OLED::printNumber(x10WattHistory.average() % 10, 1);
+ OLED::print(SymbolWatts);
+
+ if (systemSettings.sensitivity && systemSettings.SleepTime) {
+ OLED::print(SymbolSpace);
+ display_countdown(sleepThres);
+ }
+
+ OLED::setCursor(0, 8);
+ OLED::print(SleepingTipAdvancedString);
+ // OLED::printNumber(
+ // TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0)), 5); // Draw the tip temp out finally
+
+ gui_drawTipTemp(true);
+ OLED::print(SymbolSpace);
+ printVoltage();
+ OLED::print(SymbolVolts);
+ } else {
+ // We switch the layout direction depending on the orientation of the
+ // OLED::
+ if (OLED::getRotation()) {
+ // battery
+ gui_drawBatteryIcon();
+ OLED::print(SymbolSpace); // Space out gap between battery <-> temp
+ gui_drawTipTemp(true); // Draw current tip temp
+
+ // We draw boost arrow if boosting, or else gap temp <-> heat
+ // indicator
+ if (boostModeOn)
+ OLED::drawSymbol(2);
+ else
+ OLED::print(SymbolSpace);
+
+ // Draw heating/cooling symbols
+ OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory.average()));
+ } else {
+ // Draw heating/cooling symbols
+ OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory.average()));
+ // We draw boost arrow if boosting, or else gap temp <-> heat
+ // indicator
+ if (boostModeOn)
+ OLED::drawSymbol(2);
+ else
+ OLED::print(SymbolSpace);
+ gui_drawTipTemp(true); // Draw current tip temp
+
+ OLED::print(SymbolSpace); // Space out gap between battery <-> temp
+
+ gui_drawBatteryIcon();
+ }
+ }
+ OLED::refresh();
+
+ // Update the setpoints for the temperature
+ if (boostModeOn) {
+#ifdef ENABLED_FAHRENHEIT_SUPPORT
+ if (systemSettings.temperatureInF)
+ currentTempTargetDegC = TipThermoModel::convertFtoC(systemSettings.BoostTemp);
+ else
+#endif
+ {
+ currentTempTargetDegC = (systemSettings.BoostTemp);
+ }
+ } else {
+#ifdef ENABLED_FAHRENHEIT_SUPPORT
+ if (systemSettings.temperatureInF)
+ currentTempTargetDegC = TipThermoModel::convertFtoC(systemSettings.SolderingTemp);
+ else
+#endif
+ {
+ currentTempTargetDegC = (systemSettings.SolderingTemp);
+ }
+ }
+
+#ifdef MODEL_TS100
+ // Undervoltage test
+ if (checkVoltageForExit()) {
+ lastButtonTime = xTaskGetTickCount();
+ return;
+ }
+#else
+ // on the TS80 we only want to check for over voltage to prevent tip damage
+ /*if (getInputVoltageX10(systemSettings.voltageDiv, 1) > 150) {
+ lastButtonTime = xTaskGetTickCount();
+ currentlyActiveTemperatureTarget = 0;
+ return; // Over voltage
+ }*/
+#endif
+
+ if (systemSettings.sensitivity && systemSettings.SleepTime)
+ if (xTaskGetTickCount() - lastMovementTime > sleepThres && xTaskGetTickCount() - lastButtonTime > sleepThres) {
+ if (gui_SolderingSleepingMode(false)) {
+ return; // If the function returns non-0 then exit
+ }
+ }
+ // slow down ui update rate
+ GUIDelay();
+ }
+}
+
+void showDebugMenu(void) {
+ uint8_t screen = 0;
+ ButtonState b;
+ for (;;) {
+ OLED::clearScreen(); // Ensure the buffer starts clean
+ OLED::setCursor(0, 0); // Position the cursor at the 0,0 (top left)
+ OLED::setFont(1); // small font
+ OLED::print(SymbolVersionNumber); // Print version number
+ OLED::setCursor(0, 8); // second line
+ OLED::print(DebugMenu[screen]);
+ switch (screen) {
+ case 0: // Just prints date
+ break;
+ case 1:
+ // High water mark for GUI
+ OLED::printNumber(uxTaskGetStackHighWaterMark(GUITaskHandle), 5);
+ break;
+ case 2:
+ // High water mark for the Movement task
+ OLED::printNumber(uxTaskGetStackHighWaterMark(MOVTaskHandle), 5);
+ break;
+ case 3:
+ // High water mark for the PID task
+ OLED::printNumber(uxTaskGetStackHighWaterMark(PIDTaskHandle), 5);
+ break;
+ case 4:
+ // system up time stamp
+ OLED::printNumber(xTaskGetTickCount() / 100, 5);
+ break;
+ case 5:
+ // Movement time stamp
+ OLED::printNumber(lastMovementTime / 100, 5);
+ break;
+ case 6:
+ // Raw Tip
+ {
+ uint32_t temp = systemSettings.CalibrationOffset;
+ systemSettings.CalibrationOffset = 0;
+ OLED::printNumber(TipThermoModel::convertTipRawADCTouV(getTipRawTemp(1)), 6);
+ systemSettings.CalibrationOffset = temp;
+ }
+ break;
+ case 7:
+ // Temp in C
+ OLED::printNumber(TipThermoModel::getTipInC(1), 5);
+ break;
+ case 8:
+ // Handle Temp
+ OLED::printNumber(getHandleTemperature(), 3);
+ break;
+ case 9:
+ // Voltage input
+ printVoltage();
+ break;
+ case 10:
+ // Print PCB ID number
+ OLED::printNumber(PCBVersion, 1);
+ break;
+ default:
+ break;
+ }
+
+ OLED::refresh();
+ b = getButtonState();
+ if (b == BUTTON_B_SHORT)
+ return;
+ else if (b == BUTTON_F_SHORT) {
+ screen++;
+ screen = screen % 11;
+ }
+ GUIDelay();
+ }
+}
+
+/* StartGUITask function */
+void startGUITask(void const *argument __unused) {
+ FRToSI2C::FRToSInit();
+ uint8_t tempWarningState = 0;
+ bool buttonLockout = false;
+ bool tempOnDisplay = false;
+ getTipRawTemp(1); // reset filter
+ OLED::setRotation(systemSettings.OrientationMode & 1);
+ uint32_t ticks = xTaskGetTickCount();
+ ticks += 400; // 4 seconds from now
+ while (xTaskGetTickCount() < ticks) {
+ if (showBootLogoIfavailable() == false) ticks = xTaskGetTickCount();
+ ButtonState buttons = getButtonState();
+ if (buttons) ticks = xTaskGetTickCount(); // make timeout now so we will exit
+ GUIDelay();
+ }
+
+ if (settingsWereReset) {
+ // Display alert settings were reset
+ OLED::clearScreen();
+ OLED::setFont(1);
+ OLED::setCursor(0, 0);
+ OLED::print(SettingsResetMessage);
+ OLED::refresh();
+ waitForButtonPressOrTimeout(1000);
+ }
+
+ if (systemSettings.autoStartMode) {
+ // jump directly to the autostart mode
+ if (systemSettings.autoStartMode == 1) {
+ gui_solderingMode(0);
+ buttonLockout = true;
+ } else if (systemSettings.autoStartMode == 2) {
+ gui_solderingMode(1);
+ buttonLockout = true;
+ } else if (systemSettings.autoStartMode == 3) {
+ gui_solderingMode(2);
+ buttonLockout = true;
+ }
+ }
+
+ for (;;) {
+ ButtonState buttons = getButtonState();
+ if (buttons != BUTTON_NONE) {
+ OLED::setDisplayState(OLED::DisplayState::ON);
+ OLED::setFont(0);
+ }
+ if (tempWarningState == 2) buttons = BUTTON_F_SHORT;
+ if (buttons != BUTTON_NONE && buttonLockout)
+ buttons = BUTTON_NONE;
+ else
+ buttonLockout = false;
+
+ switch (buttons) {
+ case BUTTON_NONE:
+ // Do nothing
+ break;
+ case BUTTON_BOTH:
+ // Not used yet
+ // In multi-language this might be used to reset language on a long hold
+ // or some such
+ break;
+
+ case BUTTON_B_LONG:
+ // Show the version information
+ showDebugMenu();
+ break;
+ case BUTTON_F_LONG:
+ gui_solderingTempAdjust();
+ saveSettings();
+ break;
+ case BUTTON_F_SHORT:
+ gui_solderingMode(0); // enter soldering mode
+ buttonLockout = true;
+ break;
+ case BUTTON_B_SHORT:
+ enterSettingsMenu(); // enter the settings menu
+ buttonLockout = true;
+ break;
+ default:
+ break;
+ }
+
+ currentTempTargetDegC = 0; // ensure tip is off
+ getInputVoltageX10(systemSettings.voltageDiv, 0);
+ uint16_t tipTemp = TipThermoModel::getTipInC();
+
+ // Preemptively turn the display on. Turn it off if and only if
+ // the tip temperature is below 50 degrees C *and* motion sleep
+ // detection is enabled *and* there has been no activity (movement or
+ // button presses) in a while.
+ OLED::setDisplayState(OLED::DisplayState::ON);
+
+ if ((tipTemp < 50) && systemSettings.sensitivity && (((xTaskGetTickCount() - lastMovementTime) > MOVEMENT_INACTIVITY_TIME) && ((xTaskGetTickCount() - lastButtonTime) > BUTTON_INACTIVITY_TIME))) {
+ OLED::setDisplayState(OLED::DisplayState::OFF);
+ }
+
+ // Clear the lcd buffer
+ OLED::clearScreen();
+ OLED::setCursor(0, 0);
+ if (systemSettings.detailedIDLE) {
+ OLED::setFont(1);
+ if (tipTemp > 470) {
+ OLED::print(TipDisconnectedString);
+ } else {
+ OLED::print(IdleTipString);
+ gui_drawTipTemp(false);
+ OLED::print(IdleSetString);
+ OLED::printNumber(systemSettings.SolderingTemp, 3);
+ }
+ OLED::setCursor(0, 8);
+
+ OLED::print(InputVoltageString);
+ printVoltage();
+
+ } else {
+ OLED::setFont(0);
+#ifdef MODEL_TS80
+ if (!OLED::getRotation()) {
+#else
+ if (OLED::getRotation()) {
+#endif
+ OLED::drawArea(12, 0, 84, 16, idleScreenBG);
+ OLED::setCursor(0, 0);
+ gui_drawBatteryIcon();
+ } else {
+ OLED::drawArea(0, 0, 84, 16, idleScreenBGF); // Needs to be flipped so button ends up
+ // on right side of screen
+ OLED::setCursor(84, 0);
+ gui_drawBatteryIcon();
+ }
+ if (tipTemp > 55)
+ tempOnDisplay = true;
+ else if (tipTemp < 45)
+ tempOnDisplay = false;
+ if (tempOnDisplay) {
+ // draw temp over the start soldering button
+ // Location changes on screen rotation
+#ifdef MODEL_TS80
+ if (!OLED::getRotation()) {
+#else
+ if (OLED::getRotation()) {
+#endif
+ // in right handed mode we want to draw over the first part
+ OLED::fillArea(55, 0, 41, 16, 0); // clear the area for the temp
+ OLED::setCursor(56, 0);
+
+ } else {
+ OLED::fillArea(0, 0, 41, 16, 0); // clear the area
+ OLED::setCursor(0, 0);
+ }
+ // draw in the temp
+ if (!(systemSettings.coolingTempBlink && (xTaskGetTickCount() % 25 < 16))) gui_drawTipTemp(false); // draw in the temp
+ }
+ }
+ OLED::refresh();
+ GUIDelay();
+ }
+}
diff --git a/workspace/TS100/Core/Threads/MOVThread.cpp b/workspace/TS100/Core/Threads/MOVThread.cpp
new file mode 100644
index 00000000..e88cefce
--- /dev/null
+++ b/workspace/TS100/Core/Threads/MOVThread.cpp
@@ -0,0 +1,93 @@
+/*
+ * MOVThread.cpp
+ *
+ * Created on: 29 May 2020
+ * Author: Ralim
+ */
+
+#include "BSP.h"
+#include "FreeRTOS.h"
+#include "I2C_Wrapper.hpp"
+#include "LIS2DH12.hpp"
+#include "MMA8652FC.hpp"
+#include "QC3.h"
+#include "Settings.h"
+#include "TipThermoModel.h"
+#include "cmsis_os.h"
+#include "history.hpp"
+#include "main.hpp"
+#include "power.hpp"
+#include "stdlib.h"
+#include "task.h"
+#define MOVFilter 8
+uint8_t accelInit = 0;
+uint32_t lastMovementTime = 0;
+void startMOVTask(void const *argument __unused) {
+ OLED::setRotation(true);
+ postRToSInit();
+ power_probe();
+ while (pidTaskNotification == 0) osDelay(30); // Wait for PID to start
+
+ OLED::setRotation(systemSettings.OrientationMode & 1);
+ lastMovementTime = 0;
+ int16_t datax[MOVFilter] = {0};
+ int16_t datay[MOVFilter] = {0};
+ int16_t dataz[MOVFilter] = {0};
+ uint8_t currentPointer = 0;
+ int16_t tx = 0, ty = 0, tz = 0;
+ int32_t avgx, avgy, avgz;
+ if (systemSettings.sensitivity > 9) systemSettings.sensitivity = 9;
+ Orientation rotation = ORIENTATION_FLAT;
+ for (;;) {
+ int32_t threshold = 1500 + (9 * 200);
+ threshold -= systemSettings.sensitivity * 200; // 200 is the step size
+
+ if (PCBVersion == 2) {
+ LIS2DH12::getAxisReadings(tx, ty, tz);
+ rotation = LIS2DH12::getOrientation();
+ } else if (PCBVersion == 1) {
+ MMA8652FC::getAxisReadings(tx, ty, tz);
+ rotation = MMA8652FC::getOrientation();
+ }
+ if (systemSettings.OrientationMode == 2) {
+ if (rotation != ORIENTATION_FLAT) {
+ OLED::setRotation(rotation == ORIENTATION_LEFT_HAND); // link the data through
+ }
+ }
+ datax[currentPointer] = (int32_t)tx;
+ datay[currentPointer] = (int32_t)ty;
+ dataz[currentPointer] = (int32_t)tz;
+ if (!accelInit) {
+ for (uint8_t i = currentPointer + 1; i < MOVFilter; i++) {
+ datax[i] = (int32_t)tx;
+ datay[i] = (int32_t)ty;
+ dataz[i] = (int32_t)tz;
+ }
+ accelInit = 1;
+ }
+ currentPointer = (currentPointer + 1) % MOVFilter;
+ avgx = avgy = avgz = 0;
+ // calculate averages
+ for (uint8_t i = 0; i < MOVFilter; i++) {
+ avgx += datax[i];
+ avgy += datay[i];
+ avgz += dataz[i];
+ }
+ avgx /= MOVFilter;
+ avgy /= MOVFilter;
+ avgz /= MOVFilter;
+
+ // Sum the deltas
+ int32_t error = (abs(avgx - tx) + abs(avgy - ty) + abs(avgz - tz));
+ // So now we have averages, we want to look if these are different by more
+ // than the threshold
+
+ // If error has occurred then we update the tick timer
+ if (error > threshold) {
+ lastMovementTime = xTaskGetTickCount();
+ }
+
+ osDelay(100); // Slow down update rate
+ power_check();
+ }
+}
diff --git a/workspace/TS100/Core/Threads/PIDThread.cpp b/workspace/TS100/Core/Threads/PIDThread.cpp
new file mode 100644
index 00000000..844e3617
--- /dev/null
+++ b/workspace/TS100/Core/Threads/PIDThread.cpp
@@ -0,0 +1,128 @@
+/*
+ * PIDThread.cpp
+ *
+ * Created on: 29 May 2020
+ * Author: Ralim
+ */
+
+#include "main.hpp"
+#include "BSP.h"
+#include "power.hpp"
+#include "history.hpp"
+#include "TipThermoModel.h"
+#include "cmsis_os.h"
+#include "FreeRTOS.h"
+#include "task.h"
+#include "Settings.h"
+static TickType_t powerPulseRate = 1000;
+static TickType_t powerPulseDuration = 50;
+TaskHandle_t pidTaskNotification = NULL;
+uint32_t currentTempTargetDegC = 0; // Current temperature target in C
+
+/* StartPIDTask function */
+void startPIDTask(void const *argument __unused) {
+ /*
+ * We take the current tip temperature & evaluate the next step for the tip
+ * control PWM.
+ */
+ setTipX10Watts(0); // disable the output driver if the output is set to be off
+ TickType_t lastPowerPulseStart = 0;
+ TickType_t lastPowerPulseEnd = 0;
+
+ history<int32_t, PID_TIM_HZ> tempError = { { 0 }, 0, 0 };
+ currentTempTargetDegC = 0; // Force start with no output (off). If in sleep / soldering this will
+ // be over-ridden rapidly
+ pidTaskNotification = xTaskGetCurrentTaskHandle();
+ uint32_t PIDTempTarget = 0;
+ for (;;) {
+
+ if (ulTaskNotifyTake(pdTRUE, 2000)) {
+ // This is a call to block this thread until the ADC does its samples
+ int32_t x10WattsOut = 0;
+ // Do the reading here to keep the temp calculations churning along
+ uint32_t currentTipTempInC = TipThermoModel::getTipInC(true);
+ PIDTempTarget = currentTempTargetDegC;
+ if (PIDTempTarget) {
+ // Cap the max set point to 450C
+ if (PIDTempTarget > (450)) {
+ //Maximum allowed output
+ PIDTempTarget = (450);
+ }
+ //Safety check that not aiming higher than current tip can measure
+ if (PIDTempTarget > TipThermoModel::getTipMaxInC()) {
+ PIDTempTarget = TipThermoModel::getTipMaxInC();
+ }
+ // Convert the current tip to degree's C
+
+ // As we get close to our target, temp noise causes the system
+ // to be unstable. Use a rolling average to dampen it.
+ // We overshoot by roughly 1 degree C.
+ // This helps stabilize the display.
+ int32_t tError = PIDTempTarget - currentTipTempInC + 1;
+ tError = tError > INT16_MAX ? INT16_MAX : tError;
+ tError = tError < INT16_MIN ? INT16_MIN : tError;
+ tempError.update(tError);
+
+ // Now for the PID!
+
+ // P term - total power needed to hit target temp next cycle.
+ // thermal mass = 1690 milliJ/*C for my tip.
+ // = Watts*Seconds to raise Temp from room temp to +100*C, divided by 100*C.
+ // we divide milliWattsNeeded by 20 to let the I term dominate near the set point.
+ // This is necessary because of the temp noise and thermal lag in the system.
+ // Once we have feed-forward temp estimation we should be able to better tune this.
+
+ int32_t x10WattsNeeded = tempToX10Watts(tError);
+// tempError.average());
+ // note that milliWattsNeeded is sometimes negative, this counters overshoot
+ // from I term's inertia.
+ x10WattsOut += x10WattsNeeded;
+
+ // I term - energy needed to compensate for heat loss.
+ // We track energy put into the system over some window.
+ // Assuming the temp is stable, energy in = energy transfered.
+ // (If it isn't, P will dominate).
+ x10WattsOut += x10WattHistory.average();
+
+ // D term - use sudden temp change to counter fast cooling/heating.
+ // In practice, this provides an early boost if temp is dropping
+ // and counters extra power if the iron is no longer losing temp.
+ // basically: temp - lastTemp
+ // Unfortunately, our temp signal is too noisy to really help.
+
+ }
+ //If the user turns on the option of using an occasional pulse to keep the power bank on
+ if (systemSettings.KeepAwakePulse) {
+
+ if (xTaskGetTickCount() - lastPowerPulseStart
+ > powerPulseRate) {
+ lastPowerPulseStart = xTaskGetTickCount();
+ lastPowerPulseEnd = lastPowerPulseStart
+ + powerPulseDuration;
+ }
+
+ //If current PID is less than the pulse level, check if we want to constrain to the pulse as the floor
+ if (x10WattsOut < systemSettings.KeepAwakePulse
+ && xTaskGetTickCount() < lastPowerPulseEnd) {
+ x10WattsOut = systemSettings.KeepAwakePulse;
+ }
+ }
+
+ //Secondary safety check to forcefully disable header when within ADC noise of top of ADC
+ if (getTipRawTemp(0) > (0x7FFF - 150)) {
+ x10WattsOut = 0;
+ }
+ if (systemSettings.powerLimitEnable
+ && x10WattsOut > (systemSettings.powerLimit * 10)) {
+ setTipX10Watts(systemSettings.powerLimit * 10);
+ } else {
+ setTipX10Watts(x10WattsOut);
+ }
+
+ HAL_IWDG_Refresh(&hiwdg);
+ } else {
+ //ADC interrupt timeout
+ setTipPWM(0);
+ }
+ }
+}
diff --git a/workspace/TS100/Makefile b/workspace/TS100/Makefile
index 4413f2cb..a9868318 100644
--- a/workspace/TS100/Makefile
+++ b/workspace/TS100/Makefile
@@ -1,238 +1,248 @@
-
-ifndef model
-model:=TS100
-endif
-OUTPUT_EXE=$(model)_$(lang)
-ifndef lang
-lang:= EN
-endif
-
-# Discover the source files to build
-SOURCE := $(shell find . -type f -name '*.c')
-SOURCE_CPP := $(shell find . -type f -name '*.cpp')
-SOURCES := $(shell find . -type f -name '*.c*')
-S_SRCS := $(shell find . -type f -name '*.s')
-
-APP_INC_DIR = ./Core/Inc
-CMSIS_DEVICE_INC_DIR = ./Drivers/CMSIS/Device/ST/STM32F1xx/Include
-CMSIS_CORE_INC_DIR = ./Drivers/CMSIS/Include
-HAL_INC_DIR = ./Drivers/STM32F1xx_HAL_Driver/Inc
-HAL_LEGACY_INC_DIR = ./Drivers/STM32F1xx_HAL_Driver/Inc/Legacy
-FRTOS_CMIS_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS
-FRTOS_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/include
-FRTOS_GCC_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3
-
-INCLUDES = -I$(APP_INC_DIR) \
- -I$(CMSIS_DEVICE_INC_DIR)\
- -I$(CMSIS_CORE_INC_DIR) \
- -I$(HAL_INC_DIR) \
- -I$(HAL_LEGACY_INC_DIR) \
- -I$(FRTOS_CMIS_INC_DIR) \
- -I$(FRTOS_INC_DIR) \
- -I$(FRTOS_GCC_INC_DIR)
-# output folder
-HEXFILE_DIR=Hexfile
-
-# temporary objects folder
-OUTPUT_DIR=Objects
-
-# code optimisation ------------------------------------------------------------
-OPTIM=-Os -flto -ffat-lto-objects -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections
-
-
-# global defines ---------------------------------------------------------------
-GLOBAL_DEFINES += -D STM32F103T8Ux -D STM32F1 -D STM32 -D USE_HAL_DRIVER -D STM32F103xB -D USE_RTOS_SYSTICK -D LANG_$(lang) -D LANG -D MODEL_$(model)
-
-# Enable debug code generation
-DEBUG=-g3
-# Without debug code
-#DEBUG=
-
-
-# libs -------------------------------------------------------------------------
-LIBS=
-
-# linker script ----------------------------------------------------------------
-LDSCRIPT=LinkerScript.ld
-
-# ------------------------------------------------------------------------------
-COMPILER=gcc
-# arm-none is the general ARM compiler,
-# arm-atollic is the atollic customised compilers if you have them setup
-COMPILER_PREFIX=arm-none
-# programs ---------------------------------------------------------------------
-CC=$(COMPILER_PREFIX)-eabi-gcc
-CPP=$(COMPILER_PREFIX)-eabi-g++
-AS=$(COMPILER_PREFIX)-eabi-as
-GCOV=$(COMPILER_PREFIX)-eabi-gcov
-OBJCOPY=$(COMPILER_PREFIX)-eabi-objcopy
-OBJDUMP=$(COMPILER_PREFIX)-eabi-objdump
-SIZE=$(COMPILER_PREFIX)-eabi-size
-SREC=srec_cat
-SREC_INFO=srec_info
-
-
-
-
-# linker flags -----------------------------------------------------------------
-LINKER_FLAGS=-Wl,--gc-sections \
- -o$(OUT_HEXFILE).elf \
- -Wl,-Map=$(OUT_HEXFILE).map \
- -mcpu=cortex-m3 \
- -mthumb \
- -mfloat-abi=soft \
- -lm -Os -flto -Wl,--undefined=vTaskSwitchContext \
- --specs=nano.specs
-
-# compiler flags ---------------------------------------------------------------
-CPUFLAGS=-D GCC_ARMCM3 \
- -D ARM_MATH_CM3 \
- -D STM32F10X_MD \
- -mthumb \
- -mcpu=cortex-m3 \
- -mfloat-abi=soft
-
-
-
-CHECKOPTIONS= -Wall \
- -Wextra \
- -Wunused \
- -Wcomment \
- -Wtrigraphs \
- -Wuninitialized \
- -Wmissing-braces \
- -Wfloat-equal \
- -Wunreachable-code \
- -Wswitch-default \
- -Wreturn-type \
- -Wundef \
- -Wparentheses \
- -Wnonnull \
- -Winit-self \
- -Wmissing-include-dirs \
- -Wsequence-point \
- -Wswitch \
- -Wformat \
- -Wsign-compare \
- -Waddress \
- -Waggregate-return \
- -Wmissing-field-initializers \
- -Winline \
- -Wshadow \
- -Wno-unused-parameter \
- -Wdouble-promotion
-
-
-CHECKOPTIONS_C= -Wbad-function-cast
-
-
-CXXFLAGS=$(CPUFLAGS) \
- $(DEBUG) \
- $(INCLUDES) \
- $(GLOBAL_DEFINES) \
- -D${COMPILER} \
- -MMD \
- $(CHECKOPTIONS) \
- -std=c++11 \
- $(OPTIM) \
- -fno-common \
- -ffreestanding \
- -fno-rtti \
- -fno-exceptions \
- -fno-non-call-exceptions \
- -fno-use-cxa-atexit \
- -fno-strict-aliasing \
- -fno-rtti \
- -fno-exceptions \
- -fno-threadsafe-statics \
- -T$(LDSCRIPT)
-
-
-CFLAGS=$(CPUFLAGS) \
- $(DEBUG) \
- $(INCLUDES) \
- $(CHECKOPTIONS_C) \
- $(GLOBAL_DEFINES) \
- -D${COMPILER} \
- -MMD \
- -std=gnu99 \
- $(OPTIM) \
- -fno-common \
- -ffreestanding \
- -T$(LDSCRIPT) \
- -c
-
-
-AFLAGS=$(CPUFLAGS) \
- $(DEBUG) \
- $(INCLUDES)
-
-
-ifeq (${COMPILER}, gcc)
-AFLAGS += -ffunction-sections -fdata-sections
-CFLAGS += -ffunction-sections -fdata-sections
-endif
-
-
-
-OBJS = $(SOURCE:.c=.o)
-OBJS_CPP = $(SOURCE_CPP:.cpp=.o)
-OBJS_S = $(S_SRCS:.s=.o)
-
-
-
-OUT_OBJS=$(addprefix $(OUTPUT_DIR)/,$(OBJS))
-OUT_OBJS_CPP=$(addprefix $(OUTPUT_DIR)/,$(OBJS_CPP))
-OUT_OBJS_S=$(addprefix $(OUTPUT_DIR)/,$(OBJS_S))
-OUT_HEXFILE=$(addprefix $(HEXFILE_DIR)/,$(OUTPUT_EXE))
-
-all: $(OUT_HEXFILE).hex $(OUT_HEXFILE).bin
-
-#
-# The rule to create the target directory
-#
-
-# Create hexfile
-%.hex : %.elf
- $(SIZE) $^
- $(OBJCOPY) $^ -O ihex $@
-
-%.bin : %.elf
- $(SIZE) $^
- $(OBJCOPY) $^ -O binary $@
-
-$(OUT_HEXFILE).elf : $(OUT_OBJS) $(OUT_OBJS_CPP) $(OUT_OBJS_S) Makefile $(LDSCRIPT)
- @test -d $(@D) || mkdir -p $(@D)
- @echo Linking $(OUTPUT_EXE).elf
- @$(CPP) $(CXXFLAGS) $(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) $(LIBS) $(LINKER_FLAGS)
-
-$(OUT_OBJS): $(OUTPUT_DIR)/%.o : %.c Makefile
- @test -d $(@D) || mkdir -p $(@D)
- @echo Compiling ${<}
-# @echo $(CFLAGS)
- @$(CC) -c $(CFLAGS) $< -o $@
- @$(OBJDUMP) -d -S $@ > [email protected]
-
-$(OUT_OBJS_CPP): $(OUTPUT_DIR)/%.o : %.cpp Makefile
- @test -d $(@D) || mkdir -p $(@D)
- @echo Compiling ${<}
- @$(CPP) -c $(CXXFLAGS) $< -o $@
- @$(OBJDUMP) -d -S $@ > [email protected]
-
-$(OUT_OBJS_S): $(OUTPUT_DIR)/%.o: %.s Makefile
- @test -d $(@D) || mkdir -p $(@D)
- @echo 'Building file: $<'
- @echo 'Invoking: MCU GCC Assembler'
- @$(AS) -mcpu=cortex-m3 -mthumb -mfloat-abi=soft $(INCLUDES) -g $< -o $@
- @echo 'Finished building: $<'
- @echo ' '
-
-
-clean :
- rm -Rf $(OUTPUT_DIR)
- rm -Rf $(HEXFILE_DIR)
-
-# pull in dependency info for *existing* .o files
--include $(OUT_OBJS:.o=.d)
--include $(OUT_OBJS_CPP:.o=.d)
-
+
+ifndef model
+model:=TS100
+endif
+OUTPUT_EXE=$(model)_$(lang)
+ifndef lang
+lang:= EN
+endif
+
+# Discover the source files to build
+SOURCE := $(shell find . -type f -name '*.c')
+SOURCE_CPP := $(shell find . -type f -name '*.cpp')
+SOURCES := $(shell find . -type f -name '*.c*')
+S_SRCS := $(shell find . -type f -name '*.s')
+
+APP_INC_DIR = ./Core/Inc
+CMSIS_DEVICE_INC_DIR = ./Core/BSP/Miniware/Vendor/CMSIS/Device/ST/STM32F1xx/Include
+CMSIS_CORE_INC_DIR = ./Core/BSP/Miniware/Vendor/CMSIS/Include
+HAL_INC_DIR = ./Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc
+HAL_LEGACY_INC_DIR = ./Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/Legacy
+FRTOS_CMIS_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS
+FRTOS_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/include
+FRTOS_GCC_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3
+DRIVER_INC_DIR =./Core/Drivers
+BSP_INC_DIR = ./Core/BSP
+MINIWARE_INC_DIR = ./Core/BSP/Miniware
+THREADS_INC_DIR = ./Core/Threads
+
+INCLUDES = -I$(APP_INC_DIR) \
+ -I$(CMSIS_DEVICE_INC_DIR)\
+ -I$(CMSIS_CORE_INC_DIR) \
+ -I$(HAL_INC_DIR) \
+ -I$(HAL_LEGACY_INC_DIR) \
+ -I$(FRTOS_CMIS_INC_DIR) \
+ -I$(FRTOS_INC_DIR) \
+ -I$(FRTOS_GCC_INC_DIR) \
+ -I$(DRIVER_INC_DIR) \
+ -I$(BSP_INC_DIR) \
+ -I$(MINIWARE_INC_DIR) \
+ -I$(THREADS_INC_DIR)
+# output folder
+HEXFILE_DIR=Hexfile
+
+# temporary objects folder
+OUTPUT_DIR=Objects
+
+# code optimisation ------------------------------------------------------------
+OPTIM=-Os -flto -ffat-lto-objects -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections
+
+
+# global defines ---------------------------------------------------------------
+GLOBAL_DEFINES += -D STM32F103T8Ux -D STM32F1 -D STM32 -D USE_HAL_DRIVER -D STM32F103xB -D USE_RTOS_SYSTICK -D LANG_$(lang) -D LANG -D MODEL_$(model)
+
+# Enable debug code generation
+DEBUG=-g3
+# Without debug code
+#DEBUG=
+
+
+# libs -------------------------------------------------------------------------
+LIBS=
+
+# linker script ----------------------------------------------------------------
+LDSCRIPT=LinkerScript.ld
+
+# ------------------------------------------------------------------------------
+COMPILER=gcc
+# arm-none is the general ARM compiler,
+COMPILER_PREFIX=arm-none
+# programs ---------------------------------------------------------------------
+CC=$(COMPILER_PREFIX)-eabi-gcc
+CPP=$(COMPILER_PREFIX)-eabi-g++
+AS=$(COMPILER_PREFIX)-eabi-as
+GCOV=$(COMPILER_PREFIX)-eabi-gcov
+OBJCOPY=$(COMPILER_PREFIX)-eabi-objcopy
+OBJDUMP=$(COMPILER_PREFIX)-eabi-objdump
+SIZE=$(COMPILER_PREFIX)-eabi-size
+SREC=srec_cat
+SREC_INFO=srec_info
+
+
+
+
+# linker flags -----------------------------------------------------------------
+LINKER_FLAGS=-Wl,--gc-sections \
+ -Wl,--wrap=malloc \
+ -Wl,--wrap=free \
+ -o$(OUT_HEXFILE).elf \
+ -Wl,-Map=$(OUT_HEXFILE).map \
+ -mcpu=cortex-m3 \
+ -mthumb \
+ -mfloat-abi=soft \
+ -lm -Os -flto -Wl,--undefined=vTaskSwitchContext \
+ --specs=nano.specs
+
+# compiler flags ---------------------------------------------------------------
+CPUFLAGS=-D GCC_ARMCM3 \
+ -D ARM_MATH_CM3 \
+ -D STM32F10X_MD \
+ -mthumb \
+ -mcpu=cortex-m3 \
+ -mfloat-abi=soft
+
+
+
+CHECKOPTIONS= -Wall \
+ -Wextra \
+ -Wunused \
+ -Wcomment \
+ -Wtrigraphs \
+ -Wuninitialized \
+ -Wmissing-braces \
+ -Wfloat-equal \
+ -Wunreachable-code \
+ -Wswitch-default \
+ -Wreturn-type \
+ -Wundef \
+ -Wparentheses \
+ -Wnonnull \
+ -Winit-self \
+ -Wmissing-include-dirs \
+ -Wsequence-point \
+ -Wswitch \
+ -Wformat \
+ -Wsign-compare \
+ -Waddress \
+ -Waggregate-return \
+ -Wmissing-field-initializers \
+ -Winline \
+ -Wshadow \
+ -Wno-unused-parameter \
+ -Wdouble-promotion \
+ -Werror
+
+
+CHECKOPTIONS_C= -Wbad-function-cast
+
+
+CXXFLAGS=$(CPUFLAGS) \
+ $(DEBUG) \
+ $(INCLUDES) \
+ $(GLOBAL_DEFINES) \
+ -D${COMPILER} \
+ -MMD \
+ $(CHECKOPTIONS) \
+ -std=c++11 \
+ $(OPTIM) \
+ -fno-common \
+ -ffreestanding \
+ -fno-rtti \
+ -fno-exceptions \
+ -fno-non-call-exceptions \
+ -fno-use-cxa-atexit \
+ -fno-strict-aliasing \
+ -fno-rtti \
+ -fno-exceptions \
+ -fno-threadsafe-statics \
+ -T$(LDSCRIPT)
+
+
+CFLAGS=$(CPUFLAGS) \
+ $(DEBUG) \
+ $(INCLUDES) \
+ $(CHECKOPTIONS_C) \
+ $(GLOBAL_DEFINES) \
+ -D${COMPILER} \
+ -MMD \
+ -std=gnu99 \
+ $(OPTIM) \
+ -fno-common \
+ -ffreestanding \
+ -T$(LDSCRIPT) \
+ -c
+
+
+AFLAGS=$(CPUFLAGS) \
+ $(DEBUG) \
+ $(INCLUDES)
+
+
+ifeq (${COMPILER}, gcc)
+AFLAGS += -ffunction-sections -fdata-sections
+CFLAGS += -ffunction-sections -fdata-sections
+endif
+
+
+
+OBJS = $(SOURCE:.c=.o)
+OBJS_CPP = $(SOURCE_CPP:.cpp=.o)
+OBJS_S = $(S_SRCS:.s=.o)
+
+
+
+OUT_OBJS=$(addprefix $(OUTPUT_DIR)/,$(OBJS))
+OUT_OBJS_CPP=$(addprefix $(OUTPUT_DIR)/,$(OBJS_CPP))
+OUT_OBJS_S=$(addprefix $(OUTPUT_DIR)/,$(OBJS_S))
+OUT_HEXFILE=$(addprefix $(HEXFILE_DIR)/,$(OUTPUT_EXE))
+
+all: $(OUT_HEXFILE).hex $(OUT_HEXFILE).bin
+
+#
+# The rule to create the target directory
+#
+
+# Create hexfile
+%.hex : %.elf
+ $(SIZE) $^
+ $(OBJCOPY) $^ -O ihex $@
+
+%.bin : %.elf
+ $(SIZE) $^
+ $(OBJCOPY) $^ -O binary $@
+
+$(OUT_HEXFILE).elf : $(OUT_OBJS) $(OUT_OBJS_CPP) $(OUT_OBJS_S) Makefile $(LDSCRIPT)
+ @test -d $(@D) || mkdir -p $(@D)
+ @echo Linking $(OUTPUT_EXE).elf
+ @$(CPP) $(CXXFLAGS) $(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) $(LIBS) $(LINKER_FLAGS)
+
+$(OUT_OBJS): $(OUTPUT_DIR)/%.o : %.c Makefile
+ @test -d $(@D) || mkdir -p $(@D)
+ @echo Compiling ${<}
+# @echo $(CFLAGS)
+ @$(CC) -c $(CFLAGS) $< -o $@
+ @$(OBJDUMP) -d -S $@ > [email protected]
+
+$(OUT_OBJS_CPP): $(OUTPUT_DIR)/%.o : %.cpp Makefile
+ @test -d $(@D) || mkdir -p $(@D)
+ @echo Compiling ${<}
+ @$(CPP) -c $(CXXFLAGS) $< -o $@
+ @$(OBJDUMP) -d -S $@ > [email protected]
+
+$(OUT_OBJS_S): $(OUTPUT_DIR)/%.o: %.s Makefile
+ @test -d $(@D) || mkdir -p $(@D)
+ @echo 'Building file: $<'
+ @echo 'Invoking: MCU GCC Assembler'
+ @$(AS) -mcpu=cortex-m3 -mthumb -mfloat-abi=soft $(INCLUDES) -g $< -o $@
+ @echo 'Finished building: $<'
+ @echo ' '
+
+
+clean :
+ rm -Rf $(OUTPUT_DIR)
+ rm -Rf $(HEXFILE_DIR)
+
+# pull in dependency info for *existing* .o files
+-include $(OUT_OBJS:.o=.d)
+-include $(OUT_OBJS_CPP:.o=.d)
+
diff --git a/workspace/TS100/Src/syscalls.c b/workspace/TS100/Src/syscalls.c
deleted file mode 100644
index 9f32dad0..00000000
--- a/workspace/TS100/Src/syscalls.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/**
-*****************************************************************************
-**
-** File : syscalls.c
-**
-** Author : Auto-generated by STM32CubeIDE
-**
-** Abstract : STM32CubeIDE Minimal System calls file
-**
-** For more information about which c-functions
-** need which of these lowlevel functions
-** please consult the Newlib libc-manual
-**
-** Environment : STM32CubeIDE MCU
-**
-** Distribution: The file is distributed as is, without any warranty
-** of any kind.
-**
-*****************************************************************************
-**
-** <h2><center>&copy; COPYRIGHT(c) 2018 STMicroelectronics</center></h2>
-**
-** Redistribution and use in source and binary forms, with or without modification,
-** are permitted provided that the following conditions are met:
-** 1. Redistributions of source code must retain the above copyright notice,
-** this list of conditions and the following disclaimer.
-** 2. Redistributions in binary form must reproduce the above copyright notice,
-** this list of conditions and the following disclaimer in the documentation
-** and/or other materials provided with the distribution.
-** 3. Neither the name of STMicroelectronics nor the names of its contributors
-** may be used to endorse or promote products derived from this software
-** without specific prior written permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-**
-**
-*****************************************************************************
-*/
-
-/* Includes */
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <stdio.h>
-#include <signal.h>
-#include <time.h>
-#include <sys/time.h>
-#include <sys/times.h>
-
-
-/* Variables */
-//#undef errno
-extern int errno;
-extern int __io_putchar(int ch) __attribute__((weak));
-extern int __io_getchar(void) __attribute__((weak));
-
-register char * stack_ptr asm("sp");
-
-char *__env[1] = { 0 };
-char **environ = __env;
-
-
-/* Functions */
-void initialise_monitor_handles()
-{
-}
-
-int _getpid(void)
-{
- return 1;
-}
-
-int _kill(int pid, int sig)
-{
- errno = EINVAL;
- return -1;
-}
-
-void _exit (int status)
-{
- _kill(status, -1);
- while (1) {} /* Make sure we hang here */
-}
-
-__attribute__((weak)) int _read(int file, char *ptr, int len)
-{
- int DataIdx;
-
- for (DataIdx = 0; DataIdx < len; DataIdx++)
- {
- *ptr++ = __io_getchar();
- }
-
-return len;
-}
-
-__attribute__((weak)) int _write(int file, char *ptr, int len)
-{
- int DataIdx;
-
- for (DataIdx = 0; DataIdx < len; DataIdx++)
- {
- __io_putchar(*ptr++);
- }
- return len;
-}
-
-int _close(int file)
-{
- return -1;
-}
-
-
-int _fstat(int file, struct stat *st)
-{
- st->st_mode = S_IFCHR;
- return 0;
-}
-
-int _isatty(int file)
-{
- return 1;
-}
-
-int _lseek(int file, int ptr, int dir)
-{
- return 0;
-}
-
-int _open(char *path, int flags, ...)
-{
- /* Pretend like we always fail */
- return -1;
-}
-
-int _wait(int *status)
-{
- errno = ECHILD;
- return -1;
-}
-
-int _unlink(char *name)
-{
- errno = ENOENT;
- return -1;
-}
-
-int _times(struct tms *buf)
-{
- return -1;
-}
-
-int _stat(char *file, struct stat *st)
-{
- st->st_mode = S_IFCHR;
- return 0;
-}
-
-int _link(char *old, char *new)
-{
- errno = EMLINK;
- return -1;
-}
-
-int _fork(void)
-{
- errno = EAGAIN;
- return -1;
-}
-
-int _execve(char *name, char **argv, char **env)
-{
- errno = ENOMEM;
- return -1;
-}
diff --git a/workspace/TS100/Src/sysmem.c b/workspace/TS100/Src/sysmem.c
deleted file mode 100644
index e5e1bc2d..00000000
--- a/workspace/TS100/Src/sysmem.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
-*****************************************************************************
-**
-** File : sysmem.c
-**
-** Author : Auto-generated by STM32CubeIDE
-**
-** Abstract : STM32CubeIDE Minimal System Memory calls file
-**
-** For more information about which c-functions
-** need which of these lowlevel functions
-** please consult the Newlib libc-manual
-**
-** Environment : STM32CubeIDE MCU
-**
-** Distribution: The file is distributed as is, without any warranty
-** of any kind.
-**
-*****************************************************************************
-**
-** <h2><center>&copy; COPYRIGHT(c) 2018 STMicroelectronics</center></h2>
-**
-** Redistribution and use in source and binary forms, with or without modification,
-** are permitted provided that the following conditions are met:
-** 1. Redistributions of source code must retain the above copyright notice,
-** this list of conditions and the following disclaimer.
-** 2. Redistributions in binary form must reproduce the above copyright notice,
-** this list of conditions and the following disclaimer in the documentation
-** and/or other materials provided with the distribution.
-** 3. Neither the name of STMicroelectronics nor the names of its contributors
-** may be used to endorse or promote products derived from this software
-** without specific prior written permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-**
-**
-*****************************************************************************
-*/
-
-/* Includes */
-#include <errno.h>
-#include <stdio.h>
-
-/* Variables */
-extern int errno;
-register char * stack_ptr asm("sp");
-
-/* Functions */
-
-/**
- _sbrk
- Increase program data space. Malloc and related functions depend on this
-**/
-caddr_t _sbrk(int incr)
-{
- extern char end asm("end");
- static char *heap_end;
- char *prev_heap_end;
-
- if (heap_end == 0)
- heap_end = &end;
-
- prev_heap_end = heap_end;
- if (heap_end + incr > stack_ptr)
- {
- errno = ENOMEM;
- return (caddr_t) -1;
- }
-
- heap_end += incr;
-
- return (caddr_t) prev_heap_end;
-}
-
diff --git a/workspace/TS100/build.sh b/workspace/TS100/build.sh
index 77181aed..2fd28523 100755
--- a/workspace/TS100/build.sh
+++ b/workspace/TS100/build.sh
@@ -9,9 +9,8 @@ BUILD_LANGUAGES=()
AVAILABLE_MODELS=("TS100" "TS80")
BUILD_MODELS=()
-usage ()
-{
- echo "Usage : $(basename "$0") [-l <LANG_CODE>] [-m <TS100|TS80>] [-h]
+usage() {
+ echo "Usage : $(basename "$0") [-l <LANG_CODE>] [-m <TS100|TS80>] [-h]
Parameters :
-l LANG_CODE : Force a specific language (E.g. : EN, FR, NL_BE, ...)
@@ -19,59 +18,53 @@ Parameters :
-h : Show this help message
INFO : By default, without parameters, the build is for all platforms and all languages" 1>&2
- exit 1
+ exit 1
}
-checkLastCommand ()
-{
- if [ $? -eq 0 ]
- then
+checkLastCommand() {
+ if [ $? -eq 0 ]; then
echo " [Success]"
echo "*********************************************"
else
forceExit
-fi
+ fi
}
-forceExit ()
-{
+forceExit() {
echo " [Error]"
echo "*********************************************"
echo " -- Stop on error --"
exit 1
}
-isInArray ()
-{
+isInArray() {
local value="$1" # Save first argument in a variable
shift # Shift all arguments to the left (original $1 gets lost)
local array=("$@") # Rebuild the array with rest of arguments
- for item in "${array[@]}"
- do
+ for item in "${array[@]}"; do
[[ $value == "$item" ]] && return 0
done
return 1
}
-while getopts h:l:m: option
-do
+while getopts h:l:m: option; do
case "${option}" in
- h)
- usage
- ;;
- l)
- LANGUAGEREQ=${OPTARG}
- ;;
- m)
- MODEL=${OPTARG}
- ;;
- *)
- usage
- ;;
+ h)
+ usage
+ ;;
+ l)
+ LANGUAGEREQ=${OPTARG}
+ ;;
+ m)
+ MODEL=${OPTARG}
+ ;;
+ *)
+ usage
+ ;;
esac
done
-shift $((OPTIND-1))
+shift $((OPTIND - 1))
echo "*********************************************"
echo " Builder for the"
@@ -82,27 +75,24 @@ echo " "
echo "*********************************************"
# Calculate available languages
-for f in "$TRANSLATION_DIR"/translation_*.json
-do
- AVAILABLE_LANGUAGES+=(`echo $f | tr "[:lower:]" "[:upper:]" | sed "s/[^_]*_//" | sed "s/\.JSON//g"`)
-done
+for f in "$TRANSLATION_DIR"/translation_*.json; do
+ AVAILABLE_LANGUAGES+=($(echo $f | tr "[:lower:]" "[:upper:]" | sed "s/[^_]*_//" | sed "s/\.JSON//g"))
+done
# Checking requested language
echo "Available languages :"
echo " ${AVAILABLE_LANGUAGES[*]}"
echo "Requested languages :"
-if [ -n "$LANGUAGEREQ" ]
-then
- if isInArray "$LANGUAGEREQ" "${AVAILABLE_LANGUAGES[@]}"
- then
- echo " $LANGUAGEREQ"
+if [ -n "$LANGUAGEREQ" ]; then
+ if isInArray "$LANGUAGEREQ" "${AVAILABLE_LANGUAGES[@]}"; then
+ echo " $LANGUAGEREQ"
BUILD_LANGUAGES+=("$LANGUAGEREQ")
else
- echo " $LANGUAGEREQ doesn't exist"
+ echo " $LANGUAGEREQ doesn't exist"
forceExit
fi
else
- echo " [ALL LANGUAGES]"
+ echo " [ALL LANGUAGES]"
BUILD_LANGUAGES+=("${AVAILABLE_LANGUAGES[@]}")
fi
echo "*********************************************"
@@ -111,26 +101,23 @@ echo "*********************************************"
echo "Available models :"
echo " ${AVAILABLE_MODELS[*]}"
echo "Requested models :"
-if [ -n "$MODEL" ]
-then
- if isInArray "$MODEL" "${AVAILABLE_MODELS[@]}"
- then
- echo " $MODEL"
+if [ -n "$MODEL" ]; then
+ if isInArray "$MODEL" "${AVAILABLE_MODELS[@]}"; then
+ echo " $MODEL"
BUILD_MODELS+=("$MODEL")
else
- echo " $MODEL doesn't exist"
+ echo " $MODEL doesn't exist"
forceExit
fi
else
- echo " [ALL MODELS]"
+ echo " [ALL MODELS]"
BUILD_MODELS+=("${AVAILABLE_MODELS[@]}")
fi
echo "*********************************************"
-if [ ${#BUILD_LANGUAGES[@]} -gt 0 ] && [ ${#BUILD_MODELS[@]} -gt 0 ]
-then
+if [ ${#BUILD_LANGUAGES[@]} -gt 0 ] && [ ${#BUILD_MODELS[@]} -gt 0 ]; then
echo "Generating Translation.cpp"
- python3 "$TRANSLATION_DIR/$TRANSLATION_SCRIPT" "$TRANSLATION_DIR"
+ python3 "$TRANSLATION_DIR/$TRANSLATION_SCRIPT" "$TRANSLATION_DIR"
checkLastCommand
echo "Cleaning previous builds"
@@ -139,20 +126,18 @@ then
make clean >/dev/null
checkLastCommand
- for model in "${BUILD_MODELS[@]}"
- do
- for lang in "${BUILD_LANGUAGES[@]}"
- do
+ for model in "${BUILD_MODELS[@]}"; do
+ for lang in "${BUILD_LANGUAGES[@]}"; do
echo "Building firmware for $model in $lang"
make -j lang="$lang" model="$model" >/dev/null
- checkLastCommand
- echo "Cleanup Temp files 1 for $model in $lang"
- rm -rf Objects/Core >/dev/null
checkLastCommand
- echo "Cleanup Temp files 2 for $model in $lang"
- rm -rf Objects/Src >/dev/null
+ echo "Cleanup Temp files for $model in $lang"
+ rm -rf Objects/Core/ >/dev/null
checkLastCommand
done
+ echo "Cleanup model change"
+ rm -rf Objects/ >/dev/null
+ checkLastCommand
done
else
echo "Nothing to build. (no model or language specified)"