Compare commits

...

6 commits

Author SHA1 Message Date
Stephan I. Böttcher
dd6bf3ef40 ads8688: fixes
- ads8688_readings: do not count first twice
- status bits allocation
- read_cb: more frame fixes
- read_cb_auto: mask aidx when counting ch
2024-12-09 20:35:49 +01:00
Stephan I. Böttcher
38a2b0ac29 ssp/status: fix message 2024-12-09 20:30:39 +01:00
Stephan I. Böttcher
41cceb7365 ads8688: read_cd: fix man_ch encoding 2024-12-09 17:57:14 +01:00
Stephan I. Böttcher
afd92db0e2 ssp_busy: print ssel and mode 2024-12-09 17:56:14 +01:00
Stephan I. Böttcher
a4ef98473e ads8688: gain_cb: advance c
- advance the channel number, instead of running an infinite loop
- store the channel number in the proper bits.
2024-12-09 14:48:05 +01:00
Stephan I. Böttcher
2c779c8e48 ssp_busy: return status bits when batch is active 2024-12-09 13:58:37 +01:00
2 changed files with 15 additions and 15 deletions

View file

@ -27,20 +27,19 @@ static struct ads8688_control {
void ads8688_readings(struct ads8688_control *c, unsigned int cc, int i, int ii)
{
unsigned short first = ssp_buffer[0];
unsigned short first = ssp_buffer[i];
unsigned int sum = first;
int square = 0;
int n = 1;
unsigned short sdo = 0;
if (!i && ii > 1)
sdo = ssp_buffer[1];
while (i < c->nbuf) {
while ((i+=ii) < c->nbuf) {
int d = ssp_buffer[i];
sum += d;
d -= first;
square += d*d;
n++;
i += ii;
}
if (cc > 9)
cc = 9;
@ -51,7 +50,7 @@ void ads8688_readings(struct ads8688_control *c, unsigned int cc, int i, int ii)
cc = 1<<cc;
c->nchannels |= cc;
c->tchannels |= cc;
c->status |= 0x10000 | cc<<8;
c->status |= 0x1000 | cc<<16;
}
static inline int tcnh_cb(struct ads8688_control *c)
@ -69,9 +68,9 @@ static inline int alldone_cb(struct ads8688_control *c)
static int read_cb(struct ads8688_control *c)
{
c->status = c->status & 0xff | 0x300;
if ((c->frame & 0xf0ff) != 0xc000)
if ((c->frame & 0xc3ff) != 0xc000)
return tcnh_cb(c);
unsigned int cc = c->frame >> 8 & 0xf;
unsigned int cc = c->frame >> 10 & 0xf;
if (cc <= 8) {
ads8688_readings(c, cc, 0, c->match.read_count);
cc++;
@ -82,7 +81,7 @@ static int read_cb(struct ads8688_control *c)
cc++;
if (cc > 8)
return alldone_cb(c);
c->frame = 0xc000 | cc;
c->frame = 0xc000 | cc << 10;
ssp_set_buffer(0, c->nbuf);
return ssp_submit_batch(&c->frame, 1, 2, 0, 0);
}
@ -93,7 +92,7 @@ static int read_auto_cb(struct ads8688_control *c)
if (c->frame == 0xa000) {
int ii = 0;
int i = 0;
unsigned int cc = c->channels;
unsigned int cc = c->channels & 0xff;
while (cc) {
cc >>= 1;
ii++;
@ -135,15 +134,16 @@ static int gains_cb(struct ads8688_control *c)
if (f & 0xe000)
return tcnh_cb(c);
unsigned int cc = save_gain(f, *ssp_buffer, &c->gains);
if (cc == 11)
cc++;
if (cc == 12)
cc = 0;
else if (cc >= 8)
return alldone_cb(c);
else
c->status |= 0x10000 | cc<<8;
c->status |= 0x1000 | cc<<16;
c->frame = cc + 5 << 9;
if (f & 0x100)
c->frame |= 0x100 | c->gains >> 4*cc;
c->frame |= 0x100 | c->gains >> 4*cc & 0xf;
ssp_set_buffer(0, 1);
return -1;
}
@ -233,7 +233,7 @@ int adc_read_cmd(struct command *cmd, const struct command_par *par)
int aidx = c->channels >> 12;
if (!k) {
c->frame = 0xcf00;
c->frame = 0xfc00;
c->callback = read_cb;
}
else {

6
ssp.c
View file

@ -265,7 +265,7 @@ unsigned int ssp_busy(void)
if (c & mask)
return c;
if (!ssp_run_batch())
return -1;
return c | 0x8000;
ssp_reset();
return 0;
}
@ -666,8 +666,8 @@ int ssp_resp_cmd(struct command *cmd, const struct command_par *par)
if (what & 0x01000000 || r) {
if (r)
code++;
parser_format_message(cmd, "%03d ssp busy: 0x%x\n",
code, r);
parser_format_message(cmd, "%03d ssp busy: 0x%x ssel 0x%08x mode 0x%04x\n",
code, r, ssp_config.ssel, ssp_config.mode);
return code;
}
}