Commit 1cafa044 authored by Wenxi Xu's avatar Wenxi Xu
Browse files

Remove utils directory to prepare for submodule

parent fd2db6e9
Loading
Loading
Loading
Loading

app/2024_3wheel/CMakeLists.txt

deleted100644 → 0
+0 −17
Original line number Diff line number Diff line
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)
set(CMAKE_CXX_STANDARD 17)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(motor)

FILE(GLOB app_sources src/*.c)

include_directories(${ZEPHYR_BASE}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dts)
target_sources(app PRIVATE ${app_sources})
target_include_directories(app PRIVATE ${ZEPHYR_BASE}/include)
target_include_directories(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/dts)

app/2024_3wheel/README.rst

deleted100644 → 0
+0 −51
Original line number Diff line number Diff line
.. zephyr:code-sample:: can-babbling
   :name: Controller Area Network (CAN) babbling node
   :relevant-api: can_interface

   Simulate a babbling CAN node.

Overview
********

In a Controller Area Network a babbling node is a node continuously (and usually erroneously)
transmitting CAN frames with identical - often high - priority. This constant babbling blocks CAN
bus access for any CAN frame with lower priority as these frames will loose the bus arbitration.

This sample application simulates a babbling CAN node. The properties of the CAN frames sent are
configurable via :ref:`Kconfig <kconfig>`. The frames carry no data as only the arbitration part of
the CAN frame is of interest.

Being able to simulate a babbling CAN node is useful when examining the behavior of other nodes on
the same CAN bus when they constantly loose bus arbitration.

The source code for this sample application can be found at:
:zephyr_file:`samples/drivers/can/babbling`.

Requirements
************

This sample requires a board with a CAN controller. The CAN controller must be configured using the
``zephyr,canbus`` :ref:`devicetree <dt-guide>` chosen node property.

The sample supports an optional button for stopping the babbling. If present, the button must be
configured using the ``sw0`` :ref:`devicetree <dt-guide>` alias, usually in the :ref:`BOARD.dts file
<devicetree-in-out-files>`.

Building and Running
********************

Example building for :ref:`twr_ke18f`:

.. zephyr-app-commands::
   :zephyr-app: samples/drivers/can/babbling
   :board: twr_ke18f
   :goals: build flash

Sample output
=============

.. code-block:: console

   *** Booting Zephyr OS build zephyr-v3.1.0-4606-g8c1efa8b96bb  ***
   babbling on can@40024000 with standard (11-bit) CAN ID 0x010, RTR 0, CAN FD 0
   abort by pressing User SW3 button
+0 −123
Original line number Diff line number Diff line
/ {
	rm_motor {
		motor0: motor0{
			compatible = "dji,motor";
            is_m3508;
			id = <1>;
            rx_id = <0x201>;
            tx_id = <0x200>;
			gear_ratio = <1920>;
			status = "okay";
			can_channel = <&canbus1>;
			controllers = <&angle_pid_1 &speed_pid_1>;
			capabilities = "angle", "speed";
		};

		motor1: motor1{
			compatible = "dji,motor";
            is_m3508;
			id = <2>;
            rx_id = <0x202>;
            tx_id = <0x200>;
			gear_ratio = <1920>;
			status = "okay";
			can_channel = <&canbus1>;
			controllers = <&angle_pid_2 &speed_pid_2>;
			capabilities = "angle", "speed";
		};

		motor2: motor2{
			compatible = "dji,motor";
            is_m3508;
			id = <3>;
            rx_id = <0x203>;
            tx_id = <0x200>;
			gear_ratio = <1920>;
			status = "okay";
			can_channel = <&canbus1>;
			controllers = <&angle_pid_3 &speed_pid_3>;
			capabilities = "angle", "speed";
		};
	};

	pid {
		angle_pid_1: angle_pid_1 {
			#controller-cells = <0>;
			compatible = "pid,single";
			k_p = <700>;
			k_i = <3>;
			k_d = <800>;
		};
		speed_pid_1: speed_pid_1 {
			#controller-cells = <0>;
			compatible = "pid,single";
			k_p = <180>;
			k_i = <20>;
			k_d = <20>;
		};
		angle_pid_2: angle_pid_2 {
			#controller-cells = <0>;
			compatible = "pid,single";
			k_p = <700>;
			k_i = <3>;
			k_d = <800>;
		};
		speed_pid_2: speed_pid_2 {
			#controller-cells = <0>;
			compatible = "pid,single";
			k_p = <180>;
			k_i = <20>;
			k_d = <20>;
		};
		angle_pid_3: angle_pid_3 {
			#controller-cells = <0>;
			compatible = "pid,single";
			k_p = <700>;
			k_i = <3>;
			k_d = <800>;
		};
		speed_pid_3: speed_pid_3 {
			#controller-cells = <0>;
			compatible = "pid,single";
			k_p = <180>;
			k_i = <20>;
			k_d = <20>;
		};
	};
	sbus0: sbus0 {
		compatible = "ares,sbus";
		status = "okay";
	};
};

&spi1 {
    status = "okay";

    bmi08x_accel: bmi08x_accel@0 {
        compatible = "bosch,bmi08x-accel";
		status = "okay";
        reg = <0>;
        spi-max-frequency = <8000000>;
        int-gpios = <&gpioc 4 GPIO_ACTIVE_HIGH>;
        accel-hz = "1600";
        accel-fs = <12>;
		int1-map-io = <0>;
		int2-map-io = <0>;
        int1-conf-io = <0>;
		int2-conf-io = <0>;
		
    };

    bmi08x_gyro: bmi08x_gyro@1{
        compatible = "bosch,bmi08x-gyro";
		status = "okay";
        reg = <1>;
        spi-max-frequency = <8000000>;
        int-gpios = <&gpioc 5 GPIO_ACTIVE_HIGH>;
        gyro-hz = "2000_532";
        gyro-fs = <2000>;
		int3-4-map-io = <0>;
		int3-4-conf-io = <0>;
        // 其他所需属性...
    };
};
 No newline at end of file

app/2024_3wheel/prj.conf

deleted100644 → 0
+0 −79
Original line number Diff line number Diff line

# 启用线程分析器
CONFIG_THREAD_ANALYZER=y
CONFIG_THREAD_ANALYZER_USE_LOG=y
CONFIG_THREAD_ANALYZER_USE_PRINTK=n
CONFIG_THREAD_NAME=y
# CONFIG_THREAD_ANALYZER_AUTO=y
# CONFIG_THREAD_ANALYZER_AUTO_INTERVAL=5
CONFIG_THREAD_ANALYZER_LOG_LEVEL_INF=y
CONFIG_THREAD_ANALYZER_AUTO_SEPARATE_CORES=n

# 启用 Shell 支持
CONFIG_SHELL=n
CONFIG_SHELL_BACKENDS=n
CONFIG_SHELL_BACKEND_SERIAL=n

# 启用 UART 控制台
CONFIG_UART_CONSOLE=y

# 禁用 SEGGER RTT
CONFIG_USE_SEGGER_RTT=n

# 启用事件支持
CONFIG_EVENTS=y

# 启用控制台支持
CONFIG_CONSOLE=y

# 启用日志系统
CONFIG_LOG=y
CONFIG_LOG_MODE_IMMEDIATE=y
CONFIG_LOG_PRINTK=y
CONFIG_LOG_BACKEND_UART=y
CONFIG_LOG_MODE_IMMEDIATE=y

# 启用串行支持
CONFIG_SERIAL=y

# 禁用优化
CONFIG_NO_OPTIMIZATIONS=y

# 启用驱动
CONFIG_MOTOR=y
CONFIG_MOTOR_DJI=y
CONFIG_MOTOR_LOG_LEVEL=4
CONFIG_CAN=y
CONFIG_MOTOR_INIT_PRIORITY=90

CONFIG_ARES=y
CONFIG_ARES_SBUS=y
CONFIG_SBUS_INIT_PRIORITY=90

# use ASYNC uart API
CONFIG_SERIAL=y
CONFIG_UART_ASYNC_API=y
CONFIG_UART_INTERRUPT_DRIVEN=y

CONFIG_DMA=y
CONFIG_DMA_STM32=y  # STM32 DMA 驱动
CONFIG_UART_STM32=y # STM32 UART 驱动
# CONFIG_STM32_UART_DMA=y

# CONFIG_HAS_STM32CUBE=y
# CONFIG_USE_STM32_HAL_DMA=y
CONFIG_SPI=y
CONFIG_SPI_STM32=y

#
# Device Drivers
#
CONFIG_SENSOR=y
CONFIG_BMI08X=y
# CONFIG_BMI08X_ACCEL_TRIGGER_NONE is not set
CONFIG_BMI08X_ACCEL_TRIGGER_GLOBAL_THREAD=y
# CONFIG_BMI08X_ACCEL_TRIGGER_OWN_THREAD is not set
# CONFIG_BMI08X_GYRO_TRIGGER_NONE is not set
CONFIG_BMI08X_GYRO_TRIGGER_GLOBAL_THREAD=y
# CONFIG_BMI08X_GYRO_TRIGGER_OWN_THREAD is not set
CONFIG_BMI08X_I2C_WRITE_BURST_SIZE=16

app/2024_3wheel/sample.yaml

deleted100644 → 0
+0 −14
Original line number Diff line number Diff line
sample:
  name: CAN bus babbling node
tests:
  sample.drivers.can.babbling:
    tags: can
    depends_on: can
    filter: dt_chosen_enabled("zephyr,canbus")
    integration_platforms:
      - native_sim
    harness: console
    harness_config:
      type: one_line
      regex:
        - "babbling on .*"
Loading