asix-sigma: Pull out the CAPTURE mode handler
Pull out the code handling the Sigma which is in CAPTURE mode into a separate function. This is so we can start reworking this entire code easily soon. Signed-off-by: Marek Vasut <marex@denx.de>
This commit is contained in:
parent
58d6f20748
commit
d405193074
|
@ -1120,26 +1120,23 @@ static void download_capture(struct sr_dev_inst *sdi)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int receive_data(int fd, int revents, void *cb_data)
|
/*
|
||||||
|
* Handle the Sigma when in CAPTURE mode. This function checks:
|
||||||
|
* - Sampling time ended
|
||||||
|
* - DRAM capacity overflow
|
||||||
|
* This function triggers download of the samples from Sigma
|
||||||
|
* in case either of the above conditions is true.
|
||||||
|
*/
|
||||||
|
static int sigma_capture_mode(struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct sr_dev_inst *sdi;
|
struct dev_context *devc = sdi->priv;
|
||||||
struct dev_context *devc;
|
|
||||||
struct sr_datafeed_packet packet;
|
struct sr_datafeed_packet packet;
|
||||||
uint64_t running_msec;
|
uint64_t running_msec;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
int numchunks;
|
int numchunks;
|
||||||
uint8_t modestatus;
|
uint8_t modestatus;
|
||||||
|
|
||||||
(void)fd;
|
|
||||||
(void)revents;
|
|
||||||
|
|
||||||
sdi = cb_data;
|
|
||||||
devc = sdi->priv;
|
|
||||||
|
|
||||||
if (devc->state.state == SIGMA_IDLE)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
if (devc->state.state == SIGMA_CAPTURE) {
|
|
||||||
/* Get the current position. */
|
/* Get the current position. */
|
||||||
sigma_read_pos(&devc->state.stoppos, &devc->state.triggerpos,
|
sigma_read_pos(&devc->state.stoppos, &devc->state.triggerpos,
|
||||||
devc);
|
devc);
|
||||||
|
@ -1179,7 +1176,26 @@ static int receive_data(int fd, int revents, void *cb_data)
|
||||||
sr_session_send(sdi, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
dev_acquisition_stop(sdi, sdi);
|
dev_acquisition_stop(sdi, sdi);
|
||||||
}
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int receive_data(int fd, int revents, void *cb_data)
|
||||||
|
{
|
||||||
|
struct sr_dev_inst *sdi;
|
||||||
|
struct dev_context *devc;
|
||||||
|
|
||||||
|
(void)fd;
|
||||||
|
(void)revents;
|
||||||
|
|
||||||
|
sdi = cb_data;
|
||||||
|
devc = sdi->priv;
|
||||||
|
|
||||||
|
if (devc->state.state == SIGMA_IDLE)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
if (devc->state.state == SIGMA_CAPTURE)
|
||||||
|
return sigma_capture_mode(sdi);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue