Compare commits
6 commits
0affc4aa8c
...
dd6bf3ef40
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd6bf3ef40 | ||
|
|
38a2b0ac29 | ||
|
|
41cceb7365 | ||
|
|
afd92db0e2 | ||
|
|
a4ef98473e | ||
|
|
2c779c8e48 |
2 changed files with 15 additions and 15 deletions
24
ads8688.c
24
ads8688.c
|
|
@ -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
6
ssp.c
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue