Skip to content

Commit e394c89

Browse files
Merge pull request #37 from ThomasWaldmann/tsens-instruction
implement tsens instruction, fixes #1
2 parents a19ae7b + 57e6d43 commit e394c89

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

demo.S

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ rel_f: jumpr +1, 23, GE
4848

4949
adc r0, 0, 1
5050

51+
tsens r0, 42
52+
5153
nop
5254
wait 1000
5355
wake

esp32_ulp/opcodes.py

+18
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
SUB_OPCODE_END = 0
6262
SUB_OPCODE_SLEEP = 1
6363

64+
OPCODE_TSENS = 10
65+
6466
OPCODE_HALT = 11
6567

6668
OPCODE_LD = 13
@@ -133,6 +135,14 @@ def make_ins(layout):
133135
""")
134136

135137

138+
_tsens = make_ins("""
139+
dreg : 2 # Register where to store TSENS result
140+
delay : 14 # Number of cycles needed to obtain a measurement
141+
unused : 12 # Unused
142+
opcode : 4 # Opcode (OPCODE_TSENS)
143+
""")
144+
145+
136146
_adc = make_ins("""
137147
dreg : 2 # Register where to store ADC result
138148
mux : 4 # Select SARADC pad (mux + 1)
@@ -400,6 +410,14 @@ def i_wait(cycles):
400410
return _delay.all
401411

402412

413+
def i_tsens(reg_dest, delay):
414+
_tsens.dreg = get_reg(reg_dest)
415+
_tsens.delay = get_imm(delay)
416+
_tsens.unused = 0
417+
_tsens.opcode = OPCODE_TSENS
418+
return _tsens.all
419+
420+
403421
def i_adc(reg_dest, adc_idx, mux):
404422
_adc.dreg = get_reg(reg_dest)
405423
_adc.mux = get_imm(mux)

tests/compat/io.S

+3
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
i2c_wr 0x23, 0x42, 7, 0, 1
88

99
adc r0, 1, 2
10+
11+
tsens r0, 42
12+

0 commit comments

Comments
 (0)