2025-05-16 21:06:31 +03:00
|
|
|
#pragma once
|
|
|
|
#include "Arduino.h"
|
|
|
|
#include <AS5045.h>
|
|
|
|
#include <DRV8313.h>
|
|
|
|
#include <SimpleFOC.h>
|
|
|
|
#include <STM32_CAN.h>
|
2025-05-27 16:33:02 +03:00
|
|
|
#include "flash.h"
|
2025-05-16 21:06:31 +03:00
|
|
|
|
|
|
|
extern STM32_CAN Can;
|
|
|
|
extern SPIClass spi;
|
|
|
|
extern MagneticSensorAS5045 encoder;
|
|
|
|
extern BLDCMotor motor;
|
|
|
|
extern DRV8313Driver driver;
|
|
|
|
extern LowsideCurrentSense current_sense;
|
|
|
|
extern Commander command;
|
|
|
|
|
|
|
|
struct MotorControlInputs {
|
|
|
|
float target_angle = 0.0;
|
|
|
|
float target_velocity = 0.0;
|
|
|
|
bool motor_enabled = false;
|
|
|
|
bool foc_state = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern MotorControlInputs motor_control_inputs;
|
|
|
|
|
|
|
|
void doMotor(char *cmd);
|
|
|
|
void setup_foc(MagneticSensorAS5045 *encoder, BLDCMotor *motor,
|
|
|
|
DRV8313Driver *driver, LowsideCurrentSense *current_sense,
|
2025-05-30 17:14:30 +03:00
|
|
|
FLASH_RECORD* pid_data);
|
2025-05-16 21:06:31 +03:00
|
|
|
|
2025-05-30 17:14:30 +03:00
|
|
|
void foc_step(BLDCMotor *motor);
|