Compare commits

..

No commits in common. "dd6bf3ef4081cf79aa6a4d01bbadc63b56d6bfb0" and "0affc4aa8c2772f14f0460516741493b45603c03" have entirely different histories.

2 changed files with 15 additions and 15 deletions

View file

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

6
ssp.c
View file

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