mirror of
https://github.com/goldenfishs/MRobot.git
synced 2025-09-14 12:54:33 +08:00
修复init模版错误
This commit is contained in:
parent
889f34ae12
commit
822080af2f
@ -2,7 +2,7 @@
|
|||||||
#include "bsp/can.h"
|
#include "bsp/can.h"
|
||||||
#include "bsp/bsp.h"
|
#include "bsp/bsp.h"
|
||||||
#include <can.h>
|
#include <can.h>
|
||||||
#include <cmsis_os.h>
|
#include <cmsis_os2.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/* Private define ----------------------------------------------------------- */
|
/* Private define ----------------------------------------------------------- */
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
bsp,can,dwt,gpio,i2c,mm,spi,uart,pwm,time
|
bsp,can,dwt,gpio,i2c,mm,spi,uart,pwm,time
|
||||||
component,ahrs,capacity,cmd,crc8,crc16,error_detect,filter,FreeRTOS_CLI,limiter,mixer,pid,ui,user_math
|
component,ahrs,capacity,cmd,crc8,crc16,error_detect,filter,FreeRTOS_CLI,limiter,mixer,pid,ui,user_math
|
||||||
device,dr16,bmi088,ist8310,motor,motor_rm,motor_vesc,motor_lk,motor_lz,motor_odrive,dm_imu,servo,buzzer,led,ws2812,vofa
|
device,dr16,bmi088,ist8310,motor,motor_rm,motor_vesc,motor_lk,motor_lz,motor_odrive,dm_imu,servo,buzzer,led,ws2812,vofa,ops9
|
||||||
module,
|
module,
|
|
@ -15,6 +15,22 @@ devices:
|
|||||||
header: "dr16.h"
|
header: "dr16.h"
|
||||||
source: "dr16.c"
|
source: "dr16.c"
|
||||||
|
|
||||||
|
ops9:
|
||||||
|
name: "OPS9"
|
||||||
|
description: "ACTION OPS9 码盘"
|
||||||
|
dependencies:
|
||||||
|
bsp: ["uart"]
|
||||||
|
component: ["user_math"]
|
||||||
|
bsp_requirements:
|
||||||
|
- type: "uart"
|
||||||
|
var_name: "BSP_UART_OPS9" # 需要替换的变量名
|
||||||
|
description: "用于接收码盘"
|
||||||
|
thread_signals:
|
||||||
|
- name: "SIGNAL_OPS9_RAW_REDY"
|
||||||
|
files:
|
||||||
|
header: "ops9.h"
|
||||||
|
source: "ops9.c"
|
||||||
|
|
||||||
bmi088:
|
bmi088:
|
||||||
name: "BMI088"
|
name: "BMI088"
|
||||||
description: "BMI088 陀螺仪+加速度计传感器"
|
description: "BMI088 陀螺仪+加速度计传感器"
|
||||||
@ -81,8 +97,6 @@ devices:
|
|||||||
dependencies:
|
dependencies:
|
||||||
bsp: ["can", "time", "mm"]
|
bsp: ["can", "time", "mm"]
|
||||||
component: ["user_math"]
|
component: ["user_math"]
|
||||||
thread_signals:
|
|
||||||
- name: "SIGNAL_VESC_DATA_REDY"
|
|
||||||
files:
|
files:
|
||||||
header: "motor_vesc.h"
|
header: "motor_vesc.h"
|
||||||
source: "motor_vesc.c"
|
source: "motor_vesc.c"
|
||||||
@ -93,8 +107,6 @@ devices:
|
|||||||
dependencies:
|
dependencies:
|
||||||
bsp: ["can", "time", "mm"]
|
bsp: ["can", "time", "mm"]
|
||||||
component: ["user_math"]
|
component: ["user_math"]
|
||||||
thread_signals:
|
|
||||||
- name: "SIGNAL_ODRIVE_DATA_REDY"
|
|
||||||
files:
|
files:
|
||||||
header: "motor_odrive.h"
|
header: "motor_odrive.h"
|
||||||
source: "motor_odrive.c"
|
source: "motor_odrive.c"
|
||||||
@ -105,8 +117,6 @@ devices:
|
|||||||
dependencies:
|
dependencies:
|
||||||
bsp: ["can", "time", "mm"]
|
bsp: ["can", "time", "mm"]
|
||||||
component: ["user_math"]
|
component: ["user_math"]
|
||||||
thread_signals:
|
|
||||||
- name: "SIGNAL_RM_MOTOR_DATA_REDY"
|
|
||||||
files:
|
files:
|
||||||
header: "motor_rm.h"
|
header: "motor_rm.h"
|
||||||
source: "motor_rm.c"
|
source: "motor_rm.c"
|
||||||
@ -155,8 +165,6 @@ devices:
|
|||||||
dependencies:
|
dependencies:
|
||||||
bsp: ["can", "time"]
|
bsp: ["can", "time"]
|
||||||
component: ["user_math"]
|
component: ["user_math"]
|
||||||
thread_signals:
|
|
||||||
- name: "SIGNAL_DM_IMU_DATA_REDY"
|
|
||||||
files:
|
files:
|
||||||
header: "dm_imu.h"
|
header: "dm_imu.h"
|
||||||
source: "dm_imu.c"
|
source: "dm_imu.c"
|
||||||
@ -178,8 +186,6 @@ devices:
|
|||||||
dependencies:
|
dependencies:
|
||||||
bsp: ["can", "time", "mm"]
|
bsp: ["can", "time", "mm"]
|
||||||
component: ["user_math"]
|
component: ["user_math"]
|
||||||
thread_signals:
|
|
||||||
- name: "SIGNAL_LK_MOTOR_DATA_REDY"
|
|
||||||
files:
|
files:
|
||||||
header: "motor_lk.h"
|
header: "motor_lk.h"
|
||||||
source: "motor_lk.c"
|
source: "motor_lk.c"
|
||||||
@ -190,8 +196,6 @@ devices:
|
|||||||
dependencies:
|
dependencies:
|
||||||
bsp: ["can", "time", "mm"]
|
bsp: ["can", "time", "mm"]
|
||||||
component: ["user_math"]
|
component: ["user_math"]
|
||||||
thread_signals:
|
|
||||||
- name: "SIGNAL_LZ_MOTOR_DATA_REDY"
|
|
||||||
files:
|
files:
|
||||||
header: "motor_lz.h"
|
header: "motor_lz.h"
|
||||||
source: "motor_lz.c"
|
source: "motor_lz.c"
|
||||||
|
58
assets/User_code/device/ops9.c
Normal file
58
assets/User_code/device/ops9.c
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
ACTION全场定位码盘ops9
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Includes ----------------------------------------------------------------- */
|
||||||
|
#include "device/ops9.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "bsp/uart.h"
|
||||||
|
#include "bsp/time.h"
|
||||||
|
/* Private define ----------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
/* Private macro ------------------------------------------------------------ */
|
||||||
|
/* Private typedef ---------------------------------------------------------- */
|
||||||
|
/* Private variables -------------------------------------------------------- */
|
||||||
|
static osThreadId_t thread_alert;
|
||||||
|
static bool inited = false;
|
||||||
|
|
||||||
|
/* Private function -------------------------------------------------------- */
|
||||||
|
static void OPS9_RxCpltCallback(void) {
|
||||||
|
osThreadFlagsSet(thread_alert, SIGNAL_OPS9_RAW_REDY);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
int8_t OPS9_init(OPS9_t *ops9) {
|
||||||
|
if (ops9 == NULL) return DEVICE_ERR_NULL;
|
||||||
|
if (inited) return DEVICE_ERR_INITED;
|
||||||
|
if ((thread_alert = osThreadGetId()) == NULL) return DEVICE_ERR_NULL;
|
||||||
|
|
||||||
|
BSP_UART_RegisterCallback(BSP_UART_OPS9, BSP_UART_RX_CPLT_CB,
|
||||||
|
OPS9_RxCpltCallback);
|
||||||
|
|
||||||
|
inited = true;
|
||||||
|
return DEVICE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t OPS9_Restart(void) {
|
||||||
|
__HAL_UART_DISABLE(BSP_UART_GetHandle(BSP_UART_OPS9));
|
||||||
|
__HAL_UART_ENABLE(BSP_UART_GetHandle(BSP_UART_OPS9));
|
||||||
|
return DEVICE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t OPS9_StartDmaRecv(OPS9_t *ops9) {
|
||||||
|
if (HAL_UART_Receive_DMA(BSP_UART_GetHandle(BSP_UART_OPS9),
|
||||||
|
(uint8_t *)&(ops9->data),
|
||||||
|
sizeof(ops9->data)) == HAL_OK)
|
||||||
|
return DEVICE_OK;
|
||||||
|
return DEVICE_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OPS9_WaitDmaCplt(uint32_t timeout) {
|
||||||
|
return (osThreadFlagsWait(SIGNAL_OPS9_RAW_REDY, osFlagsWaitAll, timeout) ==
|
||||||
|
SIGNAL_OPS9_RAW_REDY);
|
||||||
|
}
|
||||||
|
|
42
assets/User_code/device/ops9.h
Normal file
42
assets/User_code/device/ops9.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ----------------------------------------------------------------- */
|
||||||
|
#include <cmsis_os2.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "component/user_math.h"
|
||||||
|
#include "device/device.h"
|
||||||
|
/* Exported constants ------------------------------------------------------- */
|
||||||
|
|
||||||
|
#define OPS9_HEADER 0x0D0A
|
||||||
|
#define OPS9_TAIL 0x0A0D
|
||||||
|
|
||||||
|
/* Exported macro ----------------------------------------------------------- */
|
||||||
|
/* Exported types ----------------------------------------------------------- */
|
||||||
|
|
||||||
|
// 数据包结构体
|
||||||
|
typedef struct __packed {
|
||||||
|
uint16_t header; // 2字节
|
||||||
|
float yaw; // 4字节
|
||||||
|
float pitch; // 4字节
|
||||||
|
float roll; // 4字节
|
||||||
|
float x; // 4字节
|
||||||
|
float y; // 4字节
|
||||||
|
float angular_velocity; // 4字节
|
||||||
|
uint16_t tail; // 2字节
|
||||||
|
} OPS9_Data_t; // 共28字节
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
DEVICE_Header_t header; // 设备头
|
||||||
|
OPS9_Data_t data; // 存储接收到的数据
|
||||||
|
} OPS9_t;
|
||||||
|
|
||||||
|
/* Exported functions prototypes -------------------------------------------- */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
/* USER INCLUDE BEGIN */
|
/* USER INCLUDE BEGIN */
|
||||||
|
|
||||||
/* USER INCLUDE BEGIN */
|
/* USER INCLUDE END */
|
||||||
|
|
||||||
/* Private typedef ---------------------------------------------------------- */
|
/* Private typedef ---------------------------------------------------------- */
|
||||||
/* Private define ----------------------------------------------------------- */
|
/* Private define ----------------------------------------------------------- */
|
||||||
|
Loading…
Reference in New Issue
Block a user