/*******************************************************************/
/* PXMCC - PXMC coprocessor support and communication */
-void pxmcc_pxmc_ptofs2mcc(pxmc_state_t *mcs)
+void pxmcc_pxmc_ptofs2mcc(pxmc_state_t *mcs, int enable_update)
{
volatile pxmcc_axis_data_t *mcc_axis = pxmc_rocon_mcs2pxmcc(mcs);
int inp_chan=mcs->pxms_inp_info;
uint32_t irc;
if (mcc_axis != NULL) {
+ if (enable_update >= 0)
+ mcc_axis->ptirc = 0xffffffff;
ptofs = mcs->pxms_ptofs - pxmc_rocon_irc_offset[inp_chan];
irc = fpga_irc[inp_chan]->count;
ptofs = (int16_t)(ptofs - irc) + irc;
mcc_axis->ptofs = ptofs;
+ if (enable_update > 0) {
+ mcc_axis->ptirc = mcs->pxms_ptirc;
+ }
}
}
if (!(mcs->pxms_flg & PXMS_PTI_m) || (mcs->pxms_flg & PXMS_PRA_m)) {
int set_ptofs_fl = 0;
+ int ptofs_enable_update = 0;
if (((hal_pos != mcs->pxms_hal) && (mcs->pxms_hal != 0x40)) && 1) {
short ptindx_prev = (mcs->pxms_hal * ptirc + divisor / 2) / divisor;;
}
set_ptofs_fl = 1;
+ ptofs_enable_update = 1;
pxmc_set_flag(mcs, PXMS_PTI_b);
pxmc_clear_flag(mcs, PXMS_PRA_b);
mcs->pxms_ptindx = ptindx;
mcs->pxms_ptofs = (mcs->pxms_ap >> PXMC_SUBDIV(mcs)) + mcs->pxms_ptshift - ptindx;
- pxmcc_pxmc_ptofs2mcc(mcs);
+ pxmcc_pxmc_ptofs2mcc(mcs, ptofs_enable_update);
}
} else {
/* if phase table position to mask is know do fine phase table alignment */
if (res < 0) {
pxmc_set_errno(mcs, PXMS_E_I2PT_TOOBIG);
} else if (res) {
- pxmcc_pxmc_ptofs2mcc(mcs);
+ pxmcc_pxmc_ptofs2mcc(mcs, 1);
pxmc_set_flag(mcs, PXMS_PTI_b);
pxmc_set_flag(mcs, PXMS_PHA_b);
}
int
pxmc_pxmcc_pwm2ph_out(pxmc_state_t *mcs)
{
+ if(!(mcs->pxms_flg&PXMS_PTI_m) || !(mcs->pxms_flg&PXMS_PHA_m) ||
+ (mcs->pxms_flg&PXMS_PRA_m)) {
+
+ {
+ /* Wait for index mark to align phases */
+ int res;
+ res = pxmc_inp_rocon_ptofs_from_index_poll(mcs, 0);
+ if (res < 0) {
+ pxmc_set_errno(mcs, PXMS_E_I2PT_TOOBIG);
+ } else if (res) {
+ pxmcc_pxmc_ptofs2mcc(mcs, 1);
+ pxmc_set_flag(mcs, PXMS_PTI_b);
+ pxmc_set_flag(mcs, PXMS_PHA_b);
+ } else {
+ pxmcc_pxmc_ptofs2mcc(mcs, 0);
+ }
+ }
+ }
+
{
int ene, pwm_d, pwm_q;
if (mcc_axis == NULL)
return -1;
+ if (mcc_data->common.fwversion != PXMCC_FWVERSION)
+ return -1;
+
mcc_axis->ccflg = 0;
mcc_axis->mode = PXMCC_MODE_IDLE;
ull = (1ULL << 32) * mcs->pxms_ptper;
ptreci = (ull + ptirc / 2) / ptirc;
- mcc_axis->ptirc = ptirc;
mcc_axis->ptreci = ptreci;
- pxmcc_pxmc_ptofs2mcc(mcs);
+ pxmcc_pxmc_ptofs2mcc(mcs, 0);
switch (mode) {
case PXMCC_MODE_IDLE:
mcc_axis->ccflg = 0;
mcc_axis->pwm_dq = 0;
+ pxmcc_pxmc_ptofs2mcc(mcs, 1);
+
return 0;
}
return PXMC_AXIS_MODE_BLDC;
if (mcs->pxms_do_out == pxmc_pxmcc_pwm3ph_out)
return PXMC_AXIS_MODE_BLDC_PXMCC;
+ if (mcs->pxms_do_out == pxmc_pxmcc_pwm2ph_out)
+ return PXMC_AXIS_MODE_STEPPER_WITH_IRC_PXMCC;
return -1;
}