Skip to content

Commit ef65eea

Browse files
Add Lx200Processor and Tokenizer for LX200 command processing
- Implemented Lx200Processor class to handle LX200 commands, including command parsing and buffer management. - Added methods for initializing the mount and setting target coordinates (RA/Dec). - Introduced Tokenizer for parsing commands using static and dynamic matchers. - Ensured compliance with C++20 and C++17 standards for string and character conversions. - Integrated logging for command processing and error handling.
1 parent 5662be2 commit ef65eea

35 files changed

+2888
-132
lines changed

app/CMakeLists.txt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
#-------------------------------------------------------------------------------
2-
# Zephyr Example Application
3-
#
4-
# Copyright (c) 2021 Nordic Semiconductor ASA
5-
# SPDX-License-Identifier: Apache-2.0
1+
cmake_minimum_required(VERSION 3.20.0)
62

7-
cmake_minimum_required(VERSION 3.13.1)
83
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
4+
project(OpenAstroFirmware)
95

10-
project(app LANGUAGES C)
6+
zephyr_syscall_include_directories(include)
7+
zephyr_include_directories(include)
118

12-
target_sources(app PRIVATE src/main.c)
9+
# Add the source files to the target
10+
file(GLOB_RECURSE APP_SOURCES "src/*.cpp" "src/*.c")
11+
target_sources(app PRIVATE ${APP_SOURCES})

app/Kconfig

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
# Copyright (c) 2021 Nordic Semiconductor ASA
2-
# SPDX-License-Identifier: Apache-2.0
3-
#
4-
# This file is the application Kconfig entry point. All application Kconfig
5-
# options can be defined here or included via other application Kconfig files.
6-
# You can browse these options using the west targets menuconfig (terminal) or
7-
# guiconfig (GUI).
1+
module = FIRMWARE
2+
module-str = firmware
3+
source "subsys/logging/Kconfig.template.log_config"
4+
5+
rsource "src/mount/Kconfig"
6+
rsource "src/processor/lx200/Kconfig"
87

98
menu "Zephyr"
109
source "Kconfig.zephyr"
1110
endmenu
12-
13-
module = APP
14-
module-str = APP
15-
source "subsys/logging/Kconfig.template.log_config"

app/boards/native_sim.conf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CONFIG_UART_CONSOLE=y
2+
3+
# Enable the native POSIX UART driver backend
4+
CONFIG_UART_NATIVE_POSIX=y
5+
6+
# Console (logs) will be on stdout
7+
# CONFIG_UART_NATIVE_PTY_0_ON_STDINOUT=y
8+
# CONFIG_NATIVE_UART_0_ON_STDINOUT=y
9+
10+
# Enable UART for control (e.g. lx200)
11+
CONFIG_UART_NATIVE_POSIX_PORT_1_ENABLE=y

app/boards/native_sim.overlay

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/ {
2+
chosen {
3+
zephyr,console = &uart0;
4+
oaf,uart-control = &uart1;
5+
};
6+
};
7+
8+
&uart1 {
9+
status = "okay";
10+
// current-speed = <115200>;
11+
// backend = "pty";
12+
};

app/boards/nucleo_f302r8.overlay

Lines changed: 0 additions & 27 deletions
This file was deleted.

app/boards/nucleo_f446re.conf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=180000000
2+
CONFIG_CORTEX_M_SYSTICK=y
3+
4+
CONFIG_UART_USE_RUNTIME_CONFIGURE=y
5+
6+
# CONFIG_USB_DEVICE_STACK=y
7+
# CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n
8+
# CONFIG_USB_DEVICE_VID=0x1209
9+
# CONFIG_USB_DEVICE_PID=0x0AF0
10+
# CONFIG_USB_DEVICE_PRODUCT="OpenAstroFirmware"
11+
# CONFIG_USB_DEVICE_MANUFACTURER="OpenAstroTech"
12+
13+
# CONFIG_USB_CDC_ACM=y
14+
# CONFIG_USB_CDC_ACM_RINGBUF_SIZE=512
15+
16+
# CONFIG_USB_COMPOSITE_DEVICE=y
17+
18+
# # CONFIG_USB_DEVICE_LOG_LEVEL_INF=y
19+
# # CONFIG_USB_DRIVER_LOG_LEVEL_INF=y
20+
# CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y

