--------------------------------------------------------------------------------------------------------------------------------------------------
/* Structure initialization by default values, in order to avoid blank records */
dSPIN_Regs_Struct_Reset(&dSPIN_RegsStruct);
/* Acceleration rate settings to 466 steps/s2, range 14.55 to 59590 steps/s2 */
dSPIN_RegsStruct.ACC = AccDec_Steps_to_Par(30);
/* Deceleration rate settings to 466 steps/s2, range 14.55 to 59590 steps/s2 */
dSPIN_RegsStruct.DEC = AccDec_Steps_to_Par(466);
/* Maximum speed settings to 488 steps/s, range 15.25 to 15610 steps/s */
dSPIN_RegsStruct.MAX_SPEED = MaxSpd_Steps_to_Par(10000);
/* Minimum speed settings to 0 steps/s, range 0 to 976.3 steps/s */
dSPIN_RegsStruct.MIN_SPEED = MinSpd_Steps_to_Par(0);
/* Full step speed settings 252 steps/s, range 7.63 to 15625 steps/s */
dSPIN_RegsStruct.FS_SPD = FSSpd_Steps_to_Par(252);
/* Hold duty cycle (torque) settings to 10%, range 0 to 99.6% */
dSPIN_RegsStruct.KVAL_HOLD = Kval_Perc_to_Par(50);
/* Run duty cycle (torque) settings to 10%, range 0 to 99.6% */
dSPIN_RegsStruct.KVAL_RUN = Kval_Perc_to_Par(99);
/* Acceleration duty cycle (torque) settings to 10%, range 0 to 99.6% */
dSPIN_RegsStruct.KVAL_ACC = Kval_Perc_to_Par(30);
/* Deceleration duty cycle (torque) settings to 10%, range 0 to 99.6% */
dSPIN_RegsStruct.KVAL_DEC = Kval_Perc_to_Par(10);
/* Intersect speed settings for BEMF compensation to 200 steps/s, range 0 to 3906 steps/s */
dSPIN_RegsStruct.INT_SPD = IntSpd_Steps_to_Par(200);
/* BEMF start slope settings for BEMF compensation to 0.038% step/s, range 0 to 0.4% s/step */
dSPIN_RegsStruct.ST_SLP = BEMF_Slope_Perc_to_Par(0.3);
/* BEMF final acc slope settings for BEMF compensation to 0.063% step/s, range 0 to 0.4% s/step */
dSPIN_RegsStruct.FN_SLP_ACC = BEMF_Slope_Perc_to_Par(0.1);
/* BEMF final dec slope settings for BEMF compensation to 0.063% step/s, range 0 to 0.4% s/step */
dSPIN_RegsStruct.FN_SLP_DEC = BEMF_Slope_Perc_to_Par(0.063);
/* Thermal compensation param settings to 1, range 1 to 1.46875 */
dSPIN_RegsStruct.K_THERM = KTherm_to_Par(1.3);
/* Overcurrent threshold settings to 1500mA */
dSPIN_RegsStruct.OCD_TH = dSPIN_OCD_TH_6000mA;
/* Stall threshold settings to 1000mA, range 31.25 to 4000mA */
dSPIN_RegsStruct.STALL_TH = StallTh_to_Par(4000);
/* Step mode settings to 128 microsteps */
dSPIN_RegsStruct.STEP_MODE = dSPIN_STEP_SEL_1_8;
/* Alarm settings - all alarms enabled */
dSPIN_RegsStruct.ALARM_EN = dSPIN_ALARM_EN_OVERCURRENT | dSPIN_ALARM_EN_THERMAL_SHUTDOWN
| dSPIN_ALARM_EN_THERMAL_WARNING | dSPIN_ALARM_EN_UNDER_VOLTAGE | dSPIN_ALARM_EN_STALL_DET_A
| dSPIN_ALARM_EN_STALL_DET_B | dSPIN_ALARM_EN_SW_TURN_ON | dSPIN_ALARM_EN_WRONG_NPERF_CMD;
/* Internal oscillator, 2MHz OSCOUT clock, supply voltage compensation disabled, *
* overcurrent shutdown enabled, slew-rate = 290 V/us, PWM frequency = 15.6kHz */
dSPIN_RegsStruct.CONFIG = dSPIN_CONFIG_INT_16MHZ_OSCOUT_2MHZ | dSPIN_CONFIG_SW_HARD_STOP
| dSPIN_CONFIG_VS_COMP_DISABLE | dSPIN_CONFIG_OC_SD_ENABLE | dSPIN_CONFIG_SR_260V_us
| dSPIN_CONFIG_PWM_DIV_2 | dSPIN_CONFIG_PWM_MUL_1;
/* Program all dSPIN registers */
dSPIN_Registers_Set(&dSPIN_RegsStruct);