123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- #ifndef TMC2130_H
- #define TMC2130_H
- extern uint8_t tmc2130_mode;
- extern uint8_t tmc2130_current_h[4];
- extern uint8_t tmc2130_current_r[4];
- extern uint8_t tmc2130_mres[4];
- extern uint8_t tmc2130_sg_thr[4];
- extern bool tmc2130_sg_stop_on_crash;
- extern uint8_t tmc2130_sg_crash;
- extern uint8_t tmc2130_sg_meassure;
- extern uint16_t tmc2130_sg_meassure_cnt;
- extern uint32_t tmc2130_sg_meassure_val;
- #define TMC2130_MODE_NORMAL 0
- #define TMC2130_MODE_SILENT 1
- #define TMC2130_WAVE_FAC200_MIN 180
- #define TMC2130_WAVE_FAC200_MAX 250
- #define TMC2130_WAVE_FAC200_STP 1
- extern uint8_t tmc2130_home_enabled;
- extern uint8_t tmc2130_home_origin[2];
- extern uint8_t tmc2130_home_bsteps[2];
- extern uint8_t tmc2130_home_fsteps[2];
- extern uint8_t tmc2130_wave_fac[4];
- extern void tmc2130_init();
- extern void tmc2130_st_isr(uint8_t last_step_mask);
- extern bool tmc2130_update_sg();
- extern void tmc2130_check_overtemp();
- extern void tmc2130_home_enter(uint8_t axes_mask);
- extern void tmc2130_home_exit();
- extern void tmc2130_sg_meassure_start(uint8_t axis);
- extern uint16_t tmc2130_sg_meassure_stop();
- extern void tmc2130_set_current_h(uint8_t axis, uint8_t current);
- extern void tmc2130_set_current_r(uint8_t axis, uint8_t current);
- extern void tmc2130_print_currents();
- extern void tmc2130_set_pwm_ampl(uint8_t axis, uint8_t pwm_ampl);
- extern void tmc2130_set_pwm_grad(uint8_t axis, uint8_t pwm_ampl);
- extern uint16_t tmc2130_rd_MSCNT(uint8_t axis);
- extern uint32_t tmc2130_rd_MSCURACT(uint8_t axis);
- extern uint8_t tmc2130_usteps2mres(uint16_t usteps);
- #define tmc2130_mres2usteps(mres) ((uint16_t)256 >> mres)
- extern bool tmc2130_wait_standstill_xy(int timeout);
- extern void tmc2130_eeprom_load_config();
- extern void tmc2130_eeprom_save_config();
- #pragma pack(push)
- #pragma pack(1)
- struct
- {
- uint8_t mres:5;
- uint8_t reserved_0_0:2;
- uint8_t intpol:1;
- uint8_t pwm_ampl:8;
- uint8_t pwm_grad:4;
- uint8_t pwm_freq:2;
- uint8_t reserved_2_0:2;
- uint16_t tcoolthrs:16;
- int8_t sg_thrs:8;
- int8_t current_h:6;
- uint8_t reserved_6_0:2;
- int8_t current_r:6;
- uint8_t reserved_7_0:2;
- int8_t home_sg_thrs:8;
- int8_t home_current:6;
- uint8_t reserved_9_0:2;
- int8_t home_dtcoolthrs:8;
- int8_t dtcoolthrs_low:8;
- int8_t dtcoolthrs_high:8;
- int8_t sg_thrs_low:8;
- int8_t sg_thrs_high:8;
- } tmc2130_axis_config;
- #pragma pack(pop)
- extern uint16_t tmc2130_get_res(uint8_t axis);
- extern void tmc2130_set_res(uint8_t axis, uint16_t res);
- extern uint8_t tmc2130_get_pwr(uint8_t axis);
- extern void tmc2130_set_pwr(uint8_t axis, uint8_t pwr);
- extern uint8_t tmc2130_get_inv(uint8_t axis);
- extern uint8_t tmc2130_get_dir(uint8_t axis);
- extern void tmc2130_set_dir(uint8_t axis, uint8_t dir);
- extern void tmc2130_do_step(uint8_t axis);
- extern void tmc2130_do_steps(uint8_t axis, uint16_t steps, uint8_t dir, uint16_t delay_us);
- extern void tmc2130_goto_step(uint8_t axis, uint8_t step, uint8_t dir, uint16_t delay_us, uint16_t microstep_resolution);
- extern void tmc2130_get_wave(uint8_t axis, uint8_t* data, FILE* stream);
- extern void tmc2130_set_wave(uint8_t axis, uint8_t amp, uint8_t fac200);
- extern bool tmc2130_home_calibrate(uint8_t axis);
- #endif
|