added nrf54l15 as target

This commit is contained in:
2025-12-18 11:42:29 +01:00
parent d02d2f24e1
commit 2cfd32abaf
13 changed files with 122 additions and 40 deletions

View File

@@ -0,0 +1,24 @@
# usb
CONFIG_UART_LINE_CTRL=y
CONFIG_USBD_CDC_ACM_CLASS=y
CONFIG_USB_DEVICE_STACK_NEXT=y
CONFIG_USBD_CDC_ACM_WORKQUEUE=y
CONFIG_UDC_WORKQUEUE=y
CONFIG_UDC_STM32=y
CONFIG_UDC_STM32_STACK_SIZE=2048
CONFIG_UDC_WORKQUEUE_STACK_SIZE=2048
# can FD
#CONFIG_CAN=y
#CONFIG_CAN_FD_MODE=y
#CONFIG_CAN_STM32_FDCAN=y
# timer
CONFIG_COUNTER_TIMER_STM32=y
# Microros
CONFIG_MICROROS_TRANSPORT_SERIAL_USB=y
#CONFIG_MICROROS_TRANSPORT_FDCAN=y
# i2c
CONFIG_I2C_STM32=y

View File

@@ -1,8 +1,6 @@
/ {
aliases {
led0 = &red_led_1;
led1 = &yellow_led_1;
led2 = &green_led_1;
rotenc0 = &as5600;
stepper0 = &stepper0;

View File

@@ -0,0 +1,12 @@
# timer
CONFIG_NRFX_GRTC=y
# Microros
CONFIG_MICROROS_TRANSPORT_SERIAL=y
# i2c
#CONFIG_I2C_NRF=y
# optional / recommended
CONFIG_SYS_CLOCK_EXISTS=y
CONFIG_CLOCK_CONTROL=y

View File

@@ -0,0 +1,60 @@
/ {
aliases {
led0 = &led0;
rotenc0 = &as5600;
stepper0 = &stepper0;
};
chosen {
uros,uart = &uart20;
pid,counter = &timer00;
zephyr,console = &uart21;
zephyr,shell-uart = &uart21;
nordic,rpc-uart = &uart21;
};
stepper0: tmc2209_motor {
compatible = "adi,tmc2209";
en-gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
msx-gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>,
<&gpio1 6 GPIO_ACTIVE_HIGH>;
step-gpios = <&gpio2 1 GPIO_ACTIVE_HIGH>;
dir-gpios = <&gpio2 4 GPIO_ACTIVE_HIGH>;
//dual-edge-step;
micro-step-res = <64>;
counter = <&timer10>;
status = "okay";
};
};
&timer00 {
status = "okay";
};
&timer10 {
status = "okay";
};
&uart20 {
status = "okay";
current-speed = <921600>;
};
&uart21 {
status = "okay";
current-speed = <115200>;
};
&i2c30 {
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
as5600: as5600@36 {
compatible = "ams,as5600";
reg = <0x36>; // I2C address of AS5600
label = "AS5600";
status = "okay";
};
};

View File

@@ -24,7 +24,7 @@
#include <stdbool.h>
#define RING_BUF_SIZE 2048
#define UART_NODE DT_NODELABEL(uart4)
#define UART_NODE DT_CHOSEN(uros_uart)
char uart_in_buffer[RING_BUF_SIZE];
char uart_out_buffer[RING_BUF_SIZE];

View File

@@ -18,44 +18,22 @@ CONFIG_LED=y
# usb
CONFIG_SERIAL=y
CONFIG_UART_LINE_CTRL=y
CONFIG_USBD_CDC_ACM_CLASS=y
CONFIG_USB_DEVICE_STACK_NEXT=y
CONFIG_USBD_CDC_ACM_WORKQUEUE=y
CONFIG_UDC_WORKQUEUE=y
CONFIG_UDC_STM32=y
CONFIG_UDC_STM32_STACK_SIZE=2048
CONFIG_UDC_WORKQUEUE_STACK_SIZE=2048
# timer
CONFIG_COUNTER=y
CONFIG_COUNTER_TIMER_STM32=y
# pwm
CONFIG_PWM=y
CONFIG_PWM_STM32=y
# micro ros
CONFIG_MICROROS=y
CONFIG_MICROROS_XRCE_DDS_MTU="256"
CONFIG_MICROROS_TRANSPORT_SERIAL_USB=y
#CONFIG_MICROROS_TRANSPORT_FDCAN=y
# can FD
CONFIG_CAN=y
CONFIG_CAN_FD_MODE=y
CONFIG_CAN_STM32_FDCAN=y
# sensor + i2c
CONFIG_SENSOR=y
CONFIG_I2C=y
CONFIG_I2C_STM32=y
# stepper
CONFIG_STEPPER=y
CONFIG_STEPPER_ADI_TMC2209=y
CONFIG_STEPPER_ADI_TMC=y
CONFIG_STEPPER_ADI_TMC_UART=y
# builld
CONFIG_NO_OPTIMIZATIONS=n

View File

@@ -5,7 +5,7 @@ target_include_directories(app PRIVATE ./)
add_subdirectory(./led_controller)
add_subdirectory(./stepper_controller)
add_subdirectory(./microros)
add_subdirectory(./usb)
#add_subdirectory(./usb)
target_sources(app PRIVATE
main.cpp

View File

@@ -9,6 +9,7 @@ bool verify_are_devices_available(void) {
devices_ready = false;
}
/*
if (!device_is_ready(led1.port)) {
printk("LED1 not ready\n");
devices_ready = false;
@@ -18,9 +19,10 @@ bool verify_are_devices_available(void) {
printk("LED2 not ready\n");
devices_ready = false;
}
*/
if (!device_is_ready(counter5)) {
printk("Counter 5 not ready\n");
if (!device_is_ready(pid_counter)) {
printk("Counter not ready\n");
devices_ready = false;
}

View File

@@ -13,11 +13,11 @@
#endif
static const struct gpio_dt_spec led0 = GPIO_DT_SPEC_GET(DT_ALIAS(led0), gpios);
static const struct gpio_dt_spec led1 = GPIO_DT_SPEC_GET(DT_ALIAS(led1), gpios);
static const struct gpio_dt_spec led2 = GPIO_DT_SPEC_GET(DT_ALIAS(led2), gpios);
//static const struct gpio_dt_spec led1 = GPIO_DT_SPEC_GET(DT_ALIAS(led1), gpios);
//static const struct gpio_dt_spec led2 = GPIO_DT_SPEC_GET(DT_ALIAS(led2), gpios);
static const struct device *rotenc0 = DEVICE_DT_GET(DT_ALIAS(rotenc0));
static const struct device *stepper0 = DEVICE_DT_GET(DT_ALIAS(stepper0));
static const struct device *counter5 = DEVICE_DT_GET(DT_NODELABEL(counter5));
static const struct device *pid_counter = DEVICE_DT_GET(DT_CHOSEN(pid_counter));
bool verify_are_devices_available(void);

View File

@@ -11,15 +11,17 @@
std_msgs__msg__Bool led_msg;
rcl_node_t LedController::node;
rcl_subscription_t LedController::led0_subscription;
/*
rcl_subscription_t LedController::led1_subscription;
rcl_subscription_t LedController::led2_subscription;
*/
void led0_callback(const void *msg){
gpio_pin_configure_dt(&led0, ((std_msgs__msg__Bool *)msg)->data ? GPIO_OUTPUT_ACTIVE : GPIO_OUTPUT_INACTIVE);
}
/*
void led1_callback(const void *msg){
gpio_pin_configure_dt(&led1, ((std_msgs__msg__Bool *)msg)->data ? GPIO_OUTPUT_ACTIVE : GPIO_OUTPUT_INACTIVE);
}
@@ -28,7 +30,7 @@ void led1_callback(const void *msg){
void led2_callback(const void *msg){
gpio_pin_configure_dt(&led2, ((std_msgs__msg__Bool *)msg)->data ? GPIO_OUTPUT_ACTIVE : GPIO_OUTPUT_INACTIVE);
}
*/
rcl_ret_t LedController::setup(rclc_support_t* support, rclc_executor_t* executor) {
@@ -44,6 +46,7 @@ rcl_ret_t LedController::setup(rclc_support_t* support, rclc_executor_t* executo
ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Bool),
"/nucleo/led0"));
/*
RCL_RETURN_ON_ERROR(rclc_subscription_init_default(
&LedController::led1_subscription,
&LedController::node,
@@ -55,6 +58,7 @@ rcl_ret_t LedController::setup(rclc_support_t* support, rclc_executor_t* executo
&LedController::node,
ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Bool),
"/nucleo/led2"));
*/
RCL_RETURN_ON_ERROR(rclc_executor_add_subscription(
executor,
@@ -64,6 +68,7 @@ rcl_ret_t LedController::setup(rclc_support_t* support, rclc_executor_t* executo
ON_NEW_DATA
));
/*
RCL_RETURN_ON_ERROR(rclc_executor_add_subscription(
executor,
&LedController::led1_subscription,
@@ -79,6 +84,7 @@ rcl_ret_t LedController::setup(rclc_support_t* support, rclc_executor_t* executo
led2_callback,
ON_NEW_DATA
));
*/
return RCL_RET_OK;
}
@@ -86,7 +92,7 @@ rcl_ret_t LedController::setup(rclc_support_t* support, rclc_executor_t* executo
void LedController::kill() {
rcl_subscription_fini(&LedController::led0_subscription, &LedController::node);
rcl_subscription_fini(&LedController::led1_subscription, &LedController::node);
rcl_subscription_fini(&LedController::led2_subscription, &LedController::node);
//rcl_subscription_fini(&LedController::led1_subscription, &LedController::node);
//rcl_subscription_fini(&LedController::led2_subscription, &LedController::node);
rcl_node_fini(&LedController::node);
}

View File

@@ -12,6 +12,8 @@ public:
private:
static rcl_node_t node;
static rcl_subscription_t led0_subscription;
/*
static rcl_subscription_t led1_subscription;
static rcl_subscription_t led2_subscription;
*/
};

View File

@@ -10,7 +10,7 @@
#include <rmw_microros/rmw_microros.h>
#include "devices.hpp"
#include "usb_cdc_acm.hpp"
//#include "usb_cdc_acm.hpp"
#include "stepper_controller.hpp"
#include "microros_state_machine.hpp"
@@ -23,7 +23,7 @@ int main(void)
StepperController::init();
usb_init();
//usb_init();
rmw_uros_set_custom_transport(
MICRO_ROS_FRAMING_REQUIRED,

View File

@@ -89,12 +89,12 @@ void StepperController::init() {
alarm_cfg = {
.callback = counter_cb,
.ticks = counter_us_to_ticks(counter5, PID_LOOP_US), // 2 ms = 500 Hz
.ticks = counter_us_to_ticks(pid_counter, PID_LOOP_US), // 2 ms = 500 Hz
.flags = 0,
};
counter_set_channel_alarm(counter5, 0, &alarm_cfg);
counter_start(counter5);
counter_set_channel_alarm(pid_counter, 0, &alarm_cfg);
counter_start(pid_counter);
sample_angle();
last_angle = current_angle;