This repository has been archived on 2026-06-17. You can view files and clone it, but cannot push or open issues or pull requests.
FireWatchTower_2axis/firmware/src/motor/MotorConfig.h

32 lines
1.5 KiB
C

#ifndef FTW_MOTOR_CONFIG_H
#define FTW_MOTOR_CONFIG_H
#include <stdint.h>
// Axis IDs match the TMC5160 chip-select assignments in SPI_HAL.cpp.
// They are also used as array indices where applicable, so keep them 0-based.
#define AXIS_YAW 0x00
#define AXIS_PITCH 0x01
#define AXIS_COUNT 2
// EEPROM layout for heading calibration.
// Defined here so save (case 'h') and load (case 'y') in CommandParser always
// agree on offsets — nothing should hardcode byte addresses independently.
#define EEPROM_ADDR_HDG_FLOAT 0 // float: calibrated heading value
#define EEPROM_ADDR_HDG_DIST (EEPROM_ADDR_HDG_FLOAT + sizeof(float)) // int32_t: encoder distance from left limit
// Axis lifecycle states.
// The state machine progresses: BOOT → RESET → ENC_INIT → INITIALIZED → AUTO/MANUAL
// ERROR is a terminal state; re-init via the 'r' command resets back to RESET.
typedef enum {
GIMBAL_STATUS_ERROR = -2, // homing failed or hardware fault
GIMBAL_STATUS_BOOT = -1, // initial power-on state, hardware not yet configured
GIMBAL_STATUS_RESET = 0, // registers written, motor enabled, ready to home
GIMBAL_STATUS_ENC_INIT = 1, // homing sequence in progress
GIMBAL_STATUS_INITIALIZED = 2, // homing complete, endstop limits known
GIMBAL_STATUS_AUTO = 3, // stepping through positions automatically
GIMBAL_STATUS_MANUAL = 4 // responding to direct move commands
} gimbal_status;
#endif