pd: more robust reception

Ensure that we finish reception if and only if we started it
whatever other events happened.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=none
BUG=chrome-os-partner:28332
TEST=Connect Zinger to Firefly, request higher voltage and ensure that
Firefly was still getting the Pings after several hours.

Change-Id: Ie99984aeb4c565be39d349457dbd2813203b3f5b
Reviewed-on: https://chromium-review.googlesource.com/197946
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Vincent Palatin
2014-05-01 14:56:05 -07:00
committed by chrome-internal-fetch
parent b40a82bc45
commit d2c5e22944
3 changed files with 15 additions and 5 deletions

View File

@@ -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 */

View File

@@ -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);

View File

@@ -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 */