mirror of
https://github.com/DashyFox/StackSport.git
synced 2025-05-06 00:00:18 +00:00
half work
This commit is contained in:
parent
b95af34bfd
commit
31a74305f6
2
.settings/com.st.stm32cube.ide.mcu.sfrview.prefs
Normal file
2
.settings/com.st.stm32cube.ide.mcu.sfrview.prefs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
sfrviewstate={"fFavorites"\:{"fLists"\:{}},"fProperties"\:{"fNodeProperties"\:{}}}
|
@ -108,7 +108,7 @@ typedef struct __attribute__((packed)) {
|
|||||||
typedef struct __attribute__((packed)) {
|
typedef struct __attribute__((packed)) {
|
||||||
uint32_t shotsInShot;
|
uint32_t shotsInShot;
|
||||||
uint32_t shotsInProgram;
|
uint32_t shotsInProgram;
|
||||||
uint32_t totalMacros;
|
uint32_t shotInMacro;
|
||||||
} Statistics;
|
} Statistics;
|
||||||
|
|
||||||
typedef struct __attribute__((packed)) {
|
typedef struct __attribute__((packed)) {
|
||||||
|
@ -34,23 +34,25 @@ typedef enum State{
|
|||||||
}State;
|
}State;
|
||||||
|
|
||||||
typedef struct CurrentShot {
|
typedef struct CurrentShot {
|
||||||
uint8_t index;
|
uint8_t indexGlobal;
|
||||||
uint16_t currentBallCount;
|
uint16_t currentBallCount;
|
||||||
Shot shot;
|
Shot shot;
|
||||||
} CurrentShot;
|
} CurrentShot;
|
||||||
|
|
||||||
typedef struct CurrentProgram {
|
typedef struct CurrentProgram {
|
||||||
uint8_t index;
|
uint8_t indexGlobal;
|
||||||
Program program;
|
Program program;
|
||||||
CurrentShot currentShot;
|
CurrentShot currentShot;
|
||||||
uint8_t programShotId;
|
uint8_t currentShotIndexLocal;
|
||||||
uint16_t currentBallCount;
|
uint16_t currentBallCount;
|
||||||
} CurrentProgram;
|
} CurrentProgram;
|
||||||
|
|
||||||
typedef struct CurrentMacro {
|
typedef struct CurrentMacro {
|
||||||
uint8_t index;
|
uint8_t indexGlobal;
|
||||||
Macro macro;
|
Macro macro;
|
||||||
uint8_t program_index;
|
CurrentProgram currentProgram;
|
||||||
|
uint8_t currentProgramIndexLocal;
|
||||||
|
uint16_t currentBallCount;
|
||||||
} CurrentMacro;
|
} CurrentMacro;
|
||||||
|
|
||||||
//typedef struct CurrentState {
|
//typedef struct CurrentState {
|
||||||
@ -69,7 +71,7 @@ typedef struct CurrentInfo {
|
|||||||
|
|
||||||
void Robot_INIT();
|
void Robot_INIT();
|
||||||
|
|
||||||
void shotApply(Shot*);
|
void shotApply(CurrentShot*);
|
||||||
void doShotForever(uint8_t number);
|
void doShotForever(uint8_t number);
|
||||||
|
|
||||||
void BallEXT();
|
void BallEXT();
|
||||||
@ -77,7 +79,7 @@ void RobotTick();
|
|||||||
|
|
||||||
uint8_t prepareShot(uint8_t number);
|
uint8_t prepareShot(uint8_t number);
|
||||||
uint8_t prepareProgramm(uint8_t number);
|
uint8_t prepareProgramm(uint8_t number);
|
||||||
//uint8_t prepareMacro(uint8_t number);
|
uint8_t prepareMacro(uint8_t number);
|
||||||
|
|
||||||
|
|
||||||
void startShooting(uint32_t delayTime);
|
void startShooting(uint32_t delayTime);
|
||||||
|
@ -49,7 +49,7 @@ MemoryStatus EEPROM_INIT() {
|
|||||||
|
|
||||||
infoBlock.statInfo.shotsInShot = 0;
|
infoBlock.statInfo.shotsInShot = 0;
|
||||||
infoBlock.statInfo.shotsInProgram = 0;
|
infoBlock.statInfo.shotsInProgram = 0;
|
||||||
infoBlock.statInfo.totalMacros = 0;
|
infoBlock.statInfo.shotInMacro = 0;
|
||||||
|
|
||||||
status = saveInfoBlock(&infoBlock);
|
status = saveInfoBlock(&infoBlock);
|
||||||
if (status != EEPROM_OK) {
|
if (status != EEPROM_OK) {
|
||||||
@ -121,7 +121,7 @@ MemoryStatus EEPROM_INIT() {
|
|||||||
CDC_Transmit_FS((uint8_t*) buffer, strlen(buffer));
|
CDC_Transmit_FS((uint8_t*) buffer, strlen(buffer));
|
||||||
|
|
||||||
snprintf(buffer, sizeof(buffer), "Total Macros: %lu\n\n",
|
snprintf(buffer, sizeof(buffer), "Total Macros: %lu\n\n",
|
||||||
infoBlock.statInfo.totalMacros);
|
infoBlock.statInfo.shotInMacro);
|
||||||
CDC_Transmit_FS((uint8_t*) buffer, strlen(buffer));
|
CDC_Transmit_FS((uint8_t*) buffer, strlen(buffer));
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
@ -79,7 +79,7 @@ void IR_Home_Process() {
|
|||||||
|
|
||||||
case IR_PAUSE: {
|
case IR_PAUSE: {
|
||||||
uint8_t buf[1024]; // Буфер для чтения данных размером 128 байт
|
uint8_t buf[1024]; // Буфер для чтения данных размером 128 байт
|
||||||
uint16_t blockAddr16 = 0; // Начальный адрес EEPROM
|
uint16_t blockAddr16 = START_ADR_MACRO; // Начальный адрес EEPROM
|
||||||
uint8_t blockAddr[2] = { (uint8_t) (blockAddr16 >> 8),
|
uint8_t blockAddr[2] = { (uint8_t) (blockAddr16 >> 8),
|
||||||
(uint8_t) (blockAddr16 & 0xFF) }; // Адрес в формате 2 байта
|
(uint8_t) (blockAddr16 & 0xFF) }; // Адрес в формате 2 байта
|
||||||
int max_attempts = 15; // Максимальное количество попыток для операции
|
int max_attempts = 15; // Максимальное количество попыток для операции
|
||||||
|
@ -25,22 +25,23 @@ uint8_t ballDetected = 0;
|
|||||||
uint32_t ballReact_timer = 0;
|
uint32_t ballReact_timer = 0;
|
||||||
uint8_t isDelayTimerRun = 0;
|
uint8_t isDelayTimerRun = 0;
|
||||||
uint32_t startDelay_timer;
|
uint32_t startDelay_timer;
|
||||||
Shot *postDelayShot = NULL;
|
CurrentShot *postDelayShot = NULL;
|
||||||
uint32_t lastIndicationTime = 0;
|
uint32_t lastIndicationTime = 0;
|
||||||
uint32_t noBallTimer = 0;
|
uint32_t noBallTimer = 0;
|
||||||
uint32_t noBallTimeout = 0xFFFFFFFF;
|
uint32_t noBallTimeout = 0xFFFFFFFF;
|
||||||
|
|
||||||
void BallEXT_Handler();
|
void BallEXT_Handler();
|
||||||
Shot* getShotFromProgram(CurrentProgram *currentProg);
|
|
||||||
void robotStateStart(uint32_t delayTime);
|
void robotStateStart(uint32_t delayTime);
|
||||||
void robotStatePause();
|
void robotStatePause();
|
||||||
void robotStateStop();
|
void robotStateStop();
|
||||||
float calculatePeriod(int pwm_value);
|
float calculatePeriod(int pwm_value);
|
||||||
uint8_t nextBallinShot(CurrentShot *shot);
|
uint8_t nextBallInShot(CurrentShot *shot);
|
||||||
void shotApply(Shot *shot);
|
uint8_t nextProgramInMacro(CurrentMacro *macro);
|
||||||
|
uint8_t nextShotInProgram(CurrentProgram *prog);
|
||||||
uint8_t loadNextShotInProgram(CurrentProgram *currentProg);
|
uint8_t loadNextShotInProgram(CurrentProgram *currentProg);
|
||||||
uint8_t loadShotFromProgram(CurrentProgram *currentProg);
|
uint8_t loadShotFromProgram(CurrentProgram *currentProg);
|
||||||
Shot* getShotFromProgram(CurrentProgram *currentProg);
|
uint8_t loadNextProgramInMacro(CurrentMacro *currentMacro);
|
||||||
|
uint8_t loadProgramFromMacro(CurrentMacro *currentMacro);
|
||||||
|
|
||||||
void robotStateStart(uint32_t delayTime) {
|
void robotStateStart(uint32_t delayTime) {
|
||||||
currentInfo.state = PRERUN_WAIT;
|
currentInfo.state = PRERUN_WAIT;
|
||||||
@ -56,13 +57,10 @@ void robotStateStop() {
|
|||||||
currentInfo.state = STOP;
|
currentInfo.state = STOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BallEXT() {
|
long map(long x, long in_min, long in_max, long out_min, long out_max) {
|
||||||
ballDetected = 1;
|
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||||
ballReact_timer = millis();
|
|
||||||
}
|
}
|
||||||
|
float calculatePeriod(int pwm_value) {// Функция для расчета периода вылета мяча на основе ШИМ
|
||||||
// Функция для расчета периода вылета мяча на основе ШИМ
|
|
||||||
float calculatePeriod(int pwm_value) {
|
|
||||||
// Коэффициенты из аппроксимации
|
// Коэффициенты из аппроксимации
|
||||||
float a = 100382.255;
|
float a = 100382.255;
|
||||||
float b = 0.21895;
|
float b = 0.21895;
|
||||||
@ -73,130 +71,12 @@ float calculatePeriod(int pwm_value) {
|
|||||||
return period;
|
return period;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RobotTick() {
|
|
||||||
BallEXT_Handler();
|
|
||||||
|
|
||||||
// No Ball Handler
|
|
||||||
if (currentInfo.state == RUN && millis() - noBallTimer > noBallTimeout) {
|
|
||||||
robotStateStop();
|
|
||||||
setScrewkSpeed(0);
|
|
||||||
setRollersSpeed(100, 100);
|
|
||||||
setPos(infoBlock.hwInfo.servos[SERVO_AXIAL].def,
|
|
||||||
infoBlock.hwInfo.servos[SERVO_HORIZONTAL].def,
|
|
||||||
infoBlock.hwInfo.servos[SERVO_VERTICAL].min);
|
|
||||||
print("NO BALL!!!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// PreRun delay
|
|
||||||
if (isDelayTimerRun) {
|
|
||||||
uint32_t elapsedTime = millis() - startDelay_timer;
|
|
||||||
|
|
||||||
if (elapsedTime > currentInfo.startDelay) {
|
|
||||||
isDelayTimerRun = 0;
|
|
||||||
if (currentInfo.state == PRERUN_WAIT) {
|
|
||||||
currentInfo.state = RUN;
|
|
||||||
shotApply(postDelayShot);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
uint32_t intervalStep = currentInfo.startDelay / NUMLEDS;
|
|
||||||
if (elapsedTime - lastIndicationTime >= intervalStep) {
|
|
||||||
lastIndicationTime = elapsedTime;
|
|
||||||
uint8_t progress = (elapsedTime * 100) / currentInfo.startDelay;
|
|
||||||
// indicate(progress);
|
|
||||||
print("delay: ");
|
|
||||||
printNumber(progress);
|
|
||||||
print("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t nextBallinShot(CurrentShot *shot) {
|
|
||||||
|
|
||||||
print("shot->shot.countRepeatShot ");
|
|
||||||
printNumber(shot->shot.countRepeatShot);
|
|
||||||
print("\n");
|
|
||||||
|
|
||||||
if (shot->currentBallCount + 1 < shot->shot.countRepeatShot
|
|
||||||
|| !shot->shot.countRepeatShot) {
|
|
||||||
// nextBall
|
|
||||||
print("Shot ");
|
|
||||||
printNumber(shot->currentBallCount);
|
|
||||||
print("\n\n");
|
|
||||||
|
|
||||||
shot->currentBallCount++;
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
print("Shot DONE\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BallEXT_Handler() {
|
|
||||||
if (ballDetected && millis() - ballReact_timer > ballReact_value) {
|
|
||||||
ballDetected = 0;
|
|
||||||
|
|
||||||
if (currentInfo.state != RUN) {
|
|
||||||
print("BallDetected on idle\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print("BallDetected ");
|
|
||||||
uint16_t period = ballReact_timer - noBallTimer;
|
|
||||||
printNumber(period);
|
|
||||||
print("ms\n");
|
|
||||||
noBallTimer = ballReact_timer;
|
|
||||||
|
|
||||||
switch (currentInfo.mode) {
|
|
||||||
case NoneMode:
|
|
||||||
|
|
||||||
break;
|
|
||||||
case ShotMode:
|
|
||||||
if (nextBallinShot(¤tInfo.shot)) {
|
|
||||||
stopShooting();
|
|
||||||
}
|
|
||||||
infoBlock.statInfo.shotsInShot++;
|
|
||||||
saveInfoBlock();
|
|
||||||
break;
|
|
||||||
case ProgramMode:
|
|
||||||
if (nextBallinShot(¤tInfo.program.currentShot)) {
|
|
||||||
if (!loadNextShotInProgram(¤tInfo.program)) {
|
|
||||||
stopShooting();
|
|
||||||
print("loadNextShotInProgram ERR\n");
|
|
||||||
}
|
|
||||||
shotApply(getShotFromProgram(¤tInfo.program));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentInfo.program.currentBallCount + 1
|
|
||||||
< currentInfo.program.program.header.countRepeat
|
|
||||||
|| currentInfo.program.program.header.countRepeat == 0) {
|
|
||||||
currentInfo.program.currentBallCount++;
|
|
||||||
} else {
|
|
||||||
stopShooting();
|
|
||||||
print("Program DONE\n");
|
|
||||||
}
|
|
||||||
infoBlock.statInfo.shotsInProgram++;
|
|
||||||
saveInfoBlock();
|
|
||||||
break;
|
|
||||||
case MacroMode:
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
long map(long x, long in_min, long in_max, long out_min, long out_max) {
|
|
||||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
|
||||||
}
|
|
||||||
void Robot_INIT() {
|
void Robot_INIT() {
|
||||||
memset(¤tInfo, 0x00, sizeof(currentInfo));
|
memset(¤tInfo, 0x00, sizeof(currentInfo));
|
||||||
// NULL
|
// NULL
|
||||||
currentInfo.shot.index = 0xFF;
|
currentInfo.shot.indexGlobal = 0xFF;
|
||||||
currentInfo.program.index = 0xFF;
|
currentInfo.program.indexGlobal = 0xFF;
|
||||||
currentInfo.macro.index = 0xFF;
|
currentInfo.macro.indexGlobal = 0xFF;
|
||||||
initPCA9685();
|
initPCA9685();
|
||||||
EEPROM_INIT();
|
EEPROM_INIT();
|
||||||
UART3_START();
|
UART3_START();
|
||||||
@ -262,145 +142,48 @@ void Robot_INIT() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void shotApply(Shot *shot) {
|
void BallEXT() {
|
||||||
setPos(shot->rotationAxial, shot->rotationHorizontal,
|
ballDetected = 1;
|
||||||
shot->rotationVertical);
|
ballReact_timer = millis();
|
||||||
setRollersSpeed(shot->speedRollerTop, shot->speedRollerBottom);
|
|
||||||
setScrewkSpeed(shot->speedScrew);
|
|
||||||
noBallTimeout = MIN(
|
|
||||||
calculatePeriod( shot->speedScrew) * NOBALL_TIMEOUT_MULTIPLIER,
|
|
||||||
30000);
|
|
||||||
noBallTimer = millis();
|
|
||||||
print("Fire!\n");
|
|
||||||
print("isExist ");
|
|
||||||
printNumber(shot->isExist);
|
|
||||||
print("\ncountRepeatShot; ");
|
|
||||||
printNumber(shot->countRepeatShot);
|
|
||||||
print("\nspeedRollerTop; ");
|
|
||||||
printNumber(shot->speedRollerTop);
|
|
||||||
print("\nspeedRollerBottom; ");
|
|
||||||
printNumber(shot->speedRollerBottom);
|
|
||||||
print("\nspeedScrew; ");
|
|
||||||
printNumber(shot->speedScrew);
|
|
||||||
print("\nrotationAxial; ");
|
|
||||||
printNumber(shot->rotationAxial);
|
|
||||||
print("\nrotationHorizontal; ");
|
|
||||||
printNumber(shot->rotationHorizontal);
|
|
||||||
print("\nrotationVertical; ");
|
|
||||||
printNumber(shot->rotationVertical);
|
|
||||||
print("\nnoBallTimeout: ");
|
|
||||||
printNumber(noBallTimeout);
|
|
||||||
print("\n");
|
|
||||||
print("\n\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t loadShotFromProgram(CurrentProgram *currentProg) {
|
|
||||||
Shot shot_;
|
|
||||||
uint8_t currentProgramShotId = currentProg->programShotId;
|
|
||||||
if (currentProgramShotId >= currentProg->program.header.shotCount) {
|
|
||||||
print("Shot index out of range\n");
|
|
||||||
// TODO: sound_ERR(); ledFX_ERR();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
uint8_t shotId = currentProg->program.shots[currentProgramShotId].id;
|
|
||||||
currentProg->currentShot.index = shotId;
|
|
||||||
getShot(shotId, &shot_);
|
|
||||||
if (!shot_.isExist) {
|
|
||||||
print("Shot in program is NULL\n");
|
|
||||||
// TODO: sound_ERR(); ledFX_ERR();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t overridenSpeedScrew =
|
void RobotTick() {
|
||||||
currentProg->program.shots[currentProgramShotId].speedScrew;
|
BallEXT_Handler();
|
||||||
if (overridenSpeedScrew != 0) {
|
|
||||||
shot_.speedScrew = overridenSpeedScrew;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t repeatCountFromShot = currentProg->program.header.options & 2U;
|
// No Ball Handler
|
||||||
if (!repeatCountFromShot) {
|
if (currentInfo.state == RUN && millis() - noBallTimer > noBallTimeout) {
|
||||||
print("Repeat Count Override\n");
|
|
||||||
shot_.countRepeatShot = 1;
|
|
||||||
}
|
|
||||||
currentProg->currentShot.shot = shot_;
|
|
||||||
print("REPEAT ");
|
|
||||||
printNumber(shot_.countRepeatShot);
|
|
||||||
print("\n");
|
|
||||||
currentProg->currentShot.currentBallCount = 0;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t loadNextShotInProgram(CurrentProgram *currentProg) {
|
|
||||||
uint8_t random = currentProg->program.header.options & 1U;
|
|
||||||
uint8_t *currentProgramShotId = ¤tProg->programShotId;
|
|
||||||
|
|
||||||
if (random) {
|
|
||||||
*currentProgramShotId = rand() % currentProg->program.header.shotCount;
|
|
||||||
} else {
|
|
||||||
if ((*currentProgramShotId) + 1
|
|
||||||
< currentProg->program.header.shotCount) {
|
|
||||||
++(*currentProgramShotId);
|
|
||||||
} else {
|
|
||||||
*currentProgramShotId = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return loadShotFromProgram(currentProg);
|
|
||||||
}
|
|
||||||
|
|
||||||
Shot* getShotFromProgram(CurrentProgram *currentProg) {
|
|
||||||
return ¤tProg->currentShot.shot;
|
|
||||||
}
|
|
||||||
|
|
||||||
void startShooting(uint32_t delayTime) {
|
|
||||||
print("StartShooting\n");
|
|
||||||
switch (currentInfo.mode) {
|
|
||||||
case ShotMode:
|
|
||||||
if (currentInfo.shot.shot.isExist) {
|
|
||||||
postDelayShot = ¤tInfo.shot.shot;
|
|
||||||
if (PRE_RUN_DELAY_MODE) {
|
|
||||||
setPosFromShot(postDelayShot);
|
|
||||||
}
|
|
||||||
robotStateStart(delayTime);
|
|
||||||
} else {
|
|
||||||
print("Current Shot is NULL\n");
|
|
||||||
// TODO: sound_ERR(); ledFX_ERR();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ProgramMode:
|
|
||||||
if (currentInfo.program.program.header.shotCount) {
|
|
||||||
if (!loadShotFromProgram(¤tInfo.program)) {
|
|
||||||
print("loadShotFromProgram ERR\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
postDelayShot = getShotFromProgram(¤tInfo.program);
|
|
||||||
if (PRE_RUN_DELAY_MODE) {
|
|
||||||
setPosFromShot(postDelayShot);
|
|
||||||
}
|
|
||||||
robotStateStart(delayTime);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
print("Current Program is NULL\n");
|
|
||||||
// TODO: sound_ERR(); ledFX_ERR();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MacroMode:
|
|
||||||
if (currentInfo.macro.macro.header.programmCount) {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
print("Current Macro is NULL\n");
|
|
||||||
// TODO: sound_ERR(); ledFX_ERR();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void stopShooting() {
|
|
||||||
robotStateStop();
|
robotStateStop();
|
||||||
setScrewkSpeed(0);
|
setScrewkSpeed(0);
|
||||||
setRollersSpeed(100, 100);
|
setRollersSpeed(100, 100);
|
||||||
setPosDefault();
|
setPos(infoBlock.hwInfo.servos[SERVO_AXIAL].def,
|
||||||
|
infoBlock.hwInfo.servos[SERVO_HORIZONTAL].def,
|
||||||
|
infoBlock.hwInfo.servos[SERVO_VERTICAL].min);
|
||||||
|
print("NO BALL!!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// PreRun delay
|
||||||
|
if (isDelayTimerRun) {
|
||||||
|
uint32_t elapsedTime = millis() - startDelay_timer;
|
||||||
|
|
||||||
|
if (elapsedTime > currentInfo.startDelay) {
|
||||||
|
isDelayTimerRun = 0;
|
||||||
|
if (currentInfo.state == PRERUN_WAIT) {
|
||||||
|
currentInfo.state = RUN;
|
||||||
|
shotApply(postDelayShot);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
uint32_t intervalStep = currentInfo.startDelay / NUMLEDS;
|
||||||
|
if (elapsedTime - lastIndicationTime >= intervalStep) {
|
||||||
|
lastIndicationTime = elapsedTime;
|
||||||
|
uint8_t progress = (elapsedTime * 100) / currentInfo.startDelay;
|
||||||
|
// indicate(progress);
|
||||||
|
print("delay: ");
|
||||||
|
printNumber(progress);
|
||||||
|
print("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t prepareShot(uint8_t number) {
|
uint8_t prepareShot(uint8_t number) {
|
||||||
@ -423,8 +206,8 @@ uint8_t prepareProgramm(uint8_t number) {
|
|||||||
if (program.header.shotCount) { // isExist
|
if (program.header.shotCount) { // isExist
|
||||||
currentInfo.mode = ProgramMode;
|
currentInfo.mode = ProgramMode;
|
||||||
currentInfo.program.program = program;
|
currentInfo.program.program = program;
|
||||||
currentInfo.program.index = number;
|
currentInfo.program.indexGlobal = number;
|
||||||
currentInfo.program.programShotId = 0;
|
currentInfo.program.currentShotIndexLocal = 0;
|
||||||
currentInfo.program.currentBallCount = 0;
|
currentInfo.program.currentBallCount = 0;
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
@ -434,6 +217,343 @@ uint8_t prepareProgramm(uint8_t number) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t prepareMacro(uint8_t number) {
|
||||||
|
Macro macro;
|
||||||
|
getMacro(number, ¯o);
|
||||||
|
if (macro.header.programmCount) {
|
||||||
|
currentInfo.mode = MacroMode;
|
||||||
|
currentInfo.macro.macro = macro;
|
||||||
|
currentInfo.macro.indexGlobal = number;
|
||||||
|
currentInfo.macro.currentProgramIndexLocal = 0;
|
||||||
|
currentInfo.macro.currentBallCount = 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
print("Macro not exist ");
|
||||||
|
printNumber(number);
|
||||||
|
print("\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BallEXT_Handler() {
|
||||||
|
if (ballDetected && millis() - ballReact_timer > ballReact_value) {
|
||||||
|
ballDetected = 0;
|
||||||
|
|
||||||
|
if (currentInfo.state != RUN) {
|
||||||
|
print("BallDetected on idle\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
print("BallDetected ");
|
||||||
|
uint16_t period = ballReact_timer - noBallTimer;
|
||||||
|
printNumber(period);
|
||||||
|
print("ms\n");
|
||||||
|
noBallTimer = ballReact_timer;
|
||||||
|
|
||||||
|
switch (currentInfo.mode) {
|
||||||
|
case NoneMode:
|
||||||
|
|
||||||
|
break;
|
||||||
|
case ShotMode:
|
||||||
|
print("ShotMode\n");
|
||||||
|
if (nextBallInShot(¤tInfo.shot)) {
|
||||||
|
stopShooting();
|
||||||
|
}
|
||||||
|
infoBlock.statInfo.shotsInShot++;
|
||||||
|
saveInfoBlock();
|
||||||
|
break;
|
||||||
|
case ProgramMode:
|
||||||
|
print("ProgramMode\n");
|
||||||
|
if (nextShotInProgram(¤tInfo.program)) {
|
||||||
|
stopShooting();
|
||||||
|
}
|
||||||
|
infoBlock.statInfo.shotsInProgram++;
|
||||||
|
saveInfoBlock();
|
||||||
|
break;
|
||||||
|
case MacroMode:
|
||||||
|
print("MacroMode\n");
|
||||||
|
if (nextProgramInMacro(¤tInfo.macro)) {
|
||||||
|
stopShooting();
|
||||||
|
}
|
||||||
|
infoBlock.statInfo.shotInMacro++;
|
||||||
|
saveInfoBlock();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t loadShotFromProgram(CurrentProgram *currentProg) {
|
||||||
|
Shot shot_;
|
||||||
|
uint8_t currentShotIndexLocal = currentProg->currentShotIndexLocal;
|
||||||
|
if (currentShotIndexLocal >= currentProg->program.header.shotCount) {
|
||||||
|
print("Shot indexGlobal out of range\n");
|
||||||
|
// TODO: sound_ERR(); ledFX_ERR();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
uint8_t shotId = currentProg->program.shots[currentShotIndexLocal].id;
|
||||||
|
currentProg->currentShot.indexGlobal = shotId;
|
||||||
|
getShot(shotId, &shot_);
|
||||||
|
if (!shot_.isExist) {
|
||||||
|
print("Shot in program is NULL\n");
|
||||||
|
// TODO: sound_ERR(); ledFX_ERR();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t overridenSpeedScrew =
|
||||||
|
currentProg->program.shots[currentShotIndexLocal].speedScrew;
|
||||||
|
if (overridenSpeedScrew != 0) {
|
||||||
|
shot_.speedScrew = overridenSpeedScrew;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t repeatCountFromShot = currentProg->program.header.options & 2U;
|
||||||
|
if (!repeatCountFromShot) {
|
||||||
|
print("Repeat Count Override\n");
|
||||||
|
shot_.countRepeatShot = 1;
|
||||||
|
}else if(shot_.countRepeatShot == 0 && currentInfo.mode != ShotMode){
|
||||||
|
shot_.countRepeatShot = 1;
|
||||||
|
}
|
||||||
|
currentProg->currentShot.shot = shot_;
|
||||||
|
currentProg->currentShot.currentBallCount = 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t loadNextShotInProgram(CurrentProgram *currentProg) {
|
||||||
|
uint8_t random = currentProg->program.header.options & 1U;
|
||||||
|
uint8_t *currentProgramShotId = ¤tProg->currentShotIndexLocal;
|
||||||
|
|
||||||
|
if (random) {
|
||||||
|
*currentProgramShotId = rand() % currentProg->program.header.shotCount;
|
||||||
|
} else {
|
||||||
|
if ((*currentProgramShotId) + 1
|
||||||
|
< currentProg->program.header.shotCount) {
|
||||||
|
++(*currentProgramShotId);
|
||||||
|
} else {
|
||||||
|
*currentProgramShotId = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return loadShotFromProgram(currentProg);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t loadProgramFromMacro(CurrentMacro *currentMacro) {
|
||||||
|
Program program_;
|
||||||
|
uint8_t currentProgIndexLocal = currentMacro->currentProgramIndexLocal;
|
||||||
|
if (currentMacro->currentProgramIndexLocal
|
||||||
|
>= currentMacro->macro.header.programmCount) {
|
||||||
|
print("Program indexGlobal out of range in currentMacro\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t programId = currentMacro->macro.programs[currentProgIndexLocal].id;
|
||||||
|
currentMacro->currentProgram.indexGlobal = programId;
|
||||||
|
getProg(programId, &program_);
|
||||||
|
|
||||||
|
if (program_.header.shotCount == 0) {
|
||||||
|
print("Program in macro is NULL\n");
|
||||||
|
// TODO: sound_ERR(); ledFX_ERR();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t needOverride =
|
||||||
|
currentMacro->macro.programs[currentProgIndexLocal].countRepeat != 0
|
||||||
|
&& currentMacro->macro.programs[currentProgIndexLocal].speedScrew
|
||||||
|
!= 0;
|
||||||
|
|
||||||
|
if (needOverride)
|
||||||
|
{
|
||||||
|
print("Override programs params\n");
|
||||||
|
program_.header.countRepeat = currentMacro->macro.programs[currentProgIndexLocal].countRepeat;
|
||||||
|
program_.header.options = currentMacro->macro.programs[currentProgIndexLocal].options;
|
||||||
|
for (uint8_t i = 0; i < program_.header.shotCount; i++) {
|
||||||
|
program_.shots[i].speedScrew =
|
||||||
|
currentMacro->macro.programs[currentProgIndexLocal].speedScrew;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
currentMacro->currentProgram.program = program_;
|
||||||
|
currentMacro->currentProgram.currentShotIndexLocal = 0;
|
||||||
|
currentMacro->currentProgram.currentBallCount = 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t loadNextProgramInMacro(CurrentMacro *currentMacro) {
|
||||||
|
if (currentMacro->currentProgramIndexLocal + 1
|
||||||
|
< currentMacro->macro.header.programmCount) {
|
||||||
|
currentMacro->currentProgramIndexLocal++;
|
||||||
|
} else {
|
||||||
|
currentMacro->currentProgramIndexLocal = 0;
|
||||||
|
}
|
||||||
|
return loadProgramFromMacro(currentMacro);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t nextBallInShot(CurrentShot *shot) {
|
||||||
|
|
||||||
|
print("shot->shot.countRepeatShot ");
|
||||||
|
printNumber(shot->shot.countRepeatShot);
|
||||||
|
print("\n");
|
||||||
|
|
||||||
|
if (shot->currentBallCount + 1 < shot->shot.countRepeatShot
|
||||||
|
|| !shot->shot.countRepeatShot) {
|
||||||
|
// nextBall
|
||||||
|
print("Shot ");
|
||||||
|
printNumber(shot->currentBallCount);
|
||||||
|
print("\n\n");
|
||||||
|
|
||||||
|
shot->currentBallCount++;
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
print("Shot DONE\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t nextShotInProgram(CurrentProgram *prog) {
|
||||||
|
if (nextBallInShot(&prog->currentShot)) {
|
||||||
|
print("\nSwitch shot\n");
|
||||||
|
if (!loadNextShotInProgram(prog)) {
|
||||||
|
print("loadNextShotInProgram ERR\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
shotApply(&prog->currentShot);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Проверка на завершение программы
|
||||||
|
if (prog->currentBallCount + 1 < prog->program.header.countRepeat
|
||||||
|
|| prog->program.header.countRepeat == 0) {
|
||||||
|
prog->currentBallCount++;
|
||||||
|
} else {
|
||||||
|
print("Program DONE\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t nextProgramInMacro(CurrentMacro *currentMacro) {
|
||||||
|
if (nextShotInProgram(¤tMacro->currentProgram)) {
|
||||||
|
print("\nSwitch program\n");
|
||||||
|
if (!loadNextProgramInMacro(currentMacro)) {
|
||||||
|
print("loadNextProgramInMacro ERR\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// shotApply(¤tMacro->currentProgram.currentShot);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Проверка на завершение макро
|
||||||
|
// if (currentMacro->currentProgramIndexLocal < currentMacro->macro.header.programmCount) {
|
||||||
|
// } else {
|
||||||
|
// print("Macro DONE\n");
|
||||||
|
// return 1;
|
||||||
|
// }
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void startShooting(uint32_t delayTime) {
|
||||||
|
print("StartShooting\n");
|
||||||
|
switch (currentInfo.mode) {
|
||||||
|
case ShotMode:
|
||||||
|
if (currentInfo.shot.shot.isExist) {
|
||||||
|
postDelayShot = ¤tInfo.shot;
|
||||||
|
if (PRE_RUN_DELAY_MODE) {
|
||||||
|
setPosFromShot(&postDelayShot->shot);
|
||||||
|
}
|
||||||
|
robotStateStart(delayTime);
|
||||||
|
} else {
|
||||||
|
print("Current Shot is NULL\n");
|
||||||
|
// TODO: sound_ERR(); ledFX_ERR();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ProgramMode:
|
||||||
|
if (currentInfo.program.program.header.shotCount) {
|
||||||
|
if (!loadShotFromProgram(¤tInfo.program)) {
|
||||||
|
print("loadShotFromProgram ERR\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
postDelayShot = ¤tInfo.program.currentShot;
|
||||||
|
if (PRE_RUN_DELAY_MODE) {
|
||||||
|
setPosFromShot(&postDelayShot->shot);
|
||||||
|
}
|
||||||
|
robotStateStart(delayTime);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
print("Current Program is NULL\n");
|
||||||
|
// TODO: sound_ERR(); ledFX_ERR();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MacroMode:
|
||||||
|
if (currentInfo.macro.macro.header.programmCount) {
|
||||||
|
if (!loadProgramFromMacro(¤tInfo.macro)) {
|
||||||
|
print("loadProgramFromMacro ERR\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!loadShotFromProgram(¤tInfo.macro.currentProgram)) {
|
||||||
|
print("loadShotFromProgram in macro ERR\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
postDelayShot = ¤tInfo.macro.currentProgram.currentShot;
|
||||||
|
if (PRE_RUN_DELAY_MODE) {
|
||||||
|
setPosFromShot(&postDelayShot->shot);
|
||||||
|
}
|
||||||
|
robotStateStart(delayTime);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
print("Current Macro is NULL\n");
|
||||||
|
// TODO: sound_ERR(); ledFX_ERR();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void stopShooting() {
|
||||||
|
robotStateStop();
|
||||||
|
setScrewkSpeed(0);
|
||||||
|
setRollersSpeed(100, 100);
|
||||||
|
setPosDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
void shotApply(CurrentShot *currentShot) {
|
||||||
|
Shot* shot = ¤tShot->shot;
|
||||||
|
setPos(shot->rotationAxial, shot->rotationHorizontal,
|
||||||
|
shot->rotationVertical);
|
||||||
|
setRollersSpeed(shot->speedRollerTop, shot->speedRollerBottom);
|
||||||
|
setScrewkSpeed(shot->speedScrew);
|
||||||
|
noBallTimeout = MIN(
|
||||||
|
calculatePeriod( shot->speedScrew) * NOBALL_TIMEOUT_MULTIPLIER,
|
||||||
|
30000);
|
||||||
|
noBallTimer = millis();
|
||||||
|
print("Global indx ");
|
||||||
|
printNumber(currentShot->indexGlobal);
|
||||||
|
print("\nisExist ");
|
||||||
|
printNumber(shot->isExist);
|
||||||
|
print("\ncountRepeatShot; ");
|
||||||
|
printNumber(shot->countRepeatShot);
|
||||||
|
print("\nspeedRollerTop; ");
|
||||||
|
printNumber(shot->speedRollerTop);
|
||||||
|
print("\nspeedRollerBottom; ");
|
||||||
|
printNumber(shot->speedRollerBottom);
|
||||||
|
print("\nspeedScrew; ");
|
||||||
|
printNumber(shot->speedScrew);
|
||||||
|
print("\nrotationAxial; ");
|
||||||
|
printNumber(shot->rotationAxial);
|
||||||
|
print("\nrotationHorizontal; ");
|
||||||
|
printNumber(shot->rotationHorizontal);
|
||||||
|
print("\nrotationVertical; ");
|
||||||
|
printNumber(shot->rotationVertical);
|
||||||
|
print("\nnoBallTimeout: ");
|
||||||
|
printNumber(noBallTimeout);
|
||||||
|
print("\n");
|
||||||
|
print("\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
void setPosSingle(ServoMap servo, uint8_t value) {
|
void setPosSingle(ServoMap servo, uint8_t value) {
|
||||||
ServoSetting *currentServo = &infoBlock.hwInfo.servos[servo];
|
ServoSetting *currentServo = &infoBlock.hwInfo.servos[servo];
|
||||||
uint8_t inv = currentServo->invert;
|
uint8_t inv = currentServo->invert;
|
||||||
|
@ -96,10 +96,11 @@ void UART3_SaveMacro(uint8_t *dataPtr, uint8_t len) {
|
|||||||
for (uint8_t i = 0; i < macro.header.programmCount; i++) {
|
for (uint8_t i = 0; i < macro.header.programmCount; i++) {
|
||||||
uint8_t pos = 2 + i * sizeof(MacroProgram);
|
uint8_t pos = 2 + i * sizeof(MacroProgram);
|
||||||
macro.programs[i].id = dataPtr[pos + 0];
|
macro.programs[i].id = dataPtr[pos + 0];
|
||||||
macro.programs[i].speedScrew = dataPtr[pos + 2];
|
macro.programs[i].speedScrew = dataPtr[pos + 1];
|
||||||
macro.programs[i].countRepeat = dataPtr[pos + 3];
|
macro.programs[i].countRepeat = dataPtr[pos + 2];
|
||||||
macro.programs[i].options = dataPtr[pos + 4];
|
macro.programs[i].options = dataPtr[pos + 3];
|
||||||
}
|
}
|
||||||
|
saveMacro(macroIndx, ¯o);
|
||||||
} else {
|
} else {
|
||||||
delMacro(macroIndx);
|
delMacro(macroIndx);
|
||||||
}
|
}
|
||||||
@ -107,21 +108,27 @@ void UART3_SaveMacro(uint8_t *dataPtr, uint8_t len) {
|
|||||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 100
|
||||||
void UART3_StartMacro(uint8_t *dataPtr, uint8_t len) {
|
void UART3_StartMacro(uint8_t *dataPtr, uint8_t len) {
|
||||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
const uint8_t MIN_PARAM_LENGTH = 1;
|
||||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
uint8_t macroIndx = dataPtr[1];
|
||||||
|
if(prepareMacro(macroIndx))
|
||||||
|
startShooting(infoBlock.hwInfo.timings.preRun);
|
||||||
|
|
||||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 101
|
||||||
void UART3_StartProgram(uint8_t *dataPtr, uint8_t len) {
|
void UART3_StartProgram(uint8_t *dataPtr, uint8_t len) {
|
||||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
const uint8_t MIN_PARAM_LENGTH = 1;
|
||||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint8_t progIndx = dataPtr[1];
|
uint8_t progIndx = dataPtr[1];
|
||||||
prepareProgramm(progIndx);
|
if(prepareProgramm(progIndx))
|
||||||
startShooting(infoBlock.hwInfo.timings.preRun);
|
startShooting(infoBlock.hwInfo.timings.preRun);
|
||||||
|
|
||||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||||
@ -134,7 +141,7 @@ void UART3_StartShot(uint8_t *dataPtr, uint8_t len) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
uint8_t shotIndx = dataPtr[1];
|
uint8_t shotIndx = dataPtr[1];
|
||||||
prepareShot(shotIndx);
|
if(prepareShot(shotIndx))
|
||||||
startShooting(infoBlock.hwInfo.timings.preRun);
|
startShooting(infoBlock.hwInfo.timings.preRun);
|
||||||
|
|
||||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||||
@ -470,13 +477,13 @@ void UART3_ReadStatistics(uint8_t *dataPtr, uint8_t len) {
|
|||||||
|
|
||||||
switch (currentInfo.mode) {
|
switch (currentInfo.mode) {
|
||||||
case ShotMode:
|
case ShotMode:
|
||||||
res.shot_number = isRun ? currentInfo.shot.index : 0xFF;
|
res.shot_number = isRun ? currentInfo.shot.indexGlobal : 0xFF;
|
||||||
break;
|
break;
|
||||||
case ProgramMode:
|
case ProgramMode:
|
||||||
res.program_number = isRun ? currentInfo.program.index : 0xFF;
|
res.program_number = isRun ? currentInfo.program.indexGlobal : 0xFF;
|
||||||
break;
|
break;
|
||||||
case MacroMode:
|
case MacroMode:
|
||||||
res.macro_number = isRun ? currentInfo.macro.index : 0xFF;
|
res.macro_number = isRun ? currentInfo.macro.indexGlobal : 0xFF;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -488,8 +495,8 @@ void UART3_ReadStatistics(uint8_t *dataPtr, uint8_t len) {
|
|||||||
res.total_program_done_HIGH = HIGHBIT(infoBlock.statInfo.shotsInProgram);
|
res.total_program_done_HIGH = HIGHBIT(infoBlock.statInfo.shotsInProgram);
|
||||||
res.total_program_done_LOW = LOWBIT(infoBlock.statInfo.shotsInProgram);
|
res.total_program_done_LOW = LOWBIT(infoBlock.statInfo.shotsInProgram);
|
||||||
|
|
||||||
res.total_macro_done_HIGH = HIGHBIT(infoBlock.statInfo.totalMacros);
|
res.total_macro_done_HIGH = HIGHBIT(infoBlock.statInfo.shotInMacro);
|
||||||
res.total_macro_done_LOW = LOWBIT(infoBlock.statInfo.totalMacros);
|
res.total_macro_done_LOW = LOWBIT(infoBlock.statInfo.shotInMacro);
|
||||||
|
|
||||||
SendResponse(dataPtr[0], 0, (uint8_t*) &res, sizeof(res));
|
SendResponse(dataPtr[0], 0, (uint8_t*) &res, sizeof(res));
|
||||||
}
|
}
|
||||||
|
133
Core/Src/main.c
133
Core/Src/main.c
@ -109,7 +109,8 @@ static void MX_IWDG_Init(void);
|
|||||||
* @brief The application entry point.
|
* @brief The application entry point.
|
||||||
* @retval int
|
* @retval int
|
||||||
*/
|
*/
|
||||||
int main(void) {
|
int main(void)
|
||||||
|
{
|
||||||
|
|
||||||
/* USER CODE BEGIN 1 */
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
@ -214,7 +215,8 @@ int main(void) {
|
|||||||
* @brief System Clock Configuration
|
* @brief System Clock Configuration
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void SystemClock_Config(void) {
|
void SystemClock_Config(void)
|
||||||
|
{
|
||||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||||
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
|
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
|
||||||
@ -222,8 +224,7 @@ void SystemClock_Config(void) {
|
|||||||
/** Initializes the RCC Oscillators according to the specified parameters
|
/** Initializes the RCC Oscillators according to the specified parameters
|
||||||
* in the RCC_OscInitTypeDef structure.
|
* in the RCC_OscInitTypeDef structure.
|
||||||
*/
|
*/
|
||||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE;
|
||||||
| RCC_OSCILLATORTYPE_HSE;
|
|
||||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||||
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
|
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
|
||||||
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||||
@ -231,7 +232,8 @@ void SystemClock_Config(void) {
|
|||||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||||
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
|
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
|
||||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
|
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||||
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,12 +246,14 @@ void SystemClock_Config(void) {
|
|||||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
|
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
|
||||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
||||||
|
|
||||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) {
|
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
|
||||||
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
|
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
|
||||||
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL;
|
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL;
|
||||||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) {
|
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
|
||||||
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -259,7 +263,8 @@ void SystemClock_Config(void) {
|
|||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void MX_I2C1_Init(void) {
|
static void MX_I2C1_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
/* USER CODE BEGIN I2C1_Init 0 */
|
/* USER CODE BEGIN I2C1_Init 0 */
|
||||||
|
|
||||||
@ -277,7 +282,8 @@ static void MX_I2C1_Init(void) {
|
|||||||
hi2c1.Init.OwnAddress2 = 0;
|
hi2c1.Init.OwnAddress2 = 0;
|
||||||
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
|
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
|
||||||
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
||||||
if (HAL_I2C_Init(&hi2c1) != HAL_OK) {
|
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
|
||||||
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
/* USER CODE BEGIN I2C1_Init 2 */
|
/* USER CODE BEGIN I2C1_Init 2 */
|
||||||
@ -291,7 +297,8 @@ static void MX_I2C1_Init(void) {
|
|||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void MX_IWDG_Init(void) {
|
static void MX_IWDG_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
/* USER CODE BEGIN IWDG_Init 0 */
|
/* USER CODE BEGIN IWDG_Init 0 */
|
||||||
|
|
||||||
@ -302,10 +309,11 @@ static void MX_IWDG_Init(void) {
|
|||||||
/* USER CODE END IWDG_Init 1 */
|
/* USER CODE END IWDG_Init 1 */
|
||||||
hiwdg.Instance = IWDG;
|
hiwdg.Instance = IWDG;
|
||||||
hiwdg.Init.Prescaler = IWDG_PRESCALER_64;
|
hiwdg.Init.Prescaler = IWDG_PRESCALER_64;
|
||||||
hiwdg.Init.Reload = 625 * 5;
|
hiwdg.Init.Reload = 625*3;
|
||||||
if (HAL_IWDG_Init(&hiwdg) != HAL_OK) {
|
// if (HAL_IWDG_Init(&hiwdg) != HAL_OK)
|
||||||
Error_Handler();
|
// {
|
||||||
}
|
// Error_Handler();
|
||||||
|
// }
|
||||||
/* USER CODE BEGIN IWDG_Init 2 */
|
/* USER CODE BEGIN IWDG_Init 2 */
|
||||||
|
|
||||||
/* USER CODE END IWDG_Init 2 */
|
/* USER CODE END IWDG_Init 2 */
|
||||||
@ -317,7 +325,8 @@ static void MX_IWDG_Init(void) {
|
|||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void MX_TIM1_Init(void) {
|
static void MX_TIM1_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
/* USER CODE BEGIN TIM1_Init 0 */
|
/* USER CODE BEGIN TIM1_Init 0 */
|
||||||
|
|
||||||
@ -338,20 +347,23 @@ static void MX_TIM1_Init(void) {
|
|||||||
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||||
htim1.Init.RepetitionCounter = 0;
|
htim1.Init.RepetitionCounter = 0;
|
||||||
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||||
if (HAL_TIM_Base_Init(&htim1) != HAL_OK) {
|
if (HAL_TIM_Base_Init(&htim1) != HAL_OK)
|
||||||
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
||||||
if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK) {
|
if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK)
|
||||||
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
if (HAL_TIM_PWM_Init(&htim1) != HAL_OK) {
|
if (HAL_TIM_PWM_Init(&htim1) != HAL_OK)
|
||||||
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||||
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig)
|
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
|
||||||
!= HAL_OK) {
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
||||||
@ -361,12 +373,12 @@ static void MX_TIM1_Init(void) {
|
|||||||
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
||||||
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
|
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
|
||||||
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
|
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
|
||||||
if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_1)
|
if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
|
||||||
!= HAL_OK) {
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_2)
|
if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
|
||||||
!= HAL_OK) {
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
|
sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
|
||||||
@ -376,8 +388,8 @@ static void MX_TIM1_Init(void) {
|
|||||||
sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
|
sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
|
||||||
sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;
|
sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;
|
||||||
sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
|
sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
|
||||||
if (HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTimeConfig)
|
if (HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTimeConfig) != HAL_OK)
|
||||||
!= HAL_OK) {
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
/* USER CODE BEGIN TIM1_Init 2 */
|
/* USER CODE BEGIN TIM1_Init 2 */
|
||||||
@ -392,7 +404,8 @@ static void MX_TIM1_Init(void) {
|
|||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void MX_TIM2_Init(void) {
|
static void MX_TIM2_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
/* USER CODE BEGIN TIM2_Init 0 */
|
/* USER CODE BEGIN TIM2_Init 0 */
|
||||||
|
|
||||||
@ -411,40 +424,43 @@ static void MX_TIM2_Init(void) {
|
|||||||
htim2.Init.Period = 4000;
|
htim2.Init.Period = 4000;
|
||||||
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||||
htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||||
if (HAL_TIM_Base_Init(&htim2) != HAL_OK) {
|
if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
|
||||||
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
||||||
if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK) {
|
if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK)
|
||||||
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
if (HAL_TIM_PWM_Init(&htim2) != HAL_OK) {
|
if (HAL_TIM_PWM_Init(&htim2) != HAL_OK)
|
||||||
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||||
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig)
|
if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
|
||||||
!= HAL_OK) {
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
||||||
sConfigOC.Pulse = 0;
|
sConfigOC.Pulse = 0;
|
||||||
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
||||||
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
||||||
if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_1)
|
if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
|
||||||
!= HAL_OK) {
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_2)
|
if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
|
||||||
!= HAL_OK) {
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_3)
|
if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_3) != HAL_OK)
|
||||||
!= HAL_OK) {
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_4)
|
if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_4) != HAL_OK)
|
||||||
!= HAL_OK) {
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
/* USER CODE BEGIN TIM2_Init 2 */
|
/* USER CODE BEGIN TIM2_Init 2 */
|
||||||
@ -459,7 +475,8 @@ static void MX_TIM2_Init(void) {
|
|||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void MX_TIM3_Init(void) {
|
static void MX_TIM3_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
/* USER CODE BEGIN TIM3_Init 0 */
|
/* USER CODE BEGIN TIM3_Init 0 */
|
||||||
__HAL_RCC_TIM3_CLK_ENABLE();
|
__HAL_RCC_TIM3_CLK_ENABLE();
|
||||||
@ -478,30 +495,35 @@ static void MX_TIM3_Init(void) {
|
|||||||
htim3.Init.Period = 65000;
|
htim3.Init.Period = 65000;
|
||||||
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||||
htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||||
if (HAL_TIM_Base_Init(&htim3) != HAL_OK) {
|
if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
|
||||||
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
||||||
if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK) {
|
if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK)
|
||||||
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
if (HAL_TIM_IC_Init(&htim3) != HAL_OK) {
|
if (HAL_TIM_IC_Init(&htim3) != HAL_OK)
|
||||||
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||||
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig)
|
if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
|
||||||
!= HAL_OK) {
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
sConfigIC.ICPolarity = TIM_INPUTCHANNELPOLARITY_RISING;
|
sConfigIC.ICPolarity = TIM_INPUTCHANNELPOLARITY_RISING;
|
||||||
sConfigIC.ICSelection = TIM_ICSELECTION_DIRECTTI;
|
sConfigIC.ICSelection = TIM_ICSELECTION_DIRECTTI;
|
||||||
sConfigIC.ICPrescaler = TIM_ICPSC_DIV1;
|
sConfigIC.ICPrescaler = TIM_ICPSC_DIV1;
|
||||||
sConfigIC.ICFilter = 0;
|
sConfigIC.ICFilter = 0;
|
||||||
if (HAL_TIM_IC_ConfigChannel(&htim3, &sConfigIC, TIM_CHANNEL_1) != HAL_OK) {
|
if (HAL_TIM_IC_ConfigChannel(&htim3, &sConfigIC, TIM_CHANNEL_1) != HAL_OK)
|
||||||
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
if (HAL_TIM_IC_ConfigChannel(&htim3, &sConfigIC, TIM_CHANNEL_2) != HAL_OK) {
|
if (HAL_TIM_IC_ConfigChannel(&htim3, &sConfigIC, TIM_CHANNEL_2) != HAL_OK)
|
||||||
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
/* USER CODE BEGIN TIM3_Init 2 */
|
/* USER CODE BEGIN TIM3_Init 2 */
|
||||||
@ -515,7 +537,8 @@ static void MX_TIM3_Init(void) {
|
|||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void MX_USART3_UART_Init(void) {
|
static void MX_USART3_UART_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
/* USER CODE BEGIN USART3_Init 0 */
|
/* USER CODE BEGIN USART3_Init 0 */
|
||||||
|
|
||||||
@ -532,7 +555,8 @@ static void MX_USART3_UART_Init(void) {
|
|||||||
huart3.Init.Mode = UART_MODE_TX_RX;
|
huart3.Init.Mode = UART_MODE_TX_RX;
|
||||||
huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||||
huart3.Init.OverSampling = UART_OVERSAMPLING_16;
|
huart3.Init.OverSampling = UART_OVERSAMPLING_16;
|
||||||
if (HAL_UART_Init(&huart3) != HAL_OK) {
|
if (HAL_UART_Init(&huart3) != HAL_OK)
|
||||||
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
/* USER CODE BEGIN USART3_Init 2 */
|
/* USER CODE BEGIN USART3_Init 2 */
|
||||||
@ -547,7 +571,8 @@ static void MX_USART3_UART_Init(void) {
|
|||||||
/**
|
/**
|
||||||
* Enable DMA controller clock
|
* Enable DMA controller clock
|
||||||
*/
|
*/
|
||||||
static void MX_DMA_Init(void) {
|
static void MX_DMA_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
/* DMA controller clock enable */
|
/* DMA controller clock enable */
|
||||||
__HAL_RCC_DMA1_CLK_ENABLE();
|
__HAL_RCC_DMA1_CLK_ENABLE();
|
||||||
@ -564,7 +589,8 @@ static void MX_DMA_Init(void) {
|
|||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void MX_GPIO_Init(void) {
|
static void MX_GPIO_Init(void)
|
||||||
|
{
|
||||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
/* USER CODE BEGIN MX_GPIO_Init_1 */
|
/* USER CODE BEGIN MX_GPIO_Init_1 */
|
||||||
/* USER CODE END MX_GPIO_Init_1 */
|
/* USER CODE END MX_GPIO_Init_1 */
|
||||||
@ -626,7 +652,8 @@ static void MX_GPIO_Init(void) {
|
|||||||
* @brief This function is executed in case of error occurrence.
|
* @brief This function is executed in case of error occurrence.
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void Error_Handler(void) {
|
void Error_Handler(void)
|
||||||
|
{
|
||||||
/* USER CODE BEGIN Error_Handler_Debug */
|
/* USER CODE BEGIN Error_Handler_Debug */
|
||||||
/* User can add his own implementation to report the HAL error return state */
|
/* User can add his own implementation to report the HAL error return state */
|
||||||
__disable_irq();
|
__disable_irq();
|
||||||
|
@ -367,7 +367,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
|
|||||||
__HAL_LINKDMA(huart,hdmarx,hdma_usart3_rx);
|
__HAL_LINKDMA(huart,hdmarx,hdma_usart3_rx);
|
||||||
|
|
||||||
/* USART3 interrupt Init */
|
/* USART3 interrupt Init */
|
||||||
HAL_NVIC_SetPriority(USART3_IRQn, 3, 0);
|
HAL_NVIC_SetPriority(USART3_IRQn, 0, 0);
|
||||||
HAL_NVIC_EnableIRQ(USART3_IRQn);
|
HAL_NVIC_EnableIRQ(USART3_IRQn);
|
||||||
/* USER CODE BEGIN USART3_MspInit 1 */
|
/* USER CODE BEGIN USART3_MspInit 1 */
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ File.Version=6
|
|||||||
GPIO.groupedBy=Group By Peripherals
|
GPIO.groupedBy=Group By Peripherals
|
||||||
IWDG.IPParameters=Prescaler,Reload
|
IWDG.IPParameters=Prescaler,Reload
|
||||||
IWDG.Prescaler=IWDG_PRESCALER_64
|
IWDG.Prescaler=IWDG_PRESCALER_64
|
||||||
IWDG.Reload=625*5
|
IWDG.Reload=625*3
|
||||||
KeepUserPlacement=false
|
KeepUserPlacement=false
|
||||||
Mcu.CPN=STM32F103C8T6
|
Mcu.CPN=STM32F103C8T6
|
||||||
Mcu.Family=STM32F1
|
Mcu.Family=STM32F1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user