diff --git a/app/boards/robin_e3.conf b/app/boards/robin_e3.conf new file mode 100644 index 0000000..6a53954 --- /dev/null +++ b/app/boards/robin_e3.conf @@ -0,0 +1,18 @@ +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=72000000 +CONFIG_CORTEX_M_SYSTICK=y + +CONFIG_USB_DEVICE_STACK=y +CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n +CONFIG_USB_DEVICE_VID=0x1209 +CONFIG_USB_DEVICE_PID=0x0AF0 +CONFIG_USB_DEVICE_PRODUCT="OpenAstroFirmware" +CONFIG_USB_DEVICE_MANUFACTURER="OpenAstroTech" + +CONFIG_USB_CDC_ACM=y +CONFIG_USB_CDC_ACM_RINGBUF_SIZE=512 + +CONFIG_USB_COMPOSITE_DEVICE=y + +# CONFIG_USB_DEVICE_LOG_LEVEL_INF=y +# CONFIG_USB_DRIVER_LOG_LEVEL_INF=y +CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y \ No newline at end of file diff --git a/app/boards/robin_e3.overlay b/app/boards/robin_e3.overlay new file mode 100644 index 0000000..65479d5 --- /dev/null +++ b/app/boards/robin_e3.overlay @@ -0,0 +1,115 @@ +/ { + chosen { + // Console and control interfaces + zephyr,console = &usart3; + oaf,uart-control = &cdc_acm_uart0; + + // OpenAstroFirmware specific device mappings + oaf,ra-stepper-step = &ra_step; + oaf,ra-stepper-dir = &ra_dir; + oaf,ra-stepper-en = &ra_en; + oaf,dec-stepper-step = &dec_step; + oaf,dec-stepper-dir = &dec_dir; + oaf,dec-stepper-en = &dec_en; + oaf,alt-stepper-step = &alt_step; + oaf,alt-stepper-dir = &alt_dir; + oaf,alt-stepper-en = &alt_en; + oaf,az-stepper-step = &az_step; + oaf,az-stepper-dir = &az_dir; + oaf,az-stepper-en = &az_en; + oaf,focus-stepper-step = &focus_step; + oaf,focus-stepper-dir = &focus_dir; + oaf,focus-stepper-en = &focus_en; + + // Sensor mappings + oaf,ra-home-sensor = &ra_homing; + oaf,dec-home-sensor = &dec_homing; + oaf,ra-endstop-east = &ra_endstop_east; + oaf,dec-endstop-up = &dec_endstop_up; + + + // Communication interfaces + oaf,gps-uart = &usart1; + oaf,external-i2c = &i2c1; + + // Status LED + oaf,status-led = &status_led; + }; + + /* Mount Control Configuration */ + mount_controller { + compatible = "oaf,mount-controller"; + + /* RA Axis Configuration */ + ra-axis { + step-gpio = <&ra_step>; + dir-gpio = <&ra_dir>; + enable-gpio = <&ra_en>; + diag-gpio = <&ra_diag>; + home-sensor = <&ra_homing>; + endstop-east = <&ra_endstop_east>; + + steps-per-revolution = <3200>; + gear-ratio = <144>; + max-speed = <1000>; + acceleration = <500>; + }; + + /* DEC Axis Configuration */ + dec-axis { + step-gpio = <&dec_step>; + dir-gpio = <&dec_dir>; + enable-gpio = <&dec_en>; + diag-gpio = <&dec_diag>; + home-sensor = <&dec_homing>; + endstop-up = <&dec_endstop_up>; + + steps-per-revolution = <3200>; + gear-ratio = <54>; + max-speed = <1000>; + acceleration = <500>; + }; + + /* Focus/Alt Configuration */ + focus-axis { + step-gpio = <&focus_step>; + dir-gpio = <&focus_dir>; + enable-gpio = <&focus_en>; + diag-gpio = <&focus_diag>; + + steps-per-revolution = <3200>; + max-speed = <500>; + acceleration = <250>; + }; + + status = "okay"; + }; + +}; + +// Configuration for the CDC ACM UART +&zephyr_udc0 { + cdc_acm_uart0: cdc_acm_uart0 { + compatible = "zephyr,cdc-acm-uart"; + }; +}; + +// GPS UART configuration +&usart1 { + current-speed = <9600>; + status = "okay"; +}; + +// Additional ADC channel for LCD keypad +&adc1 { + #address-cells = <1>; + #size-cells = <0>; + + channel@10 { + reg = <10>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + }; +}; \ No newline at end of file diff --git a/app/sample.yaml b/app/sample.yaml index ec82a08..de1d655 100644 --- a/app/sample.yaml +++ b/app/sample.yaml @@ -8,6 +8,7 @@ common: build_only: true integration_platforms: - robin_nano + - robin_e3 - native_sim tests: app.default: {} diff --git a/boards/mks/robin_e3/Kconfig.robin_e3 b/boards/mks/robin_e3/Kconfig.robin_e3 new file mode 100644 index 0000000..259371d --- /dev/null +++ b/boards/mks/robin_e3/Kconfig.robin_e3 @@ -0,0 +1,5 @@ +# Copyright (c) 2021 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_ROBIN_E3 + select SOC_STM32F103XE diff --git a/boards/mks/robin_e3/board.cmake b/boards/mks/robin_e3/board.cmake new file mode 100644 index 0000000..72a1957 --- /dev/null +++ b/boards/mks/robin_e3/board.cmake @@ -0,0 +1,7 @@ +# Copyright (c) 2021 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +board_runner_args(jlink "--device=STM32F103XB" "--speed=4000") + +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) +include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) \ No newline at end of file diff --git a/boards/mks/robin_e3/board.yml b/boards/mks/robin_e3/board.yml new file mode 100644 index 0000000..9e34068 --- /dev/null +++ b/boards/mks/robin_e3/board.yml @@ -0,0 +1,5 @@ +board: + name: robin_e3 + vendor: mks + socs: + - name: stm32f103xe diff --git a/boards/mks/robin_e3/doc/MKS Robin E3 V1.1_004 PIN.pdf b/boards/mks/robin_e3/doc/MKS Robin E3 V1.1_004 PIN.pdf new file mode 100644 index 0000000..ac777a2 Binary files /dev/null and b/boards/mks/robin_e3/doc/MKS Robin E3 V1.1_004 PIN.pdf differ diff --git a/boards/mks/robin_e3/doc/MKS Robin E3 V1.1_004 SCH.pdf b/boards/mks/robin_e3/doc/MKS Robin E3 V1.1_004 SCH.pdf new file mode 100644 index 0000000..5767682 Binary files /dev/null and b/boards/mks/robin_e3/doc/MKS Robin E3 V1.1_004 SCH.pdf differ diff --git a/boards/mks/robin_e3/robin_e3.dts b/boards/mks/robin_e3/robin_e3.dts new file mode 100644 index 0000000..3eb0d3d --- /dev/null +++ b/boards/mks/robin_e3/robin_e3.dts @@ -0,0 +1,244 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include + + +/ { + model = "MKS Robin E3 board"; + compatible = "mks,robin_e3"; + + chosen { + zephyr,console = &usart3; + zephyr,shell-uart = &usart3; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + }; + + leds { + compatible = "gpio-leds"; + tf_led: led_0 { + gpios = <&gpiod 12 GPIO_ACTIVE_HIGH>; + label = "TF Card detection LED"; + }; + status_led: status_led { + gpios = <&gpiod 12 GPIO_ACTIVE_HIGH>; + label = "Status LED"; + }; + }; + + /* Stepper Motor GPIO Definitions */ + steppers { + compatible = "gpio-steppers"; + + /* RA (Right Ascension) Stepper - X Axis */ + ra_step: ra_step { + gpios = <&gpioe 5 GPIO_ACTIVE_HIGH>; + label = "RA Stepper Step"; + }; + ra_dir: ra_dir { + gpios = <&gpioe 6 GPIO_ACTIVE_HIGH>; + label = "RA Stepper Direction"; + }; + ra_en: ra_en { + gpios = <&gpioe 4 GPIO_ACTIVE_LOW>; + label = "RA Stepper Enable"; + }; + ra_diag: ra_diag { + gpios = <&gpioe 7 GPIO_ACTIVE_HIGH>; + label = "RA Stepper Diag"; + }; + + /* DEC (Declination) Stepper - Y Axis */ + dec_step: dec_step { + gpios = <&gpioe 2 GPIO_ACTIVE_HIGH>; + label = "DEC Stepper Step"; + }; + dec_dir: dec_dir { + gpios = <&gpioe 3 GPIO_ACTIVE_HIGH>; + label = "DEC Stepper Direction"; + }; + dec_en: dec_en { + gpios = <&gpioe 1 GPIO_ACTIVE_LOW>; + label = "DEC Stepper Enable"; + }; + dec_diag: dec_diag { + gpios = <&gpioe 0 GPIO_ACTIVE_HIGH>; + label = "DEC Stepper Diag"; + }; + + /* ALT (Altitude) Stepper - Z Axis */ + alt_step: alt_step { + gpios = <&gpiob 5 GPIO_ACTIVE_HIGH>; + label = "ALT Stepper Step"; + }; + alt_dir: alt_dir { + gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>; + label = "ALT Stepper Direction"; + }; + alt_en: alt_en { + gpios = <&gpiob 4 GPIO_ACTIVE_LOW>; + label = "ALT Stepper Enable"; + }; + alt_diag: alt_diag { + gpios = <&gpiob 7 GPIO_ACTIVE_HIGH>; + label = "ALT Stepper Diag"; + }; + + /* AZ (Azimuth) Stepper - E0 */ + az_step: az_step { + gpios = <&gpiod 6 GPIO_ACTIVE_HIGH>; + label = "AZ Stepper Step"; + }; + az_dir: az_dir { + gpios = <&gpiod 3 GPIO_ACTIVE_HIGH>; + label = "AZ Stepper Direction"; + }; + az_en: az_en { + gpios = <&gpiob 3 GPIO_ACTIVE_LOW>; + label = "AZ Stepper Enable"; + }; + az_diag: az_diag { + gpios = <&gpioa 15 GPIO_ACTIVE_HIGH>; + label = "AZ Stepper Diag"; + }; + + /* Focus Stepper - E1 */ + focus_step: focus_step { + gpios = <&gpioa 6 GPIO_ACTIVE_HIGH>; + label = "Focus Stepper Step"; + }; + focus_dir: focus_dir { + gpios = <&gpioa 1 GPIO_ACTIVE_HIGH>; + label = "Focus Stepper Direction"; + }; + focus_en: focus_en { + gpios = <&gpioa 3 GPIO_ACTIVE_LOW>; + label = "Focus Stepper Enable"; + }; + focus_diag: focus_diag { + gpios = <&gpioa 2 GPIO_ACTIVE_HIGH>; + label = "Focus Stepper Diag"; + }; + }; + + /* Endstops and Sensors */ + sensors { + compatible = "gpio-keys"; + + ra_homing: ra_homing { + gpios = <&gpioa 7 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + label = "RA Homing Sensor"; + }; + dec_homing: dec_homing { + gpios = <&gpioa 5 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + label = "DEC Homing Sensor"; + }; + ra_endstop_east: ra_endstop_east { + gpios = <&gpioa 4 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + label = "RA East Endstop"; + }; + dec_endstop_up: dec_endstop_up { + gpios = <&gpioa 6 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + label = "DEC Up Endstop"; + }; + }; + + aliases { + led0 = &tf_led; + led1 = &status_led; + ra-step = &ra_step; + ra-dir = &ra_dir; + ra-en = &ra_en; + dec-step = &dec_step; + dec-dir = &dec_dir; + dec-en = &dec_en; + alt-step = &alt_step; + alt-dir = &alt_dir; + alt-en = &alt_en; + az-step = &az_step; + az-dir = &az_dir; + az-en = &az_en; + focus-step = &focus_step; + focus-dir = &focus_dir; + focus-en = &focus_en; + ra-home = &ra_homing; + dec-home = &dec_homing; + }; +}; + +&clk_lsi { + status = "okay"; +}; + +&clk_hse { + clock-frequency = ; + status = "okay"; +}; + +&pll { + mul = <9>; + clocks = <&clk_hse>; + status = "okay"; +}; + +&rcc { + clocks = <&pll>; + clock-frequency = ; + ahb-prescaler = <1>; + apb1-prescaler = <2>; + apb2-prescaler = <1>; +}; + +&usart1 { + pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>; + pinctrl-names = "default"; + current-speed = <115200>; + status = "okay"; +}; + +&usart2 { + pinctrl-0 = <&usart2_tx_pa2 &usart2_rx_pa3>; + pinctrl-names = "default"; + current-speed = <115200>; + status = "okay"; +}; + +&usart3 { + pinctrl-0 = <&usart3_tx_pb10 &usart3_rx_pb11>; + pinctrl-names = "default"; + current-speed = <115200>; + status = "okay"; +}; + +zephyr_udc0: &usb { + pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>; + pinctrl-names = "default"; + status = "okay"; +}; + +&rtc { + clocks = <&rcc STM32_CLOCK_BUS_APB1 0x10000000>, + <&rcc STM32_SRC_LSI RTC_SEL(2)>; + status = "okay"; +}; + + +/* I2C for external devices */ +&i2c1 { + pinctrl-0 = <&i2c1_scl_pb6 &i2c1_sda_pb7>; + pinctrl-names = "default"; + status = "okay"; + clock-frequency = ; +}; + +/* ADC for analog sensors (LCD keypad, etc.) */ +&adc1 { + pinctrl-0 = <&adc1_in10_pc0>; + pinctrl-names = "default"; + status = "okay"; +}; \ No newline at end of file diff --git a/boards/mks/robin_e3/robin_e3.yaml b/boards/mks/robin_e3/robin_e3.yaml new file mode 100644 index 0000000..ec6ff78 --- /dev/null +++ b/boards/mks/robin_e3/robin_e3.yaml @@ -0,0 +1,13 @@ +identifier: robin_e3 +name: Robin E3 +vendor: mks +type: mcu +arch: arm +ram: 48 +flash: 256 +toolchain: + - zephyr + - gnuarmemb + - xtools +supported: + - gpio diff --git a/boards/mks/robin_e3/robin_e3_defconfig b/boards/mks/robin_e3/robin_e3_defconfig new file mode 100644 index 0000000..201c26b --- /dev/null +++ b/boards/mks/robin_e3/robin_e3_defconfig @@ -0,0 +1,20 @@ +# Enable MPU +CONFIG_ARM_MPU=y + +# Enable HW stack protection +CONFIG_HW_STACK_PROTECTION=y + +CONFIG_SERIAL=y + +# console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +# enable GPIO +CONFIG_GPIO=y + +# Enable Clocks +CONFIG_CLOCK_CONTROL=y + +# enable pin controller +CONFIG_PINCTRL=y diff --git a/boards/mks/robin_e3/support/openocd.cfg b/boards/mks/robin_e3/support/openocd.cfg new file mode 100644 index 0000000..a1f073d --- /dev/null +++ b/boards/mks/robin_e3/support/openocd.cfg @@ -0,0 +1,12 @@ +source [find board/stm32f1discovery.cfg] + +$_TARGETNAME configure -event gdb-attach { + echo "Debugger attaching: halting execution" + reset halt + gdb_breakpoint_override hard +} + +$_TARGETNAME configure -event gdb-detach { + echo "Debugger detaching: resuming execution" + resume +}