senxor.regmap
senxor.regmap¶
Register system for the senxor.
SenxorFieldsManager(regmap)
¶
Bases: Fields
The field system for the senxor.
Attributes:
| Name | Type | Description |
|---|---|---|
regmap |
SenxorRegistersManager
|
The register system for the senxor. |
fields |
dict[FieldName, Field]
|
The dictionary of field instances by name. |
cache |
dict[FieldName, int | None]
|
The cache of the fields values. |
cache_display |
dict[FieldName, str | int | float | None]
|
The cache of the fields display values. |
Examples:
- Iterate over the fields:
>>> fieldmap = SenxorFieldsManager(regmap)
>>> for field in fieldmap:
... print(field.name, field.address)
- Use subscript notation to get a field instance:
>>> fieldmap["MCU_TYPE"]
- Check if a field exists:
>>> "MCU_TYPE" in fieldmap
- Use the cache to get the cached field value:
>>> fieldmap.cache
{SENXOR_TYPE: 1, MODULE_TYPE: 19, ...}
- Use the cache_display to get the cached field display value:
>>> fieldmap.cache_display
{SENXOR_TYPE: "MI0801", MODULE_TYPE: "MI0802M5S", ...}
SenxorRegistersManager(interface)
¶
Bases: Registers, Generic[TDevice]
The register system for the senxor.
Attributes:
| Name | Type | Description |
|---|---|---|
interface |
ISenxorInterface[TDevice]
|
The interface of the senxor. |
registers |
dict[int, Register]
|
The dictionary of registers instance by address. |
fieldmap |
SenxorFieldsManager
|
The field system for the senxor. |
cache |
dict[int, int | None]
|
The cache of the registers values. |
Examples:
- Iterate over the registers:
>>> regs = SenxorRegistersManager(interface)
>>> for reg in regs:
... print(reg.name, reg.address)
- Use subscript notation to get a register instance:
>>> regs = SenxorRegistersManager(interface)
>>> regs["MCU_RESET"]
>>> regs[0x00]
- Check if a register exists:
>>> "MCU_RESET" in regs
>>> 0x00 in regs
- Use the cache to get the cached register value:
>>> regs.cache
{0x00: 0x00, 0x01: 0x01, ...}
- Refresh the cache of all registers:
>>> regs.refresh_all()
>>> regs.cache
{0x00: 0x00, 0x01: 0x01, ...}
Notes
Each register operation should be performed through this class to ensure logging, cache updating and error handling.
refresh_all()
¶
Refresh the cache of all registers and fields.
get_reg(name_or_addr)
¶
Get a register instance by name or address.
read_reg(addr)
¶
Read a register value from the senxor.
write_reg(addr, value)
¶
Write a value to a register.
read_regs(addrs)
¶
Read the values from multiple registers at once.
write_regs(regs)
¶
Write the values to multiple registers at once.
Fields()
¶
The definition of the fields for the senxor.
You can use this class to get the field definitions statically, without connecting to a device.
Attributes:
| Name | Type | Description |
|---|---|---|
__fields__ |
list[type[Field]]
|
The list of field definitions. |
__reg2fields__ |
dict[int, list[str]]
|
The dictionary of register addresses to field names. |
Examples:
>>> from senxor.regmap import Fields
>>> Fields.__fields__
['SW_RESET', ...]
>>> Fields.__reg2fields__
{0x00: ['SW_RESET'], 0x01: ['DMA_TIMEOUT_ENABLE', 'TIMEOUT_PERIOD', 'STOP_HOST_XFER'], ...}
>>> Fields.SW_RESET.name
'SW_RESET'
Registers()
¶
The definition of the registers for the senxor.
You can use this class to get the register definitions statically, without connecting to a device.
Attributes:
| Name | Type | Description |
|---|---|---|
__regs__ |
list[type[Register]]
|
The list of register definitions. |
__addrs__ |
dict[int, RegisterName]
|
The dictionary of register addresses to register names. |
Examples:
>>> from senxor.regmap import Registers
>>> Registers.__regs__
['MCU_RESET', ...]
>>> Registers.MCU_RESET.name
'MCU_RESET'
>>> Registers.MCU_RESET.address
0x00
>>> Registers.MCU_RESET.description
'Software Reset of the MI48'
>>> Registers.MCU_RESET.writable
True
>>> Registers.MCU_RESET.readable
True
>>> Registers.MCU_RESET.self_reset
True
self_reset: Whether the register value can be modified by the senxor itself.