forked from espressif/esp-idf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchip_specific_config.py
70 lines (63 loc) · 2.48 KB
/
chip_specific_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Copyright 2015-2021 Espressif Systems (Shanghai) CO LTD
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This file contains values (e.g. delay time, ...) that are different for each chip for a particular action.
# If adding a new device, set only values that are different from the default, e.g.:
# 'esp32s2': {
# 0: {
# 'reset': 0.35,
# }
# },
#
# for more information see the method "handle_commands" in idf_monitor.py
conf = {
# the default values were previously hardcoded in idf_monitor.py (taken from esptool.py)
'default': {
0: {
'reset': 0.2,
'enter_boot_set': 0.1,
'enter_boot_unset': 0.05,
}
},
'esp32': {
0: {
'reset': 0.2,
'enter_boot_set': 1.3,
'enter_boot_unset': 0.45,
},
1: {
'reset': 0.2,
'enter_boot_set': 0.1,
'enter_boot_unset': 0.05,
}
},
}
def get_chip_config(chip, revision=0):
# type: (str, int) -> dict
# If the config is not set in the `conf` dict for a specific chip, the `default` will be used.
# In case if only some values are specified, others are used from the `default`.
# If chip is set in `conf` but the specific revision R is missing,
# the values from highest revision lower than R are used.
# If some fields are missing, they will be taken from next lower revision or from the `default`.
default = dict(conf['default'][0])
rev_number = int(revision)
if chip not in conf.keys():
return default
chip_revisions = sorted(list(conf[chip].keys()), key=int)
for rev in chip_revisions:
if int(rev) > rev_number:
break
for key in conf[chip][rev].keys():
default[key] = conf[chip][rev][key]
return default