Standardize CPU temp and voltage. Add autogen warning

This commit is contained in:
Scott Shawcroft 2023-04-28 16:19:43 -07:00
parent 18207cd547
commit 8104b824e0
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA
35 changed files with 249 additions and 9 deletions

View File

@ -34,7 +34,7 @@ float common_hal_mcu_processor_get_temperature(void) {
}
float common_hal_mcu_processor_get_voltage(void) {
return 1.2f;
return NAN;
}
uint32_t common_hal_mcu_processor_get_frequency(void) {

View File

@ -47,7 +47,7 @@
float common_hal_mcu_processor_get_temperature(void) {
float tsens_out;
#if defined(CONFIG_IDF_TARGET_ESP32)
mp_raise_NotImplementedError(NULL);
return NAN;
#else
temp_sensor_config_t temp_sensor = TSENS_CONFIG_DEFAULT(); // DEFAULT: range:-10℃ ~ 80℃, error < 1℃.
temp_sensor_set_config(temp_sensor);

View File

@ -54,7 +54,7 @@ float common_hal_mcu_processor_get_temperature(void) {
return temp;
#else
return 0;
return NAN;
#endif
}

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1011` to update this file.
*/
#include "py/obj.h"
#include "py/mphal.h"
#include "mimxrt10xx/periph.h"

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1011` to update this file.
*/
#pragma once
extern LPI2C_Type *const mcu_i2c_banks[2];
extern const mcu_periph_obj_t mcu_i2c_sda_list[8];

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1011` to update this file.
*/
#include "py/obj.h"
#include "py/mphal.h"
#include "mimxrt10xx/pins.h"

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1011` to update this file.
*/
#pragma once
#define FORMAT_PIN(pin_name) extern const mcu_pin_obj_t pin_##pin_name;

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1015` to update this file.
*/
#include "py/obj.h"
#include "py/mphal.h"
#include "mimxrt10xx/periph.h"

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1015` to update this file.
*/
#pragma once
extern LPI2C_Type *const mcu_i2c_banks[2];
extern const mcu_periph_obj_t mcu_i2c_sda_list[2];

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1015` to update this file.
*/
#include "py/obj.h"
#include "py/mphal.h"
#include "mimxrt10xx/pins.h"

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1015` to update this file.
*/
#pragma once
#define FORMAT_PIN(pin_name) extern const mcu_pin_obj_t pin_##pin_name;

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1021` to update this file.
*/
#include "py/obj.h"
#include "py/mphal.h"
#include "mimxrt10xx/periph.h"

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1021` to update this file.
*/
#pragma once
extern LPI2C_Type *const mcu_i2c_banks[4];
extern const mcu_periph_obj_t mcu_i2c_sda_list[8];

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1021` to update this file.
*/
#include "py/obj.h"
#include "py/mphal.h"
#include "mimxrt10xx/pins.h"

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1021` to update this file.
*/
#pragma once
#define FORMAT_PIN(pin_name) extern const mcu_pin_obj_t pin_##pin_name;

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1042` to update this file.
*/
#include "py/obj.h"
#include "py/mphal.h"
#include "mimxrt10xx/periph.h"

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1042` to update this file.
*/
#pragma once
extern LPI2C_Type *const mcu_i2c_banks[4];
extern const mcu_periph_obj_t mcu_i2c_sda_list[9];

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1042` to update this file.
*/
#include "py/obj.h"
#include "py/mphal.h"
#include "mimxrt10xx/pins.h"

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1042` to update this file.
*/
#pragma once
#define FORMAT_PIN(pin_name) extern const mcu_pin_obj_t pin_##pin_name;

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1052` to update this file.
*/
#include "py/obj.h"
#include "py/mphal.h"
#include "mimxrt10xx/periph.h"

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1052` to update this file.
*/
#pragma once
extern LPI2C_Type *const mcu_i2c_banks[4];
extern const mcu_periph_obj_t mcu_i2c_sda_list[9];

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1052` to update this file.
*/
#include "py/obj.h"
#include "py/mphal.h"
#include "mimxrt10xx/pins.h"

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1052` to update this file.
*/
#pragma once
#define FORMAT_PIN(pin_name) extern const mcu_pin_obj_t pin_##pin_name;

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1062` to update this file.
*/
#include "py/obj.h"
#include "py/mphal.h"
#include "mimxrt10xx/periph.h"

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1062` to update this file.
*/
#pragma once
extern LPI2C_Type *const mcu_i2c_banks[4];
extern const mcu_periph_obj_t mcu_i2c_sda_list[9];

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1062` to update this file.
*/
#include "py/obj.h"
#include "py/mphal.h"
#include "mimxrt10xx/pins.h"

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1062` to update this file.
*/
#pragma once
#define FORMAT_PIN(pin_name) extern const mcu_pin_obj_t pin_##pin_name;

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1176` to update this file.
*/
#include "py/obj.h"
#include "py/mphal.h"
#include "mimxrt10xx/periph.h"

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1176` to update this file.
*/
#pragma once
extern LPI2C_Type *const mcu_i2c_banks[6];
extern const mcu_periph_obj_t mcu_i2c_sda_list[8];

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1176` to update this file.
*/
#include "py/obj.h"
#include "py/mphal.h"
#include "mimxrt10xx/pins.h"

View File

@ -26,6 +26,14 @@
* THE SOFTWARE.
*/
/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> MIMXRT1176` to update this file.
*/
#pragma once
#define FORMAT_PIN(pin_name) extern const mcu_pin_obj_t pin_##pin_name;

View File

@ -60,8 +60,18 @@ copyright = """/*
*/
"""
autogen_warning_template = """/*
* This file is autogenerated! Do NOT hand edit it. Instead, edit tools/gen_peripherals_data.py and
* then rerun the script. You'll need to 1) clone https://github.com/nxp-mcuxpresso/mcux-soc-svd/
* and 2) download and extract config tools data from https://mcuxpresso.nxp.com/en/select_config_tools_data.
*
* Run `python tools/gen_peripherals_data.py <svd dir> <config dir> {}` to update this file.
*/
"""
for device in devices:
print(device)
autogen_warning = autogen_warning_template.format(device)
svd_fn = svd_folder / device / (device + ".xml")
if not svd_fn.exists():
svd_fn = svd_folder / device / (device + "_cm7.xml")
@ -129,6 +139,7 @@ for device in devices:
pins_h = [
copyright,
autogen_warning,
"#pragma once",
"",
"#define FORMAT_PIN(pin_name) extern const mcu_pin_obj_t pin_##pin_name;",
@ -137,6 +148,7 @@ for device in devices:
]
pins_c = [
copyright,
autogen_warning,
'#include "py/obj.h"',
'#include "py/mphal.h"',
'#include "mimxrt10xx/pins.h"',
@ -255,7 +267,8 @@ for device in devices:
f"const mcu_pin_obj_t pin_{pin_name} = PIN({gpio_instance}, {gpio_number}, {pin_name}, {adc_instance}, {adc_channel}, 0x{mux_reset:08X}, 0x{pad_reset:08X});"
)
pins_c.append("")
if usb_pins:
pins_c.append("")
for pin_name in sorted(usb_pins):
pin_names_h.append(f"FORMAT_PIN({pin_name})")
@ -275,9 +288,10 @@ for device in devices:
(out_dir / "pins.h").write_text("\n".join(pins_h))
(out_dir / "pins.c").write_text("\n".join(pins_c))
periph_h = [copyright, "#pragma once"]
periph_h = [copyright, autogen_warning, "#pragma once"]
periph_c = [
copyright,
autogen_warning,
'#include "py/obj.h"',
'#include "py/mphal.h"',
'#include "mimxrt10xx/periph.h"',
@ -352,5 +366,7 @@ for device in devices:
periph_c.append(f"}};")
periph_c.append("")
periph_h.append("")
(out_dir / "periph.h").write_text("\n".join(periph_h))
(out_dir / "periph.c").write_text("\n".join(periph_c))

View File

@ -53,7 +53,7 @@ float common_hal_mcu_processor_get_temperature(void) {
}
float common_hal_mcu_processor_get_voltage(void) {
return 3.3f;
return NAN;
}
uint32_t common_hal_mcu_processor_get_frequency(void) {

View File

@ -46,7 +46,7 @@ float common_hal_mcu_processor_get_temperature(void) {
float common_hal_mcu_processor_get_voltage(void) {
// xG24 does not have built-in direct reading of processor voltage
// Have Only 1 of IADC, already used for analogio module
return 3.3f;
return NAN;
}
uint32_t common_hal_mcu_processor_get_frequency(void) {

View File

@ -96,7 +96,7 @@ float common_hal_mcu_processor_get_temperature(void) {
float core_temp_avg_slope = (*ADC_CAL2 - *ADC_CAL1) / 80.0;
return (((float)value * adc_refcor - *ADC_CAL1) / core_temp_avg_slope) + 30.0f;
#else
return false;
return NAN;
#endif
}
@ -129,7 +129,7 @@ float common_hal_mcu_processor_get_voltage(void) {
return adc_refcor * 3.3f;
#else
return false;
return NAN;
#endif
}