cu-linux-resources
Linux/host resource bundle for serial, I2C, and GPIO peripherals.
Provider
Use cu_linux_resources::LinuxResources in copperconfig.ron.
resources: [
(
id: "linux",
provider: "cu_linux_resources::LinuxResources",
config: {
"serial3_dev": "/dev/ttyUSB0",
"serial3_baudrate": 420000,
"serial3_parity": "none",
"serial3_stopbits": 1,
"serial3_timeout_ms": 100,
"i2c1_dev": "/dev/i2c-1",
"gpio0_pin": 23,
"gpio0_direction": "output",
"gpio0_bias": "pull_up",
"gpio0_initial_level": "high",
"gpio1_pin": 24,
"gpio1_direction": "input",
"gpio1_bias": "pull_down",
},
),
],
Fixed Resource Slots
LinuxResources exposes embedded-style fixed slots:
- Serial:
serial0,serial1,serial2,serial3,serial4,serial5 - I2C:
i2c0,i2c1,i2c2 - GPIO:
gpio0,gpio1,gpio2,gpio3,gpio4,gpio5
Bind tasks/bridges to these slots via <bundle>.<slot> (for example linux.serial3).
Config Keys
Serial
Per-slot keys are serial0..serial5. Each slot maps to a fixed resource id:
serial0_*->serial0serial1_*->serial1serial2_*->serial2serial3_*->serial3serial4_*->serial4serial5_*->serial5
Note: Serial and I2C slots are only initialized when explicitly configured. Unconfigured slots are skipped.
Supported keys per serial slot serialN:
serialN_dev(string)serialN_baudrate(u32, default115200)serialN_parity(string:none,odd,even; defaultnone)serialN_stopbits(u8:1or2; default1)serialN_timeout_ms(u64, default50)
I2C
i2c0_dev(no default - must be configured)i2c1_dev(no default - must be configured)i2c2_dev(no default - must be configured)
GPIO
Each slot gpioN (N=0..5) is enabled only when gpioN_pin is set.
Per-slot keys:
gpioN_pin(u8, required when slot is configured)gpioN_direction(string, required when slot is configured):inputoroutputgpioN_bias(string, optional, defaultoff):off,pull_up,pull_downgpioN_initial_level(string, optional, output-only):low,high
Direction determines the concrete resource type:
direction: "input"registersLinuxInputPindirection: "output"registersLinuxOutputPin(output mode with optional pull bias)
If gpioN_initial_level is omitted for an output slot, initialization preserves the current
GPIO output level.
Validation is strict for GPIO config:
- Invalid
direction,bias, orinitial_levelvalues fail bundle build. - Setting
gpioN_initial_levelon an input pin fails bundle build. - Setting
gpioN_direction/bias/initial_levelwithoutgpioN_pinfails bundle build.
Exclusive Wrapper
cu_linux_resources::Exclusive<T> is the bundle-layer wrapper for resources that are logically single-owner but must satisfy Sync for ResourceManager::add_owned.
Keeping that adaptation in the resource layer avoids consumer-side wrappers in bridges/tasks.