2024/1/25飞行测试

This commit is contained in:
2024-01-26 15:31:40 +08:00
parent 9be12234ec
commit 08cbf4ba74
5 changed files with 80 additions and 20 deletions

View File

@ -23,6 +23,7 @@ void mymain()
Angel_closed_loop(motory,&FOCStruct_Y,2.3);
i++;
}
i=0;
LED_ON;
while(1)
{
@ -32,8 +33,8 @@ void mymain()
y = Angle.roll ;
Zitai_closed_loop(motorx,&FOCStruct_X,x);
Zitai_closed_loop(motory,&FOCStruct_Y,-y);
x = getAngle(motorx);
y = getAngle(motory);
// x = getAngle(motorx);
// y = getAngle(motory);
// printf("%fY%f\n",x,y);
// speed_closed_loop(motorx,&FOCStruct_X,_2PI*5);
// speed_closed_loop(motory,&FOCStruct_Y,_2PI*2);
@ -44,7 +45,7 @@ void mymain()
// }
// i++;
//
// Data_send(x,y,0,0);
Data_send(x,y);
// HAL_Delay(3);
}
}

View File

@ -5,11 +5,12 @@
#include "usart_ano.h"
unsigned char Data_Buff[32] ={0XAA,0XFF,0XF1};
//AA FF F1 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 AA 37
void Data_send(int32_t _a,int32_t _b,int32_t _c,int32_t _d)
void Data_send(int32_t _a,int32_t _b)
{
unsigned char i,cnt=4;
unsigned char sc=0,ac=0;
Data_Buff[3]=0x08;
Data_Buff[cnt++] = BYTE0(_a);
Data_Buff[cnt++] = BYTE1(_a);
Data_Buff[cnt++] = BYTE2(_a);
@ -20,19 +21,6 @@ void Data_send(int32_t _a,int32_t _b,int32_t _c,int32_t _d)
Data_Buff[cnt++] = BYTE2(_b);
Data_Buff[cnt++] = BYTE3(_b);
Data_Buff[cnt++] = BYTE0(_c);
Data_Buff[cnt++] = BYTE1(_c);
Data_Buff[cnt++] = BYTE2(_c);
Data_Buff[cnt++] = BYTE3(_c);
Data_Buff[cnt++] = BYTE0(_d);
Data_Buff[cnt++] = BYTE1(_d);
Data_Buff[cnt++] = BYTE2(_d);
Data_Buff[cnt++] = BYTE3(_d);
Data_Buff[3]=cnt-4;
for(i=0;i<cnt;i++)
{
sc+=Data_Buff[i];

View File

@ -10,6 +10,6 @@
#define BYTE2(dwTemp) ( *( (char *)(&dwTemp) + 2) )
#define BYTE3(dwTemp) ( *( (char *)(&dwTemp) + 3) )
void Data_send(int32_t _a,int32_t _b,int32_t _c,int32_t _d);
void Data_send(int32_t _a,int32_t _b);
//void Data_send(int32_t _a,int32_t _b,int32_t _c,int32_t _d);
#endif //FOC_N_USART_ANO_H

72
CMakeLists_template.txt Normal file
View File

@ -0,0 +1,72 @@
#${templateWarning}
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
${cmakeRequiredVersion}
# specify cross-compilers and tools
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(CMAKE_ASM_COMPILER arm-none-eabi-gcc)
set(CMAKE_AR arm-none-eabi-ar)
set(CMAKE_OBJCOPY arm-none-eabi-objcopy)
set(CMAKE_OBJDUMP arm-none-eabi-objdump)
set(SIZE arm-none-eabi-size)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
# project settings
project(${projectName} C CXX ASM)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 11)
#Uncomment for hardware floating point
#add_compile_definitions(ARM_MATH_CM4;ARM_MATH_MATRIX_CHECK;ARM_MATH_ROUNDING)
#add_compile_options(-mfloat-abi=hard -mfpu=fpv4-sp-d16)
#add_link_options(-mfloat-abi=hard -mfpu=fpv4-sp-d16)
#Uncomment for software floating point
#add_compile_options(-mfloat-abi=soft)
add_compile_options(-mcpu=${mcpu} -mthumb -mthumb-interwork)
add_compile_options(-ffunction-sections -fdata-sections -fno-common -fmessage-length=0)
# uncomment to mitigate c++17 absolute addresses warnings
#set(CMAKE_CXX_FLAGS "$${CMAKE_CXX_FLAGS} -Wno-register")
# Enable assembler files preprocessing
add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-x$<SEMICOLON>assembler-with-cpp>)
if ("$${CMAKE_BUILD_TYPE}" STREQUAL "Release")
message(STATUS "Maximum optimization for speed")
add_compile_options(-Ofast)
elseif ("$${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
message(STATUS "Maximum optimization for speed, debug info included")
add_compile_options(-Ofast -g)
elseif ("$${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
message(STATUS "Maximum optimization for size")
add_compile_options(-Os)
else ()
message(STATUS "Minimal optimization, debug info included")
add_compile_options(-Og -g)
endif ()
include_directories(${includes})
add_definitions(${defines})
file(GLOB_RECURSE SOURCES ${sources})
set(LINKER_SCRIPT $${CMAKE_SOURCE_DIR}/${linkerScript})
add_link_options(-Wl,-gc-sections,--print-memory-usage,-Map=$${PROJECT_BINARY_DIR}/$${PROJECT_NAME}.map)
add_link_options(-mcpu=${mcpu} -mthumb -mthumb-interwork)
add_link_options(-T $${LINKER_SCRIPT})
add_executable($${PROJECT_NAME}.elf $${SOURCES} $${LINKER_SCRIPT})
set(HEX_FILE $${PROJECT_BINARY_DIR}/$${PROJECT_NAME}.hex)
set(BIN_FILE $${PROJECT_BINARY_DIR}/$${PROJECT_NAME}.bin)
add_custom_command(TARGET $${PROJECT_NAME}.elf POST_BUILD
COMMAND $${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:$${PROJECT_NAME}.elf> $${HEX_FILE}
COMMAND $${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:$${PROJECT_NAME}.elf> $${BIN_FILE}
COMMENT "Building $${HEX_FILE}
Building $${BIN_FILE}")

View File

@ -396,7 +396,6 @@ uint8_t MpuGetData(void)
pMpu[i] = tBuff[k] = tBuff[k] * (1 - factor) + pMpu[i] * factor;
}
}
return 0;
}