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