* Remove unused includes * Adding in submodule * Move fusb functions to the BSP * Remove old code * Creating IronOS PD integration wrapper * Redirect to wrapper * pd lib updates * fix Docker build * Finish linking across * Cleanup * Update Makefile * Update push.yml * Update push.yml * PD -> Compensate for different tick rates * Update codeql-analysis.yml * Fix PD #define for @Firebie * Check irq low at start * Update BSP.h * Update main.cpp * Closer delay * Update OLED.cpp * Bugfix trying to start QC too early * Missing fusb shouldnt hang qc * Update FreeRTOSConfig.h * Update the GD drivers * Update Pinecil IRQ setup * Redirect printf() to uart * Update Power.cpp * Adding extras to PD state * Update USBPD.cpp * Delay in printf * Iterate once before delay on start * Update usb-pd * master usb-pd now * Format gd libs * Update gd32vf103_bkp.c * Guard with PD timeout * Remove CodeQL * Slow for testing, fix runt pulses at start * Fix runt pulse in read size 1 * Cleaner probing setup * Testing delay during stop gen in read 1 * Update I2C driver * Update gd32vf103_i2c.c * Cleaning up i2c wrapper a little, given up on dma for rx * Update preRTOS.cpp * Update Setup.cpp * Update MOVThread.cpp * Slow down UART to work with new clock config * Better ack setup for 2 byte read * Cleanup POW_PD so cant be lost in #includes * tipResistance -> TIP_RESISTANCE * handle NOP race on len==2 * Update configuration.h * Dont use neg timeout to mask anymore * Not required for MHP * Fix up source display Miniware * Fix race on PD init * Update POWThread.cpp * Update formatting * MHP format * Update push.yml * Faster TS80P I2C * Bugfix for IRQ handlers * Correctly handle I2C race on PD access * Fix CI error (unused var) and MHP IRQ * Test Pinecil alt ADC mode
70 lines
2.5 KiB
C++
70 lines
2.5 KiB
C++
// By Ben V. Brown - V2.0 of the TS100 firmware
|
|
|
|
/*
|
|
* Main.cpp bootstraps the device and then hands over to FreeRTOS and the threads
|
|
*/
|
|
|
|
#include "main.hpp"
|
|
#include "BSP.h"
|
|
#include "Settings.h"
|
|
#include "cmsis_os.h"
|
|
#include "power.hpp"
|
|
AccelType DetectedAccelerometerVersion = AccelType::Scanning;
|
|
bool settingsWereReset = false;
|
|
// FreeRTOS variables
|
|
|
|
osThreadId GUITaskHandle;
|
|
static const size_t GUITaskStackSize = 1024 / 4;
|
|
uint32_t GUITaskBuffer[GUITaskStackSize];
|
|
osStaticThreadDef_t GUITaskControlBlock;
|
|
|
|
osThreadId PIDTaskHandle;
|
|
static const size_t PIDTaskStackSize = 1024 / 4;
|
|
uint32_t PIDTaskBuffer[PIDTaskStackSize];
|
|
osStaticThreadDef_t PIDTaskControlBlock;
|
|
|
|
osThreadId MOVTaskHandle;
|
|
static const size_t MOVTaskStackSize = 1024 / 4;
|
|
uint32_t MOVTaskBuffer[MOVTaskStackSize];
|
|
osStaticThreadDef_t MOVTaskControlBlock;
|
|
|
|
osThreadId POWTaskHandle;
|
|
static const size_t POWTaskStackSize = 512 / 4;
|
|
uint32_t POWTaskBuffer[POWTaskStackSize];
|
|
osStaticThreadDef_t POWTaskControlBlock;
|
|
|
|
// End FreeRTOS
|
|
// Main sets up the hardware then hands over to the FreeRTOS kernel
|
|
int main(void) {
|
|
preRToSInit();
|
|
setTipX10Watts(0); // force tip off
|
|
resetWatchdog();
|
|
// Testing for which accelerometer is mounted
|
|
settingsWereReset = loadSettings(); // load the settings from flash
|
|
resetWatchdog();
|
|
/* Create the thread(s) */
|
|
|
|
/* definition and creation of PIDTask - Heating control*/
|
|
osThreadStaticDef(PIDTask, startPIDTask, osPriorityRealtime, 0, PIDTaskStackSize, PIDTaskBuffer, &PIDTaskControlBlock);
|
|
PIDTaskHandle = osThreadCreate(osThread(PIDTask), NULL);
|
|
|
|
/* definition and creation of POWTask - Power management for QC / PD */
|
|
osThreadStaticDef(POWTask, startPOWTask, osPriorityAboveNormal, 0, POWTaskStackSize, POWTaskBuffer, &POWTaskControlBlock);
|
|
POWTaskHandle = osThreadCreate(osThread(POWTask), NULL);
|
|
|
|
/* definition and creation of MOVTask - Accelerometer management */
|
|
osThreadStaticDef(MOVTask, startMOVTask, osPriorityNormal, 0, MOVTaskStackSize, MOVTaskBuffer, &MOVTaskControlBlock);
|
|
MOVTaskHandle = osThreadCreate(osThread(MOVTask), NULL);
|
|
|
|
/* definition and creation of GUITask - The OLED control & update*/
|
|
osThreadStaticDef(GUITask, startGUITask, osPriorityBelowNormal, 0, GUITaskStackSize, GUITaskBuffer, &GUITaskControlBlock);
|
|
GUITaskHandle = osThreadCreate(osThread(GUITask), NULL);
|
|
|
|
resetWatchdog();
|
|
|
|
/* Start scheduler */
|
|
osKernelStart();
|
|
/* We should never get here as control is now taken by the scheduler */
|
|
for (;;) {}
|
|
}
|