mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
TS101 (#1695)
* Refactor I2C_SOFT to new #define * Stitch in some of TS101 Update ShowStartupWarnings.cpp Update OLED.hpp Update stm32f1xx_hal_msp.c Update Setup.cpp Update Power.cpp Update Pins.h Update configuration.h Power Muxing Working dual input Voltage handler Scan mode required for differing injected channels Inject both dc readings Update configuration.h Update configuration.h Use htim4 for adc control on TS101 Refactor htim names Add ADC_TRIGGER Speed up BB I2C a lil Update configuration.h Update startup_stm32f103t8ux.S Update configuration.h Add LIS2DH clone LIS2DH gains another clone Create tooling to allow mapping accelerometers onto different buses Update startup_stm32f103t8ux.S Ensure PD IRQ is pulled up * Stitch in some of TS101 Update ShowStartupWarnings.cpp Update OLED.hpp Update stm32f1xx_hal_msp.c Update Setup.cpp Update Power.cpp Update Pins.h Update configuration.h Power Muxing Working dual input Voltage handler Scan mode required for differing injected channels Inject both dc readings Update configuration.h Update configuration.h Use htim4 for adc control on TS101 Refactor htim names Add ADC_TRIGGER Speed up BB I2C a lil Update configuration.h Update startup_stm32f103t8ux.S Update configuration.h Add LIS2DH clone LIS2DH gains another clone Create tooling to allow mapping accelerometers onto different buses Update startup_stm32f103t8ux.S Ensure PD IRQ is pulled up Allow toggle which button enters PD debug * Update Pins.h * Fix hard coded IRQ Pin Update stm32f1xx_it.c * Enable EPR * Tip resistance measurement * TS101 is a direct drive tip Update BSP.cpp * Add S60 and TS101 to builds Update push.yml * Update MOVThread.cpp * Refactor power menu handler * Correct prescaler Forgot to update since I changed the period * Tune in the timer divider for tip control to make PWM less audible --------- Co-authored-by: discip <53649486+discip@users.noreply.github.com>
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
#include "HUB238.hpp"
|
||||
#include "I2CBB.hpp"
|
||||
#include "I2CBB2.hpp"
|
||||
#include "Utils.h"
|
||||
#include "configuration.h"
|
||||
|
||||
#if POW_PD_EXT == 1
|
||||
bool hub238_probe() { return I2CBB::probe(HUB238_ADDR); }
|
||||
bool hub238_probe() { return I2CBB2::probe(HUB238_ADDR); }
|
||||
|
||||
extern int32_t powerSupplyWattageLimit;
|
||||
|
||||
uint16_t hub238_debug_state() {
|
||||
uint8_t status0 = 0;
|
||||
uint8_t status1 = 0;
|
||||
if (!I2CBB::Mem_Read(HUB238_ADDR, HUB238_REG_PD_STATUS0, &status0, 1)) {
|
||||
if (!I2CBB2::Mem_Read(HUB238_ADDR, HUB238_REG_PD_STATUS0, &status0, 1)) {
|
||||
return 0xFFFF;
|
||||
}
|
||||
if (!I2CBB::Mem_Read(HUB238_ADDR, HUB238_REG_PD_STATUS1, &status1, 1)) {
|
||||
if (!I2CBB2::Mem_Read(HUB238_ADDR, HUB238_REG_PD_STATUS1, &status1, 1)) {
|
||||
return 0xFFFF;
|
||||
}
|
||||
return status1 | (((uint16_t)status0) << 8);
|
||||
@@ -81,7 +81,7 @@ uint16_t hub238_getVoltagePDOCurrent(uint8_t voltage) {
|
||||
return 0;
|
||||
}
|
||||
uint8_t temp = 0;
|
||||
if (I2CBB::Mem_Read(HUB238_ADDR, reg, &temp, 1) == true) {
|
||||
if (I2CBB2::Mem_Read(HUB238_ADDR, reg, &temp, 1) == true) {
|
||||
if (temp & HUB238_PDO_DETECTED) {
|
||||
return pdo_slot_to_currentx100(temp);
|
||||
}
|
||||
@@ -156,17 +156,17 @@ void hub238_check_negotiation() {
|
||||
|
||||
uint8_t bestPDO = findBestPDO();
|
||||
|
||||
if (I2CBB::Mem_Read(HUB238_ADDR, HUB238_REG_SRC_PDO, ¤tPDO, 1) == true) {
|
||||
if (I2CBB2::Mem_Read(HUB238_ADDR, HUB238_REG_SRC_PDO, ¤tPDO, 1) == true) {
|
||||
currentPDO >>= 4; // grab upper bits
|
||||
if (currentPDO == bestPDO) {
|
||||
haveSelected = bestPDO;
|
||||
return;
|
||||
}
|
||||
currentPDO = bestPDO << 4;
|
||||
if (I2CBB::Mem_Write(HUB238_ADDR, HUB238_REG_SRC_PDO, ¤tPDO, 1) == true) {
|
||||
if (I2CBB2::Mem_Write(HUB238_ADDR, HUB238_REG_SRC_PDO, ¤tPDO, 1) == true) {
|
||||
|
||||
currentPDO = 0x01; // request for new PDO
|
||||
if (I2CBB::Mem_Write(HUB238_ADDR, HUB238_REG_GO_COMMAND, ¤tPDO, 1) == true) {
|
||||
if (I2CBB2::Mem_Write(HUB238_ADDR, HUB238_REG_GO_COMMAND, ¤tPDO, 1) == true) {
|
||||
haveSelected = bestPDO;
|
||||
vTaskDelay(50);
|
||||
|
||||
@@ -179,7 +179,7 @@ bool hub238_has_run_selection() { return haveSelected != 0xFF; }
|
||||
|
||||
bool hub238_has_negotiated() {
|
||||
uint8_t temp = 0;
|
||||
if (I2CBB::Mem_Read(HUB238_ADDR, HUB238_REG_PD_STATUS1, &temp, 1) == true) {
|
||||
if (I2CBB2::Mem_Read(HUB238_ADDR, HUB238_REG_PD_STATUS1, &temp, 1) == true) {
|
||||
temp >>= 3;
|
||||
return (temp & 0b111) == 0b001; // success
|
||||
}
|
||||
@@ -189,7 +189,7 @@ bool hub238_has_negotiated() {
|
||||
// Return selected source voltage in V
|
||||
uint16_t hub238_source_voltage() {
|
||||
uint8_t temp = 0;
|
||||
if (I2CBB::Mem_Read(HUB238_ADDR, HUB238_REG_PD_STATUS0, &temp, 1) == true) {
|
||||
if (I2CBB2::Mem_Read(HUB238_ADDR, HUB238_REG_PD_STATUS0, &temp, 1) == true) {
|
||||
temp >>= 4;
|
||||
switch (temp) {
|
||||
case 0b0001:
|
||||
@@ -211,7 +211,7 @@ uint16_t hub238_source_voltage() {
|
||||
// Return selected source current in Amps * 100
|
||||
uint8_t hub238_source_currentX100() {
|
||||
uint8_t temp = 0;
|
||||
if (I2CBB::Mem_Read(HUB238_ADDR, HUB238_REG_PD_STATUS0, &temp, 1) == true) {
|
||||
if (I2CBB2::Mem_Read(HUB238_ADDR, HUB238_REG_PD_STATUS0, &temp, 1) == true) {
|
||||
temp &= 0b1111;
|
||||
return pdo_slot_to_currentx100(temp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user