app/boards/nucleo_f446re.overlay

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/ {
2+
chosen {
3+
zephyr,console = &usart2;
4+
zephyr,uart-pipe = &usart2;
5+
oaf,uart-control = &usart2;
6+
};
7+
8+
stepper0: drv8424 {
9+
compatible = "ti,drv8424";
10+
status = "okay";
11+
12+
#address-cells = <1>;
13+
#size-cells = <0>;
14+
#stepper-motor-cells = <0>;
15+
16+
dir-gpios = <&gpiob 11 GPIO_ACTIVE_HIGH>;
17+
step-gpios = <&gpiob 10 GPIO_ACTIVE_HIGH>;
18+
en-gpios = <&gpiob 12 GPIO_ACTIVE_HIGH>;
19+
m0-gpios = <&gpiob 13 GPIO_ACTIVE_HIGH>;
20+
m1-gpios = <&gpiob 14 GPIO_ACTIVE_HIGH>;
21+
sleep-gpios = <&gpiob 15 GPIO_ACTIVE_HIGH>;
22+
23+
counter = <&counter2>;
24+
};
25+
};
26+
27+
&clk_hse {
28+
clock-frequency = <DT_FREQ_M(8)>;
29+
};
30+
31+
&pll {
32+
div-m = <4>;
33+
mul-n = <180>;
34+
div-p = <2>;
35+
div-q = <7>;
36+
clocks = <&clk_hse>;
37+
status = "okay";
38+
};
39+
40+
&rcc {
41+
clocks = <&pll>;
42+
clock-frequency = <DT_FREQ_M(180)>;
43+
ahb-prescaler = <1>;
44+
apb1-prescaler = <4>;
45+
apb2-prescaler = <2>;
46+
};
47+
48+
&usart1 {
49+
status = "okay";
50+
current-speed = <115200>;
51+
};
52+
53+
&usart2 {
54+
status = "okay";
55+
current-speed = <115200>;
56+
};
57+
58+
&timers2 {
59+
status = "okay";
60+
st,prescaler = <0>;
61+
62+
counter2: counter {
63+
status = "okay";
64+
};
65+
};

app/boards/robin_nano.conf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=168000000
2+
CONFIG_CORTEX_M_SYSTICK=y
3+
4+
CONFIG_USB_DEVICE_STACK=y
5+
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n
6+
CONFIG_USB_DEVICE_VID=0x1209
7+
CONFIG_USB_DEVICE_PID=0x0AF0
8+
CONFIG_USB_DEVICE_PRODUCT="OpenAstroFirmware"
9+
CONFIG_USB_DEVICE_MANUFACTURER="OpenAstroTech"
10+
11+
CONFIG_USB_CDC_ACM=y
12+
CONFIG_USB_CDC_ACM_RINGBUF_SIZE=512
13+
14+
CONFIG_USB_COMPOSITE_DEVICE=y
15+
16+
# CONFIG_USB_DEVICE_LOG_LEVEL_INF=y
17+
# CONFIG_USB_DRIVER_LOG_LEVEL_INF=y
18+
CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y

app/boards/robin_nano.overlay

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/ {
2+
chosen {
3+
// we can't use cdc acm as console because it lacks required amount of cdc acm endpoints
4+
zephyr,console = &usart3;
5+
oaf,uart-control = &cdc_acm_uart0;
6+
};
7+
};
8+
9+
// Configuration for the CDC ACM UART
10+
&zephyr_udc0 {
11+
cdc_acm_uart0: cdc_acm_uart0 {
12+
compatible = "zephyr,cdc-acm-uart";
13+
};
14+
};

app/include/device/gpio/GPIO.hpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#pragma once
2+
3+
#include <zephyr/device.h>
4+
#include <zephyr/drivers/gpio.h>
5+
#include <functional>
6+
7+
using button_callback_t = std::function<void()>;
8+
9+
namespace oaf
10+
{
11+
namespace device
12+
{
13+
namespace gpio
14+
{
15+
class _Device
16+
{
17+
protected:
18+
const gpio_dt_spec *dev;
19+
20+
public:
21+
_Device(const gpio_dt_spec *dev);
22+
~_Device() = default;
23+
};
24+
25+
class Input : public _Device
26+
{
27+
private:
28+
std::function<void()> callback;
29+
30+
struct CallbackData
31+
{
32+
struct gpio_callback cb;
33+
Input *context;
34+
} cb_data;
35+
36+
public:
37+
Input(const gpio_dt_spec *dev, std::function<void()> callback = nullptr);
38+
~Input();
39+
40+
private:
41+
static void handle_gpio_callback(const struct device *port, struct gpio_callback *cb, gpio_port_pins_t pins);
42+
};
43+
44+
class Output : public _Device
45+
{
46+
47+
public:
48+
Output(const gpio_dt_spec *dev);
49+
~Output();
50+
51+
void set(int value);
52+
53+
void toggle();
54+
};
55+
} // namespace gpio
56+
} // namespace device
57+
} // namespace oaf

0 commit comments

Comments
 (0)