More shuffle
This commit is contained in:
44
workspace/TS100/Core/BSP/BSP.h
Normal file
44
workspace/TS100/Core/BSP/BSP.h
Normal 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_ */
|
||||||
12
workspace/TS100/Core/BSP/Miniware/README.md
Normal file
12
workspace/TS100/Core/BSP/Miniware/README.md
Normal 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
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
* Author: Ben V. Brown
|
* Author: Ben V. Brown
|
||||||
*/
|
*/
|
||||||
#include "Setup.h"
|
#include "Setup.h"
|
||||||
|
#include "Pins.h"
|
||||||
ADC_HandleTypeDef hadc1;
|
ADC_HandleTypeDef hadc1;
|
||||||
ADC_HandleTypeDef hadc2;
|
ADC_HandleTypeDef hadc2;
|
||||||
DMA_HandleTypeDef hdma_adc1;
|
DMA_HandleTypeDef hdma_adc1;
|
||||||
@@ -32,12 +33,8 @@ static void MX_ADC2_Init(void);
|
|||||||
|
|
||||||
void Setup_HAL() {
|
void Setup_HAL() {
|
||||||
SystemClock_Config();
|
SystemClock_Config();
|
||||||
#ifndef LOCAL_BUILD
|
|
||||||
__HAL_AFIO_REMAP_SWJ_DISABLE()
|
__HAL_AFIO_REMAP_SWJ_DISABLE()
|
||||||
;
|
;
|
||||||
#else
|
|
||||||
__HAL_AFIO_REMAP_SWJ_NOJTAG();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
MX_GPIO_Init();
|
MX_GPIO_Init();
|
||||||
MX_DMA_Init();
|
MX_DMA_Init();
|
||||||
@@ -49,8 +46,8 @@ void Setup_HAL() {
|
|||||||
MX_IWDG_Init();
|
MX_IWDG_Init();
|
||||||
HAL_ADC_Start(&hadc2);
|
HAL_ADC_Start(&hadc2);
|
||||||
HAL_ADCEx_MultiModeStart_DMA(&hadc1, (uint32_t*) ADCReadings, 64); // start DMA of normal readings
|
HAL_ADCEx_MultiModeStart_DMA(&hadc1, (uint32_t*) ADCReadings, 64); // start DMA of normal readings
|
||||||
HAL_ADCEx_InjectedStart(&hadc1); // enable injected readings
|
HAL_ADCEx_InjectedStart(&hadc1); // enable injected readings
|
||||||
HAL_ADCEx_InjectedStart(&hadc2); // enable injected readings
|
HAL_ADCEx_InjectedStart(&hadc2); // enable injected readings
|
||||||
}
|
}
|
||||||
|
|
||||||
// channel 0 -> temperature sensor, 1-> VIN
|
// channel 0 -> temperature sensor, 1-> VIN
|
||||||
@@ -336,7 +333,7 @@ static void MX_TIM2_Init(void) {
|
|||||||
HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig);
|
HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig);
|
||||||
|
|
||||||
sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
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
|
//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.
|
* It takes 4 milliseconds for output to be stable after PWM turns off.
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
#include <hardware.h>
|
|
||||||
#include "stm32f1xx_hal.h"
|
#include "stm32f1xx_hal.h"
|
||||||
|
|
||||||
extern ADC_HandleTypeDef hadc1;
|
extern ADC_HandleTypeDef hadc1;
|
||||||
@@ -29,7 +29,7 @@ extern TIM_HandleTypeDef htim3;
|
|||||||
void Setup_HAL();
|
void Setup_HAL();
|
||||||
uint16_t getADC(uint8_t channel);
|
uint16_t getADC(uint8_t channel);
|
||||||
|
|
||||||
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim); //Since the hal header file does not define this one
|
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); //Since the hal header file does not define this one
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
19
workspace/TS100/Core/BSP/Miniware/preRTOS.c
Normal file
19
workspace/TS100/Core/BSP/Miniware/preRTOS.c
Normal 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);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <hardware.h>
|
#include "Pins.h"
|
||||||
#include "stm32f1xx_hal.h"
|
#include "stm32f1xx_hal.h"
|
||||||
#include "Setup.h"
|
#include "Setup.h"
|
||||||
/**
|
/**
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
// By Ben V. Brown - V2.0 of the TS100 firmware
|
// By Ben V. Brown - V2.0 of the TS100 firmware
|
||||||
|
|
||||||
|
#include "BSP.h"
|
||||||
|
|
||||||
#include <MMA8652FC.hpp>
|
#include <MMA8652FC.hpp>
|
||||||
#include <gui.hpp>
|
#include <gui.hpp>
|
||||||
#include <main.hpp>
|
#include <main.hpp>
|
||||||
@@ -45,13 +48,10 @@ void startMOVTask(void const *argument);
|
|||||||
|
|
||||||
// Main sets up the hardware then hands over to the FreeRTOS kernel
|
// Main sets up the hardware then hands over to the FreeRTOS kernel
|
||||||
int main(void) {
|
int main(void) {
|
||||||
/* Reset of all peripherals, Initializes the Flash interface and the Systick.
|
preRToSInit();
|
||||||
*/
|
|
||||||
HAL_Init();
|
|
||||||
Setup_HAL(); // Setup all the HAL objects
|
|
||||||
HAL_IWDG_Refresh(&hiwdg);
|
|
||||||
setTipX10Watts(0); // force tip off
|
setTipX10Watts(0); // force tip off
|
||||||
FRToSI2C::init(&hi2c1);
|
FRToSI2C::init (&hi2c1);
|
||||||
OLED::initialize(); // start up the LCD
|
OLED::initialize(); // start up the LCD
|
||||||
OLED::setFont(0); // default to bigger font
|
OLED::setFont(0); // default to bigger font
|
||||||
// Testing for which accelerometer is mounted
|
// Testing for which accelerometer is mounted
|
||||||
@@ -69,10 +69,10 @@ int main(void) {
|
|||||||
systemSettings.ShutdownTime = 0; // No accel -> disable sleep
|
systemSettings.ShutdownTime = 0; // No accel -> disable sleep
|
||||||
systemSettings.sensitivity = 0;
|
systemSettings.sensitivity = 0;
|
||||||
}
|
}
|
||||||
HAL_IWDG_Refresh(&hiwdg);
|
resetWatchdog();
|
||||||
settingsWereReset = restoreSettings(); // load the settings from flash
|
settingsWereReset = restoreSettings(); // load the settings from flash
|
||||||
|
|
||||||
HAL_IWDG_Refresh(&hiwdg);
|
resetWatchdog();
|
||||||
|
|
||||||
/* Create the thread(s) */
|
/* Create the thread(s) */
|
||||||
/* definition and creation of GUITask */
|
/* definition and creation of GUITask */
|
||||||
@@ -200,7 +200,7 @@ void startPIDTask(void const *argument __unused) {
|
|||||||
setTipX10Watts(x10WattsOut);
|
setTipX10Watts(x10WattsOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
HAL_IWDG_Refresh(&hiwdg);
|
HAL_IWDG_Refresh (&hiwdg);
|
||||||
} else {
|
} else {
|
||||||
//ADC interrupt timeout
|
//ADC interrupt timeout
|
||||||
setTipPWM(0);
|
setTipPWM(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user