From 606438a736c514e64b6ed1e9202a0cd53920232b Mon Sep 17 00:00:00 2001 From: saji Date: Sun, 31 Mar 2024 11:31:24 -0500 Subject: [PATCH] added first pass of telem3 board --- app/boards/nucleo_f302r8.overlay | 21 --- app/src/main.c | 30 ++++- boards/vendor/telem3/Kconfig.telem3 | 2 + boards/vendor/telem3/README.md | 15 +++ boards/vendor/telem3/board.cmake | 7 + boards/vendor/telem3/board.yml | 5 + boards/vendor/telem3/telem3.dts | 182 ++++++++++++++++++++++++++ boards/vendor/telem3/telem3.yaml | 26 ++++ boards/vendor/telem3/telem3_defconfig | 27 ++++ west.yml | 7 +- 10 files changed, 291 insertions(+), 31 deletions(-) delete mode 100644 app/boards/nucleo_f302r8.overlay create mode 100644 boards/vendor/telem3/Kconfig.telem3 create mode 100644 boards/vendor/telem3/README.md create mode 100644 boards/vendor/telem3/board.cmake create mode 100644 boards/vendor/telem3/board.yml create mode 100644 boards/vendor/telem3/telem3.dts create mode 100644 boards/vendor/telem3/telem3.yaml create mode 100644 boards/vendor/telem3/telem3_defconfig diff --git a/app/boards/nucleo_f302r8.overlay b/app/boards/nucleo_f302r8.overlay deleted file mode 100644 index c792480..0000000 --- a/app/boards/nucleo_f302r8.overlay +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2021 Nordic Semiconductor ASA - * SPDX-License-Identifier: Apache-2.0 - */ - -/* This devicetree overlay file will be automatically picked by the Zephyr - * build system when building the sample for the nucleo_f302r8 board. It shows - * how the example-application can be built on sample boards already provided - * by Zephyr. - */ - -/ { - examplesensor0: examplesensor_0 { - compatible = "zephyr,examplesensor"; - input-gpios = <&gpioc 13 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; - }; -}; - -&gpioc { - status = "okay"; -}; diff --git a/app/src/main.c b/app/src/main.c index 0bf9b67..241cc95 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -5,24 +5,42 @@ #include #include -#include - +#include +#include +#include #include + + +static void gnss_data_cb(const struct device *dev, const struct gnss_data *data) +{ + if (data->info.fix_status != GNSS_FIX_STATUS_NO_FIX) { + printf("%s has fix!\r\n", dev->name); + } +} +GNSS_SATELLITES_CALLBACK_DEFINE(DEVICE_DT_GET(DT_ALIAS(gnss)), gnss_satellites_cb); + LOG_MODULE_REGISTER(main, CONFIG_APP_LOG_LEVEL); + +static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(gps_en, gpios); int main(void) { int ret; const struct device *sensor; - printk("Zephyr Example Application %s\n", APP_VERSION_STRING); + printk("Zephyr Example Application! hello\n"); - sensor = DEVICE_DT_GET(DT_NODELABEL(examplesensor0)); - if (!device_is_ready(sensor)) { - LOG_ERR("Sensor not ready"); + if (!gpio_is_ready_dt(&led)) { return 0; } + ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE); + if (ret < 0) { + return 0; + } + + gpio_pin_set_dt(&led, 1); + while (1) { struct sensor_value val; diff --git a/boards/vendor/telem3/Kconfig.telem3 b/boards/vendor/telem3/Kconfig.telem3 new file mode 100644 index 0000000..7f34025 --- /dev/null +++ b/boards/vendor/telem3/Kconfig.telem3 @@ -0,0 +1,2 @@ +config BOARD_TELEM3 + select SOC_STM32L562XX diff --git a/boards/vendor/telem3/README.md b/boards/vendor/telem3/README.md new file mode 100644 index 0000000..9111333 --- /dev/null +++ b/boards/vendor/telem3/README.md @@ -0,0 +1,15 @@ +# Telem Version 3 Hardware + +This board is the third major revision of telemetry. It has the following features: + +- SD Card logging +- CAN bus interface +- Li-Ion battery backup +- USB-C device for real-time CAN data +- GPS for position data +- ESP32-C3 with AT firmware for Wifi +- 32 MB onboard SPI flash +- Expansion header for modular radio solution. + + + diff --git a/boards/vendor/telem3/board.cmake b/boards/vendor/telem3/board.cmake new file mode 100644 index 0000000..c951cbb --- /dev/null +++ b/boards/vendor/telem3/board.cmake @@ -0,0 +1,7 @@ + +board_runner_args(pyocd "--target=stm32l562zetx") +board_runner_args(stm32cubeprogrammer "--port=swd" "--reset-mode=hw") + +include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake) +include(${ZEPHYR_BASE}/boards/common/stm32cubeprogrammer.board.cmake) +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) diff --git a/boards/vendor/telem3/board.yml b/boards/vendor/telem3/board.yml new file mode 100644 index 0000000..eec439b --- /dev/null +++ b/boards/vendor/telem3/board.yml @@ -0,0 +1,5 @@ +board: + name: telem3 + vendor: vendor + socs: + - name: stm32l562xx diff --git a/boards/vendor/telem3/telem3.dts b/boards/vendor/telem3/telem3.dts new file mode 100644 index 0000000..063cf1e --- /dev/null +++ b/boards/vendor/telem3/telem3.dts @@ -0,0 +1,182 @@ + + +/dts-v1/; +#include +#include + +/ { + model = "Telem3"; + compatible = "vendor,telem3"; + #address-cells = <1>; + #size-cells = <1>; + leds { + compatible = "gpio-leds"; + + fault_led: led_d12 { + gpios = <&gpiod 12 GPIO_ACTIVE_HIGH>; + label = "Fault Indicator"; + }; + status_led0: led_d10 { + gpios = <&gpiod 10 GPIO_ACTIVE_HIGH>; + label = "Status 0 Indicator"; + }; + status_led1: led_d15 { + gpios = <&gpiod 15 GPIO_ACTIVE_HIGH>; + label = "Status 1 Indicator"; + }; + status_led2: led_d13 { + gpios = <&gpiod 13 GPIO_ACTIVE_HIGH>; + label = "Status 2 Indicator"; + }; + status_led3: led_d11 { + gpios = <&gpiod 11 GPIO_ACTIVE_HIGH>; + label = "Status 3 Indicator"; + }; + good_led: led_d14 { + gpios = <&gpiod 14 GPIO_ACTIVE_HIGH>; + label = "Good Indicator"; + }; + + // TODO: should this really be here + // gps_en: gps_en { + // gpios = <&gpiod 9 GPIO_ACTIVE_HIGH>; + // label = "GPS power enable"; + // }; + }; + + option_switches { + compatible = "gpio-keys"; + option_0: opt_0 { + gpios = <&gpioe 15 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + label = "Switch Option 0"; + }; + option_1: opt_1 { + gpios = <&gpioe 14 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + label = "Switch Option 1"; + }; + option_2: opt_2 { + gpios = <&gpioe 13 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + label = "Switch Option 2"; + }; + }; + chosen { + zephyr,console = &usart1; + zephyr,shell-uart = &usart1; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + }; + aliases { + led0 = &good_led; + sw0 = &option_0; + die-temp0 = &die_temp; + volt-sensor0 = &vref; + volt-sensor1 = &vbat; + }; +}; + +// &clk_lse { +// status = "okay"; +// }; + +&clk_hse { + status = "okay"; + clock-frequency = ; +}; +&pll { + // 96 MHz core, 48/24 elsewhere + div-m = <1>; + mul-n = <24>; + div-p = <7>; + div-q = <4>; + div-r = <2>; + status = "okay"; + clocks = <&clk_hse>; +}; + +&rcc { + clocks = <&pll>; + clock-frequency = ; + ahb-prescaler = <1>; + apb1-prescaler = <4>; + apb2-prescaler = <4>; +}; + +// stm32_lp_tick_source: &lptim1 { +// clocks = <&rcc STM32_CLOCK_BUS_APB1 0x80000000>, +// <&rcc STM32_SRC_LSE LPTIM1_SEL(3)>; +// status = "okay"; +// }; +&usart1 { + current-speed = <115200>; + pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>; + pinctrl-names = "default"; + status = "okay"; +}; + +&usart2 { + current-speed = <9600>; + pinctrl-0 = <&usart2_tx_pd5 &usart2_rx_pd6>; + pinctrl-names = "default"; + status = "okay"; + gnss: gnss-nmea-generic { + compatible = "gnss-nmea-generic"; + }; +}; + + +&rng { + status = "okay"; +}; +&die_temp { + status = "okay"; +}; + +zephyr_udc0: &usb { + pinctrl-0 = <&usb_dp_pa12 &usb_dm_pa11>; + pinctrl-names = "default"; + status = "okay"; +}; + +&sdmmc1 { + status = "okay"; + + pinctrl-0 = <&sdmmc1_d0_pc8 + &sdmmc1_d1_pc9 + &sdmmc1_d2_pc10 + &sdmmc1_d3_pc11 + &sdmmc1_ck_pc12 + &sdmmc1_cmd_pd2>; + + pinctrl-names = "default"; +}; + +&spi1 { + pinctrl-0 = <&spi1_sck_pa5 &spi1_miso_pa6 &spi1_mosi_pa7>; + pinctrl-names = "default"; + cs-gpios = <&gpioa 3 GPIO_ACTIVE_LOW>; + status = "okay"; + + bme280@0 { + compatible = "bosch,bme280"; + reg = <0>; + spi-max-frequency = ; + }; +}; + +&vref { + status = "okay"; +}; + +&vbat { + status = "okay"; +}; + +&iwdg { + status = "okay"; +}; + +&aes { + status = "okay"; +}; + + diff --git a/boards/vendor/telem3/telem3.yaml b/boards/vendor/telem3/telem3.yaml new file mode 100644 index 0000000..5c80b46 --- /dev/null +++ b/boards/vendor/telem3/telem3.yaml @@ -0,0 +1,26 @@ +identifier: telem3 +name: Telem 3 +vendor: vendor +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb +supported: + - gpio + - i2c + - lptim + - pwm + - counter + - watchdog + - dac + - adc + - spi + - ble + - dma + - usart + - arduino_spi + - sdhc + - usb + - usb_device + - nvs diff --git a/boards/vendor/telem3/telem3_defconfig b/boards/vendor/telem3/telem3_defconfig new file mode 100644 index 0000000..31c2add --- /dev/null +++ b/boards/vendor/telem3/telem3_defconfig @@ -0,0 +1,27 @@ +# enable uart driver +CONFIG_SERIAL=y + +# enable GPIO +CONFIG_GPIO=y + +# Enable Clocks +CONFIG_CLOCK_CONTROL=y + +# console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +CONFIG_GNSS=y +CONFIG_UART_INTERRUPT_DRIVEN=y +CONFIG_LOG=y +CONFIG_GNSS_DUMP_TO_LOG=y + + +# Enable MPU +CONFIG_ARM_MPU=y + +# Enable HW stack protection +CONFIG_HW_STACK_PROTECTION=y + +# enable pin controller +CONFIG_PINCTRL=y diff --git a/west.yml b/west.yml index 6bb551c..5335323 100644 --- a/west.yml +++ b/west.yml @@ -1,6 +1,3 @@ -# Copyright (c) 2021 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 - manifest: self: west-commands: scripts/west-commands.yml @@ -17,6 +14,8 @@ manifest: # By using name-allowlist we can clone only the modules that are # strictly needed by the application. name-allowlist: + - fatfs + - cmsis-dsp + - mcuboot - cmsis # required by the ARM port - - hal_nordic # required by the custom_plank board (Nordic based) - hal_stm32 # required by the nucleo_f302r8 board (STM32 based)