Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(power): diamond: remove 12v power supply, use only 12v-caps #164

Draft
wants to merge 1 commit into
base: fouge/zephyr-4.0.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 21 additions & 32 deletions boards/tfh/diamond_main/diamond_main.dts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@

supply-3v3-ssd-enable-gpios = <&gpio_exp_pwr_brd 2 GPIO_ACTIVE_HIGH>;
supply-3v3-wifi-enable-gpios = <&gpio_exp1 10 GPIO_ACTIVE_HIGH>;
supply-12v-enable-gpios = <&gpio_exp_pwr_brd 7 GPIO_ACTIVE_HIGH>;
supply-5v-enable-gpios = <&gpio_exp_pwr_brd 1 GPIO_ACTIVE_LOW>;
supply-3v3-enable-gpios = <&gpio_exp1 9 GPIO_ACTIVE_HIGH>;
supply-1v8-enable-gpios = <&gpio_exp2 3 GPIO_ACTIVE_HIGH>;
Expand Down Expand Up @@ -193,41 +192,39 @@
// Diamond PoC2: R1=10k, R2=10k
// [3]: PVCC
// Diamond PoC2: R1=442k, R2=23.5k
// [4]: 12V
// [4]: 12V_CAPS
// Diamond PoC2: R1=57k, R2=10k
// [5]: 12V_CAPS
// Diamond PoC2: R1=57k, R2=10k
// [6]: V_SCAP_LOW
// [5]: V_SCAP_LOW
// Diamond PoC2
// [7]: V_SCAP_HIGH
// [6]: V_SCAP_HIGH
// Diamond PoC2
// [8]: Die Temperature
// [9]: Vbat / 3
// [7]: Die Temperature
// [8]: Vbat / 3
// adc4:
// [10]: 1V8_SEC
// [9]: 1V8_SEC
// Diamond PoC2: R1=27R, R2=inf
// [11]: 4V7_SEC
// [10]: 4V7_SEC
// Diamond PoC2: R1=2*47k, R2=47k
// adc5:
// [12]: 1V8
// [11]: 1V8
// Diamond PoC2: R1=27R, R2=inf
// [13]: 3V3
// [12]: 3V3
// Diamond PoC2: R1=10k, R2=10k
// [14]: 5V
// [13]: 5V
// Diamond PoC2: R1=20k, R2=10k
// [15]: 3V6
// [14]: 3V6
// Diamond PoC2: R1=10k, R2=10k
// [16]: 3V3_LTE
// [15]: 3V3_LTE
// Diamond PoC2: R1=10k, R2=10k
// [17]: 1V2
// [16]: 1V2
// Diamond PoC2: R1=27R, R2=inf
// [18]: 2V8
// [17]: 2V8
// Diamond PoC2: R1=10k, R2=10k
// [19]: VREFINT (typ. 1.212 V)
// [18]: VREFINT (typ. 1.212 V)
//
io-channels = <&adc1 1>, <&adc1 2>, <&adc1 3>, <&adc1 7>, <&adc1 8>, <&adc1 9>, <&adc1 11>, <&adc1 14>, <&adc1 16>, <&adc1 17>,<&adc4 1>, <&adc4 2>, <&adc5 7>, <&adc5 8>, <&adc5 9>, <&adc5 12>, <&adc5 13>, <&adc5 14>, <&adc5 15>, <&adc5 18>;
io-channel-names = "vbat_sw", "3v3_ssd", "3v3_wifi", "pvcc", "12v", "12v_caps", "v_scap_low", "v_scap_high", "die_temp", "3v3_uc","1v8_sec", "4v7_sec", "1v8", "3v3", "5v", "3v6", "3v3_lte", "1v2", "2V8", "vrefint";
voltage-divider-scalings = "10.4f", "2.0f", "2.0f", "19.81f", "6.7f", "6.7f", "1.0f", "1.0f", "1.0f", "3.0f","1.0f", "3.0f", "1.0f", "2.0f", "3.0f", "2.0f", "2.0f", "1.0f", "2.0f", "1.0f";
io-channels = <&adc1 1>, <&adc1 2>, <&adc1 3>, <&adc1 7>, <&adc1 9>, <&adc1 11>, <&adc1 14>, <&adc1 16>, <&adc1 17>,<&adc4 1>, <&adc4 2>, <&adc5 7>, <&adc5 8>, <&adc5 9>, <&adc5 12>, <&adc5 13>, <&adc5 14>, <&adc5 15>, <&adc5 18>;
io-channel-names = "vbat_sw", "3v3_ssd", "3v3_wifi", "pvcc", "12v_caps", "v_scap_low", "v_scap_high", "die_temp", "3v3_uc","1v8_sec", "4v7_sec", "1v8", "3v3", "5v", "3v6", "3v3_lte", "1v2", "2V8", "vrefint";
voltage-divider-scalings = "10.4f", "2.0f", "2.0f", "19.81f", "6.7f", "1.0f", "1.0f", "1.0f", "3.0f","1.0f", "3.0f", "1.0f", "2.0f", "3.0f", "2.0f", "2.0f", "1.0f", "2.0f", "1.0f";
};

i2c-mux-gpio-mainboard {
Expand Down Expand Up @@ -519,7 +516,7 @@
dma-names = "dmamux";

status = "okay";
pinctrl-0 = <&adc1_in1_pa0 &adc1_in2_pa1 &adc1_in3_pa2 &adc1_in7_pc1 &adc1_in8_pc2 &adc1_in9_pc3 &adc1_in11_pb12 &adc1_in14_pb11>;
pinctrl-0 = <&adc1_in1_pa0 &adc1_in2_pa1 &adc1_in3_pa2 &adc1_in7_pc1 &adc1_in9_pc3 &adc1_in11_pb12 &adc1_in14_pb11>;
pinctrl-names = "default";
st,adc-clock-source = "SYNC";
st,adc-prescaler = <4>;
Expand Down Expand Up @@ -560,14 +557,6 @@
zephyr,resolution = <12>;
};

channel@8 { // 12V
reg = <8>;
zephyr,acquisition-time = <ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 48)>; // ~1.1 µs @ ADC_CLK = 42.5 MHz
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,resolution = <12>;
};

channel@9 { // 12V_CAPS
reg = <9>;
zephyr,acquisition-time = <ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 48)>; // ~1.1 µs @ ADC_CLK = 42.5 MHz
Expand Down Expand Up @@ -763,8 +752,8 @@
channel@12 { // VREFINT (typ. 1.212 V)
reg = <18>;
// Minimum required sampling time is 4 µs according to the datasheet
// Our ADC is running with 42.5 MHz (AHB = 170 MHz / 4)
// This means we need to set the sampling time to at least 4 µs * 42.5 MHz = 170 ADC Ticks
// Our ADC is running with 42.5 MHz (AHB = 170 MHz / 4)
// This means we need to set the sampling time to at least 4 µs * 42.5 MHz = 170 ADC Ticks
zephyr,acquisition-time = <ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 248)>; // ~5.8 µs @ ADC_CLK = 42.5 MHz
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
Expand Down
27 changes: 15 additions & 12 deletions main_board/src/power/boot/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ static const struct gpio_dt_spec supply_3v8_enable_rfid_irq_gpio_spec =
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), supply_3v8_enable_rfid_irq_gpios);
static const struct gpio_dt_spec lte_gps_usb_reset_gpio_spec =
GPIO_DT_SPEC_GET(DT_PATH(lte_gps_usb_reset), gpios);
static const struct gpio_dt_spec supply_12v_enable_gpio_spec =
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), supply_12v_enable_gpios);
#endif

static const struct gpio_dt_spec supply_3v3_ssd_enable_gpio_spec =
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), supply_3v3_ssd_enable_gpios);
static const struct gpio_dt_spec supply_3v3_wifi_enable_gpio_spec =
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), supply_3v3_wifi_enable_gpios);
static const struct gpio_dt_spec supply_12v_enable_gpio_spec =
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), supply_12v_enable_gpios);
static const struct gpio_dt_spec supply_5v_enable_gpio_spec =
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), supply_5v_enable_gpios);
static const struct gpio_dt_spec supply_3v3_enable_gpio_spec =
Expand Down Expand Up @@ -113,10 +113,12 @@ power_configure_gpios(void)
int ret;

if (!device_is_ready(supply_vbat_sw_enable_gpio_spec.port) ||
!device_is_ready(supply_12v_enable_gpio_spec.port) ||
!device_is_ready(supply_5v_enable_gpio_spec.port) ||
#if defined(CONFIG_BOARD_PEARL_MAIN)
!device_is_ready(supply_12v_enable_gpio_spec.port) ||
!device_is_ready(supply_3v8_enable_rfid_irq_gpio_spec.port) ||
#elif defined(CONFIG_BOARD_DIAMOND_MAIN)
!device_is_ready(supply_12v_caps_enable_gpio_spec.port) ||
#endif
!device_is_ready(supply_3v3_enable_gpio_spec.port) ||
!device_is_ready(supply_1v8_enable_gpio_spec.port) ||
Expand All @@ -138,12 +140,21 @@ power_configure_gpios(void)
return RET_ERROR_INTERNAL;
}

