shibosoftwaredev/f1c100s-linux-nema17-stepper-controller

A four-layer NEMA 17 motor-controller PCB combining an Allwinner F1C100S Linux computer, USB‑PD/buck power system, W5500 Ethernet, STM32 real-time motion control, DRV8825 stepper driver, protection/temperature/current telemetry, USB interfaces, and local LED/buzzer diagnostics.

Version
0.4.56
License
unset
Stars
0

firmware/stm32/motion.h

#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

enum { POWER_FAULT=1, DRIVER_FAULT=2, TEMP_FAULT=4, SENSOR_FAULT=8,
       PROTOCOL_FAULT=16, HEARTBEAT_FAULT=32, CURRENT_LIMIT_FAULT=64 };
typedef struct {
  bool pd_good, driver_ok, sensor_ok;
  uint32_t pd_mv;
  int32_t temperature_mc;
} Inputs;
typedef struct {
  Inputs inputs;
  uint32_t now, last_heartbeat, last_ramp, armed_at, remaining, rate;
  uint8_t faults;
  uint16_t limit_ma;
  bool limit_ready, limit_io_ok;
  bool armed, step_high, reverse, stopping, heartbeat_seen;
} Motion;
typedef struct { uint8_t command; uint16_t length; const uint8_t *payload; } Request;

void motion_init(Motion *);
void motion_sample(Motion *, const Inputs *);
void motion_tick(Motion *, uint32_t now);
void motion_fault(Motion *, uint8_t reason);
uint8_t motion_command(Motion *, const Request *);
void motion_step_tick(Motion *);
uint16_t motion_crc16(const uint8_t *, size_t length);