Compare commits
6 commits
dd6bf3ef40
...
2d853d7804
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d853d7804 | ||
|
|
c29c5a4a74 | ||
|
|
e07084356a | ||
|
|
7473c73be6 | ||
|
|
2174022a93 | ||
|
|
480574d902 |
5 changed files with 44 additions and 38 deletions
19
ads8688.c
19
ads8688.c
|
|
@ -27,15 +27,15 @@ static struct ads8688_control {
|
|||
|
||||
void ads8688_readings(struct ads8688_control *c, unsigned int cc, int i, int ii)
|
||||
{
|
||||
unsigned short first = ssp_buffer[i];
|
||||
unsigned short first = ssp_scratch[i];
|
||||
unsigned int sum = first;
|
||||
int square = 0;
|
||||
int n = 1;
|
||||
unsigned short sdo = 0;
|
||||
if (!i && ii > 1)
|
||||
sdo = ssp_buffer[1];
|
||||
sdo = ssp_scratch[1];
|
||||
while ((i+=ii) < c->nbuf) {
|
||||
int d = ssp_buffer[i];
|
||||
int d = ssp_scratch[i];
|
||||
sum += d;
|
||||
d -= first;
|
||||
square += d*d;
|
||||
|
|
@ -83,6 +83,7 @@ static int read_cb(struct ads8688_control *c)
|
|||
return alldone_cb(c);
|
||||
c->frame = 0xc000 | cc << 10;
|
||||
ssp_set_buffer(0, c->nbuf);
|
||||
ssp_assert_ssel();
|
||||
return ssp_submit_batch(&c->frame, 1, 2, 0, 0);
|
||||
}
|
||||
|
||||
|
|
@ -112,6 +113,7 @@ static int read_auto_cb(struct ads8688_control *c)
|
|||
else
|
||||
return tcnh_cb(c);
|
||||
ssp_set_buffer(0, n);
|
||||
ssp_assert_ssel();
|
||||
return ssp_submit_batch(&c->frame, 1, 2, 0, 0);
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +135,7 @@ static int gains_cb(struct ads8688_control *c)
|
|||
unsigned short f = c->frame;
|
||||
if (f & 0xe000)
|
||||
return tcnh_cb(c);
|
||||
unsigned int cc = save_gain(f, *ssp_buffer, &c->gains);
|
||||
unsigned int cc = save_gain(f, *ssp_scratch, &c->gains);
|
||||
cc++;
|
||||
if (cc == 12)
|
||||
cc = 0;
|
||||
|
|
@ -161,19 +163,18 @@ static const struct ssp_batch ads8688_batch[] = {
|
|||
{ .ssel = &ssp_conf_adc },
|
||||
},
|
||||
[1] = {
|
||||
.flags = ssp_b_call
|
||||
| ssp_b_deassert,
|
||||
.flags = ssp_b_call,
|
||||
{ .callback = ads8688_cb },
|
||||
{ .data = &ads8688_control },
|
||||
},
|
||||
[2] {
|
||||
[2] = {
|
||||
.flags = ssp_b_job
|
||||
| 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},
|
||||
{ .match = &ads8688_control.match},
|
||||
},
|
||||
[3] {
|
||||
[3] = {
|
||||
.flags = ssp_b_goto
|
||||
| ssp_b_stop | ssp_b_deassert,
|
||||
{ .batch = 0 },
|
||||
|
|
|
|||
|
|
@ -633,7 +633,6 @@ def init_irena(scope, name="xRENA", prod=None, options="", long_options=[]):
|
|||
else:
|
||||
_ifc_uart = uartterm.init_uart(scope=scope, prefix="serial_", dname=name, addr=v, isp=False)
|
||||
_ifc_uart._shell_scope = scope
|
||||
_ifc_uart.uart.wait_for_message(b"Altera")
|
||||
if o in "-N --network":
|
||||
import udpterm
|
||||
_ifc = udpterm.init_udp(scope=scope, dname=name, addr=v)
|
||||
|
|
@ -648,7 +647,7 @@ def init_irena(scope, name="xRENA", prod=None, options="", long_options=[]):
|
|||
vvv=vv.split(".")
|
||||
bus = int(vvv[0]) if vvv[0] else None
|
||||
address = int(vvv[1]) if len(vvv)>1 and vvv[1] else None
|
||||
if bus and _ifc_uart:
|
||||
if _ifc_uart:
|
||||
address = _ifc_uart.uart.wait_for_usb()
|
||||
_ifc = usbterm.init_usb(scope=scope, dname=name,
|
||||
prod=prod, bus=bus, address=address)
|
||||
|
|
|
|||
48
ssp.c
48
ssp.c
|
|
@ -68,17 +68,19 @@ static void ssp_isr(void)
|
|||
unsigned int dr = SSPDR;
|
||||
sr=SSPSR;
|
||||
nread++;
|
||||
fr++;
|
||||
if (!rc
|
||||
&& fr >= ssp_match.frame_count
|
||||
&& (fr == ssp_match.frame_count || ssp_match.mask)
|
||||
&& (dr & ssp_match.mask) == ssp_match.value) {
|
||||
rc = ssp_match.read_count;
|
||||
if (ssp_match.count)
|
||||
j->count = ssp_match.count
|
||||
+ ssp_match.frame_count
|
||||
- ssp_frames_sent;
|
||||
if (ssp_match.count) {
|
||||
int c = 1 + fr + ssp_match.count - ssp_frames_sent;
|
||||
if (c < 0)
|
||||
c = 0;
|
||||
j->count = c;
|
||||
}
|
||||
}
|
||||
fr++;
|
||||
if (rc) {
|
||||
rc--;
|
||||
unsigned int bc = j->buf_count;
|
||||
|
|
@ -341,9 +343,6 @@ int ssp_run_batch()
|
|||
if (f & ssp_b_scratch)
|
||||
ssp_set_buffer(0, -1);
|
||||
|
||||
if (c == ssp_b_buffer)
|
||||
ssp_set_buffer(batch->buffer, f & 0xffff);
|
||||
|
||||
if (f & ssp_b_deassert) {
|
||||
ssp_deassert_ssel();
|
||||
ssel_delay(f);
|
||||
|
|
@ -374,12 +373,24 @@ int ssp_run_batch()
|
|||
if (buffer_empty)
|
||||
continue;
|
||||
|
||||
if (c == ssp_b_job) {
|
||||
if (batch->match)
|
||||
ssp_match = *batch->match;
|
||||
else
|
||||
memset(&ssp_match, 0, sizeof(ssp_match));
|
||||
if (batch->job && batch->job->count)
|
||||
return ssp_submit_job(batch->job);
|
||||
}
|
||||
|
||||
if (c == ssp_b_buffer)
|
||||
ssp_set_buffer(batch->buffer, f & 0xffff);
|
||||
|
||||
if (c == ssp_b_call) {
|
||||
int c = batch->callback(batch);
|
||||
if (c != -1) {
|
||||
if (c)
|
||||
int r = batch->callback(batch);
|
||||
if (r != -1) {
|
||||
if (r)
|
||||
ssp_batch = 0;
|
||||
return c;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -395,15 +406,6 @@ int ssp_run_batch()
|
|||
ssp_batch += batch->offset;
|
||||
}
|
||||
|
||||
if (c == ssp_b_job) {
|
||||
if (batch->match)
|
||||
ssp_match = *batch->match;
|
||||
else
|
||||
memset(&ssp_match, 0, sizeof(ssp_match));
|
||||
if (batch->job && batch->job->count)
|
||||
return ssp_submit_job(batch->job);
|
||||
}
|
||||
|
||||
if (c == ssp_b_wait) {
|
||||
const struct timer_wait *wait = batch->wait;
|
||||
if (!wait) {
|
||||
|
|
@ -666,8 +668,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 ssel 0x%08x mode 0x%04x\n",
|
||||
code, r, ssp_config.ssel, ssp_config.mode);
|
||||
parser_format_message(cmd, "%03d ssp busy: 0x%x [%u] ssel 0x%08x mode 0x%04x\n",
|
||||
code, r, job.buf_count, ssp_config.ssel, ssp_config.mode);
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
ssp.h
2
ssp.h
|
|
@ -15,7 +15,7 @@ unsigned int ssp_busy(void);
|
|||
int ssp_wait(int timeout);
|
||||
|
||||
extern unsigned int ssp_bits;
|
||||
unsigned short *ssp_buffer;
|
||||
extern unsigned short *ssp_buffer;
|
||||
extern unsigned int ssp_ssel_mask;
|
||||
extern unsigned int ssp_ssel;
|
||||
extern unsigned int ssp_read_size;
|
||||
|
|
|
|||
10
uartterm.py
10
uartterm.py
|
|
@ -872,7 +872,6 @@ class irena_uart(irena_ifc):
|
|||
irena_ifc.__init__(self, dname=dname)
|
||||
self._data = uart(self, dev, baudrate)
|
||||
self.uart = self._data
|
||||
self.resp = self._data.resp
|
||||
if isp:
|
||||
self._prompt += "-ISP"
|
||||
self.uart.Init_ISP()
|
||||
|
|
@ -881,14 +880,19 @@ class irena_uart(irena_ifc):
|
|||
|
||||
_CMDN = 1 # skip the first response character
|
||||
|
||||
def cmd(self, c, timeout=10000):
|
||||
def ucmd(self, c, timeout=10000, raise_e=None):
|
||||
self._data.flush_responses()
|
||||
self._data.serial.write(utf8_encode(c).strip()+b'\n')
|
||||
r = self._data.resp(timeout=timeout/1000.)
|
||||
r = self._data.resp(timeout=timeout/1000)
|
||||
if self.verbosity >= 2:
|
||||
sys.stderr.write("sent: %s recv: %s\n" % (repr(c),repr(r)))
|
||||
return r
|
||||
|
||||
def resp(self, timeout=1000, raise_e=None):
|
||||
return self._data.resp(timeout = timeout/1000,
|
||||
blocking = timeout > 0,
|
||||
verbose = self.verbosity )
|
||||
|
||||
DataThread = None
|
||||
|
||||
class md3_gse(uart):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue