Coverage for tropicsquare / config / debug.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-03-27 21:24 +0000

1"""Debug configuration (CFG_DEBUG @ 0x10)""" 

2 

3from tropicsquare.config.base import BaseConfig 

4from tropicsquare.config.constants import DEBUG_FW_LOG_EN_BIT 

5 

6 

7class DebugConfig(BaseConfig): 

8 """Debug configuration register. 

9 

10 Controls debugging features and logging. 

11 

12 Fields: 

13 fw_log_en: Firmware logging enable (bit 0) 

14 """ 

15 

16 @property 

17 def fw_log_en(self) -> bool: 

18 """Firmware logging enable flag. 

19 

20 When True, firmware logging is enabled. Logs can be retrieved 

21 using appropriate debug commands. 

22 Default: False (logging disabled) 

23 

24 :returns: True if firmware logging is enabled 

25 :rtype: bool 

26 """ 

27 return bool((self._value >> DEBUG_FW_LOG_EN_BIT) & 1) 

28 

29 @fw_log_en.setter 

30 def fw_log_en(self, value: bool) -> None: 

31 if value: 

32 self._value |= (1 << DEBUG_FW_LOG_EN_BIT) 

33 else: 

34 self._value &= ~(1 << DEBUG_FW_LOG_EN_BIT) 

35 

36 def to_dict(self) -> dict: 

37 """Export fields as dictionary. 

38 

39 :returns: Configuration fields and their values 

40 :rtype: dict 

41 """ 

42 return { 

43 'fw_log_en': self.fw_log_en 

44 } 

45 

46 def __str__(self) -> str: 

47 """Human-readable representation.""" 

48 return "DebugConfig(fw_log_en={})".format(self.fw_log_en)