mirror of
https://github.com/DashyFox/StackSport.git
synced 2025-05-03 14:50:21 +00:00
Uart working
This commit is contained in:
parent
419c55d807
commit
cad6b45c5d
@ -36,7 +36,7 @@
|
||||
</tool>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.400718382" name="MCU/MPU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler">
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.1282773953" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g3" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.394842051" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.oz" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.394842051" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.os" valueType="enumerated"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1350178782" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="DEBUG"/>
|
||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
||||
@ -117,7 +117,7 @@
|
||||
</tool>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.422705567" name="MCU/MPU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler">
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.131805638" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g0" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.324687102" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.os" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.324687102" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.o1" valueType="enumerated"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.971138536" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
||||
<listOptionValue builtIn="false" value="STM32F103xB"/>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="4489868063458550" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="1139920058673081605" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
@ -16,7 +16,7 @@
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="4489868063458550" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="1139920058673081605" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
|
@ -10,21 +10,21 @@
|
||||
|
||||
#define START_ADR_SHOT (START_ADR_STAT+STAT_BLOCKSIZE)
|
||||
#define SHOT_BLOCKSIZE 10
|
||||
#define MAX_NUMBER_SHOTS 255
|
||||
#define MAX_SHOT_COUNT 256
|
||||
|
||||
#define START_ADR_PROGRAM (START_ADR_SHOT + (SHOT_BLOCKSIZE*MAX_NUMBER_SHOTS))
|
||||
#define PROGRAM_BLOCKSIZE 203
|
||||
#define MAX_NUMBER_PROGRAMS 100
|
||||
#define MAX_NUMBER_SHOTS_IN_PROGRAMS \
|
||||
(PROGRAM_BLOCKSIZE-sizeof(ProgramHeader)) /sizeof(ProgramShot) // 100
|
||||
#define START_ADR_PROGRAM (START_ADR_SHOT + (SHOT_BLOCKSIZE*MAX_SHOT_COUNT))
|
||||
#define PROGRAM_BLOCKSIZE 67
|
||||
#define MAX_PROGRAM_COUNT 256
|
||||
#define MAX_SHOT_COUNT_IN_PROGRAMS \
|
||||
(PROGRAM_BLOCKSIZE-sizeof(ProgramHeader)) /sizeof(ProgramShot) //
|
||||
|
||||
#define START_ADR_MACRO (START_ADR_PROGRAM + (PROGRAM_BLOCKSIZE*MAX_NUMBER_PROGRAMS))
|
||||
#define MACRO_BLOCKSIZE 81
|
||||
#define MAX_NUMBER_MACRO 100
|
||||
#define MAX_NUMBER_PROGRAMS_IN_MACRO \
|
||||
(MACRO_BLOCKSIZE-sizeof(MacroHeader)) /sizeof(MacroProgram) // 20
|
||||
#define START_ADR_MACRO (START_ADR_PROGRAM + (PROGRAM_BLOCKSIZE*MAX_PROGRAM_COUNT))
|
||||
#define MACRO_BLOCKSIZE 129
|
||||
#define MAX_MACRO_COUNT 100
|
||||
#define MAX_PROGRAM_COUNT_IN_MACRO \
|
||||
(MACRO_BLOCKSIZE-sizeof(MacroHeader)) /sizeof(MacroProgram) //
|
||||
|
||||
#define MEMORY_END (START_ADR_MACRO + (MACRO_BLOCKSIZE*MAX_NUMBER_MACRO))
|
||||
#define MEMORY_END (START_ADR_MACRO + (MACRO_BLOCKSIZE*MAX_MACRO_COUNT))
|
||||
|
||||
typedef enum MemoryStatus {
|
||||
EEPROM_FAIL,
|
||||
@ -58,7 +58,7 @@ typedef struct ProgramShot {
|
||||
|
||||
typedef struct Program {
|
||||
ProgramHeader header;
|
||||
ProgramShot shots[MAX_NUMBER_SHOTS_IN_PROGRAMS];
|
||||
ProgramShot shots[MAX_SHOT_COUNT_IN_PROGRAMS];
|
||||
} Program;
|
||||
|
||||
typedef struct MacroHeader {
|
||||
@ -74,7 +74,7 @@ typedef struct MacroProgram {
|
||||
|
||||
typedef struct Macro {
|
||||
MacroHeader header;
|
||||
MacroProgram programs[MAX_NUMBER_PROGRAMS_IN_MACRO];
|
||||
MacroProgram programs[MAX_PROGRAM_COUNT_IN_MACRO];
|
||||
} Macro;
|
||||
|
||||
typedef struct ServoSetting {
|
||||
|
@ -1,13 +0,0 @@
|
||||
/*
|
||||
* GlobalDefines.h
|
||||
*
|
||||
* Created on: Aug 25, 2024
|
||||
* Author: DashyFox
|
||||
*/
|
||||
|
||||
#ifndef INC_GLOBALDEFINES_H_
|
||||
#define INC_GLOBALDEFINES_H_
|
||||
|
||||
#define UART_BUFFER_SIZE 64
|
||||
|
||||
#endif /* INC_GLOBALDEFINES_H_ */
|
@ -9,3 +9,4 @@
|
||||
void print(char* str);
|
||||
void int_to_str(int number, char *str, int base);
|
||||
void printNumber(long int number);
|
||||
void printHexBuffer(uint8_t *buffer, uint16_t size);
|
||||
|
@ -30,6 +30,7 @@ void stopShooting();
|
||||
|
||||
|
||||
void setPos(uint8_t axial, uint8_t horizontal, uint8_t vertical);
|
||||
void setPosSingle(ServoMap servo, uint8_t value);
|
||||
void setPosDefault();
|
||||
|
||||
// 0 .. 100
|
||||
|
42
Core/Inc/UART3_CMD_Handler.h
Normal file
42
Core/Inc/UART3_CMD_Handler.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* UART3_CMD_Handler.h
|
||||
*
|
||||
* Created on: Sep 12, 2024
|
||||
* Author: DashyFox
|
||||
*/
|
||||
|
||||
#ifndef INC_UART3_CMD_HANDLER_H_
|
||||
#define INC_UART3_CMD_HANDLER_H_
|
||||
|
||||
#include "stm32f1xx_hal.h"
|
||||
|
||||
void UART3_SaveShot(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_SaveProgram(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_SaveMacro(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_StartMacro(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_StartProgram(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_StartShot(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_Stop(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_DeleteShot(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_DeleteProgram(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_DeleteMacro(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_DeleteAllData(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_GetDeviceStatus(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_SetServoOffset(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_GetServoOffset(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_SetServoMaxAngle(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_GetServoMaxAngle(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_MoveServoToInitialPosition(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_SetStartupDelay(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_GetStartupDelay(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_SetMinRollerSpeed(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_GetMinRollerSpeed(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_SetMinScrewSpeed(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_GetMinScrewSpeed(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_SetServoInvertFlag(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_GetServoInvertFlag(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_ReadStatistics(uint8_t *dataPtr, uint8_t len);
|
||||
void UART3_ResetStatistics(uint8_t *dataPtr, uint8_t len);
|
||||
|
||||
|
||||
#endif /* INC_UART3_CMD_HANDLER_H_ */
|
20
Core/Inc/UART3_Handler.h
Normal file
20
Core/Inc/UART3_Handler.h
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* UART3_Handler.h
|
||||
*
|
||||
* Created on: Sep 12, 2024
|
||||
* Author: DashyFox
|
||||
*/
|
||||
|
||||
#ifndef INC_UART3_HANDLER_H_
|
||||
#define INC_UART3_HANDLER_H_
|
||||
|
||||
#include "stm32f1xx_hal.h"
|
||||
|
||||
#define UART_BUFFER_SIZE 256
|
||||
|
||||
extern uint8_t uart_rx_buffer[UART_BUFFER_SIZE];
|
||||
|
||||
void UART3_START();
|
||||
void UART3_Handler();
|
||||
|
||||
#endif /* INC_UART3_HANDLER_H_ */
|
@ -42,7 +42,7 @@
|
||||
/*#define HAL_CORTEX_MODULE_ENABLED */
|
||||
/*#define HAL_CRC_MODULE_ENABLED */
|
||||
/*#define HAL_DAC_MODULE_ENABLED */
|
||||
/*#define HAL_DMA_MODULE_ENABLED */
|
||||
#define HAL_DMA_MODULE_ENABLED
|
||||
/*#define HAL_ETH_MODULE_ENABLED */
|
||||
/*#define HAL_FLASH_MODULE_ENABLED */
|
||||
#define HAL_GPIO_MODULE_ENABLED
|
||||
|
@ -57,6 +57,7 @@ void PendSV_Handler(void);
|
||||
void SysTick_Handler(void);
|
||||
void EXTI0_IRQHandler(void);
|
||||
void EXTI1_IRQHandler(void);
|
||||
void DMA1_Channel3_IRQHandler(void);
|
||||
void USB_LP_CAN1_RX0_IRQHandler(void);
|
||||
void TIM3_IRQHandler(void);
|
||||
void I2C1_EV_IRQHandler(void);
|
||||
|
@ -43,7 +43,7 @@ MemoryStatus getShot(unsigned char number, Shot *shot) {
|
||||
|
||||
MemoryStatus saveProg(unsigned char number, Program *prog) {
|
||||
MemoryStatus result = EEPROM_OK;
|
||||
for (uint16_t i = 0; i < MAX_NUMBER_SHOTS_IN_PROGRAMS; ++i) {
|
||||
for (uint16_t i = 0; i < MAX_SHOT_COUNT_IN_PROGRAMS; ++i) {
|
||||
Shot shot;
|
||||
MemoryStatus stat = getShot(prog->shots[i].id, &shot);
|
||||
if (!(stat == EEPROM_OK || stat == EEPROM_MISSING_ELEMENT)) {
|
||||
@ -77,7 +77,7 @@ MemoryStatus getProg(unsigned char number, Program *prog) {
|
||||
|
||||
MemoryStatus saveMacro(unsigned char number, Macro *macro) {
|
||||
MemoryStatus result = EEPROM_OK;
|
||||
for (uint16_t i = 0; i < MAX_NUMBER_PROGRAMS_IN_MACRO; ++i) {
|
||||
for (uint16_t i = 0; i < MAX_PROGRAM_COUNT_IN_MACRO; ++i) {
|
||||
Program prog;
|
||||
MemoryStatus stat = getProg(macro->programs[i].id, &prog);
|
||||
if (!(stat == EEPROM_OK || stat == EEPROM_MISSING_ELEMENT)) {
|
||||
@ -246,9 +246,9 @@ MemoryStatus FLASH_WriteBlock(uint16_t startAddr, uint8_t number,
|
||||
HAL_StatusTypeDef result;
|
||||
|
||||
// Проверка на корректность входных данных
|
||||
if ((startAddr == START_ADR_SHOT && number > MAX_NUMBER_SHOTS)
|
||||
|| (startAddr == START_ADR_PROGRAM && number > MAX_NUMBER_PROGRAMS)
|
||||
|| (startAddr == START_ADR_MACRO && number > MAX_NUMBER_MACRO)) {
|
||||
if ((startAddr == START_ADR_SHOT && number >= MAX_SHOT_COUNT)
|
||||
|| (startAddr == START_ADR_PROGRAM && number >= MAX_PROGRAM_COUNT)
|
||||
|| (startAddr == START_ADR_MACRO && number >= MAX_MACRO_COUNT)) {
|
||||
return EEPROM_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
@ -278,9 +278,9 @@ MemoryStatus FLASH_ReadBlock(uint16_t startAddr, uint8_t number,
|
||||
HAL_StatusTypeDef result;
|
||||
|
||||
// Проверка на корректность входных данных
|
||||
if ((startAddr == START_ADR_SHOT && number > MAX_NUMBER_SHOTS)
|
||||
|| (startAddr == START_ADR_PROGRAM && number > MAX_NUMBER_PROGRAMS)
|
||||
|| (startAddr == START_ADR_MACRO && number > MAX_NUMBER_MACRO)) {
|
||||
if ((startAddr == START_ADR_SHOT && number > MAX_SHOT_COUNT)
|
||||
|| (startAddr == START_ADR_PROGRAM && number > MAX_PROGRAM_COUNT)
|
||||
|| (startAddr == START_ADR_MACRO && number > MAX_MACRO_COUNT)) {
|
||||
return EEPROM_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
|
@ -6,53 +6,75 @@
|
||||
*/
|
||||
#include "Print.h"
|
||||
|
||||
void print(char* str){
|
||||
void print(char *str) {
|
||||
unsigned int size = 0;
|
||||
while (str[size] != '\0')
|
||||
{
|
||||
while (str[size] != '\0') {
|
||||
size++;
|
||||
}
|
||||
CDC_Transmit_FS((unsigned char*)str, size);
|
||||
CDC_Transmit_FS((unsigned char*) str, size);
|
||||
}
|
||||
|
||||
void int_to_str(int number, char *str, int base)
|
||||
{
|
||||
static const char digits[] = "0123456789ABCDEF";
|
||||
char buffer[32];
|
||||
char *ptr = buffer + sizeof(buffer) - 1;
|
||||
int is_negative = 0;
|
||||
void int_to_str(int number, char *str, int base) {
|
||||
static const char digits[] = "0123456789ABCDEF";
|
||||
char buffer[32];
|
||||
char *ptr = buffer + sizeof(buffer) - 1;
|
||||
int is_negative = 0;
|
||||
|
||||
if (number < 0 && base == 10) {
|
||||
is_negative = 1;
|
||||
number = -number;
|
||||
}
|
||||
if (number < 0 && base == 10) {
|
||||
is_negative = 1;
|
||||
number = -number;
|
||||
}
|
||||
|
||||
*ptr = '\0';
|
||||
do {
|
||||
*--ptr = digits[number % base];
|
||||
number /= base;
|
||||
} while (number);
|
||||
*ptr = '\0';
|
||||
do {
|
||||
*--ptr = digits[number % base];
|
||||
number /= base;
|
||||
} while (number);
|
||||
|
||||
if (is_negative) {
|
||||
*--ptr = '-';
|
||||
}
|
||||
if (is_negative) {
|
||||
*--ptr = '-';
|
||||
}
|
||||
|
||||
// Дополнение ведущим нулем для шестнадцатеричных чисел
|
||||
if (base == 16 && (buffer + sizeof(buffer) - 1 - ptr) == 1) {
|
||||
*--ptr = '0';
|
||||
}
|
||||
// Дополнение ведущим нулем для шестнадцатеричных чисел
|
||||
if (base == 16 && (buffer + sizeof(buffer) - 1 - ptr) == 1) {
|
||||
*--ptr = '0';
|
||||
}
|
||||
|
||||
strcpy(str, ptr);
|
||||
strcpy(str, ptr);
|
||||
}
|
||||
|
||||
void printNumber(long int number)
|
||||
{
|
||||
char buffer[BUFFER_SIZE];
|
||||
void printNumber(long int number) {
|
||||
char buffer[BUFFER_SIZE];
|
||||
|
||||
// Преобразование числа в строку
|
||||
int_to_str(number, buffer, 10); // 10 — это основание системы счисления (десятичная система)
|
||||
strcat(buffer, "\r\n"); // Добавление новой строки
|
||||
// Преобразование числа в строку
|
||||
int_to_str(number, buffer, 10); // 10 — это основание системы счисления (десятичная система)
|
||||
strcat(buffer, "\r\n"); // Добавление новой строки
|
||||
|
||||
// Отправка строки через USB CDC
|
||||
CDC_Transmit_FS((uint8_t*)buffer, strlen(buffer));
|
||||
// Отправка строки через USB CDC
|
||||
CDC_Transmit_FS((uint8_t*) buffer, strlen(buffer));
|
||||
}
|
||||
|
||||
void printHexBuffer(uint8_t *buffer, uint16_t size) {
|
||||
char hex_str[3 * size + 3]; // Строка для хранения шестнадцатеричных значений (2 символа на байт, пробелы и переносы строк)
|
||||
int index = 0;
|
||||
|
||||
for (uint16_t i = 0; i < size; i++) {
|
||||
// Преобразуем каждый байт в шестнадцатеричный формат
|
||||
index += sprintf(&hex_str[index], "%02X ", buffer[i]);
|
||||
|
||||
// Добавляем перенос строки после каждых 8 байт
|
||||
if ((i + 1) % 32 == 0) {
|
||||
hex_str[index++] = '\n';
|
||||
} else if ((i + 1) % 8 == 0) {
|
||||
hex_str[index++] = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
// Добавляем два переноса строки в конце
|
||||
hex_str[index++] = '\n';
|
||||
hex_str[index++] = '\n';
|
||||
hex_str[index] = '\0'; // Завершаем строку символом конца строки
|
||||
|
||||
// Отправляем строку через UART (CDC)
|
||||
CDC_Transmit_FS((uint8_t*) hex_str, strlen(hex_str));
|
||||
}
|
||||
|
@ -36,24 +36,17 @@ typedef struct Current {
|
||||
Current current;
|
||||
|
||||
HardwareInit_t hwSettings = {
|
||||
/*DelayTimes*/ {
|
||||
/*preRun*/ 0
|
||||
},
|
||||
/*ServoSetting*/{
|
||||
{0, 0, 90, 180},
|
||||
{0, 0, 90, 180},
|
||||
{0, 0, 90, 180}
|
||||
},
|
||||
/*Motors*/{
|
||||
0, 0
|
||||
}
|
||||
};
|
||||
/*DelayTimes*/{
|
||||
/*preRun*/0 },
|
||||
/*ServoSetting*/{ { 0, 0, 90, 180 }, { 0, 0, 90, 180 }, { 0, 0, 90, 180 } },
|
||||
/*Motors*/{ 0, 0 } };
|
||||
|
||||
extern int16_t Vz1;
|
||||
extern int16_t Vz2;
|
||||
|
||||
int16_t map(int16_t x, int16_t in_min, int16_t in_max, int16_t out_min, int16_t out_max) {
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
int16_t map(int16_t x, int16_t in_min, int16_t in_max, int16_t out_min,
|
||||
int16_t out_max) {
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
}
|
||||
|
||||
void doShot(Shot *shot) {
|
||||
@ -67,36 +60,43 @@ void doShot(Shot *shot) {
|
||||
|
||||
void startShooting() {
|
||||
switch (current.mode) {
|
||||
case ShotMode:
|
||||
print("StartShooting\n");
|
||||
if(current.shot.isExist){
|
||||
print("Fire!\n");
|
||||
case ShotMode:
|
||||
print("StartShooting\n");
|
||||
if (current.shot.isExist) {
|
||||
print("Fire!\n");
|
||||
|
||||
print("isExist ");printNumber(current.shot.isExist);
|
||||
print("countRepeatShot; ");printNumber(current.shot.countRepeatShot);
|
||||
print("speedRollerTop; ");printNumber(current.shot.speedRollerTop);
|
||||
print("speedRollerBottom; ");printNumber(current.shot.speedRollerBottom);
|
||||
print("speedScrew; ");printNumber(current.shot.speedScrew);
|
||||
print("rotationAxial; ");printNumber(current.shot.rotationAxial);
|
||||
print("rotationHorizontal; ");printNumber(current.shot.rotationHorizontal);
|
||||
print("rotationVertical; ");printNumber(current.shot.rotationVertical);
|
||||
print("isExist ");
|
||||
printNumber(current.shot.isExist);
|
||||
print("countRepeatShot; ");
|
||||
printNumber(current.shot.countRepeatShot);
|
||||
print("speedRollerTop; ");
|
||||
printNumber(current.shot.speedRollerTop);
|
||||
print("speedRollerBottom; ");
|
||||
printNumber(current.shot.speedRollerBottom);
|
||||
print("speedScrew; ");
|
||||
printNumber(current.shot.speedScrew);
|
||||
print("rotationAxial; ");
|
||||
printNumber(current.shot.rotationAxial);
|
||||
print("rotationHorizontal; ");
|
||||
printNumber(current.shot.rotationHorizontal);
|
||||
print("rotationVertical; ");
|
||||
printNumber(current.shot.rotationVertical);
|
||||
|
||||
isShooting = 1;
|
||||
doShot(¤t.shot);
|
||||
} else {
|
||||
print("Current Shot is NULL\n");
|
||||
// TODO: sound_ERR(); ledFX_ERR();
|
||||
}
|
||||
break;
|
||||
case ProgramMode:
|
||||
|
||||
isShooting = 1;
|
||||
doShot(¤t.shot);
|
||||
} else {
|
||||
print("Current Shot is NULL\n");
|
||||
// TODO: sound_ERR(); ledFX_ERR();
|
||||
}
|
||||
break;
|
||||
case ProgramMode:
|
||||
break;
|
||||
case MacroMode:
|
||||
|
||||
break;
|
||||
case MacroMode:
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,49 +126,53 @@ uint8_t prepareShot(uint8_t number) {
|
||||
}
|
||||
}
|
||||
|
||||
void setPosSingle(ServoMap servo, uint8_t value) {
|
||||
if (hwSettings.servos[servo].invert)
|
||||
value = 180 - value;
|
||||
SetServo(servo, value);
|
||||
}
|
||||
void setPos(uint8_t axial, uint8_t horizontal, uint8_t vertical) {
|
||||
|
||||
//todo:
|
||||
// hwSettings.servos[SERVO_AXIAL].invert
|
||||
|
||||
SetServo(SERVO_AXIAL, axial); // Axial
|
||||
SetServo(SERVO_HORIZONTAL, horizontal); // Horizontal
|
||||
SetServo(SERVO_VERTICAL, vertical); // Vertical
|
||||
setPosSingle(SERVO_AXIAL, axial);
|
||||
setPosSingle(SERVO_HORIZONTAL, horizontal);
|
||||
setPosSingle(SERVO_VERTICAL, vertical);
|
||||
}
|
||||
void setPosDefault() {
|
||||
SetServo(SERVO_AXIAL, hwSettings.servos[SERVO_AXIAL].def); // Axial
|
||||
SetServo(SERVO_HORIZONTAL, hwSettings.servos[SERVO_HORIZONTAL].def); // Horizontal
|
||||
SetServo(SERVO_VERTICAL, hwSettings.servos[SERVO_VERTICAL].def); // Vertical
|
||||
setPos(
|
||||
hwSettings.servos[SERVO_AXIAL].def,
|
||||
hwSettings.servos[SERVO_HORIZONTAL].def,
|
||||
hwSettings.servos[SERVO_VERTICAL].def
|
||||
);
|
||||
}
|
||||
|
||||
// 0 .. 100
|
||||
void setScrewkSpeed(uint8_t speed) {
|
||||
|
||||
// if(speed < 0) speed = 0;
|
||||
if(speed > 100) speed = 100;
|
||||
if (speed > 100)
|
||||
speed = 100;
|
||||
|
||||
speed = map(speed, 0, 100, hwSettings.motors.speed_Screw_min, 100);
|
||||
|
||||
TIM1->CCR1 = 0;
|
||||
TIM1->CCR2 = (uint16_t)(40 * speed);
|
||||
TIM1->CCR2 = (uint16_t) (40 * speed);
|
||||
}
|
||||
|
||||
//(-v) 0 .. 100(stop) .. 200(+v)
|
||||
void setRollersSpeed(uint8_t up, uint8_t down) {
|
||||
|
||||
if(up < 100){
|
||||
up = map(up, 0, 100, 0, 100-hwSettings.motors.speed_Screw_min);
|
||||
if (up < 100) {
|
||||
up = map(up, 0, 100, 0, 100 - hwSettings.motors.speed_Screw_min);
|
||||
} else {
|
||||
up = map(up, 0, 100, 0, 100+hwSettings.motors.speed_Screw_min);
|
||||
up = map(up, 0, 100, 0, 100 + hwSettings.motors.speed_Screw_min);
|
||||
}
|
||||
|
||||
if(down < 100){
|
||||
map(down, 0, 100, 0, 100-hwSettings.motors.speed_Screw_min);
|
||||
if (down < 100) {
|
||||
map(down, 0, 100, 0, 100 - hwSettings.motors.speed_Screw_min);
|
||||
} else {
|
||||
map(down, 0, 100, 0, 100+hwSettings.motors.speed_Screw_min);
|
||||
map(down, 0, 100, 0, 100 + hwSettings.motors.speed_Screw_min);
|
||||
}
|
||||
|
||||
Vz1 = 200-up; // invert
|
||||
Vz1 = 200 - up; // invert
|
||||
Vz2 = down;
|
||||
}
|
||||
// shot sequence
|
||||
|
239
Core/Src/UART3_CMD_Handler.c
Normal file
239
Core/Src/UART3_CMD_Handler.c
Normal file
@ -0,0 +1,239 @@
|
||||
/*
|
||||
* UART3_CMD_Handler.c
|
||||
*
|
||||
* Created on: Sep 12, 2024
|
||||
* Author: DashyFox
|
||||
*/
|
||||
|
||||
#include "UART3_CMD_Handler.h"
|
||||
#include "Print.h"
|
||||
|
||||
extern void SendResponse(uint8_t command, uint8_t result, uint8_t *data,
|
||||
uint8_t data_length);
|
||||
|
||||
uint8_t checkLen(uint8_t cmd, uint8_t current_length, uint8_t required_length) {
|
||||
if (current_length >= required_length) {
|
||||
print("Invalid length for command");
|
||||
printNumber(cmd);
|
||||
print("\n");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void UART3_SaveShot(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_SaveProgram(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_SaveMacro(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_StartMacro(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_StartProgram(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_StartShot(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_Stop(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_DeleteShot(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_DeleteProgram(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_DeleteMacro(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_DeleteAllData(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_GetDeviceStatus(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_SetServoOffset(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_GetServoOffset(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_SetServoMaxAngle(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_GetServoMaxAngle(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_MoveServoToInitialPosition(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_SetStartupDelay(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_GetStartupDelay(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_SetMinRollerSpeed(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_GetMinRollerSpeed(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_SetMinScrewSpeed(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_GetMinScrewSpeed(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_SetServoInvertFlag(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_GetServoInvertFlag(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_ReadStatistics(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
||||
void UART3_ResetStatistics(uint8_t *dataPtr, uint8_t len) {
|
||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||
return;
|
||||
|
||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||
}
|
||||
|
295
Core/Src/UART3_Handler.c
Normal file
295
Core/Src/UART3_Handler.c
Normal file
@ -0,0 +1,295 @@
|
||||
/*
|
||||
* UART3_Handler.c
|
||||
*
|
||||
* Created on: Sep 12, 2024
|
||||
* Author: DashyFox
|
||||
*/
|
||||
|
||||
#include "UART3_Handler.h"
|
||||
#include "UART3_CMD_Handler.h"
|
||||
#include "Print.h"
|
||||
#include "SimpleTimer.h"
|
||||
|
||||
uint8_t uart_rx_buffer[UART_BUFFER_SIZE];
|
||||
uint8_t uart_rx_buffer_out[UART_BUFFER_SIZE];
|
||||
volatile uint8_t uart_rx_comlite = 0;
|
||||
|
||||
extern UART_HandleTypeDef huart3;
|
||||
|
||||
void UART3_CMD_Handler(uint8_t *dataPtr, uint8_t len);
|
||||
|
||||
|
||||
|
||||
void UART3_START() {
|
||||
HAL_UART_Receive_DMA(&huart3, uart_rx_buffer, UART_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
//void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
|
||||
// if (huart->Instance == USART3) {
|
||||
// uartTimer = millis();
|
||||
// packet_index++;
|
||||
//
|
||||
// CDC_Transmit_FS(uart_rx_buffer, UART_BUFFER_SIZE);
|
||||
//
|
||||
// if (packet_index < UART_BUFFER_SIZE) {
|
||||
// HAL_UART_Receive_DMA(&huart3, &uart_rx_buffer[packet_index], 1);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
volatile uint32_t last_rx_time = 0;
|
||||
volatile uint32_t rx_complete_timeout = 10;
|
||||
volatile uint32_t old_pos = 0;
|
||||
volatile uint16_t rx_index = 0;
|
||||
extern DMA_HandleTypeDef hdma_usart3_rx;
|
||||
void handle_rx_complete(uint8_t *data, uint16_t len)
|
||||
{
|
||||
// Проверка, если данных пришло меньше двух байт
|
||||
if (len < 2) {
|
||||
char error_msg[64];
|
||||
snprintf(error_msg, sizeof(error_msg),
|
||||
"Received less than 2 bytes: len = %d\n", len);
|
||||
CDC_Transmit_FS((uint8_t*) error_msg, strlen(error_msg));
|
||||
return;
|
||||
}
|
||||
|
||||
// Распечатать пришедший буфер с указанием номеров байт
|
||||
char byte_msg[128];
|
||||
snprintf(byte_msg, sizeof(byte_msg), "Received buffer (%d bytes):\n", len);
|
||||
CDC_Transmit_FS((uint8_t*) byte_msg, strlen(byte_msg));
|
||||
|
||||
for (uint16_t i = 0; i < len; i++) {
|
||||
char byte_info[32];
|
||||
snprintf(byte_info, sizeof(byte_info), "Byte %d: 0x%02X\n", i, data[i]);
|
||||
CDC_Transmit_FS((uint8_t*) byte_info, strlen(byte_info));
|
||||
}
|
||||
|
||||
// Проверка правильности пакета (первый байт должен быть 0xF0)
|
||||
if (data[0] != 0xF0) {
|
||||
char error_msg[64];
|
||||
snprintf(error_msg, sizeof(error_msg),
|
||||
"Wrong fix 0xF0: received 0x%02X\n", data[0]);
|
||||
CDC_Transmit_FS((uint8_t*) error_msg, strlen(error_msg));
|
||||
return;
|
||||
}
|
||||
|
||||
// Проверка длины пакета
|
||||
uint8_t length = data[1];
|
||||
if (length + 3 > UART_BUFFER_SIZE) {
|
||||
char error_msg[128];
|
||||
snprintf(error_msg, sizeof(error_msg),
|
||||
"Packet length exceeds buffer size: received length = %d, max size = %d\n",
|
||||
length + 3, UART_BUFFER_SIZE);
|
||||
CDC_Transmit_FS((uint8_t*) error_msg, strlen(error_msg));
|
||||
return;
|
||||
}
|
||||
|
||||
// Проверка контрольной суммы
|
||||
uint16_t checksum = 0;
|
||||
for (uint8_t i = 0; i < length + 2; i++) {
|
||||
checksum += data[i];
|
||||
}
|
||||
checksum %= 0xFF;
|
||||
|
||||
if (checksum != data[length + 2]) {
|
||||
char error_msg[64];
|
||||
snprintf(error_msg, sizeof(error_msg),
|
||||
"Wrong checksum: calculated 0x%02X, received 0x%02X\n",
|
||||
checksum, data[length + 2]);
|
||||
CDC_Transmit_FS((uint8_t*) error_msg, strlen(error_msg));
|
||||
return;
|
||||
}
|
||||
|
||||
CDC_Transmit_FS((uint8_t*)"\n\n", 2);
|
||||
|
||||
// Если пакет корректен, передать управление обработчику команд
|
||||
uint8_t *data_ptr = &data[2];
|
||||
UART3_CMD_Handler(data_ptr, length);
|
||||
}
|
||||
|
||||
|
||||
void handle_rx_data(uint8_t* data, uint16_t len)
|
||||
{
|
||||
if (len > 0)
|
||||
{
|
||||
if(!rx_index){
|
||||
memset(uart_rx_buffer_out, 0x00, UART_BUFFER_SIZE);
|
||||
}
|
||||
memcpy(uart_rx_buffer_out+rx_index, data, len);
|
||||
rx_index += len;
|
||||
|
||||
// uint8_t ff = 0xFF;
|
||||
// CDC_Transmit_FS(&ff, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void process_uart_data(uint32_t old_pos, uint32_t new_pos)
|
||||
{
|
||||
if (new_pos > old_pos)
|
||||
{
|
||||
// Обрабатываем данные между old_pos и new_pos
|
||||
handle_rx_data(&uart_rx_buffer[old_pos], new_pos - old_pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Обрабатываем данные от old_pos до конца буфера и от начала до new_pos
|
||||
handle_rx_data(&uart_rx_buffer[old_pos], UART_BUFFER_SIZE - old_pos);
|
||||
handle_rx_data(&uart_rx_buffer[0], new_pos);
|
||||
}
|
||||
}
|
||||
volatile uint8_t rx_in_progress = 0;
|
||||
void check_uart3_timeout(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void UART3_Handler() {
|
||||
// Текущая позиция в буфере (DMA передаёт значение обратного счётчика)
|
||||
uint32_t pos = UART_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&hdma_usart3_rx);
|
||||
|
||||
if (pos != old_pos)
|
||||
{
|
||||
// Если есть новые данные, обновляем таймер
|
||||
last_rx_time = millis();
|
||||
rx_in_progress = 1;
|
||||
process_uart_data(old_pos, pos); // Обрабатываем новые данные
|
||||
old_pos = pos; // Обновляем позицию
|
||||
}
|
||||
else if (rx_in_progress && (millis() - last_rx_time) > rx_complete_timeout)
|
||||
{
|
||||
handle_rx_complete(uart_rx_buffer_out, rx_index);
|
||||
rx_index = 0;
|
||||
last_rx_time = millis();
|
||||
rx_in_progress = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void SendResponse(uint8_t command, uint8_t result, uint8_t *data,
|
||||
uint8_t data_length) {
|
||||
uint8_t response_buffer[64];
|
||||
uint8_t index = 0;
|
||||
|
||||
response_buffer[index++] = 0xF0;
|
||||
response_buffer[index++] = data_length + 3;
|
||||
response_buffer[index++] = command;
|
||||
response_buffer[index++] = result;
|
||||
|
||||
if (data != NULL && data_length > 0) {
|
||||
for (uint8_t i = 0; i < data_length; i++) {
|
||||
response_buffer[index++] = data[i];
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t checksum = 0;
|
||||
for (uint8_t i = 0; i < index; i++) {
|
||||
checksum += response_buffer[i];
|
||||
}
|
||||
checksum %= 0xFF;
|
||||
|
||||
response_buffer[index++] = checksum;
|
||||
HAL_UART_Transmit(&huart3, response_buffer, index, HAL_MAX_DELAY);
|
||||
}
|
||||
|
||||
void UART3_CMD_Handler(uint8_t *dataPtr, uint8_t len) {
|
||||
uint8_t command = dataPtr[0];
|
||||
|
||||
print("Received command: ");
|
||||
printNumber(command);
|
||||
print("\nParameters: [");
|
||||
|
||||
for (uint8_t i = 1; i < len; i++) {
|
||||
printNumber(dataPtr[i]);
|
||||
if (i < len - 1) {
|
||||
print(", ");
|
||||
}
|
||||
}
|
||||
print("]\n");
|
||||
|
||||
switch (command) {
|
||||
case 10:
|
||||
UART3_SaveShot(dataPtr, len);
|
||||
break;
|
||||
case 11:
|
||||
UART3_SaveProgram(dataPtr, len);
|
||||
break;
|
||||
case 12:
|
||||
UART3_SaveMacro(dataPtr, len);
|
||||
break;
|
||||
case 100:
|
||||
UART3_StartMacro(dataPtr, len);
|
||||
break;
|
||||
case 101:
|
||||
UART3_StartProgram(dataPtr, len);
|
||||
break;
|
||||
case 102:
|
||||
UART3_StartShot(dataPtr, len);
|
||||
break;
|
||||
case 110:
|
||||
UART3_Stop(dataPtr, len);
|
||||
break;
|
||||
case 13:
|
||||
UART3_DeleteShot(dataPtr, len);
|
||||
break;
|
||||
case 14:
|
||||
UART3_DeleteProgram(dataPtr, len);
|
||||
break;
|
||||
case 15:
|
||||
UART3_DeleteMacro(dataPtr, len);
|
||||
break;
|
||||
case 120:
|
||||
UART3_DeleteAllData(dataPtr, len);
|
||||
break;
|
||||
case 180:
|
||||
UART3_GetDeviceStatus(dataPtr, len);
|
||||
break;
|
||||
case 200:
|
||||
UART3_SetServoOffset(dataPtr, len);
|
||||
break;
|
||||
case 204:
|
||||
UART3_GetServoOffset(dataPtr, len);
|
||||
break;
|
||||
case 201:
|
||||
UART3_SetServoMaxAngle(dataPtr, len);
|
||||
break;
|
||||
case 202:
|
||||
UART3_GetServoMaxAngle(dataPtr, len);
|
||||
break;
|
||||
case 203:
|
||||
UART3_MoveServoToInitialPosition(dataPtr, len);
|
||||
break;
|
||||
case 206:
|
||||
UART3_SetStartupDelay(dataPtr, len);
|
||||
break;
|
||||
case 207:
|
||||
UART3_GetStartupDelay(dataPtr, len);
|
||||
break;
|
||||
case 210:
|
||||
UART3_SetMinRollerSpeed(dataPtr, len);
|
||||
break;
|
||||
case 211:
|
||||
UART3_GetMinRollerSpeed(dataPtr, len);
|
||||
break;
|
||||
case 212:
|
||||
UART3_SetMinScrewSpeed(dataPtr, len);
|
||||
break;
|
||||
case 213:
|
||||
UART3_GetMinScrewSpeed(dataPtr, len);
|
||||
break;
|
||||
case 214:
|
||||
UART3_SetServoInvertFlag(dataPtr, len);
|
||||
break;
|
||||
case 215:
|
||||
UART3_GetServoInvertFlag(dataPtr, len);
|
||||
break;
|
||||
case 181:
|
||||
UART3_ReadStatistics(dataPtr, len);
|
||||
break;
|
||||
case 121:
|
||||
UART3_ResetStatistics(dataPtr, len);
|
||||
break;
|
||||
default:
|
||||
print("Unknown command");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
208
Core/Src/main.c
208
Core/Src/main.c
@ -23,8 +23,6 @@
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
#include "GlobalDefines.h"
|
||||
|
||||
#include "usbd_cdc_if.h"
|
||||
#include "pca9685.h"
|
||||
#include "IR.h"
|
||||
@ -34,6 +32,7 @@
|
||||
#include "SimpleTimer.h"
|
||||
#include "RobotFunctions.h"
|
||||
#include "ShiftReg.h"
|
||||
#include "UART3_Handler.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
@ -59,6 +58,7 @@ TIM_HandleTypeDef htim2;
|
||||
TIM_HandleTypeDef htim3;
|
||||
|
||||
UART_HandleTypeDef huart3;
|
||||
DMA_HandleTypeDef hdma_usart3_rx;
|
||||
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
@ -68,8 +68,6 @@ uint8_t velosety[600];
|
||||
uint8_t rxcomlite = 0;
|
||||
uint8_t initcomlete = 0;
|
||||
|
||||
uint8_t uart_rx_buffer[UART_BUFFER_SIZE];
|
||||
|
||||
unsigned char Shiftreg[3];
|
||||
|
||||
uint8_t rejim[60]; // 0 - chislo rejimov, 1-6 - rejim1, 7-12 - rejim2...
|
||||
@ -84,10 +82,6 @@ uint16_t vi = 0;
|
||||
uint16_t timing1 = 0;
|
||||
uint16_t timing2 = 0;
|
||||
|
||||
struct Shot BufShots[MAX_NUMBER_SHOTS];
|
||||
struct Program BufPrograms;
|
||||
struct Macro BufMacro;
|
||||
|
||||
extern PCD_HandleTypeDef hpcd_USB_FS;
|
||||
|
||||
/* USER CODE END PV */
|
||||
@ -95,6 +89,7 @@ extern PCD_HandleTypeDef hpcd_USB_FS;
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
void SystemClock_Config(void);
|
||||
static void MX_GPIO_Init(void);
|
||||
static void MX_DMA_Init(void);
|
||||
static void MX_I2C1_Init(void);
|
||||
static void MX_TIM1_Init(void);
|
||||
static void MX_TIM2_Init(void);
|
||||
@ -126,7 +121,7 @@ int main(void)
|
||||
HAL_Init();
|
||||
|
||||
/* USER CODE BEGIN Init */
|
||||
|
||||
HAL_Delay(10);
|
||||
/* USER CODE END Init */
|
||||
|
||||
/* Configure the system clock */
|
||||
@ -142,10 +137,12 @@ int main(void)
|
||||
__HAL_RCC_USB_FORCE_RESET();
|
||||
HAL_Delay(10);
|
||||
__HAL_RCC_USB_RELEASE_RESET();
|
||||
HAL_Delay(10);
|
||||
/* USER CODE END SysInit */
|
||||
|
||||
/* Initialize all configured peripherals */
|
||||
MX_GPIO_Init();
|
||||
MX_DMA_Init();
|
||||
MX_I2C1_Init();
|
||||
MX_USB_DEVICE_Init();
|
||||
MX_TIM1_Init();
|
||||
@ -153,29 +150,20 @@ int main(void)
|
||||
MX_TIM3_Init();
|
||||
MX_USART3_UART_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
HAL_Delay(10);
|
||||
__HAL_RCC_USART3_CLK_ENABLE();
|
||||
HAL_Delay(10);
|
||||
__HAL_RCC_DMA1_CLK_ENABLE();
|
||||
HAL_Delay(10);
|
||||
|
||||
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1); //PA8
|
||||
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_2); //PA9
|
||||
|
||||
HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); //PA0
|
||||
HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2); //PA1
|
||||
HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_3); //PA2
|
||||
HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_4); //PA3
|
||||
|
||||
initPCA9685();
|
||||
|
||||
//BufShots[0].countRepeatShot = 5;
|
||||
//BufShots[0].speedRollerTop = 120;
|
||||
//BufShots[0].speedRollerBottom = 130;
|
||||
//BufShots[0].speedScrew = 50;
|
||||
//BufShots[0].rotationAxial = 90;
|
||||
//BufShots[0].rotationHorizontal = 90;
|
||||
//BufShots[0].rotationVertical = 90;
|
||||
|
||||
// SaveShot(0, &BufShots[0]);
|
||||
|
||||
// BufShots[1] = GetShot(0);
|
||||
|
||||
|
||||
Shiftreg[0] = 0x00; Shiftreg[1] = 0x44; Shiftreg[2] = 0x00; SetShiftReg(Shiftreg); HAL_Delay(10);
|
||||
Shiftreg[0] = 0x00; Shiftreg[1] = 0x66; Shiftreg[2] = 0x00; SetShiftReg(Shiftreg); HAL_Delay(10);
|
||||
@ -198,6 +186,7 @@ initcomlete = 1;
|
||||
|
||||
HAL_TIM_Base_Start_IT(&htim3);
|
||||
HAL_NVIC_EnableIRQ(TIM3_IRQn);
|
||||
UART3_START();
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
@ -226,148 +215,7 @@ initcomlete = 1;
|
||||
{
|
||||
|
||||
IR_CMD_Handler();
|
||||
|
||||
// if (rxcomlite == 1)
|
||||
// {
|
||||
//
|
||||
// txdata[0] = 'O';
|
||||
// txdata[1] = 'K';
|
||||
// txdata[2] = '?';
|
||||
//
|
||||
// switch (rxdata[0])
|
||||
// {
|
||||
//
|
||||
// case 1:
|
||||
// {
|
||||
// SetServo(0, rxdata[1]);
|
||||
// txdata[0] = 'O';
|
||||
// txdata[1] = 'K';
|
||||
// txdata[2] = '1';
|
||||
//// CDC_Transmit_FS(txdata, 3);
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// case 2:
|
||||
// {
|
||||
// SetServo(1, rxdata[1]);
|
||||
// txdata[0] = 'O';
|
||||
// txdata[1] = 'K';
|
||||
// txdata[2] = '2';
|
||||
//// CDC_Transmit_FS(txdata, 3);
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// case 3:
|
||||
// {
|
||||
// SetServo(2, rxdata[1]);
|
||||
// txdata[0] = 'O';
|
||||
// txdata[1] = 'K';
|
||||
// txdata[2] = '3';
|
||||
//// CDC_Transmit_FS(txdata, 3);
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// case 4:
|
||||
// {
|
||||
// SetServo(0, rxdata[1]);
|
||||
// SetServo(1, rxdata[2]);
|
||||
// SetServo(2, rxdata[3]);
|
||||
//
|
||||
// Vz1 = rxdata[4]; // rolic verh 0..200
|
||||
// Vz2 = rxdata[5]; // rolic niz 0..200
|
||||
// vi = 0;
|
||||
//
|
||||
// // shnek 0..100
|
||||
// if (rxdata[6] < 101)
|
||||
// {
|
||||
// TIM1->CCR1 = 0;
|
||||
// TIM1->CCR2 = (uint16_t)(40 * rxdata[6]);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// TIM1->CCR1 = 0;
|
||||
// TIM1->CCR2 = 4000;
|
||||
// }
|
||||
//
|
||||
// txdata[0] = 'O';
|
||||
// txdata[1] = 'K';
|
||||
// txdata[2] = '4';
|
||||
//// CDC_Transmit_FS(txdata, 3);
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// case 5:
|
||||
// {
|
||||
// txdata[0] = LOBYTE(timing1);
|
||||
// txdata[1] = HIBYTE(timing1);
|
||||
//// CDC_Transmit_FS(txdata, 3);
|
||||
// break;
|
||||
// }
|
||||
// case 6:
|
||||
// {
|
||||
//// CDC_Transmit_FS(velosety, 600);
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// case 7:
|
||||
// {
|
||||
// rejim[0] = rxdata[1];
|
||||
// // copy to buffer
|
||||
// for (uint8_t i = 0; i < rejim[0]; i++)
|
||||
// {
|
||||
// rejim[(i * 6) + 1] = rxdata[(i * 6) + 2];
|
||||
// rejim[(i * 6) + 2] = rxdata[(i * 6) + 3];
|
||||
// rejim[(i * 6) + 3] = rxdata[(i * 6) + 4];
|
||||
// rejim[(i * 6) + 4] = rxdata[(i * 6) + 5];
|
||||
// rejim[(i * 6) + 5] = rxdata[(i * 6) + 6];
|
||||
// rejim[(i * 6) + 6] = rxdata[(i * 6) + 7];
|
||||
// }
|
||||
// // set rejim #1
|
||||
// SetServo(0, rejim[1]);
|
||||
// SetServo(1, rejim[2]);
|
||||
// SetServo(2, rejim[3]);
|
||||
// Vz1 = rejim[4];
|
||||
// Vz2 = rejim[5];
|
||||
// TIM1->CCR1 = 0;
|
||||
// TIM1->CCR2 = (uint16_t)(40 * rejim[6]);
|
||||
// // set avto
|
||||
// rejim_number = 1;
|
||||
// avto = 1;
|
||||
// break;
|
||||
// }
|
||||
// case 8:
|
||||
// { // stop avto
|
||||
// avto = 0;
|
||||
// rejim_number = 1;
|
||||
// // stop mecanics
|
||||
// SetServo(0, 90);
|
||||
// SetServo(1, 90);
|
||||
// SetServo(2, 90);
|
||||
// Vz1 = 100;
|
||||
// Vz2 = 100;
|
||||
// TIM1->CCR1 = 0;
|
||||
// TIM1->CCR2 = 0;
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// case 9:
|
||||
// {
|
||||
// txdata[0] = avto;
|
||||
// txdata[1] = rejim_number;
|
||||
//// CDC_Transmit_FS(txdata, 3);
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// rxcomlite = 0;
|
||||
//
|
||||
// // // HAL_Delay(1000);
|
||||
// }
|
||||
UART3_Handler();
|
||||
|
||||
forTimer(blinkTimer, 500)
|
||||
{
|
||||
@ -693,7 +541,7 @@ static void MX_USART3_UART_Init(void)
|
||||
|
||||
/* USER CODE END USART3_Init 1 */
|
||||
huart3.Instance = USART3;
|
||||
huart3.Init.BaudRate = 115200;
|
||||
huart3.Init.BaudRate = 9600;
|
||||
huart3.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
huart3.Init.StopBits = UART_STOPBITS_1;
|
||||
huart3.Init.Parity = UART_PARITY_NONE;
|
||||
@ -705,14 +553,30 @@ static void MX_USART3_UART_Init(void)
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN USART3_Init 2 */
|
||||
if (HAL_UART_Receive_IT(&huart3, uart_rx_buffer, UART_BUFFER_SIZE) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
// if (HAL_UART_Receive_IT(&huart3, uart_rx_buffer, UART_BUFFER_SIZE) != HAL_OK)
|
||||
// {
|
||||
// Error_Handler();
|
||||
// }
|
||||
/* USER CODE END USART3_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable DMA controller clock
|
||||
*/
|
||||
static void MX_DMA_Init(void)
|
||||
{
|
||||
|
||||
/* DMA controller clock enable */
|
||||
__HAL_RCC_DMA1_CLK_ENABLE();
|
||||
|
||||
/* DMA interrupt init */
|
||||
/* DMA1_Channel3_IRQn interrupt configuration */
|
||||
HAL_NVIC_SetPriority(DMA1_Channel3_IRQn, 2, 0);
|
||||
HAL_NVIC_EnableIRQ(DMA1_Channel3_IRQn);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief GPIO Initialization Function
|
||||
* @param None
|
||||
@ -763,10 +627,10 @@ static void MX_GPIO_Init(void)
|
||||
HAL_GPIO_Init(IR_EXT_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/* EXTI interrupt init*/
|
||||
HAL_NVIC_SetPriority(EXTI0_IRQn, 0, 0);
|
||||
HAL_NVIC_SetPriority(EXTI0_IRQn, 7, 0);
|
||||
HAL_NVIC_EnableIRQ(EXTI0_IRQn);
|
||||
|
||||
HAL_NVIC_SetPriority(EXTI1_IRQn, 0, 0);
|
||||
HAL_NVIC_SetPriority(EXTI1_IRQn, 7, 0);
|
||||
HAL_NVIC_EnableIRQ(EXTI1_IRQn);
|
||||
|
||||
/* USER CODE BEGIN MX_GPIO_Init_2 */
|
||||
|
@ -24,6 +24,7 @@
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
extern DMA_HandleTypeDef hdma_usart3_rx;
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN TD */
|
||||
@ -348,8 +349,25 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(RX_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/* USART3 DMA Init */
|
||||
/* USART3_RX Init */
|
||||
hdma_usart3_rx.Instance = DMA1_Channel3;
|
||||
hdma_usart3_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
||||
hdma_usart3_rx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
hdma_usart3_rx.Init.MemInc = DMA_MINC_ENABLE;
|
||||
hdma_usart3_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||
hdma_usart3_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||
hdma_usart3_rx.Init.Mode = DMA_CIRCULAR;
|
||||
hdma_usart3_rx.Init.Priority = DMA_PRIORITY_HIGH;
|
||||
if (HAL_DMA_Init(&hdma_usart3_rx) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
__HAL_LINKDMA(huart,hdmarx,hdma_usart3_rx);
|
||||
|
||||
/* USART3 interrupt Init */
|
||||
HAL_NVIC_SetPriority(USART3_IRQn, 0, 0);
|
||||
HAL_NVIC_SetPriority(USART3_IRQn, 3, 0);
|
||||
HAL_NVIC_EnableIRQ(USART3_IRQn);
|
||||
/* USER CODE BEGIN USART3_MspInit 1 */
|
||||
|
||||
@ -381,6 +399,9 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOB, TX_Pin|RX_Pin);
|
||||
|
||||
/* USART3 DMA DeInit */
|
||||
HAL_DMA_DeInit(huart->hdmarx);
|
||||
|
||||
/* USART3 interrupt DeInit */
|
||||
HAL_NVIC_DisableIRQ(USART3_IRQn);
|
||||
/* USER CODE BEGIN USART3_MspDeInit 1 */
|
||||
|
@ -28,8 +28,10 @@
|
||||
#include "usb_device.h"
|
||||
#include "usbd_cdc_if.h"
|
||||
|
||||
#include "GlobalDefines.h"
|
||||
#include "Print.h"
|
||||
|
||||
#include "UART3_Handler.h"
|
||||
#include "SimpleTimer.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
@ -50,17 +52,22 @@
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
extern uint8_t uart_rx_buffer[UART_BUFFER_SIZE];
|
||||
extern volatile uint16_t packet_index;
|
||||
extern volatile uint32_t uartTimer;
|
||||
extern volatile uint8_t uart_rx_in_progress;
|
||||
|
||||
uint8_t myi;
|
||||
extern uint16_t vi; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><> 0..599
|
||||
uint16_t v1[30]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) [0] - <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, [1-29] - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint16_t v1[30]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) [0] - <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, [1-29] - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint16_t v2[30];
|
||||
|
||||
uint32_t vt1 = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||
uint32_t vt2 = 0;
|
||||
|
||||
uint16_t vs1[4] = {0, 0, 0, 0}; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> 3 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint16_t vs2[4] = {0, 0, 0, 0}; //[0] - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//[1-3] - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> vt
|
||||
uint16_t vs1[4] = { 0, 0, 0, 0 }; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> 3 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint16_t vs2[4] = { 0, 0, 0, 0 }; //[0] - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//[1-3] - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> vt
|
||||
|
||||
uint32_t vsk1 = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||
uint32_t vsk2 = 0;
|
||||
@ -71,7 +78,7 @@ uint16_t Vupr1 = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint16_t Vzad2 = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint16_t Vupr2 = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
extern uint8_t rejim[60]; // 0 - chislo rejimov, 1-6 - rejim1, 7-12 - rejim2...
|
||||
extern uint8_t rejim[60]; // 0 - chislo rejimov, 1-6 - rejim1, 7-12 - rejim2...
|
||||
extern uint8_t avto; // vkl/otkl avtomaticheskoi raboti
|
||||
extern uint8_t rejim_number; // nomer tekyshego rejima
|
||||
|
||||
@ -93,86 +100,72 @@ int32_t computePID2(uint16_t input, uint16_t setpoint);
|
||||
|
||||
/* Private user code ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN 0 */
|
||||
int32_t computePID1(uint16_t input, uint16_t setpoint)
|
||||
{
|
||||
static int32_t integral = 0, prevErr = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int32_t computePID1(uint16_t input, uint16_t setpoint) {
|
||||
static int32_t integral = 0, prevErr = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
int32_t err = setpoint - input; // 1.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int32_t err = setpoint - input; // 1.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
integral = integral + err / 20; // 2.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> dt = 0.01, ki = 5;
|
||||
integral = integral + err / 20; // 2.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> dt = 0.01, ki = 5;
|
||||
|
||||
if (integral > 4000)
|
||||
{
|
||||
integral = 4000;
|
||||
}
|
||||
if (integral < 0)
|
||||
{
|
||||
integral = 0;
|
||||
}
|
||||
if (integral > 4000) {
|
||||
integral = 4000;
|
||||
}
|
||||
if (integral < 0) {
|
||||
integral = 0;
|
||||
}
|
||||
|
||||
int32_t D = (err - prevErr); // 3.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> dt = 0.01, kd = 0.01
|
||||
if (D > 4000)
|
||||
{
|
||||
D = 4000;
|
||||
}
|
||||
if (D < 0)
|
||||
{
|
||||
D = 0;
|
||||
}
|
||||
int32_t D = (err - prevErr); // 3.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> dt = 0.01, kd = 0.01
|
||||
if (D > 4000) {
|
||||
D = 4000;
|
||||
}
|
||||
if (D < 0) {
|
||||
D = 0;
|
||||
}
|
||||
|
||||
prevErr = err;
|
||||
//
|
||||
int32_t Rout = ((err * 3) >> 1) + integral + D; // 4. <20>=1,5 + <20>=5 + <20>=0.01
|
||||
if (Rout > 4000)
|
||||
{
|
||||
Rout = 4000;
|
||||
} //
|
||||
if (Rout < 0)
|
||||
{
|
||||
Rout = 0;
|
||||
} //
|
||||
prevErr = err;
|
||||
//
|
||||
int32_t Rout = ((err * 3) >> 1) + integral + D; // 4. <20>=1,5 + <20>=5 + <20>=0.01
|
||||
if (Rout > 4000) {
|
||||
Rout = 4000;
|
||||
} //
|
||||
if (Rout < 0) {
|
||||
Rout = 0;
|
||||
} //
|
||||
|
||||
return Rout;
|
||||
return Rout;
|
||||
}
|
||||
|
||||
int32_t computePID2(uint16_t input, uint16_t setpoint)
|
||||
{
|
||||
static int32_t integral = 0, prevErr = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int32_t err = setpoint - input; // 1.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int32_t computePID2(uint16_t input, uint16_t setpoint) {
|
||||
static int32_t integral = 0, prevErr = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int32_t err = setpoint - input; // 1.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
integral = integral + err / 20; // 2.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> dt = 0.01, ki = 5;
|
||||
if (integral > 4000)
|
||||
{
|
||||
integral = 4000;
|
||||
}
|
||||
if (integral < 0)
|
||||
{
|
||||
integral = 0;
|
||||
}
|
||||
integral = integral + err / 20; // 2.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> dt = 0.01, ki = 5;
|
||||
if (integral > 4000) {
|
||||
integral = 4000;
|
||||
}
|
||||
if (integral < 0) {
|
||||
integral = 0;
|
||||
}
|
||||
|
||||
int32_t D = (err - prevErr); // 3.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> dt = 0.01, kd = 0.01
|
||||
if (D > 4000)
|
||||
{
|
||||
D = 4000;
|
||||
}
|
||||
if (D < 0)
|
||||
{
|
||||
D = 0;
|
||||
}
|
||||
int32_t D = (err - prevErr); // 3.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> dt = 0.01, kd = 0.01
|
||||
if (D > 4000) {
|
||||
D = 4000;
|
||||
}
|
||||
if (D < 0) {
|
||||
D = 0;
|
||||
}
|
||||
|
||||
prevErr = err;
|
||||
//
|
||||
int32_t Rout = ((err * 3) >> 1) + integral + D; // 4. <20>=1,5 + <20>=5 + <20>=0.01
|
||||
if (Rout > 4000)
|
||||
{
|
||||
Rout = 4000;
|
||||
} //
|
||||
if (Rout < 0)
|
||||
{
|
||||
Rout = 0;
|
||||
} //
|
||||
prevErr = err;
|
||||
//
|
||||
int32_t Rout = ((err * 3) >> 1) + integral + D; // 4. <20>=1,5 + <20>=5 + <20>=0.01
|
||||
if (Rout > 4000) {
|
||||
Rout = 4000;
|
||||
} //
|
||||
if (Rout < 0) {
|
||||
Rout = 0;
|
||||
} //
|
||||
|
||||
return Rout;
|
||||
return Rout;
|
||||
}
|
||||
/* USER CODE END 0 */
|
||||
|
||||
@ -180,6 +173,7 @@ int32_t computePID2(uint16_t input, uint16_t setpoint)
|
||||
extern PCD_HandleTypeDef hpcd_USB_FS;
|
||||
extern I2C_HandleTypeDef hi2c1;
|
||||
extern TIM_HandleTypeDef htim3;
|
||||
extern DMA_HandleTypeDef hdma_usart3_rx;
|
||||
extern UART_HandleTypeDef huart3;
|
||||
/* USER CODE BEGIN EV */
|
||||
extern uint8_t uart_rx_buffer[UART_BUFFER_SIZE];
|
||||
@ -197,9 +191,8 @@ void NMI_Handler(void)
|
||||
|
||||
/* USER CODE END NonMaskableInt_IRQn 0 */
|
||||
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
while (1) {
|
||||
}
|
||||
/* USER CODE END NonMaskableInt_IRQn 1 */
|
||||
}
|
||||
|
||||
@ -309,175 +302,152 @@ void SysTick_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN SysTick_IRQn 0 */
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1
|
||||
if (v1[0] > 0)
|
||||
{ // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
vt1 = 0;
|
||||
for (uint8_t i = 1; i <= v1[0]; i++)
|
||||
{
|
||||
vt1 += v1[i];
|
||||
}
|
||||
vt1 = vt1 / v1[0];
|
||||
// <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
else
|
||||
{
|
||||
vt1 = timing1;
|
||||
}
|
||||
v1[0] = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1
|
||||
if (v1[0] > 0) { // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
vt1 = 0;
|
||||
for (uint8_t i = 1; i <= v1[0]; i++) {
|
||||
vt1 += v1[i];
|
||||
}
|
||||
vt1 = vt1 / v1[0];
|
||||
// <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
} else {
|
||||
vt1 = timing1;
|
||||
}
|
||||
v1[0] = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2
|
||||
if (v2[0] > 0)
|
||||
{ // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
vt2 = 0;
|
||||
for (uint8_t i = 1; i <= v2[0]; i++)
|
||||
{
|
||||
vt2 += v2[i];
|
||||
}
|
||||
vt2 = vt2 / v2[0];
|
||||
// <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
else
|
||||
{
|
||||
vt2 = timing2;
|
||||
}
|
||||
v2[0] = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2
|
||||
if (v2[0] > 0) { // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
vt2 = 0;
|
||||
for (uint8_t i = 1; i <= v2[0]; i++) {
|
||||
vt2 += v2[i];
|
||||
}
|
||||
vt2 = vt2 / v2[0];
|
||||
// <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
} else {
|
||||
vt2 = timing2;
|
||||
}
|
||||
v2[0] = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> 3
|
||||
if (vs1[0] < 3)
|
||||
{
|
||||
vs1[vs1[0] + 1] = (uint16_t)vt1;
|
||||
vs1[0]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
vs1[0] = 0;
|
||||
vs1[vs1[0] + 1] = (uint16_t)vt1;
|
||||
vs1[0]++;
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> 3
|
||||
if (vs1[0] < 3) {
|
||||
vs1[vs1[0] + 1] = (uint16_t) vt1;
|
||||
vs1[0]++;
|
||||
} else {
|
||||
vs1[0] = 0;
|
||||
vs1[vs1[0] + 1] = (uint16_t) vt1;
|
||||
vs1[0]++;
|
||||
}
|
||||
|
||||
vsk1 = (vs1[1] + vs1[2] + vs1[3]) / 3;
|
||||
vsk1 = (vs1[1] + vs1[2] + vs1[3]) / 3;
|
||||
|
||||
if (vs2[0] < 3)
|
||||
{
|
||||
vs2[vs2[0] + 1] = (uint16_t)vt2;
|
||||
vs2[0]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
vs2[0] = 0;
|
||||
vs2[vs2[0] + 1] = (uint16_t)vt2;
|
||||
vs2[0]++;
|
||||
}
|
||||
if (vs2[0] < 3) {
|
||||
vs2[vs2[0] + 1] = (uint16_t) vt2;
|
||||
vs2[0]++;
|
||||
} else {
|
||||
vs2[0] = 0;
|
||||
vs2[vs2[0] + 1] = (uint16_t) vt2;
|
||||
vs2[0]++;
|
||||
}
|
||||
|
||||
vsk2 = (vs2[1] + vs2[2] + vs2[3]) / 3;
|
||||
vsk2 = (vs2[1] + vs2[2] + vs2[3]) / 3;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 60*1000000/(<28>*10)
|
||||
if (vsk1 != 0)
|
||||
{
|
||||
vsk1 = 6000000 / vsk1;
|
||||
}
|
||||
else
|
||||
{
|
||||
vsk1 = 0;
|
||||
}
|
||||
if (vsk1 > 10000) vsk1 = 10000;
|
||||
if (vsk1 < 150) vsk1 = 0;
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 60*1000000/(<28>*10)
|
||||
if (vsk1 != 0) {
|
||||
vsk1 = 6000000 / vsk1;
|
||||
} else {
|
||||
vsk1 = 0;
|
||||
}
|
||||
if (vsk1 > 10000)
|
||||
vsk1 = 10000;
|
||||
if (vsk1 < 150)
|
||||
vsk1 = 0;
|
||||
|
||||
if (vsk2 != 0)
|
||||
{
|
||||
vsk2 = 6000000 / vsk2;
|
||||
}
|
||||
else
|
||||
{
|
||||
vsk2 = 0;
|
||||
}
|
||||
if (vsk2 > 10000)
|
||||
vsk2 = 10000;
|
||||
if (vsk2 < 150)
|
||||
vsk2 = 0;
|
||||
if (vsk2 != 0) {
|
||||
vsk2 = 6000000 / vsk2;
|
||||
} else {
|
||||
vsk2 = 0;
|
||||
}
|
||||
if (vsk2 > 10000)
|
||||
vsk2 = 10000;
|
||||
if (vsk2 < 150)
|
||||
vsk2 = 0;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0 - 200 <20> -8000 ... 8000 <20><>./<2F><><EFBFBD>.
|
||||
if (Vz1 < 0) {Vz1 = 0;}
|
||||
if (Vz1 > 200) {Vz1 = 200;}
|
||||
if (Vz2 < 0) {Vz2 = 0;}
|
||||
if (Vz2 > 200) {Vz2 = 200;}
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0 - 200 <20> -8000 ... 8000 <20><>./<2F><><EFBFBD>.
|
||||
if (Vz1 < 0) {
|
||||
Vz1 = 0;
|
||||
}
|
||||
if (Vz1 > 200) {
|
||||
Vz1 = 200;
|
||||
}
|
||||
if (Vz2 < 0) {
|
||||
Vz2 = 0;
|
||||
}
|
||||
if (Vz2 > 200) {
|
||||
Vz2 = 200;
|
||||
}
|
||||
|
||||
if (Vz1 > 100)
|
||||
{
|
||||
Vzad1 = (Vz1 - 100) * 80;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vzad1 = (100 - Vz1) * 80;
|
||||
}
|
||||
if (Vz2 > 100)
|
||||
{
|
||||
Vzad2 = (Vz2 - 100) * 80;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vzad2 = (100 - Vz2) * 80;
|
||||
}
|
||||
if (Vz1 > 100) {
|
||||
Vzad1 = (Vz1 - 100) * 80;
|
||||
} else {
|
||||
Vzad1 = (100 - Vz1) * 80;
|
||||
}
|
||||
if (Vz2 > 100) {
|
||||
Vzad2 = (Vz2 - 100) * 80;
|
||||
} else {
|
||||
Vzad2 = (100 - Vz2) * 80;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Vupr1 = (uint16_t)computePID1(vsk1, Vzad1);
|
||||
Vupr2 = (uint16_t)computePID2(vsk2, Vzad2);
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Vupr1 = (uint16_t) computePID1(vsk1, Vzad1);
|
||||
Vupr2 = (uint16_t) computePID2(vsk2, Vzad2);
|
||||
|
||||
if (Vz1 > 100)
|
||||
{
|
||||
TIM2->CCR2 = 0;
|
||||
TIM2->CCR1 = Vupr1;
|
||||
}
|
||||
else
|
||||
{
|
||||
TIM2->CCR1 = 0;
|
||||
TIM2->CCR2 = Vupr1;
|
||||
}
|
||||
if (Vz1 > 100) {
|
||||
TIM2->CCR2 = 0;
|
||||
TIM2->CCR1 = Vupr1;
|
||||
} else {
|
||||
TIM2->CCR1 = 0;
|
||||
TIM2->CCR2 = Vupr1;
|
||||
}
|
||||
|
||||
if (Vz2 > 100)
|
||||
{
|
||||
TIM2->CCR3 = 0;
|
||||
TIM2->CCR4 = Vupr2;
|
||||
}
|
||||
else
|
||||
{
|
||||
TIM2->CCR4 = 0;
|
||||
TIM2->CCR3 = Vupr2;
|
||||
}
|
||||
if (Vz2 > 100) {
|
||||
TIM2->CCR3 = 0;
|
||||
TIM2->CCR4 = Vupr2;
|
||||
} else {
|
||||
TIM2->CCR4 = 0;
|
||||
TIM2->CCR3 = Vupr2;
|
||||
}
|
||||
|
||||
// TIM2->CCR4 = 0xffff;
|
||||
// TIM2->CCR3 = 0xffff;
|
||||
// TIM2->CCR1 = 0xffff;
|
||||
// TIM2->CCR2 = 0xffff;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><>
|
||||
if (vi < 600)
|
||||
{
|
||||
velosety[vi] = LOBYTE(timing1);
|
||||
velosety[vi + 1] = HIBYTE(timing1);
|
||||
velosety[vi + 2] = LOBYTE(vsk1);
|
||||
velosety[vi + 3] = HIBYTE(vsk1);
|
||||
velosety[vi + 4] = LOBYTE(vsk2);
|
||||
velosety[vi + 5] = HIBYTE(vsk2);
|
||||
vi = vi + 6;
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><>
|
||||
if (vi < 600) {
|
||||
velosety[vi] = LOBYTE(timing1);
|
||||
velosety[vi + 1] = HIBYTE(timing1);
|
||||
velosety[vi + 2] = LOBYTE(vsk1);
|
||||
velosety[vi + 3] = HIBYTE(vsk1);
|
||||
velosety[vi + 4] = LOBYTE(vsk2);
|
||||
velosety[vi + 5] = HIBYTE(vsk2);
|
||||
vi = vi + 6;
|
||||
}
|
||||
|
||||
// else
|
||||
// {vi = 0;
|
||||
// velosety[vi] = LOBYTE(timing1);
|
||||
// velosety[vi+1] = HIBYTE(timing1);
|
||||
// velosety[vi+2] = LOBYTE(vt);
|
||||
// velosety[vi+3] = HIBYTE(vt);
|
||||
// velosety[vi+4] = LOBYTE(vsk);
|
||||
// velosety[vi+5] = HIBYTE(vsk);
|
||||
// vi = vi + 6; }
|
||||
// else
|
||||
// {vi = 0;
|
||||
// velosety[vi] = LOBYTE(timing1);
|
||||
// velosety[vi+1] = HIBYTE(timing1);
|
||||
// velosety[vi+2] = LOBYTE(vt);
|
||||
// velosety[vi+3] = HIBYTE(vt);
|
||||
// velosety[vi+4] = LOBYTE(vsk);
|
||||
// velosety[vi+5] = HIBYTE(vsk);
|
||||
// vi = vi + 6; }
|
||||
|
||||
/* USER CODE END SysTick_IRQn 0 */
|
||||
HAL_IncTick();
|
||||
@ -528,7 +498,7 @@ void EXTI0_IRQHandler(void)
|
||||
void EXTI1_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN EXTI1_IRQn 0 */
|
||||
IR_handler();
|
||||
IR_handler();
|
||||
/* USER CODE END EXTI1_IRQn 0 */
|
||||
HAL_GPIO_EXTI_IRQHandler(IR_EXT_Pin);
|
||||
/* USER CODE BEGIN EXTI1_IRQn 1 */
|
||||
@ -536,6 +506,20 @@ void EXTI1_IRQHandler(void)
|
||||
/* USER CODE END EXTI1_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles DMA1 channel3 global interrupt.
|
||||
*/
|
||||
void DMA1_Channel3_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN DMA1_Channel3_IRQn 0 */
|
||||
|
||||
/* USER CODE END DMA1_Channel3_IRQn 0 */
|
||||
HAL_DMA_IRQHandler(&hdma_usart3_rx);
|
||||
/* USER CODE BEGIN DMA1_Channel3_IRQn 1 */
|
||||
|
||||
/* USER CODE END DMA1_Channel3_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles USB low priority or CAN RX0 interrupts.
|
||||
*/
|
||||
@ -557,82 +541,67 @@ void TIM3_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN TIM3_IRQn 0 */
|
||||
|
||||
static uint32_t prev_capture1 = 0;
|
||||
static uint32_t prev_capture2 = 0;
|
||||
static uint32_t prev_capture1 = 0;
|
||||
static uint32_t prev_capture2 = 0;
|
||||
|
||||
uint32_t current_capture1 = 0;
|
||||
uint32_t current_capture2 = 0;
|
||||
uint32_t elapsed_time1 = 0;
|
||||
uint32_t elapsed_time2 = 0;
|
||||
uint32_t current_capture1 = 0;
|
||||
uint32_t current_capture2 = 0;
|
||||
uint32_t elapsed_time1 = 0;
|
||||
uint32_t elapsed_time2 = 0;
|
||||
|
||||
/* USER CODE BEGIN TIM3_IRQn 0 */
|
||||
/* USER CODE BEGIN TIM3_IRQn 0 */
|
||||
|
||||
// Обработка переполнения таймера
|
||||
if (TIM3->SR & TIM_SR_UIF)
|
||||
{
|
||||
current_capture1 = 0xFFFFFFFF;
|
||||
current_capture2 = 0xFFFFFFFF;
|
||||
// Сброс флага переполнения
|
||||
TIM3->SR &= ~TIM_SR_UIF;
|
||||
}
|
||||
// Обработка переполнения таймера
|
||||
if (TIM3->SR & TIM_SR_UIF) {
|
||||
current_capture1 = 0xFFFFFFFF;
|
||||
current_capture2 = 0xFFFFFFFF;
|
||||
// Сброс флага переполнения
|
||||
TIM3->SR &= ~TIM_SR_UIF;
|
||||
}
|
||||
|
||||
// Обработка захвата сигнала для канала 1
|
||||
if (TIM3->SR & TIM_SR_CC1IF)
|
||||
{
|
||||
current_capture1 = TIM3->CCR1;
|
||||
// Обработка захвата сигнала для канала 1
|
||||
if (TIM3->SR & TIM_SR_CC1IF) {
|
||||
current_capture1 = TIM3->CCR1;
|
||||
|
||||
if (current_capture1 >= prev_capture1)
|
||||
{
|
||||
elapsed_time1 = current_capture1 - prev_capture1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Учёт переполнения таймера
|
||||
elapsed_time1 = (65000 - prev_capture1) + current_capture1 + 1;
|
||||
}
|
||||
if (current_capture1 >= prev_capture1) {
|
||||
elapsed_time1 = current_capture1 - prev_capture1;
|
||||
} else {
|
||||
// Учёт переполнения таймера
|
||||
elapsed_time1 = (65000 - prev_capture1) + current_capture1 + 1;
|
||||
}
|
||||
|
||||
// Ограничение значения для сохранения в 16-битную переменную
|
||||
if (elapsed_time1 > 65535)
|
||||
{
|
||||
timing1 = 65535; // Максимальное значение
|
||||
}
|
||||
else
|
||||
{
|
||||
timing1 = (uint16_t)elapsed_time1;
|
||||
}
|
||||
// Ограничение значения для сохранения в 16-битную переменную
|
||||
if (elapsed_time1 > 65535) {
|
||||
timing1 = 65535; // Максимальное значение
|
||||
} else {
|
||||
timing1 = (uint16_t) elapsed_time1;
|
||||
}
|
||||
|
||||
prev_capture1 = current_capture1;
|
||||
TIM3->SR &= ~TIM_SR_CC1IF; // Сброс флага захвата сигнала
|
||||
}
|
||||
prev_capture1 = current_capture1;
|
||||
TIM3->SR &= ~TIM_SR_CC1IF; // Сброс флага захвата сигнала
|
||||
}
|
||||
|
||||
// Обработка захвата сигнала для канала 2
|
||||
if (TIM3->SR & TIM_SR_CC2IF)
|
||||
{
|
||||
current_capture2 = TIM3->CCR2;
|
||||
// Обработка захвата сигнала для канала 2
|
||||
if (TIM3->SR & TIM_SR_CC2IF) {
|
||||
current_capture2 = TIM3->CCR2;
|
||||
|
||||
if (current_capture2 >= prev_capture2)
|
||||
{
|
||||
elapsed_time2 = current_capture2 - prev_capture2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Учёт переполнения таймера
|
||||
elapsed_time2 = (65000 - prev_capture2) + current_capture2 + 1;
|
||||
}
|
||||
if (current_capture2 >= prev_capture2) {
|
||||
elapsed_time2 = current_capture2 - prev_capture2;
|
||||
} else {
|
||||
// Учёт переполнения таймера
|
||||
elapsed_time2 = (65000 - prev_capture2) + current_capture2 + 1;
|
||||
}
|
||||
|
||||
// Ограничение значения для сохранения в 16-битную переменную
|
||||
if (elapsed_time2 > 65535)
|
||||
{
|
||||
timing2 = 65535; // Максимальное значение
|
||||
}
|
||||
else
|
||||
{
|
||||
timing2 = (uint16_t)elapsed_time2;
|
||||
}
|
||||
// Ограничение значения для сохранения в 16-битную переменную
|
||||
if (elapsed_time2 > 65535) {
|
||||
timing2 = 65535; // Максимальное значение
|
||||
} else {
|
||||
timing2 = (uint16_t) elapsed_time2;
|
||||
}
|
||||
|
||||
prev_capture2 = current_capture2;
|
||||
TIM3->SR &= ~TIM_SR_CC2IF; // Сброс флага захвата сигнала
|
||||
}
|
||||
prev_capture2 = current_capture2;
|
||||
TIM3->SR &= ~TIM_SR_CC2IF; // Сброс флага захвата сигнала
|
||||
}
|
||||
|
||||
/* USER CODE END TIM3_IRQn 0 */
|
||||
HAL_TIM_IRQHandler(&htim3);
|
||||
@ -675,15 +644,19 @@ void I2C1_ER_IRQHandler(void)
|
||||
void USART3_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN USART3_IRQn 0 */
|
||||
HAL_UART_Receive_IT(&huart3, uart_rx_buffer, UART_BUFFER_SIZE);
|
||||
// CDC_Transmit_FS(uart_rx_buffer, UART_BUFFER_SIZE);
|
||||
|
||||
|
||||
// if (USART3->SR & USART_SR_RXNE) {
|
||||
// uartTimer = millis();
|
||||
// uart_rx_in_progress = 1;
|
||||
// uint8_t received_byte = (uint8_t) (USART3->DR & 0xFF);
|
||||
// uart_rx_buffer[uart_rx_index++] = received_byte;
|
||||
// if (uart_rx_index >= UART_BUFFER_SIZE) {
|
||||
// uart_rx_index = 0;
|
||||
// }
|
||||
// }
|
||||
|
||||
/* USER CODE END USART3_IRQn 0 */
|
||||
HAL_UART_IRQHandler(&huart3);
|
||||
/* USER CODE BEGIN USART3_IRQn 1 */
|
||||
|
||||
/* USER CODE END USART3_IRQn 1 */
|
||||
}
|
||||
|
||||
|
@ -2,22 +2,34 @@
|
||||
CAD.formats=
|
||||
CAD.pinconfig=
|
||||
CAD.provider=
|
||||
Dma.Request0=USART3_RX
|
||||
Dma.RequestsNb=1
|
||||
Dma.USART3_RX.0.Direction=DMA_PERIPH_TO_MEMORY
|
||||
Dma.USART3_RX.0.Instance=DMA1_Channel3
|
||||
Dma.USART3_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||
Dma.USART3_RX.0.MemInc=DMA_MINC_ENABLE
|
||||
Dma.USART3_RX.0.Mode=DMA_CIRCULAR
|
||||
Dma.USART3_RX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||
Dma.USART3_RX.0.PeriphInc=DMA_PINC_DISABLE
|
||||
Dma.USART3_RX.0.Priority=DMA_PRIORITY_HIGH
|
||||
Dma.USART3_RX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
|
||||
File.Version=6
|
||||
GPIO.groupedBy=Group By Peripherals
|
||||
KeepUserPlacement=false
|
||||
Mcu.CPN=STM32F103C8T6
|
||||
Mcu.Family=STM32F1
|
||||
Mcu.IP0=I2C1
|
||||
Mcu.IP1=NVIC
|
||||
Mcu.IP2=RCC
|
||||
Mcu.IP3=SYS
|
||||
Mcu.IP4=TIM1
|
||||
Mcu.IP5=TIM2
|
||||
Mcu.IP6=TIM3
|
||||
Mcu.IP7=USART3
|
||||
Mcu.IP8=USB
|
||||
Mcu.IP9=USB_DEVICE
|
||||
Mcu.IPNb=10
|
||||
Mcu.IP0=DMA
|
||||
Mcu.IP1=I2C1
|
||||
Mcu.IP10=USB_DEVICE
|
||||
Mcu.IP2=NVIC
|
||||
Mcu.IP3=RCC
|
||||
Mcu.IP4=SYS
|
||||
Mcu.IP5=TIM1
|
||||
Mcu.IP6=TIM2
|
||||
Mcu.IP7=TIM3
|
||||
Mcu.IP8=USART3
|
||||
Mcu.IP9=USB
|
||||
Mcu.IPNb=11
|
||||
Mcu.Name=STM32F103C(8-B)Tx
|
||||
Mcu.Package=LQFP48
|
||||
Mcu.Pin0=PC13-TAMPER-RTC
|
||||
@ -55,22 +67,23 @@ Mcu.UserName=STM32F103C8Tx
|
||||
MxCube.Version=6.12.0
|
||||
MxDb.Version=DB.6.0.120
|
||||
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.DMA1_Channel3_IRQn=true\:2\:0\:true\:false\:true\:false\:true\:true
|
||||
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.EXTI0_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||
NVIC.EXTI1_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||
NVIC.EXTI0_IRQn=true\:7\:0\:true\:false\:true\:true\:true\:true
|
||||
NVIC.EXTI1_IRQn=true\:7\:0\:true\:false\:true\:true\:true\:true
|
||||
NVIC.ForceEnableDMAVector=true
|
||||
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.I2C1_ER_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||
NVIC.I2C1_EV_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||
NVIC.I2C1_EV_IRQn=true\:0\:0\:true\:false\:true\:true\:true\:true
|
||||
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
|
||||
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
|
||||
NVIC.TIM3_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||
NVIC.USART3_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||
NVIC.USB_LP_CAN1_RX0_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true
|
||||
NVIC.TIM3_IRQn=true\:0\:0\:true\:false\:true\:true\:true\:true
|
||||
NVIC.USART3_IRQn=true\:3\:0\:true\:false\:true\:true\:true\:true
|
||||
NVIC.USB_LP_CAN1_RX0_IRQn=true\:1\:0\:true\:false\:true\:false\:true\:true
|
||||
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
PA0-WKUP.GPIOParameters=GPIO_Speed,GPIO_Label
|
||||
PA0-WKUP.GPIO_Label=RPWM_UP
|
||||
@ -187,7 +200,7 @@ ProjectManager.ToolChainLocation=
|
||||
ProjectManager.UAScriptAfterPath=
|
||||
ProjectManager.UAScriptBeforePath=
|
||||
ProjectManager.UnderRoot=true
|
||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_I2C1_Init-I2C1-false-HAL-true,4-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,5-MX_TIM1_Init-TIM1-false-HAL-true,6-MX_TIM2_Init-TIM2-false-HAL-true,7-MX_TIM3_Init-TIM3-false-HAL-true,8-MX_USART3_UART_Init-USART3-false-HAL-true
|
||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_I2C1_Init-I2C1-false-HAL-true,5-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,6-MX_TIM1_Init-TIM1-false-HAL-true,7-MX_TIM2_Init-TIM2-false-HAL-true,8-MX_TIM3_Init-TIM3-false-HAL-true,9-MX_USART3_UART_Init-USART3-false-HAL-true
|
||||
RCC.ADCFreqValue=24000000
|
||||
RCC.AHBFreq_Value=48000000
|
||||
RCC.APB1CLKDivider=RCC_HCLK_DIV2
|
||||
@ -243,7 +256,8 @@ TIM3.Channel-Input_Capture2_from_TI2=TIM_CHANNEL_2
|
||||
TIM3.IPParameters=Channel-Input_Capture1_from_TI1,Channel-Input_Capture2_from_TI2,Prescaler,Period
|
||||
TIM3.Period=65000
|
||||
TIM3.Prescaler=47
|
||||
USART3.IPParameters=VirtualMode
|
||||
USART3.BaudRate=9600
|
||||
USART3.IPParameters=VirtualMode,BaudRate
|
||||
USART3.VirtualMode=VM_ASYNC
|
||||
USB_DEVICE.APP_RX_DATA_SIZE=64
|
||||
USB_DEVICE.APP_TX_DATA_SIZE=64
|
||||
|
@ -1,21 +1,21 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file : usbd_cdc_if.c
|
||||
* @version : v2.0_Cube
|
||||
* @brief : Usb device for Virtual Com Port.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2024 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
******************************************************************************
|
||||
* @file : usbd_cdc_if.c
|
||||
* @version : v2.0_Cube
|
||||
* @brief : Usb device for Virtual Com Port.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2024 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
@ -150,10 +150,10 @@ USBD_CDC_ItfTypeDef USBD_Interface_fops_FS =
|
||||
static int8_t CDC_Init_FS(void)
|
||||
{
|
||||
/* USER CODE BEGIN 3 */
|
||||
/* Set Application Buffers */
|
||||
USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0);
|
||||
USBD_CDC_SetRxBuffer(&hUsbDeviceFS, UserRxBufferFS);
|
||||
return (USBD_OK);
|
||||
/* Set Application Buffers */
|
||||
USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0);
|
||||
USBD_CDC_SetRxBuffer(&hUsbDeviceFS, UserRxBufferFS);
|
||||
return (USBD_OK);
|
||||
/* USER CODE END 3 */
|
||||
}
|
||||
|
||||
@ -164,7 +164,7 @@ static int8_t CDC_Init_FS(void)
|
||||
static int8_t CDC_DeInit_FS(void)
|
||||
{
|
||||
/* USER CODE BEGIN 4 */
|
||||
return (USBD_OK);
|
||||
return (USBD_OK);
|
||||
/* USER CODE END 4 */
|
||||
}
|
||||
|
||||
@ -178,66 +178,65 @@ static int8_t CDC_DeInit_FS(void)
|
||||
static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length)
|
||||
{
|
||||
/* USER CODE BEGIN 5 */
|
||||
switch(cmd)
|
||||
{
|
||||
case CDC_SEND_ENCAPSULATED_COMMAND:
|
||||
switch (cmd) {
|
||||
case CDC_SEND_ENCAPSULATED_COMMAND:
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case CDC_GET_ENCAPSULATED_RESPONSE:
|
||||
case CDC_GET_ENCAPSULATED_RESPONSE:
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case CDC_SET_COMM_FEATURE:
|
||||
case CDC_SET_COMM_FEATURE:
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case CDC_GET_COMM_FEATURE:
|
||||
case CDC_GET_COMM_FEATURE:
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case CDC_CLEAR_COMM_FEATURE:
|
||||
case CDC_CLEAR_COMM_FEATURE:
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Line Coding Structure */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Offset | Field | Size | Value | Description */
|
||||
/* 0 | dwDTERate | 4 | Number |Data terminal rate, in bits per second*/
|
||||
/* 4 | bCharFormat | 1 | Number | Stop bits */
|
||||
/* 0 - 1 Stop bit */
|
||||
/* 1 - 1.5 Stop bits */
|
||||
/* 2 - 2 Stop bits */
|
||||
/* 5 | bParityType | 1 | Number | Parity */
|
||||
/* 0 - None */
|
||||
/* 1 - Odd */
|
||||
/* 2 - Even */
|
||||
/* 3 - Mark */
|
||||
/* 4 - Space */
|
||||
/* 6 | bDataBits | 1 | Number Data bits (5, 6, 7, 8 or 16). */
|
||||
/*******************************************************************************/
|
||||
case CDC_SET_LINE_CODING:
|
||||
/*******************************************************************************/
|
||||
/* Line Coding Structure */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Offset | Field | Size | Value | Description */
|
||||
/* 0 | dwDTERate | 4 | Number |Data terminal rate, in bits per second*/
|
||||
/* 4 | bCharFormat | 1 | Number | Stop bits */
|
||||
/* 0 - 1 Stop bit */
|
||||
/* 1 - 1.5 Stop bits */
|
||||
/* 2 - 2 Stop bits */
|
||||
/* 5 | bParityType | 1 | Number | Parity */
|
||||
/* 0 - None */
|
||||
/* 1 - Odd */
|
||||
/* 2 - Even */
|
||||
/* 3 - Mark */
|
||||
/* 4 - Space */
|
||||
/* 6 | bDataBits | 1 | Number Data bits (5, 6, 7, 8 or 16). */
|
||||
/*******************************************************************************/
|
||||
case CDC_SET_LINE_CODING:
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case CDC_GET_LINE_CODING:
|
||||
case CDC_GET_LINE_CODING:
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case CDC_SET_CONTROL_LINE_STATE:
|
||||
case CDC_SET_CONTROL_LINE_STATE:
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case CDC_SEND_BREAK:
|
||||
case CDC_SEND_BREAK:
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return (USBD_OK);
|
||||
return (USBD_OK);
|
||||
/* USER CODE END 5 */
|
||||
}
|
||||
|
||||
@ -259,9 +258,9 @@ static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length)
|
||||
static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len)
|
||||
{
|
||||
/* USER CODE BEGIN 6 */
|
||||
USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]);
|
||||
USBD_CDC_ReceivePacket(&hUsbDeviceFS);
|
||||
return (USBD_OK);
|
||||
USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]);
|
||||
USBD_CDC_ReceivePacket(&hUsbDeviceFS);
|
||||
return (USBD_OK);
|
||||
/* USER CODE END 6 */
|
||||
}
|
||||
|
||||
@ -280,13 +279,20 @@ uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len)
|
||||
{
|
||||
uint8_t result = USBD_OK;
|
||||
/* USER CODE BEGIN 7 */
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData;
|
||||
if (hcdc->TxState != 0){
|
||||
return USBD_BUSY;
|
||||
}
|
||||
USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len);
|
||||
result = USBD_CDC_TransmitPacket(&hUsbDeviceFS);
|
||||
while(hcdc->TxState != 0);
|
||||
USBD_CDC_HandleTypeDef *hcdc =
|
||||
(USBD_CDC_HandleTypeDef*) hUsbDeviceFS.pClassData;
|
||||
if (hcdc->TxState != 0) {
|
||||
return USBD_BUSY;
|
||||
}
|
||||
USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len);
|
||||
result = USBD_CDC_TransmitPacket(&hUsbDeviceFS);
|
||||
volatile uint32_t timeout = 5000;
|
||||
while (hcdc->TxState != 0) {
|
||||
if (!timeout) {
|
||||
return USBD_FAIL;
|
||||
}
|
||||
timeout--;
|
||||
}
|
||||
/* USER CODE END 7 */
|
||||
return result;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)
|
||||
__HAL_RCC_USB_CLK_ENABLE();
|
||||
|
||||
/* Peripheral interrupt init */
|
||||
HAL_NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 0, 0);
|
||||
HAL_NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 1, 0);
|
||||
HAL_NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn);
|
||||
/* USER CODE BEGIN USB_MspInit 1 */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user