Compare commits
3 commits
bc0d3da4b8
...
0affc4aa8c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0affc4aa8c | ||
|
|
9ef3a9e879 | ||
|
|
7cc586f8be |
3 changed files with 25 additions and 19 deletions
29
ads8688.c
29
ads8688.c
|
|
@ -108,7 +108,7 @@ static int read_auto_cb(struct ads8688_control *c)
|
|||
n = 0;
|
||||
c->frame = 0x0300 | c->channels & 0xff;
|
||||
}
|
||||
else if ((c->frame & 0xff) == 0x03)
|
||||
else if ((c->frame & 0xff00) == 0x0300)
|
||||
c->frame = 0xa000;
|
||||
else
|
||||
return tcnh_cb(c);
|
||||
|
|
@ -132,7 +132,7 @@ static int gains_cb(struct ads8688_control *c)
|
|||
{
|
||||
c->status = c->status & ~0xf00 | 0x500;
|
||||
unsigned short f = c->frame;
|
||||
if (f & 0x1e00)
|
||||
if (f & 0xe000)
|
||||
return tcnh_cb(c);
|
||||
unsigned int cc = save_gain(f, *ssp_buffer, &c->gains);
|
||||
if (cc == 11)
|
||||
|
|
@ -145,7 +145,7 @@ static int gains_cb(struct ads8688_control *c)
|
|||
if (f & 0x100)
|
||||
c->frame |= 0x100 | c->gains >> 4*cc;
|
||||
ssp_set_buffer(0, 1);
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int ads8688_cb(const struct ssp_batch *b)
|
||||
|
|
@ -161,32 +161,35 @@ static const struct ssp_batch ads8688_batch[] = {
|
|||
{ .ssel = &ssp_conf_adc },
|
||||
},
|
||||
[1] = {
|
||||
.flags = ssp_b_call,
|
||||
.flags = ssp_b_call
|
||||
| ssp_b_deassert,
|
||||
{ .callback = ads8688_cb },
|
||||
{ .data = &ads8688_control },
|
||||
},
|
||||
[2] {
|
||||
.flags = ssp_b_job
|
||||
| SSP_B_REPEAT(256) | ssp_b_whilebuf
|
||||
| ssp_b_deassert | ssp_b_assert | SSP_B_DELAY(10),
|
||||
| ssp_b_assert | SSP_B_DELAY(10),
|
||||
{ .job = &ads8688_control.job},
|
||||
{ .match = &ads8688_control.match},
|
||||
},
|
||||
[3] {
|
||||
.flags = ssp_b_goto | ssp_b_stop,
|
||||
.flags = ssp_b_goto
|
||||
| ssp_b_stop | ssp_b_deassert,
|
||||
{ .batch = 0 },
|
||||
{ .offset = -2 },
|
||||
},
|
||||
};
|
||||
|
||||
static int ads8688_start(int nskip, int nread)
|
||||
static int ads8688_start(int write, int skip, int read)
|
||||
{
|
||||
struct ads8688_control *c = &ads8688_control;
|
||||
c->status = 0x100;
|
||||
c->job.command = &c->frame;
|
||||
c->job.count = 1 + nskip + nread;
|
||||
c->match.frame_count = nskip;
|
||||
c->match.read_count = nread;
|
||||
c->job.cmd_count = write;
|
||||
c->job.count = write + skip + read;
|
||||
c->match.frame_count = write + skip;
|
||||
c->match.read_count = read;
|
||||
return ssp_start_batch(ads8688_batch, 0);
|
||||
}
|
||||
|
||||
|
|
@ -207,9 +210,8 @@ int adc_gains_cmd(struct command *cmd, const struct command_par *par)
|
|||
}
|
||||
unsigned int newgains = c->gains; // volatile
|
||||
|
||||
c->job.cmd_count = 1;
|
||||
c->callback = gains_cb;
|
||||
int r = ads8688_start(1, 1);
|
||||
int r = ads8688_start(1, 0, 1);
|
||||
int code = par->code;
|
||||
if (r)
|
||||
code++;
|
||||
|
|
@ -238,9 +240,8 @@ int adc_read_cmd(struct command *cmd, const struct command_par *par)
|
|||
c->frame = 0x0000;
|
||||
c->callback = read_auto_cb;
|
||||
}
|
||||
c->job.cmd_count = 0; // idle_frame = continue command
|
||||
c->nbuf = NSCRATCH;
|
||||
int r = ads8688_start(aidx+1, 1);
|
||||
int r = ads8688_start(0, 1+aidx, 1);
|
||||
int code = par->code;
|
||||
if (r)
|
||||
code++;
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ static int bate_callback(const struct ssp_batch *batch)
|
|||
calib_pressure(0);
|
||||
barrier();
|
||||
bate_status = 0;
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static const unsigned short bate_cmds[] = {
|
||||
|
|
|
|||
13
ssp.c
13
ssp.c
|
|
@ -355,9 +355,8 @@ int ssp_run_batch()
|
|||
|
||||
static const struct ssp_batch *gosub_return;
|
||||
static unsigned int repeats, gosub_repeats;
|
||||
if (c != ssp_b_job && c != ssp_b_gosub
|
||||
|| repeats++ >= (f & ssp_b_repeat)
|
||||
|| f & ssp_b_whilebuf && !job.buf_count) {
|
||||
int buffer_empty = f & ssp_b_whilebuf && !job.buf_count;
|
||||
if (repeats++ >= (f & ssp_b_repeat) || buffer_empty) {
|
||||
// we did all repeats … advance to the next job
|
||||
repeats = 0;
|
||||
ssp_batch++;
|
||||
|
|
@ -372,10 +371,16 @@ int ssp_run_batch()
|
|||
}
|
||||
}
|
||||
|
||||
if (buffer_empty)
|
||||
continue;
|
||||
|
||||
if (c == ssp_b_call) {
|
||||
int c = batch->callback(batch);
|
||||
if (c)
|
||||
if (c != -1) {
|
||||
if (c)
|
||||
ssp_batch = 0;
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
if (c == ssp_b_goto || c == ssp_b_gosub) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue