Skip to content

Commit 2cdb4b2

Browse files
committed
UZDAT: restart timer_switch_transmit only if not already active
1 parent 314fb5a commit 2cdb4b2

4 files changed

Lines changed: 158 additions & 1 deletion

File tree

src/io/cchar/uzdat.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,9 @@ static void uzdat_on_async_switch_dir(uv_async_t *handle)
351351
{
352352
uzdat_t *uzdat = (uzdat_t*) handle->data;
353353

354-
uv_timer_start(&uzdat->timer_switch_transmit, uzdat_on_transmit_switch_timeout, XFER_DIR_SWITCH_DELAY_MS, 0);
354+
if (!uv_is_active((uv_handle_t*) &uzdat->timer_switch_transmit)) {
355+
uv_timer_start(&uzdat->timer_switch_transmit, uzdat_on_transmit_switch_timeout, XFER_DIR_SWITCH_DELAY_MS, 0);
356+
}
355357
}
356358

357359
// -----------------------------------------------------------------------

tests/configs/uzdat.ini

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[cpu]
2+
speed_real = false
3+
modifications = false
4+
5+
[memory]
6+
elwro_modules = 1
7+
mega_modules = 0
8+
hardwired_segments = 2
9+
10+
[log]
11+
enabled = false
12+
13+
[io]
14+
channel_7 = char
15+
16+
[dev7.0]
17+
type = terminal
18+
port = 32000
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
; OPTS -c configs/uzdat.ini
2+
; PRECMD CLOCK ON
3+
4+
; first read from UZDAT should switch transmission to OUT after a while
5+
6+
.cpu mera400
7+
8+
.include cpu.inc
9+
.include io.inc
10+
11+
mcl
12+
uj start
13+
14+
.const CHAR_CHAN 7
15+
.const UZDAT_DEV 0
16+
.const UZDAT CHAR_CHAN\IO_CHAN | UZDAT_DEV\IO_DEV
17+
.org OS_START
18+
19+
; ------------------------------------------------------------------------
20+
mask: .word IMASK_GROUP_H | IMASK_CH4_9
21+
22+
int_uzdat:
23+
lwt r6, 1 ; uzdat interrupt marker
24+
lip
25+
int_timer:
26+
cwt r6, 1 ; uzdat sent interrupt?
27+
jes .fin ; yes
28+
awt r7, 1 ; wait more
29+
cwt r7, 2 ; done waiting?
30+
jes .fail ; yes
31+
lip ; no
32+
.fail: hlt 060
33+
ujs .fail
34+
.fin: hlt 077
35+
ujs .fin
36+
37+
; ------------------------------------------------------------------------
38+
; ------------------------------------------------------------------------
39+
; ------------------------------------------------------------------------
40+
41+
start:
42+
lw r1, stack
43+
rw r1, STACKP
44+
lw r1, int_uzdat
45+
rw r1, INTV_CH0 + CHAR_CHAN
46+
lw r1, int_timer
47+
rw r1, INTV_TIMER
48+
49+
lwt r7, 0
50+
lwt r6, 0
51+
52+
im mask
53+
.loop:
54+
ou r3, KZ_CMD_DEV_WRITE | UZDAT
55+
.word .no1, .en1, .ok1, .pe1
56+
.no1: hlt 040
57+
ujs .no1
58+
.ok1: hlt
59+
ujs .ok1
60+
.pe1: hlt 042
61+
ujs .pe1
62+
.en1: ujs .loop
63+
64+
stack:
65+
66+
; XPCT ir : 0xec3f
67+
; XPCT r6 : 1
68+
; XPCT alarm : 0
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
; OPTS -c configs/uzdat.ini
2+
; PRECMD CLOCK ON
3+
4+
; first read from UZDAT should switch transmission to OUT after a while
5+
6+
.cpu mera400
7+
8+
.include cpu.inc
9+
.include io.inc
10+
11+
mcl
12+
uj start
13+
14+
.const CHAR_CHAN 7
15+
.const UZDAT_DEV 0
16+
.const UZDAT CHAR_CHAN\IO_CHAN | UZDAT_DEV\IO_DEV
17+
.org OS_START
18+
19+
; ------------------------------------------------------------------------
20+
mask: .word IMASK_GROUP_H | IMASK_CH4_9
21+
22+
int_uzdat:
23+
lwt r6, 1 ; uzdat interrupt marker
24+
lip
25+
int_timer:
26+
cwt r6, 1 ; uzdat sent interrupt?
27+
jes .fin ; yes
28+
awt r7, 1 ; wait more
29+
cwt r7, 2 ; done waiting?
30+
jes .fail ; yes
31+
lip ; no
32+
.fail: hlt 060
33+
ujs .fail
34+
.fin: hlt 077
35+
ujs .fin
36+
37+
; ------------------------------------------------------------------------
38+
; ------------------------------------------------------------------------
39+
; ------------------------------------------------------------------------
40+
41+
start:
42+
lw r1, stack
43+
rw r1, STACKP
44+
lw r1, int_uzdat
45+
rw r1, INTV_CH0 + CHAR_CHAN
46+
lw r1, int_timer
47+
rw r1, INTV_TIMER
48+
49+
lwt r7, 0
50+
lwt r6, 0
51+
52+
im mask
53+
.loop:
54+
ou r3, KZ_CMD_DEV_WRITE | UZDAT
55+
.word .no1, .en1, .ok1, .pe1
56+
.no1: hlt 040
57+
ujs .no1
58+
.ok1: hlt 041
59+
ujs .ok1
60+
.pe1: hlt 042
61+
ujs .pe1
62+
; busy wait for the interrupt
63+
.en1: ujs .en1
64+
65+
stack:
66+
67+
; XPCT ir : 0xec3f
68+
; XPCT r6 : 1
69+
; XPCT alarm : 0

0 commit comments

Comments
 (0)