static void sps_tpm_enable(void) { /* * Let's make sure we get an interrupt as soon as the header is * received. */ sps_register_rx_handler(SPS_GENERIC_MODE, tpm_rx_handler, 3); init_new_cycle(); }
static int command_sps(int argc, char **argv) { int count = 0; int target = 10; /* Expect 10 frames by default.*/ char *e; sps_tx_status(GC_SPS_DUMMY_WORD_DEFAULT); rx_state = spstrx_not_started; sps_register_rx_handler(SPS_GENERIC_MODE, sps_receive_callback); if (argc > 1) { target = strtoi(argv[1], &e, 10); if (*e) return EC_ERROR_PARAM1; } while (count++ < target) { size_t transmitted; size_t to_go; size_t index; /* Wait for a frame to be received.*/ while (rx_state != spstrx_finished) { watchdog_reload(); usleep(10); } /* Transmit the frame back to the host.*/ index = frame_base; to_go = frame_index - frame_base; do { if ((index == frame_base) && (to_go > 8)) { /* * This is the first transmit attempt for this * frame. Send a little just to prime the * transmit FIFO. */ transmitted = sps_transmit (test_frame + index, 8); } else { transmitted = sps_transmit (test_frame + index, to_go); } index += transmitted; to_go -= transmitted; } while (to_go); /* * Wait for receive state machine to transition out of 'frame * finised' state. */ while (rx_state == spstrx_finished) { watchdog_reload(); usleep(10); } } sps_unregister_rx_handler(); ccprintf("Processed %d frames\n", count - 1); ccprintf("rx count %d, tx count %d, tx_empty %d, max rx batch %d\n", sps_rx_count, sps_tx_count, tx_empty_count, max_rx_batch); sps_rx_count = sps_tx_count = tx_empty_count = max_rx_batch = 0; return EC_SUCCESS; }