mirror of
https://github.com/Ralim/IronOS.git
synced 2025-07-23 20:30:38 +02:00
* 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 commit2078b89be7
. * Revert "Remove unused timer funcs" This reverts commit0c693a89cc
. * 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
101 lines
2.8 KiB
C++
101 lines
2.8 KiB
C++
// BSP mapping functions
|
|
|
|
#include "BSP.h"
|
|
#include "I2C_Wrapper.hpp"
|
|
#include "IRQ.h"
|
|
#include "Pins.h"
|
|
#include "Setup.h"
|
|
#include "TipThermoModel.h"
|
|
#include "configuration.h"
|
|
#include "gd32vf103_timer.h"
|
|
#include "history.hpp"
|
|
#include "main.hpp"
|
|
|
|
const uint16_t powerPWM = 255;
|
|
const uint8_t holdoffTicks = 10;
|
|
const uint8_t tempMeasureTicks = 14;
|
|
|
|
uint16_t totalPWM; // Total length of the cycle's ticks
|
|
|
|
void resetWatchdog() { fwdgt_counter_reload(); }
|
|
|
|
uint16_t getHandleTemperature(uint8_t sample) {
|
|
#ifdef TEMP_TMP36
|
|
// 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 = getADCHandleTemp(sample);
|
|
result -= 4965; // remove 0.5V offset
|
|
// 10mV per C
|
|
// 99.29 counts per Deg C above 0C
|
|
result *= 100;
|
|
result /= 993;
|
|
return result;
|
|
#else
|
|
#error Pinecil only uses TMP36
|
|
#endif
|
|
}
|
|
uint16_t getInputVoltageX10(uint16_t divisor, uint8_t sample) {
|
|
uint32_t res = getADCVin(sample);
|
|
res *= 4;
|
|
res /= divisor;
|
|
return res;
|
|
}
|
|
|
|
void unstick_I2C() {
|
|
/* configure SDA/SCL for GPIO */
|
|
GPIO_BC(GPIOB) |= SDA_Pin | SCL_Pin;
|
|
gpio_init(SDA_GPIO_Port, GPIO_MODE_OUT_OD, GPIO_OSPEED_50MHZ, SDA_Pin | SCL_Pin);
|
|
for (int i = 0; i < 8; i++) {
|
|
asm("nop");
|
|
asm("nop");
|
|
asm("nop");
|
|
asm("nop");
|
|
asm("nop");
|
|
GPIO_BOP(GPIOB) |= SCL_Pin;
|
|
asm("nop");
|
|
asm("nop");
|
|
asm("nop");
|
|
asm("nop");
|
|
asm("nop");
|
|
GPIO_BOP(GPIOB) &= SCL_Pin;
|
|
}
|
|
/* connect PB6 to I2C0_SCL */
|
|
/* connect PB7 to I2C0_SDA */
|
|
gpio_init(SDA_GPIO_Port, GPIO_MODE_AF_OD, GPIO_OSPEED_50MHZ, SDA_Pin | SCL_Pin);
|
|
}
|
|
|
|
uint8_t getButtonA() { return (gpio_input_bit_get(KEY_A_GPIO_Port, KEY_A_Pin) == SET) ? 1 : 0; }
|
|
uint8_t getButtonB() { return (gpio_input_bit_get(KEY_B_GPIO_Port, KEY_B_Pin) == SET) ? 1 : 0; }
|
|
|
|
void reboot() {
|
|
// Spin for watchdog
|
|
for (;;) {}
|
|
}
|
|
|
|
void delay_ms(uint16_t count) { delay_1ms(count); }
|
|
uint32_t __get_IPSR(void) {
|
|
return 0; // To shut-up CMSIS
|
|
}
|
|
|
|
bool isTipDisconnected() {
|
|
|
|
uint16_t tipDisconnectedThres = TipThermoModel::getTipMaxInC() - 5;
|
|
uint32_t tipTemp = TipThermoModel::getTipInC();
|
|
return tipTemp > tipDisconnectedThres;
|
|
}
|
|
|
|
void setStatusLED(const enum StatusLED state) {}
|
|
|
|
uint8_t preStartChecks() { return 1; }
|
|
uint64_t getDeviceID() { return dbg_id_get(); }
|
|
|
|
uint8_t getTipResistanceX10() { return TIP_RESISTANCE; }
|
|
|
|
uint8_t preStartChecksDone() { return 1; }
|
|
|
|
uint8_t getTipThermalMass() { return TIP_THERMAL_MASS; } |