#if defined(CONFIG_BOARD_PEARL_MAIN)
ret = gpio_pin_configure_dt(&supply_12v_enable_gpio_spec,
GPIO_OUTPUT_INACTIVE);
if (ret != 0) {
ASSERT_SOFT(ret);
return RET_ERROR_INTERNAL;
}
#elif defined(CONFIG_BOARD_DIAMOND_MAIN)
ret = gpio_pin_configure_dt(&supply_12v_caps_enable_gpio_spec,
GPIO_OUTPUT_INACTIVE);
if (ret != 0) {
ASSERT_SOFT(ret);
return RET_ERROR_INTERNAL;
}
#endif

ret = gpio_pin_configure_dt(&supply_5v_enable_gpio_spec,
GPIO_OUTPUT_INACTIVE);
Expand Down Expand Up @@ -266,7 +277,6 @@ power_configure_gpios(void)

#if defined(CONFIG_BOARD_DIAMOND_MAIN)
if (!device_is_ready(supply_3v3_lte_enable_gpio_spec.port) ||
!device_is_ready(supply_12v_caps_enable_gpio_spec.port) ||
!device_is_ready(supply_1v2_enable_gpio_spec.port) ||
!device_is_ready(supply_2v8_enable_gpio_spec.port) ||
!device_is_ready(supply_3v6_enable_gpio_spec.port) ||
Expand All @@ -282,13 +292,6 @@ power_configure_gpios(void)
return RET_ERROR_INTERNAL;
}

ret = gpio_pin_configure_dt(&supply_12v_caps_enable_gpio_spec,
GPIO_OUTPUT_INACTIVE);
if (ret != 0) {
ASSERT_SOFT(ret);
return RET_ERROR_INTERNAL;
}

ret = gpio_pin_configure_dt(&supply_1v2_enable_gpio_spec,
GPIO_OUTPUT_INACTIVE);
if (ret != 0) {
Expand Down Expand Up @@ -422,10 +425,10 @@ turn_on_power_supplies(void)

k_msleep(100);

#if defined(CONFIG_BOARD_PEARL_MAIN)
gpio_pin_set_dt(&supply_12v_enable_gpio_spec, 1);
LOG_INF("12V enabled");

#if defined(CONFIG_BOARD_PEARL_MAIN)
// 3.8V regulator only available on EV1...4
if ((version == orb_mcu_Hardware_OrbVersion_HW_VERSION_PEARL_EV1) ||
(version == orb_mcu_Hardware_OrbVersion_HW_VERSION_PEARL_EV2) ||
Expand Down
7 changes: 6 additions & 1 deletion main_board/src/voltage_measurement/voltage_measurement.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static volatile const struct device *const adc5_dev =
#define MAX_VOLTAGE_TRANSMIT_PERIOD_MS 60000

#if defined(CONFIG_BOARD_DIAMOND_MAIN)
#define NUMBER_OF_CHANNELS_ADC_1 10
#define NUMBER_OF_CHANNELS_ADC_1 9
#define NUMBER_OF_CHANNELS_ADC_4 2
#define NUMBER_OF_CHANNELS_ADC_5 8
#else
Expand Down Expand Up @@ -621,7 +621,12 @@ publish_all_voltages(void)
// not available on Main MCU
continue;
case orb_mcu_main_Voltage_VoltageSource_SUPPLY_12V:
#ifdef CONFIG_BOARD_PEARL_MAIN
channel = CHANNEL_12V;
#else
// not available on Diamond, 12V_CAPS is used instead
continue;
#endif
break;
case orb_mcu_main_Voltage_VoltageSource_SUPPLY_5V:
channel = CHANNEL_5V;
Expand Down
1 change: 0 additions & 1 deletion main_board/src/voltage_measurement/voltage_measurement.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ typedef enum {
CHANNEL_3V3_SSD_3V8,
CHANNEL_3V3_WIFI,
CHANNEL_PVCC,
CHANNEL_12V,
CHANNEL_12V_CAPS,
CHANNEL_V_SCAP_LOW,
CHANNEL_V_SCAP_HIGH,
Expand Down
Loading