diff options
-rw-r--r-- | chip/stm32/usb_pd_phy.c | 6 | ||||
-rw-r--r-- | common/usb_pd_protocol.c | 7 | ||||
-rw-r--r-- | include/usb_pd.h | 7 |
3 files changed, 15 insertions, 5 deletions
diff --git a/chip/stm32/usb_pd_phy.c b/chip/stm32/usb_pd_phy.c index 4417cd3f54..4a4e63b51b 100644 --- a/chip/stm32/usb_pd_phy.c +++ b/chip/stm32/usb_pd_phy.c @@ -349,6 +349,12 @@ void pd_rx_complete(void) dma_disable(DMAC_TIM_RX); } +int pd_rx_started(void) +{ + /* is the sampling timer running ? */ + return STM32_TIM_CR1(TIM_RX) & 1; +} + void pd_rx_enable_monitoring(void) { /* clear comparator external interrupt */ diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index af68874984..442cccce2d 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -631,7 +631,6 @@ void pd_task(void) void *ctxt = pd_hw_init(); uint32_t payload[7]; int timeout = 10*MSEC; - uint32_t evt; int cc1_volt, cc2_volt; int res; @@ -644,9 +643,9 @@ void pd_task(void) /* Verify board specific health status : current, voltages... */ pd_board_checks(); /* wait for next event/packet or timeout expiration */ - evt = task_wait_event(timeout); + task_wait_event(timeout); /* incoming packet ? */ - if (evt & PD_EVENT_RX) { + if (pd_rx_started()) { head = analyze_rx(payload); pd_rx_complete(); if (head > 0) @@ -795,8 +794,6 @@ static int command_pd(int argc, char **argv) if (!strcasecmp(argv[1], "tx")) { pd_task_state = PD_STATE_SNK_DISCOVERY; task_wake(TASK_ID_PD); - } else if (!strcasecmp(argv[1], "rx")) { - pd_rx_event(); } else if (!strcasecmp(argv[1], "bist")) { pd_task_state = PD_STATE_BIST; task_wake(TASK_ID_PD); diff --git a/include/usb_pd.h b/include/usb_pd.h index e11d712800..84d98dff9b 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -255,6 +255,13 @@ void pd_start_tx(void *ctxt, int polarity, int bit_len); */ void pd_tx_done(int polarity); +/** + * Check whether the PD reception is started. + * + * @return true if the reception is on-going. + */ +int pd_rx_started(void); + /* Callback when the hardware has detected an incoming packet */ void pd_rx_event(void); /* Start sampling the CC line for reception */ |