aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBen V. Brown <[email protected]>2020-09-05 20:19:12 +1000
committerBen V. Brown <[email protected]>2020-09-05 20:19:12 +1000
commit12cf20233836f2f0d4f85d6571e4a9613f7146fd (patch)
treed9bfb3de2895308a083e06fcc5fd560e5b18f238
parent11e583be63a164b11d582d730c0721bd15bfbd1f (diff)
downloadIronOS-12cf20233836f2f0d4f85d6571e4a9613f7146fd.tar.gz
IronOS-12cf20233836f2f0d4f85d6571e4a9613f7146fd.zip
Remove reset handler
-rw-r--r--workspace/TS100/Core/Drivers/FUSB302/fusbpd.cpp2
-rw-r--r--workspace/TS100/Core/Drivers/FUSB302/hard_reset.cpp152
-rw-r--r--workspace/TS100/Core/Drivers/FUSB302/hard_reset.h63
-rw-r--r--workspace/TS100/Core/Drivers/FUSB302/int_n.cpp17
-rw-r--r--workspace/TS100/Core/Drivers/FUSB302/policy_engine.cpp11
5 files changed, 2 insertions, 243 deletions
diff --git a/workspace/TS100/Core/Drivers/FUSB302/fusbpd.cpp b/workspace/TS100/Core/Drivers/FUSB302/fusbpd.cpp
index b48c42fa..fb8c833c 100644
--- a/workspace/TS100/Core/Drivers/FUSB302/fusbpd.cpp
+++ b/workspace/TS100/Core/Drivers/FUSB302/fusbpd.cpp
@@ -15,12 +15,10 @@
#include "protocol_rx.h"
#include "protocol_tx.h"
#include "int_n.h"
-#include "hard_reset.h"
void fusb302_start_processing() {
/* Initialize the FUSB302B */
fusb_setup();
- ResetHandler::init();
PolicyEngine::init();
ProtocolTransmit::init();
ProtocolReceive::init();
diff --git a/workspace/TS100/Core/Drivers/FUSB302/hard_reset.cpp b/workspace/TS100/Core/Drivers/FUSB302/hard_reset.cpp
deleted file mode 100644
index 97ffdd71..00000000
--- a/workspace/TS100/Core/Drivers/FUSB302/hard_reset.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * PD Buddy Firmware Library - USB Power Delivery for everyone
- * Copyright 2017-2018 Clayton G. Hobbs
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "hard_reset.h"
-#include "fusbpd.h"
-#include <pd.h>
-#include "policy_engine.h"
-#include "protocol_rx.h"
-#include "protocol_tx.h"
-#include "fusb302b.h"
-
-osThreadId ResetHandler::TaskHandle = NULL;
-uint32_t ResetHandler::TaskBuffer[ResetHandler::TaskStackSize];
-osStaticThreadDef_t ResetHandler::TaskControlBlock;
-
-/*
- * PRL_HR_Reset_Layer state
- */
-ResetHandler::hardrst_state ResetHandler::hardrst_reset_layer() {
- /* First, wait for the signal to run a hard reset. */
- eventmask_t evt = waitForEvent(
- PDB_EVT_HARDRST_RESET | PDB_EVT_HARDRST_I_HARDRST);
- if (evt & (PDB_EVT_HARDRST_RESET | PDB_EVT_HARDRST_I_HARDRST)) {
- /* Reset the Protocol RX machine */
- ProtocolReceive::notify( PDB_EVT_PRLRX_RESET);
- taskYIELD();
- /* Reset the Protocol TX machine */
- ProtocolTransmit::notify(
- ProtocolTransmit::Notifications::PDB_EVT_PRLTX_RESET);
- taskYIELD();
- /* Continue the process based on what event started the reset. */
- if (evt & PDB_EVT_HARDRST_RESET) {
- /* Policy Engine started the reset. */
- return PRLHRRequestHardReset;
- } else {
- /* PHY started the reset */
- return PRLHRIndicateHardReset;
- }
- } else {
- return PRLHRResetLayer;
- }
-}
-
-ResetHandler::hardrst_state ResetHandler::hardrst_indicate_hard_reset() {
- /* Tell the PE that we're doing a hard reset */
- PolicyEngine::notify( PDB_EVT_PE_RESET);
-
- return PRLHRWaitPE;
-}
-
-ResetHandler::hardrst_state ResetHandler::hardrst_request_hard_reset() {
- /* Tell the PHY to send a hard reset */
- fusb_send_hardrst();
-
- return PRLHRWaitPHY;
-}
-
-ResetHandler::hardrst_state ResetHandler::hardrst_wait_phy() {
- /* Wait for the PHY to tell us that it's done sending the hard reset */
- waitForEvent(PDB_EVT_HARDRST_I_HARDSENT, PD_T_HARD_RESET_COMPLETE);
-
- /* Move on no matter what made us stop waiting. */
- return PRLHRHardResetRequested;
-}
-
-ResetHandler::hardrst_state ResetHandler::hardrst_hard_reset_requested() {
- /* Tell the PE that the hard reset was sent */
- PolicyEngine::notify( PDB_EVT_PE_HARD_SENT);
-
- return PRLHRWaitPE;
-}
-
-ResetHandler::hardrst_state ResetHandler::hardrst_wait_pe() {
- /* Wait for the PE to tell us that it's done */
- waitForEvent(PDB_EVT_HARDRST_DONE);
-
- return PRLHRComplete;
-}
-
-ResetHandler::hardrst_state ResetHandler::hardrst_complete() {
- /* I'm not aware of anything we have to tell the FUSB302B, so just finish
- * the reset routine. */
- return PRLHRResetLayer;
-}
-
-void ResetHandler::init() {
- osThreadStaticDef(rstHand, Thread, PDB_PRIO_PRL, 0, TaskStackSize,
- TaskBuffer, &TaskControlBlock);
- TaskHandle = osThreadCreate(osThread(rstHand), NULL);
-}
-
-void ResetHandler::notify(uint32_t notification) {
- if (TaskHandle != NULL) {
- xTaskNotify(TaskHandle, notification, eNotifyAction::eSetBits);
- }
-}
-
-void ResetHandler::Thread(const void *arg) {
- (void) arg;
- ResetHandler::hardrst_state state = PRLHRResetLayer;
-
- while (true) {
- switch (state) {
- case PRLHRResetLayer:
- state = hardrst_reset_layer();
- break;
- case PRLHRIndicateHardReset:
- state = hardrst_indicate_hard_reset();
- break;
- case PRLHRRequestHardReset:
- state = hardrst_request_hard_reset();
- break;
- case PRLHRWaitPHY:
- state = hardrst_wait_phy();
- break;
- case PRLHRHardResetRequested:
- state = hardrst_hard_reset_requested();
- break;
- case PRLHRWaitPE:
- state = hardrst_wait_pe();
- break;
- case PRLHRComplete:
- state = hardrst_complete();
- break;
- default:
- /* This is an error. It really shouldn't happen. We might
- * want to handle it anyway, though. */
- state = PRLHRResetLayer;
- break;
- }
- }
-}
-
-uint32_t ResetHandler::waitForEvent(uint32_t mask, uint32_t ticksToWait) {
- uint32_t pulNotificationValue;
- xTaskNotifyWait(0x00, mask, &pulNotificationValue, ticksToWait);
- return pulNotificationValue;
-}
diff --git a/workspace/TS100/Core/Drivers/FUSB302/hard_reset.h b/workspace/TS100/Core/Drivers/FUSB302/hard_reset.h
deleted file mode 100644
index 9466b33c..00000000
--- a/workspace/TS100/Core/Drivers/FUSB302/hard_reset.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * PD Buddy Firmware Library - USB Power Delivery for everyone
- * Copyright 2017-2018 Clayton G. Hobbs
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef PDB_HARD_RESET_H
-#define PDB_HARD_RESET_H
-
-#include <pd.h>
-
-/* Events for the Hard Reset thread */
-#define PDB_EVT_HARDRST_RESET EVENT_MASK(0)
-#define PDB_EVT_HARDRST_I_HARDRST EVENT_MASK(1)
-#define PDB_EVT_HARDRST_I_HARDSENT EVENT_MASK(2)
-#define PDB_EVT_HARDRST_DONE EVENT_MASK(3)
-
-class ResetHandler {
-public:
- static void init();
- static void notify(uint32_t notification);
-private:
- static void Thread(const void *arg);
- static osThreadId TaskHandle;
- static const size_t TaskStackSize = 1536 / 2;
- static uint32_t TaskBuffer[TaskStackSize];
- static osStaticThreadDef_t TaskControlBlock;
- static uint32_t waitForEvent(uint32_t mask, uint32_t ticksToWait =
- portMAX_DELAY);
-
- /*
- * Hard Reset machine states
- */
- enum hardrst_state {
- PRLHRResetLayer,
- PRLHRIndicateHardReset,
- PRLHRRequestHardReset,
- PRLHRWaitPHY,
- PRLHRHardResetRequested,
- PRLHRWaitPE,
- PRLHRComplete
- };
- static hardrst_state hardrst_reset_layer();
- static hardrst_state hardrst_indicate_hard_reset();
- static hardrst_state hardrst_request_hard_reset();
- static hardrst_state hardrst_wait_phy();
- static hardrst_state hardrst_hard_reset_requested();
- static hardrst_state hardrst_wait_pe();
- static hardrst_state hardrst_complete();
-};
-
-#endif /* PDB_HARD_RESET_H */
diff --git a/workspace/TS100/Core/Drivers/FUSB302/int_n.cpp b/workspace/TS100/Core/Drivers/FUSB302/int_n.cpp
index 1206928e..7f5fd4bf 100644
--- a/workspace/TS100/Core/Drivers/FUSB302/int_n.cpp
+++ b/workspace/TS100/Core/Drivers/FUSB302/int_n.cpp
@@ -21,7 +21,6 @@
#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"
@@ -73,22 +72,6 @@ void InterruptHandler::Thread(const void *arg) {
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
diff --git a/workspace/TS100/Core/Drivers/FUSB302/policy_engine.cpp b/workspace/TS100/Core/Drivers/FUSB302/policy_engine.cpp
index 0e8464fc..4c2a5127 100644
--- a/workspace/TS100/Core/Drivers/FUSB302/policy_engine.cpp
+++ b/workspace/TS100/Core/Drivers/FUSB302/policy_engine.cpp
@@ -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;
@@ -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;
}