Cleanup FUSB setup
This commit is contained in:
@@ -132,10 +132,15 @@ bool fusb_setup() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* Fully reset the FUSB302B */
|
/* Fully reset the FUSB302B */
|
||||||
// fusb_write_byte( FUSB_RESET, FUSB_RESET_SW_RES);
|
fusb_write_byte(FUSB_RESET, FUSB_RESET_SW_RES);
|
||||||
// osDelay(2);
|
vTaskDelay(TICKS_10MS);
|
||||||
if (!fusb_read_id()) {
|
uint8_t tries = 0;
|
||||||
return false;
|
while (!fusb_read_id()) {
|
||||||
|
vTaskDelay(TICKS_10MS);
|
||||||
|
tries++;
|
||||||
|
if (tries > 5) {
|
||||||
|
return false; // Welp :(
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Turn on all power */
|
/* Turn on all power */
|
||||||
@@ -157,12 +162,12 @@ bool fusb_setup() {
|
|||||||
|
|
||||||
/* Measure CC1 */
|
/* Measure CC1 */
|
||||||
fusb_write_byte(FUSB_SWITCHES0, 0x07);
|
fusb_write_byte(FUSB_SWITCHES0, 0x07);
|
||||||
osDelay(10);
|
vTaskDelay(TICKS_10MS);
|
||||||
uint8_t cc1 = fusb_read_byte(FUSB_STATUS0) & FUSB_STATUS0_BC_LVL;
|
uint8_t cc1 = fusb_read_byte(FUSB_STATUS0) & FUSB_STATUS0_BC_LVL;
|
||||||
|
|
||||||
/* Measure CC2 */
|
/* Measure CC2 */
|
||||||
fusb_write_byte(FUSB_SWITCHES0, 0x0B);
|
fusb_write_byte(FUSB_SWITCHES0, 0x0B);
|
||||||
osDelay(10);
|
vTaskDelay(TICKS_10MS);
|
||||||
uint8_t cc2 = fusb_read_byte(FUSB_STATUS0) & FUSB_STATUS0_BC_LVL;
|
uint8_t cc2 = fusb_read_byte(FUSB_STATUS0) & FUSB_STATUS0_BC_LVL;
|
||||||
|
|
||||||
/* Select the correct CC line for BMC signaling; also enable AUTO_CRC */
|
/* Select the correct CC line for BMC signaling; also enable AUTO_CRC */
|
||||||
|
|||||||
@@ -127,10 +127,10 @@ bool fusb_setup() {
|
|||||||
}
|
}
|
||||||
/* Fully reset the FUSB302B */
|
/* Fully reset the FUSB302B */
|
||||||
fusb_write_byte(FUSB_RESET, FUSB_RESET_SW_RES);
|
fusb_write_byte(FUSB_RESET, FUSB_RESET_SW_RES);
|
||||||
osDelay(2);
|
vTaskDelay(TICKS_10MS);
|
||||||
uint8_t tries = 0;
|
uint8_t tries = 0;
|
||||||
while (!fusb_read_id()) {
|
while (!fusb_read_id()) {
|
||||||
osDelay(10);
|
vTaskDelay(TICKS_10MS);
|
||||||
tries++;
|
tries++;
|
||||||
if (tries > 5) {
|
if (tries > 5) {
|
||||||
return false; // Welp :(
|
return false; // Welp :(
|
||||||
@@ -156,12 +156,12 @@ bool fusb_setup() {
|
|||||||
|
|
||||||
/* Measure CC1 */
|
/* Measure CC1 */
|
||||||
fusb_write_byte(FUSB_SWITCHES0, 0x07);
|
fusb_write_byte(FUSB_SWITCHES0, 0x07);
|
||||||
osDelay(10);
|
vTaskDelay(TICKS_10MS);
|
||||||
uint8_t cc1 = fusb_read_byte(FUSB_STATUS0) & FUSB_STATUS0_BC_LVL;
|
uint8_t cc1 = fusb_read_byte(FUSB_STATUS0) & FUSB_STATUS0_BC_LVL;
|
||||||
|
|
||||||
/* Measure CC2 */
|
/* Measure CC2 */
|
||||||
fusb_write_byte(FUSB_SWITCHES0, 0x0B);
|
fusb_write_byte(FUSB_SWITCHES0, 0x0B);
|
||||||
osDelay(10);
|
vTaskDelay(TICKS_10MS);
|
||||||
uint8_t cc2 = fusb_read_byte(FUSB_STATUS0) & FUSB_STATUS0_BC_LVL;
|
uint8_t cc2 = fusb_read_byte(FUSB_STATUS0) & FUSB_STATUS0_BC_LVL;
|
||||||
|
|
||||||
/* Select the correct CC line for BMC signaling; also enable AUTO_CRC */
|
/* Select the correct CC line for BMC signaling; also enable AUTO_CRC */
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ void InterruptHandler::Thread(const void *arg) {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
// If the irq is low continue, otherwise wait for irq or timeout
|
// If the irq is low continue, otherwise wait for irq or timeout
|
||||||
if (!getFUS302IRQLow()) {
|
if (!getFUS302IRQLow()) {
|
||||||
xTaskNotifyWait(0x00, 0x0F, NULL, PolicyEngine::setupCompleteOrTimedOut() ? 100 : 10);
|
xTaskNotifyWait(0x00, 0x0F, NULL, TICKS_SECOND * 30);
|
||||||
}
|
}
|
||||||
/* Read the FUSB302B status and interrupt registers */
|
/* Read the FUSB302B status and interrupt registers */
|
||||||
fusb_get_status(&status);
|
fusb_get_status(&status);
|
||||||
|
|||||||
@@ -16,10 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "protocol_tx.h"
|
#include "protocol_tx.h"
|
||||||
|
#include "Defines.h"
|
||||||
#include "fusb302b.h"
|
#include "fusb302b.h"
|
||||||
#include "fusbpd.h"
|
#include "fusbpd.h"
|
||||||
#include "policy_engine.h"
|
#include "policy_engine.h"
|
||||||
|
|
||||||
#include <pd.h>
|
#include <pd.h>
|
||||||
|
|
||||||
osThreadId ProtocolTransmit::TaskHandle = NULL;
|
osThreadId ProtocolTransmit::TaskHandle = NULL;
|
||||||
@@ -103,7 +103,7 @@ ProtocolTransmit::protocol_tx_state ProtocolTransmit::protocol_tx_construct_mess
|
|||||||
if (PolicyEngine::isPD3_0()) {
|
if (PolicyEngine::isPD3_0()) {
|
||||||
/* If we're starting an AMS, wait for permission to transmit */
|
/* If we're starting an AMS, wait for permission to transmit */
|
||||||
while (fusb_get_typec_current() != fusb_sink_tx_ok) {
|
while (fusb_get_typec_current() != fusb_sink_tx_ok) {
|
||||||
osDelay(1);
|
vTaskDelay(TICKS_10MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
messageSending = true;
|
messageSending = true;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ void startPOWTask(void const *argument __unused) {
|
|||||||
fusb302_start_processing();
|
fusb302_start_processing();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
vTaskDelay(TICKS_100MS);
|
||||||
// Init any other misc sensors
|
// Init any other misc sensors
|
||||||
postRToSInit();
|
postRToSInit();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user