1# This file describes eFuses fields and registers for ESP32 chip 2# 3# SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD 4# 5# SPDX-License-Identifier: GPL-2.0-or-later 6 7from collections import namedtuple 8 9 10class EfuseRegistersBase(object): 11 # Coding Scheme values 12 CODING_SCHEME_NONE = 0 13 CODING_SCHEME_34 = 1 14 CODING_SCHEME_REPEAT = 2 15 CODING_SCHEME_NONE_RECOVERY = 3 16 CODING_SCHEME_RS = 4 17 18 EFUSE_BURN_TIMEOUT = 0.250 # seconds 19 20 21class EfuseBlocksBase(object): 22 BLOCKS = None 23 NamedtupleBlock = namedtuple( 24 "Block", 25 "name alias id rd_addr wr_addr write_disable_bit " 26 "read_disable_bit len key_purpose", 27 ) 28 29 @staticmethod 30 def get(tuple_block): 31 return EfuseBlocksBase.NamedtupleBlock._make(tuple_block) 32 33 def get_blocks_for_keys(self): 34 list_of_names = [] 35 for block in self.BLOCKS: 36 blk = self.get(block) 37 if blk.id > 0: 38 if blk.name: 39 list_of_names.append(blk.name) 40 if blk.alias: 41 for alias in blk.alias: 42 list_of_names.append(alias) 43 return list_of_names 44 45 46class EfuseFieldsBase(object): 47 NamedtupleField = namedtuple( 48 "Efuse", 49 "name category block word pos type write_disable_bit " 50 "read_disable_bit class_type description dictionary", 51 ) 52 53 @staticmethod 54 def get(tuple_field): 55 return EfuseFieldsBase.NamedtupleField._make(tuple_field) 56