USB-PD Support for Sequre S60P (#1883)

* Basic Init

* Rought implementation of fs2711 usb pd interface

* Rought implementation of fs2711 usb pd interface

* Still needs work overcurrent protection keeps getting tripped

* New pdo selection logic

* Update push.yml

* Update push.yml

* Update push.yml

* Update Makefile

* Adds PPS

* Removed unused define

* Adds PPS

* Apply suggestions from code review

Co-authored-by: Ben V. Brown <5425387+Ralim@users.noreply.github.com>

* Code review changes

* Added osDelay include

* New line alignment for S60 softwarei2c

* Code review

* Fixes code review stuff

* code review changes

* Change voltage limit to 20 as that's what the device is rated for

* Shortened wait time for usb pd

* Fixed issues that cuase S60P to restart constantly

* fixing minimal OLED brightness

With the current settings, the OLED turns off if the first level is selected.

* Adds protocol to s60p debug menu

* loosened fs2711 protocol selection timing

* Adds PDO register reading to negotiation logic

* Fixes FS2711 timeout issue and cleans up driver

* Adds FS2711 protocol negotiation to power loop

* Removed uneeded define

* Reverts changes to Font.h and adds clang-format comments

---------

Co-authored-by: Ben V. Brown <Ralim@Ralimtek.com>
Co-authored-by: discip <53649486+discip@users.noreply.github.com>
Co-authored-by: Ben V. Brown <5425387+Ralim@users.noreply.github.com>
This commit is contained in:
Arturo
2024-02-25 05:04:48 -06:00
committed by GitHub
parent 9f6f2f86ff
commit 9ea71bc4d2
12 changed files with 507 additions and 14 deletions

View File

@@ -2,6 +2,7 @@
#include "BSP.h"
#include "BootLogo.h"
#include "FS2711.hpp"
#include "HUB238.hpp"
#include "I2C_Wrapper.hpp"
#include "Pins.h"
@@ -210,13 +211,23 @@ bool isTipDisconnected() {
void setStatusLED(const enum StatusLED state) {}
uint8_t preStartChecks() {
#if POW_PD_EXT == 1
if (!hub238_has_run_selection() && (xTaskGetTickCount() < TICKS_SECOND * 5)) {
return 0;
}
// We check if we are in a "Limited" mode; where we have to run the PWM really fast
// Where as if we are on 9V for example, the tip resistance is enough
uint16_t voltage = hub238_source_voltage();
uint16_t currentx100 = hub238_source_currentX100();
uint16_t voltage = hub238_source_voltage();
uint16_t currentx100 = hub238_source_currentX100();
#endif
#if POW_PD_EXT == 2
if (!FS2711::has_run_selection() && (xTaskGetTickCount() < TICKS_SECOND * 5)) {
return 0;
}
uint16_t voltage = FS2711::source_voltage();
uint16_t currentx100 = FS2711::source_currentx100();
#endif
uint16_t thresholdResistancex10 = ((voltage * 1000) / currentx100) + 5;
if (getTipResistanceX10() <= thresholdResistancex10) {