From 4c2fb11d3269b8e43ef0ef51e087e0bd07c10e5d Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 16 Jun 2020 21:25:28 +1000 Subject: [PATCH] Filter returned WFE --- workspace/TS100/Core/BSP/Miniware/Power.cpp | 24 ++++++++----------- .../TS100/Core/Drivers/FUSB302/hard_reset.cpp | 4 ++-- .../TS100/Core/Drivers/FUSB302/int_n.cpp | 2 ++ workspace/TS100/Core/Drivers/FUSB302/pd.h | 2 +- .../Core/Drivers/FUSB302/policy_engine.cpp | 7 +++--- .../Core/Drivers/FUSB302/protocol_rx.cpp | 6 +++-- .../Core/Drivers/FUSB302/protocol_tx.cpp | 9 ++++--- workspace/TS100/Core/Src/main.cpp | 16 ++++++------- 8 files changed, 35 insertions(+), 35 deletions(-) diff --git a/workspace/TS100/Core/BSP/Miniware/Power.cpp b/workspace/TS100/Core/BSP/Miniware/Power.cpp index 3faeedb5..d65c5d4f 100644 --- a/workspace/TS100/Core/BSP/Miniware/Power.cpp +++ b/workspace/TS100/Core/BSP/Miniware/Power.cpp @@ -8,7 +8,7 @@ bool FUSB302_present = false; void power_probe() { // If TS80 probe for QC // If TS100 - noop -#ifdef defined(MODEL_TS80)+defined(MODEL_TS80P)>0 +#if defined(MODEL_TS80)+defined(MODEL_TS80P)>0 startQC(systemSettings.voltageDiv); seekQC((systemSettings.cutoutSetting) ? 120 : 90, @@ -18,31 +18,27 @@ void power_probe() { } void power_check() { -#ifdef defined(MODEL_TS80)+defined(MODEL_TS80P)>0 +#if defined(MODEL_TS80)+defined(MODEL_TS80P)>0 QC_resync(); #endif } uint8_t usb_pd_detect() { #ifdef MODEL_TS80P FUSB302_present = fusb302_detect(); - if (FUSB302_present) { - GPIO_InitTypeDef GPIO_InitStruct; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; - GPIO_InitStruct.Pin = GPIO_PIN_9; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_PULLUP; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - } + GPIO_InitTypeDef GPIO_InitStruct; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; + GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_PULLUP; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); return FUSB302_present; #endif return false; } uint8_t pd_irq_read() { #ifdef MODEL_TS80P - if (FUSB302_present) { - return HAL_GPIO_ReadPin(INT_PD_GPIO_Port, INT_PD_Pin) == GPIO_PIN_SET ? - 1 : 0; - } + return HAL_GPIO_ReadPin(INT_PD_GPIO_Port, INT_PD_Pin) == GPIO_PIN_SET ? + 1 : 0; #endif return 0; } diff --git a/workspace/TS100/Core/Drivers/FUSB302/hard_reset.cpp b/workspace/TS100/Core/Drivers/FUSB302/hard_reset.cpp index 0f81f646..772aa6b6 100644 --- a/workspace/TS100/Core/Drivers/FUSB302/hard_reset.cpp +++ b/workspace/TS100/Core/Drivers/FUSB302/hard_reset.cpp @@ -37,11 +37,11 @@ ResetHandler::hardrst_state ResetHandler::hardrst_reset_layer() { /* Reset the Protocol RX machine */ ProtocolReceive::notify( PDB_EVT_PRLRX_RESET); - taskYIELD(); + osDelay(1); /* Reset the Protocol TX machine */ ProtocolTransmit::notify(PDB_EVT_PRLTX_RESET); - taskYIELD(); + osDelay(1); /* Continue the process based on what event started the reset. */ if (evt & PDB_EVT_HARDRST_RESET) { diff --git a/workspace/TS100/Core/Drivers/FUSB302/int_n.cpp b/workspace/TS100/Core/Drivers/FUSB302/int_n.cpp index 58ea1b9d..d2329226 100644 --- a/workspace/TS100/Core/Drivers/FUSB302/int_n.cpp +++ b/workspace/TS100/Core/Drivers/FUSB302/int_n.cpp @@ -91,6 +91,8 @@ void InterruptHandler::Thread(const void *arg) { } } + } else { + osDelay(1); } osDelay(1); } diff --git a/workspace/TS100/Core/Drivers/FUSB302/pd.h b/workspace/TS100/Core/Drivers/FUSB302/pd.h index e94e9cbe..7bd754b5 100644 --- a/workspace/TS100/Core/Drivers/FUSB302/pd.h +++ b/workspace/TS100/Core/Drivers/FUSB302/pd.h @@ -278,7 +278,7 @@ #define PD_T_PS_TRANSITION (500) #define PD_T_SENDER_RESPONSE (27) #define PD_T_SINK_REQUEST (100) -#define PD_T_TYPEC_SINK_WAIT_CAP (465+100) +#define PD_T_TYPEC_SINK_WAIT_CAP (465) #define PD_T_PD_DEBOUNCE (15) /* diff --git a/workspace/TS100/Core/Drivers/FUSB302/policy_engine.cpp b/workspace/TS100/Core/Drivers/FUSB302/policy_engine.cpp index 1a0b9e23..7adf5cd3 100644 --- a/workspace/TS100/Core/Drivers/FUSB302/policy_engine.cpp +++ b/workspace/TS100/Core/Drivers/FUSB302/policy_engine.cpp @@ -54,8 +54,7 @@ void PolicyEngine::init() { } void PolicyEngine::notify(uint32_t notification) { - xTaskNotify(TaskHandle, notification, - eNotifyAction::eSetBits); + xTaskNotify(TaskHandle, notification, eNotifyAction::eSetBits); } void PolicyEngine::pe_task(const void *arg) { @@ -242,6 +241,8 @@ PolicyEngine::policy_engine_state PolicyEngine::pe_sink_eval_cap() { } PolicyEngine::policy_engine_state PolicyEngine::pe_sink_select_cap() { + waitForEvent( + PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR | PDB_EVT_PE_RESET, 0); /* Transmit the request */ ProtocolTransmit::pushMessage(&_last_dpm_request); //Send indication that there is a message pending @@ -785,7 +786,7 @@ bool PolicyEngine::heatingAllowed() { uint32_t PolicyEngine::waitForEvent(uint32_t mask, uint32_t ticksToWait) { uint32_t pulNotificationValue; xTaskNotifyWait(0x00, mask, &pulNotificationValue, ticksToWait); - return pulNotificationValue; + return pulNotificationValue & mask; } bool PolicyEngine::isPD3_0() { diff --git a/workspace/TS100/Core/Drivers/FUSB302/protocol_rx.cpp b/workspace/TS100/Core/Drivers/FUSB302/protocol_rx.cpp index 14573aca..26117da5 100644 --- a/workspace/TS100/Core/Drivers/FUSB302/protocol_rx.cpp +++ b/workspace/TS100/Core/Drivers/FUSB302/protocol_rx.cpp @@ -98,9 +98,11 @@ ProtocolReceive::protocol_rx_state ProtocolReceive::protocol_rx_check_messageid( /* Otherwise, there's either no stored ID or this message has an ID we * haven't just seen. Transition to the Store_MessageID state. */ - if (PD_MESSAGEID_GET(&tempMessage) == _rx_messageid) { + /*if (PD_MESSAGEID_GET(&tempMessage) == _rx_messageid) { return PRLRxWaitPHY; - } else { + } else*/ + + { return PRLRxStoreMessageID; } } diff --git a/workspace/TS100/Core/Drivers/FUSB302/protocol_tx.cpp b/workspace/TS100/Core/Drivers/FUSB302/protocol_tx.cpp index 00fd8f02..43c8a945 100644 --- a/workspace/TS100/Core/Drivers/FUSB302/protocol_tx.cpp +++ b/workspace/TS100/Core/Drivers/FUSB302/protocol_tx.cpp @@ -254,16 +254,15 @@ void ProtocolTransmit::thread(const void *args) { } void ProtocolTransmit::notify(uint32_t notification) { - xTaskNotify(TaskHandle, notification, - eNotifyAction::eSetBits); + xTaskNotify(TaskHandle, notification, eNotifyAction::eSetBits); } void ProtocolTransmit::init() { messagesWaiting = xQueueCreateStatic(PDB_MSG_POOL_SIZE, sizeof(union pd_msg), ucQueueStorageArea, &xStaticQueue); - osThreadStaticDef(pd_txTask, thread,osPriorityAboveNormal, 0, TaskStackSize, - TaskBuffer, &TaskControlBlock); + osThreadStaticDef(pd_txTask, thread, PDB_PRIO_PRL, 0, + TaskStackSize, TaskBuffer, &TaskControlBlock); TaskHandle = osThreadCreate(osThread(pd_txTask), NULL); } @@ -283,5 +282,5 @@ void ProtocolTransmit::getMessage() { uint32_t ProtocolTransmit::waitForEvent(uint32_t mask, uint32_t ticksToWait) { uint32_t pulNotificationValue; xTaskNotifyWait(0x00, mask, &pulNotificationValue, ticksToWait); - return pulNotificationValue; + return pulNotificationValue & mask; } diff --git a/workspace/TS100/Core/Src/main.cpp b/workspace/TS100/Core/Src/main.cpp index 023fd287..78a7d5d9 100644 --- a/workspace/TS100/Core/Src/main.cpp +++ b/workspace/TS100/Core/Src/main.cpp @@ -46,14 +46,14 @@ int main(void) { usb_pd_available = usb_pd_detect(); resetWatchdog(); settingsWereReset = restoreSettings(); // load the settings from flash - if (MMA8652FC::detect()) { - PCBVersion = 1; - MMA8652FC::initalize(); // this sets up the I2C registers - } else if (LIS2DH12::detect()) { - PCBVersion = 2; - // Setup the ST Accelerometer - LIS2DH12::initalize(); // startup the accelerometer - } else { + /*if (MMA8652FC::detect()) { + PCBVersion = 1; + MMA8652FC::initalize(); // this sets up the I2C registers + } else if (LIS2DH12::detect()) { + PCBVersion = 2; + // Setup the ST Accelerometer + LIS2DH12::initalize(); // startup the accelerometer + } else*/{ PCBVersion = 3; systemSettings.SleepTime = 0; systemSettings.ShutdownTime = 0; // No accel -> disable sleep