Coverage for tropicsquare / config / startup.py: 100%
31 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-27 21:24 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-27 21:24 +0000
1"""Startup configuration (CFG_START_UP @ 0x00)"""
3from tropicsquare.config.base import BaseConfig
4from tropicsquare.config.constants import (
5 STARTUP_MBIST_DIS_BIT,
6 STARTUP_RNGTEST_DIS_BIT,
7 STARTUP_MAINTENANCE_ENA_BIT
8)
11class StartUpConfig(BaseConfig):
12 """Startup configuration register.
14 Controls bootloader behavior including built-in self-tests
15 and maintenance mode.
17 Fields:
18 mbist_dis: Memory built-in self-test disable (bit 1)
19 rngtest_dis: Random number generator test disable (bit 2)
20 maintenance_ena: Maintenance mode enable (bit 3)
21 """
23 @property
24 def mbist_dis(self) -> bool:
25 """Memory BIST disable flag.
27 When True, memory built-in self-test is disabled during startup.
28 Default: False (BIST enabled)
30 :returns: True if MBIST is disabled
31 """
32 return bool((self._value >> STARTUP_MBIST_DIS_BIT) & 1)
34 @mbist_dis.setter
35 def mbist_dis(self, value: bool) -> None:
36 if value:
37 self._value |= (1 << STARTUP_MBIST_DIS_BIT)
38 else:
39 self._value &= ~(1 << STARTUP_MBIST_DIS_BIT)
41 @property
42 def rngtest_dis(self) -> bool:
43 """RNG test disable flag.
45 When True, random number generator test is disabled during startup.
46 Default: False (RNG test enabled)
48 :returns: True if RNG test is disabled
49 """
50 return bool((self._value >> STARTUP_RNGTEST_DIS_BIT) & 1)
52 @rngtest_dis.setter
53 def rngtest_dis(self, value: bool) -> None:
54 if value:
55 self._value |= (1 << STARTUP_RNGTEST_DIS_BIT)
56 else:
57 self._value &= ~(1 << STARTUP_RNGTEST_DIS_BIT)
59 @property
60 def maintenance_ena(self) -> bool:
61 """Maintenance mode enable flag.
63 When True, chip boots into maintenance mode instead of
64 normal application mode.
65 Default: False (normal boot)
67 :returns: True if maintenance mode is enabled
68 """
69 return bool((self._value >> STARTUP_MAINTENANCE_ENA_BIT) & 1)
71 @maintenance_ena.setter
72 def maintenance_ena(self, value: bool) -> None:
73 if value:
74 self._value |= (1 << STARTUP_MAINTENANCE_ENA_BIT)
75 else:
76 self._value &= ~(1 << STARTUP_MAINTENANCE_ENA_BIT)
78 def to_dict(self) -> dict:
79 """Export fields as dictionary.
81 :returns: Configuration fields and their values
82 """
83 return {
84 'mbist_dis': self.mbist_dis,
85 'rngtest_dis': self.rngtest_dis,
86 'maintenance_ena': self.maintenance_ena
87 }
89 def __str__(self) -> str:
90 """Human-readable representation."""
91 return "StartUpConfig(mbist_dis={}, rngtest_dis={}, maintenance_ena={})".format(
92 self.mbist_dis, self.rngtest_dis, self.maintenance_ena)