Commit 78eaebbf authored by ttwards's avatar ttwards
Browse files

PID is done.

parent 5177690f
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -16,3 +16,13 @@

set(ENV{ZEPHYR_BASE} "${CMAKE_CURRENT_SOURCE_DIR}/../zephyr")
list(APPEND BOARD_ROOT .)

# zephyr_library()
zephyr_include_directories(include)
zephyr_syscall_include_directories(include)
add_subdirectory(drivers)
# zephyr_syscall_header(${CMAKE_CURRENT_SOURCE_DIR}/include/zephyr/drivers/motor.h)
# zephyr_library_sources(
#     drivers/motor/motor_m3508.c
#     drivers/motor/motor_dji.h
#     )
 No newline at end of file
+16 −0
Original line number Diff line number Diff line
@@ -7,3 +7,19 @@

# rsource "drivers/Kconfig"
# rsource "lib/Kconfig"

config MOTOR_M3508
    bool "Enable MOTOR_M3508"
    default n

config MOTOR_LOG_LEVEL
    int "Motor log level"
    default 4
    help
      The log level of motor driver

config MOTOR_INIT_PRIORITY
    int "Motor init priority"
    default 90
    help
      The init priority of motor driver
 No newline at end of file
+27 −6
Original line number Diff line number Diff line
@@ -54,25 +54,46 @@
			zephyr,code = <INPUT_KEY_0>;
		};
	};
	canbus {
		canbus1: canbus1 {
				compatible = "vnd,canbus";
				status = "okay";
				can_device = <&can1>;
		};
		canbus2: canbus2 {
				compatible = "vnd,canbus";
				status = "okay";
				can_device = <&can2>;
		};
	};
    motor {
		motor0{
		motor0: motor0{
			compatible = "dji,m3508";
			k_p = <100>;
			k_i = <10000>;
			k_d = <3000>;
			tx_addr = <0x200>;
			rx_addr = <0x201>;
			gear_ratio = <1900>;
			label = "Motor0";
			status = "okay";
			can_channel = <&can1>;
			can_channel = <&canbus1>;
		};

		motor1{
			compatible = "dji,m2006";
		motor1: motor1{
			compatible = "dji,m3508";
			k_p = <100>;
			k_i = <10000>;
			k_d = <10000>;
			tx_addr = <0x200>;
			rx_addr = <0x202>;
			label = "Motor1";
			gear_ratio = <1900>;
			label = "Motor0";
			status = "okay";
			can_channel = <&can1>;
			can_channel = <&canbus1>;
		};
	};

};

&clk_lsi {
+3 −5
Original line number Diff line number Diff line
# SPDX-License-Identifier: Apache-2.0

# FIXME: SHADOW_VARS: Remove this once we have enabled -Wshadow globally.
add_compile_options($<TARGET_PROPERTY:compiler,warning_shadow_variables>)
# add_compile_options($<TARGET_PROPERTY:compiler,warning_shadow_variables>)

add_definitions(-D__ZEPHYR_SUPERVISOR__)
# add_definitions(-D__ZEPHYR_SUPERVISOR__)

add_subdirectory(motor_controller.c)

add_subdirectory_ifdef(CONFIG_MOTOR_M3508 motor_m3508.c)
add_subdirectory_ifdef(CONFIG_MOTOR_M3508 motor)

drivers/Kconfig

0 → 100644
+9 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2024 ttwards <12411711@mail.sustech.edu.cn>
 *
 * SPDX-License-Identifier: Apache-2.0
 */

menu "Device Drivers"
source "motor/Kconfig"
endmenu
 No newline at end of file
Loading