mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Backport some master changes
This commit is contained in:
@@ -15,24 +15,13 @@
|
||||
#include "protocol_rx.h"
|
||||
#include "protocol_tx.h"
|
||||
#include "int_n.h"
|
||||
#include "hard_reset.h"
|
||||
|
||||
|
||||
|
||||
void fusb302_start_processing() {
|
||||
/* Initialize the FUSB302B */
|
||||
resetWatchdog();
|
||||
fusb_setup();
|
||||
resetWatchdog();
|
||||
/* Create the policy engine thread. */
|
||||
PolicyEngine::init();
|
||||
|
||||
/* Create the protocol layer threads. */
|
||||
ProtocolReceive::init();
|
||||
ProtocolTransmit::init();
|
||||
ResetHandler::init();
|
||||
resetWatchdog();
|
||||
/* Create the INT_N thread. */
|
||||
ProtocolReceive::init();
|
||||
InterruptHandler::init();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -21,14 +21,13 @@
|
||||
#include "fusb302b.h"
|
||||
#include "protocol_rx.h"
|
||||
#include "protocol_tx.h"
|
||||
#include "hard_reset.h"
|
||||
#include "policy_engine.h"
|
||||
#include "protocol_rx.h"
|
||||
#include "protocol_tx.h"
|
||||
#include "task.h"
|
||||
#include "BSP.h"
|
||||
|
||||
osThreadId InterruptHandler::TaskHandle=NULL;
|
||||
osThreadId InterruptHandler::TaskHandle = NULL;
|
||||
uint32_t InterruptHandler::TaskBuffer[InterruptHandler::TaskStackSize];
|
||||
osStaticThreadDef_t InterruptHandler::TaskControlBlock;
|
||||
|
||||
@@ -41,8 +40,6 @@ void InterruptHandler::init() {
|
||||
void InterruptHandler::Thread(const void *arg) {
|
||||
(void) arg;
|
||||
union fusb_status status;
|
||||
volatile uint32_t events;
|
||||
bool notifSent = false;
|
||||
while (true) {
|
||||
/* If the INT_N line is low */
|
||||
if (xTaskNotifyWait(0x00, 0x0F, NULL,
|
||||
@@ -50,7 +47,6 @@ void InterruptHandler::Thread(const void *arg) {
|
||||
//delay slightly so we catch the crc with better timing
|
||||
osDelay(1);
|
||||
}
|
||||
notifSent = false;
|
||||
/* Read the FUSB302B status and interrupt registers */
|
||||
fusb_get_status(&status);
|
||||
/* If the I_TXSENT or I_RETRYFAIL flag is set, tell the Protocol TX
|
||||
@@ -58,43 +54,23 @@ void InterruptHandler::Thread(const void *arg) {
|
||||
if (status.interrupta & FUSB_INTERRUPTA_I_TXSENT) {
|
||||
ProtocolTransmit::notify(
|
||||
ProtocolTransmit::Notifications::PDB_EVT_PRLTX_I_TXSENT);
|
||||
notifSent = true;
|
||||
}
|
||||
if (status.interrupta & FUSB_INTERRUPTA_I_RETRYFAIL) {
|
||||
ProtocolTransmit::notify(
|
||||
ProtocolTransmit::Notifications::PDB_EVT_PRLTX_I_RETRYFAIL);
|
||||
notifSent = true;
|
||||
}
|
||||
|
||||
/* If the I_GCRCSENT flag is set, tell the Protocol RX thread */
|
||||
//This means a message was recieved with a good CRC
|
||||
if (status.interruptb & FUSB_INTERRUPTB_I_GCRCSENT) {
|
||||
ProtocolReceive::notify(PDB_EVT_PRLRX_I_GCRCSENT);
|
||||
notifSent = true;
|
||||
}
|
||||
|
||||
/* If the I_HARDRST or I_HARDSENT flag is set, tell the Hard Reset
|
||||
* thread */
|
||||
|
||||
if (notifSent == false) {
|
||||
events = 0;
|
||||
if (status.interrupta & FUSB_INTERRUPTA_I_HARDRST) {
|
||||
events |= PDB_EVT_HARDRST_I_HARDRST;
|
||||
notifSent = true;
|
||||
} else if (status.interrupta & FUSB_INTERRUPTA_I_HARDSENT) {
|
||||
events |= PDB_EVT_HARDRST_I_HARDSENT;
|
||||
notifSent = true;
|
||||
}
|
||||
if (events) {
|
||||
ResetHandler::notify(events);
|
||||
}
|
||||
}
|
||||
/* If the I_OCP_TEMP and OVRTEMP flags are set, tell the Policy
|
||||
* Engine thread */
|
||||
if (status.interrupta & FUSB_INTERRUPTA_I_OCP_TEMP
|
||||
&& status.status1 & FUSB_STATUS1_OVRTEMP) {
|
||||
PolicyEngine::notify(PDB_EVT_PE_I_OVRTEMP);
|
||||
notifSent = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "int_n.h"
|
||||
#include <pd.h>
|
||||
#include "protocol_tx.h"
|
||||
#include "hard_reset.h"
|
||||
#include "fusb302b.h"
|
||||
bool PolicyEngine::pdNegotiationComplete;
|
||||
int PolicyEngine::current_voltage_mv;
|
||||
@@ -189,15 +188,15 @@ PolicyEngine::policy_engine_state PolicyEngine::pe_sink_wait_cap() {
|
||||
&& PD_NUMOBJ_GET(&tempMessage) > 0) {
|
||||
/* First, determine what PD revision we're using */
|
||||
if ((hdr_template & PD_HDR_SPECREV) == PD_SPECREV_1_0) {
|
||||
// /* If the other end is using at least version 3.0, we'll
|
||||
// * use version 3.0. */
|
||||
// if ((tempMessage.hdr & PD_HDR_SPECREV) >= PD_SPECREV_3_0) {
|
||||
// hdr_template |= PD_SPECREV_3_0;
|
||||
// /* Otherwise, use 2.0. Don't worry about the 1.0 case
|
||||
// * because we don't have hardware for PD 1.0 signaling. */
|
||||
// } else {
|
||||
hdr_template |= PD_SPECREV_2_0;
|
||||
// }
|
||||
/* If the other end is using at least version 3.0, we'll
|
||||
* use version 3.0. */
|
||||
if ((tempMessage.hdr & PD_HDR_SPECREV) >= PD_SPECREV_3_0) {
|
||||
hdr_template |= PD_SPECREV_3_0;
|
||||
/* Otherwise, use 2.0. Don't worry about the 1.0 case
|
||||
* because we don't have hardware for PD 1.0 signaling. */
|
||||
} else {
|
||||
hdr_template |= PD_SPECREV_2_0;
|
||||
}
|
||||
}
|
||||
return PESinkEvalCap;
|
||||
/* If the message was a Soft_Reset, do the soft reset procedure */
|
||||
@@ -516,11 +515,8 @@ PolicyEngine::policy_engine_state PolicyEngine::pe_sink_hard_reset() {
|
||||
if (_hard_reset_counter > PD_N_HARD_RESET_COUNT) {
|
||||
return PESinkSourceUnresponsive;
|
||||
}
|
||||
|
||||
/* Generate a hard reset signal */
|
||||
ResetHandler::notify(PDB_EVT_HARDRST_RESET);
|
||||
waitForEvent(PDB_EVT_PE_HARD_SENT);
|
||||
|
||||
//So, we could send a hardreset here; however that will cause a power cycle on the PSU end.. Which will then reset this MCU
|
||||
//So therefore we went get anywhere :)
|
||||
/* Increment HardResetCounter */
|
||||
_hard_reset_counter++;
|
||||
|
||||
@@ -537,9 +533,6 @@ PolicyEngine::policy_engine_state PolicyEngine::pe_sink_transition_default() {
|
||||
/* Since we never change our data role from UFP, there is no reason to set
|
||||
* it here. */
|
||||
|
||||
/* Tell the protocol layer we're done with the reset */
|
||||
ResetHandler::notify( PDB_EVT_HARDRST_DONE);
|
||||
|
||||
return PESinkStartup;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user