:name: RAMN
:description: Runs the RAMN firmware (https://github.com/ToyotaInfoTech/RAMN). By default emulates ECUC but can be overriden by setting $name

$global.name?="ECUC"
mach create $name
include @platforms/boards/ramn.repl

if `str_contains $global.name "ECUA"`
"""
$bin= @https://dl.antmicro.com/projects/renode/ECUA.elf-s_2734852-5896caa99eb55997686c9235ab5fa1e6587c2180
include @platforms/boards/ramn/GATEWAY.repl
"""

if `str_contains $global.name "ECUB"`
"""
$bin= @https://dl.antmicro.com/projects/renode/ECUB.elf-s_2423936-4be3c992fca8a9795ba5630628ceef50a568f23f
include @platforms/boards/ramn/CHASSIS.repl
"""

if `str_contains $global.name "ECUC"`
"""
$bin= @https://dl.antmicro.com/projects/renode/ECUC.elf-s_2416512-f9fab061973e8720fcf4882bd192fe5f2a34f4a0
include @platforms/boards/ramn/POWERTRAIN.repl
"""

if `str_contains $global.name "ECUD"`
"""
$bin= @https://dl.antmicro.com/projects/renode/ECUD.elf-s_2438796-cb40e76e43568eaa82bb74f9c3b7caf804f34449
include @platforms/boards/ramn/BODY.repl
"""

sysbus LoadELF $bin

python
"""
adc = monitor.Machine['sysbus.adc1']

def mc_SetEngineKey(position):
    if position in ["left", "OFF", "off"]:
        adc.SetDefaultValue(0, 9)
    elif position in ["middle", "ACC", "Accessory", "accessory"]:
        adc.SetDefaultValue(1650, 9)
    elif position in ["right", "IGN", "Ignition", "ignition"]:
        adc.SetDefaultValue(3300, 9)
    else:
        print('Unknown position' % position)
"""
