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)
|
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;
|
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 < c->nbuf) {
|
while ((i+=ii) < 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;
|
||||||
|
|
@ -51,7 +50,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 |= 0x10000 | cc<<8;
|
c->status |= 0x1000 | cc<<16;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int tcnh_cb(struct ads8688_control *c)
|
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)
|
static int read_cb(struct ads8688_control *c)
|
||||||
{
|
{
|
||||||
c->status = c->status & 0xff | 0x300;
|
c->status = c->status & 0xff | 0x300;
|
||||||
if ((c->frame & 0xf0ff) != 0xc000)
|
if ((c->frame & 0xc3ff) != 0xc000)
|
||||||
return tcnh_cb(c);
|
return tcnh_cb(c);
|
||||||
unsigned int cc = c->frame >> 8 & 0xf;
|
unsigned int cc = c->frame >> 10 & 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++;
|
||||||
|
|
@ -82,7 +81,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;
|
c->frame = 0xc000 | cc << 10;
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
@ -93,7 +92,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;
|
unsigned int cc = c->channels & 0xff;
|
||||||
while (cc) {
|
while (cc) {
|
||||||
cc >>= 1;
|
cc >>= 1;
|
||||||
ii++;
|
ii++;
|
||||||
|
|
@ -135,15 +134,16 @@ 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);
|
||||||
if (cc == 11)
|
cc++;
|
||||||
|
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 |= 0x10000 | cc<<8;
|
c->status |= 0x1000 | cc<<16;
|
||||||
c->frame = cc + 5 << 9;
|
c->frame = cc + 5 << 9;
|
||||||
if (f & 0x100)
|
if (f & 0x100)
|
||||||
c->frame |= 0x100 | c->gains >> 4*cc;
|
c->frame |= 0x100 | c->gains >> 4*cc & 0xf;
|
||||||
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 = 0xcf00;
|
c->frame = 0xfc00;
|
||||||
c->callback = read_cb;
|
c->callback = read_cb;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
6
ssp.c
6
ssp.c
|
|
@ -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 -1;
|
return c | 0x8000;
|
||||||
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\n",
|
parser_format_message(cmd, "%03d ssp busy: 0x%x ssel 0x%08x mode 0x%04x\n",
|
||||||
code, r);
|
code, r, ssp_config.ssel, ssp_config.mode);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue