Files
IronOS/source/Core/BSP/BSP.h
Ben V. Brown 1fbcdcdf98 Pinecil V2 (#1341)
* Add SDK

* fork

* massaging makefile

* Drop git module

* Bring in sdk as its broken

Far, Far to much crap to fix with regex now

* Remove bl706

* rf_para_flash_t is missing defs

* Remove crapton of junk

* Remove yet more

* Poking I2C

* Update peripheral_config.h

* Update pinmux_config.h

* Update preRTOS.cpp

* Update main.hpp

* Setup template

* Verbose boot

* I2C ish

* Update I2C_Wrapper.cpp

* Update main.cpp

* Turn off I2C reading for now

* Display running

* Roughing out scheduling timer0

* Starting ADC setup

* Working scheduling of ADC 🎉

* Format adc headers

* Update IRQ.cpp

* Buttons working

* Slow down I2C

* Poking IRQ

* Larger stack required

* Accel on

* Trying to chase down why __libc_init_array isnt working yet

* Working c++

* Cleanup

* Bump stacks

* I2C wake part workaround

* Cleanup

* Working PWM init

* qc draft

* Hookup PWM

* Stable enough ADC

* ADC timing faster + timer without HAL

* Silence

* Remove boot banner

* Tuning in ADC

* Wake PID after ADC

* Remove unused hal

* Draft flash settings

* Working settings save & restore

* Update to prod model

* Cleanup

* NTC thermistor

* Correct adc gain

* Rough tip resistance progress

* Scratch out resistance awareness of the tip

* better adc settings

* Tweaking ADC

* ADC tweaking

* Make adc range scalable

* Update Dockerfile

* Update configuration.h

* Can read same ADC twice in a row

* ADC Setup

* Update PIDThread.cpp

* Lesser adc backoff

* Update USBPD.h

* Add device ID

* Update BSP_Power.h

* Update BSP.cpp

* DrawHex dynamicLength

* Shorter ID padding

* Show validation code

* tip measurement

* Create access for w0w1

* Expose w0 w1

* Enable debug

* crc32

* Device validation

* wip starting epr

* Logic refactor

* Safer PWM Init

* PD cleanups

* Update bl702_pwm.c

* Update power.cpp

* Update usb-pd

* io

* EPR decode

* Better gui for showing pd specs

* Rough handler for capabilities

* EPR

* Fix > 25V input

* Perform pow step after PPS

* Update BSP.cpp

* Fix timer output

* QC3

* Add tip resistance view

* Hold PD negotiation until detection is done for tip res

* Get Thermal mass

* Tip res =0 protection

* Update PIDThread.cpp

* Update GUIThread.cpp

* Rewrite tip resistance measurement

* Update GUIThread.cpp

* Fix fallback

* Far better tip resistance measurement

* Fix QC 0.6V D-

* Convert the interpolator to int32

* Correct the NTC lookup

* Update BSP.cpp

* Update Setup.cpp

* .

Update configuration #defines

More backported functions

* Update usb-pd

* More missed updates

* Refactor BSP

Magic BSP -> PinecilV2
Pine64 BSP -> Pinecil

Update Makefile

* Add Pinecilv2 to CI

* Pinecil v2 multi-lang

Update push.yml

* Update HallSensor.md

* Update README.md

* Fix wrong prestartcheck default

* Fix logo mapping

* Update Makefile

* Remove unused font block

* Style

* Style

* Remove unused timer funcs

* More culling TS80P

* Revert "More culling TS80P"

This reverts commit 2078b89be7.

* Revert "Remove unused timer funcs"

This reverts commit 0c693a89cc.

* Make VBus check maskable

* Remove DMA half transfer

* Drop using brightness and invert icons and go back to text

Saves flash space

* Refactor settings UI drawing descriptions

* Shorten setting function names

* Store bin file assets

* Fix MHP prestart
2022-08-19 15:39:37 +10:00

106 lines
3.5 KiB
C

#include "BSP_Flash.h"
#include "BSP_PD.h"
#include "BSP_Power.h"
#include "BSP_QC.h"
#include "Defines.h"
#include "configuration.h"
#include <stdbool.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
// maximum htim2 PWM value
extern const uint16_t powerPWM;
// htim2.Init.Period, the full PWM cycle
extern uint16_t totalPWM;
// Called first thing in main() to init the hardware
void preRToSInit();
// Called once the RToS has started for any extra work
void postRToSInit();
// Called once from preRToSInit()
void BSPInit(void);
// 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(const uint8_t pulse, const bool shouldUseFastModePWM);
// Returns the Handle temp in C, X10
uint16_t getHandleTemperature(uint8_t sample);
// 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
void showBootLogoIfavailable();
// delay wrapper for delay using the hardware timer (used before RTOS)
void delay_ms(uint16_t count);
// Probe if the Hall sensor is fitted to the unit
bool getHallSensorFitted();
// If the iron has a hall effect sensor in the handle, return an signed count of the reading
// If the sensor is single polarity (or polarity insensitive) just return 0..32768
int16_t getRawHallEffect();
// Returns true if power is from dumb "DC" input rather than "smart" QC or PD
bool getIsPoweredByDCIN();
// Logs the system state to a debug interface if supported
void log_system_state(int32_t PWMWattsx10);
// Returns true if the tip is disconnected
bool isTipDisconnected();
// Return hardware unique ID if possible
uint64_t getDeviceID();
// If device has burned in validation code's, return the code
uint32_t getDeviceValidation();
// If device validation passes returns 0
uint8_t getDeviceValidationStatus();
// Status LED controls
enum StatusLED {
LED_OFF = 0, // Turn off status led
LED_STANDBY, // unit is in sleep /standby
LED_HEATING, // The unit is heating up to temperature
LED_HOT, // The unit is at operating temperature
LED_COOLING_STILL_HOT, // The unit is off and cooling but still hot
LED_UNKNOWN, //
};
void setStatusLED(const enum StatusLED state);
// preStartChecks are run until they return 0
// By the PID, after each ADC sample comes in
// For example, on the MHP30 this is used to figure out the resistance of the hotplate
uint8_t preStartChecks();
uint8_t preStartChecksDone();
#ifdef __cplusplus
}
#endif
#endif /* BSP_BSP_H_ */