1
0
forked from me/IronOS

More shuffle

This commit is contained in:
Ben V. Brown
2020-05-29 21:39:12 +10:00
parent fd700aecb9
commit 8d59b072ef
9 changed files with 504 additions and 432 deletions

View File

@@ -0,0 +1,44 @@
#include "defines.h"
#include "stdint.h"
#include "UnitSettings.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();
#ifdef __cplusplus
}
#endif
#endif /* BSP_BSP_H_ */

View File

@@ -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

View File

@@ -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();

View File

@@ -11,7 +11,7 @@
#ifdef __cplusplus
extern "C" {
#endif
#include <hardware.h>
#include "stm32f1xx_hal.h"
extern ADC_HandleTypeDef hadc1;

View File

@@ -0,0 +1,19 @@
/*
* preRTOS.c
*
* Created on: 29 May 2020
* Author: Ralim
*/
#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
HAL_Delay(50);
HAL_GPIO_WritePin(OLED_RESET_GPIO_Port, OLED_RESET_Pin, GPIO_PIN_SET);
HAL_Delay(50);
}

View File

@@ -1,4 +1,4 @@
#include <hardware.h>
#include "Pins.h"
#include "stm32f1xx_hal.h"
#include "Setup.h"
/**

View File

@@ -1,4 +1,7 @@
// By Ben V. Brown - V2.0 of the TS100 firmware
#include "BSP.h"
#include <MMA8652FC.hpp>
#include <gui.hpp>
#include <main.hpp>
@@ -45,11 +48,8 @@ void startMOVTask(void const *argument);
// 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
@@ -69,10 +69,10 @@ int main(void) {
systemSettings.ShutdownTime = 0; // No accel -> disable sleep
systemSettings.sensitivity = 0;
}
HAL_IWDG_Refresh(&hiwdg);
resetWatchdog();
settingsWereReset = restoreSettings(); // load the settings from flash
HAL_IWDG_Refresh(&hiwdg);
resetWatchdog();
/* Create the thread(s) */
/* definition and creation of GUITask */