Commit 5b9041b2 authored by Wenxi XU's avatar Wenxi XU
Browse files

移动include下的所有源文件到lib/,另外将plotter改为PROTOCOL形式

parent 83a32b82
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
add_subdirectory(ares)
 No newline at end of file
# Include目录只包含头文件,不需要编译源文件
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
#include <zephyr/kernel.h>
#include <zephyr/net_buf.h>

int ares_bind_interface(struct AresInterface *interface, struct AresProtocol *protocol)
static inline int ares_bind_interface(struct AresInterface *interface, struct AresProtocol *protocol)
{
	// Notice that we initialize interface before protocol
	if (interface == NULL || protocol == NULL) {
+64 −62
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
 
 int ares_uart_init(struct AresInterface *interface);
 int ares_uart_send(struct AresInterface *interface, struct net_buf *buf);
 int ares_uart_send_raw(struct AresInterface *interface, uint8_t *data, uint16_t len);
 struct net_buf *ares_uart_interface_alloc_buf(struct AresInterface *interface);
 
 void ares_uart_init_dev(struct AresInterface *interface, const struct device *uart_dev);
@@ -25,7 +26,7 @@ void ares_uart_init_dev(struct AresInterface *interface, const struct device *ua
 
 #define ARES_UART_BLOCK_SIZE    72
 #define MAX_FRAME_PAYLOAD_SIZE  ARES_UART_BLOCK_SIZE
#define ARES_UART_TX_QUEUE_SIZE 10
 #define ARES_UART_TX_QUEUE_SIZE 32
 
 
 struct AresUartInterface {
@@ -55,6 +56,7 @@ struct AresUartInterface {
	 struct AresInterfaceAPI ares_uart_interface_api = {                                        \
		 .init = ares_uart_init,                                                            \
		 .send = ares_uart_send,                                                           \
		 .send_raw = ares_uart_send_raw,                                                   \
		 .alloc_buf = ares_uart_interface_alloc_buf,                                             \
	 };                                                                                         \
	 struct AresUartInterface Internal_##Interface_name = {NULL};                               \
+47 −0
Original line number Diff line number Diff line
//=====================================================================================================
// MahonyAHRS.h
//=====================================================================================================
//
// Madgwick's implementation of Mayhony's AHRS algorithm.
// See: http://www.x-io.co.uk/node/8#open_source_ahrs_and_imu_algorithms
//
// Date			Author			Notes
// 29/09/2011	SOH Madgwick    Initial release
// 02/10/2011	SOH Madgwick	Optimised for reduced CPU load
//
//=====================================================================================================

#include <stdbool.h>

#ifndef MahonyAHRS_h
#define MahonyAHRS_h

typedef struct {
	float q[4];
	float Accel[3];
	float Gyro[3];
	float Mag[3];
	float Yaw, Pitch, Roll;
	float g;
} MahonyAHRS_INS_t;

//----------------------------------------------------------------------------------------------------
// Variable declaration

extern volatile float twoKp;			// 2 * proportional gain (Kp)
extern volatile float twoKi;			// 2 * integral gain (Ki)
extern volatile float q0, q1, q2, q3; // quaternion of sensor frame relative to auxiliary frame

extern MahonyAHRS_INS_t MahonyAHRS_INS;

//---------------------------------------------------------------------------------------------------
// Function declarations

void MahonyAHRSupdate(float gx, float gy, float gz, float gyro_dt, float ax, float ay, float az, float mx, float my, float mz, float accel_dt);
void MahonyAHRSupdateIMU(float gx, float gy, float gz, float gyro_dt, float ax, float ay, float az, float accel_dt);
void MahonyAHRSupdateGyro(float gx, float gy, float gz, float gyro_dt);

#endif
//=====================================================================================================
// End of file
//=====================================================================================================
+116 −0
Original line number Diff line number Diff line
/**
 ******************************************************************************
 * @file	 user_lib.h
 * @author  Wang Hongxi
 * @version V1.0.0
 * @date    2021/2/18
 * @brief
 ******************************************************************************
 * @attention
 *
 ******************************************************************************
 */
#ifndef _USER_LIB_H
#define _USER_LIB_H

#include "stdint.h"
#include "arm_math.h"

#define user_malloc(size) malloc(size)

#define msin(x) (arm_sin_f32(x))
#define mcos(x) (arm_cos_f32(x))

// 若运算速度不够,可以使用q31代替f32,但是精度会降低
#define mat              arm_matrix_instance_f32
#define Matrix_Init      arm_mat_init_f32
#define Matrix_Add       arm_mat_add_f32
#define Matrix_Subtract  arm_mat_sub_f32
#define Matrix_Multiply  arm_mat_mult_f32
#define Matrix_Transpose arm_mat_trans_f32
#define Matrix_Inverse   arm_mat_inverse_f32

void MatInit(mat *m, uint8_t row, uint8_t col);

/* boolean type definitions */
#ifndef TRUE
#define TRUE 1 /**< boolean true  */
#endif

#ifndef FALSE
#define FALSE 0 /**< boolean fails */
#endif

/* circumference ratio */
#ifndef PI
#define PI 3.14159265354f
#endif

#define VAL_LIMIT(val, min, max)                                                                   \
	do {                                                                                       \
		if ((val) <= (min)) {                                                              \
			(val) = (min);                                                             \
		} else if ((val) >= (max)) {                                                       \
			(val) = (max);                                                             \
		}                                                                                  \
	} while (0)

#define ANGLE_LIMIT_360(val, angle)                                                                \
	do {                                                                                       \
		(val) = (angle) - (int)(angle);                                                    \
		(val) += (int)(angle) % 360;                                                       \
	} while (0)

#define ANGLE_LIMIT_360_TO_180(val)                                                                \
	do {                                                                                       \
		if ((val) > 180)                                                                   \
			(val) -= 360;                                                              \
	} while (0)

#define VAL_MIN(a, b) ((a) < (b) ? (a) : (b))
#define VAL_MAX(a, b) ((a) > (b) ? (a) : (b))

/**
 * @brief 返回一块干净的内�?,不过仍然需要强制转�?为你需要的类型
 *
 * @param size 分配大小
 * @return void*
 */
void *zmalloc(size_t size);

// ���ٿ���
float Sqrt(float x);
// ��������
float abs_limit(float num, float Limit);
// �жϷ���λ
float sign(float value);
// ��������
float float_deadband(float Value, float minValue, float maxValue);
// �޷�����
float float_constrain(float Value, float minValue, float maxValue);
// �޷�����
int16_t int16_constrain(int16_t Value, int16_t minValue, int16_t maxValue);
// ѭ���޷�����
float loop_float_constrain(float Input, float minValue, float maxValue);
// �Ƕ� ���޷� 180 ~ -180
float theta_format(float Ang);

int float_rounding(float raw);

float *Norm3d(float *v);

float NormOf3d(float *v);

void Cross3d(float *v1, float *v2, float *res);

float Dot3d(float *v1, float *v2);

float AverageFilter(float new_data, float *buf, uint8_t len);

void GetGroundAccel(float *q, float *accel, float g, float *ground_accel);

void quaternionToYawPitchRoll(float *q, float *yaw, float *pitch, float *roll);

#define rad_format(Ang) loop_float_constrain((Ang), -PI, PI)

#endif
 No newline at end of file
Loading