/* * File: Shunt_Three_Sample_Point.c * * Code generated for Simulink model 'PMSM_Controller'. * * Model version : 1.885 * Simulink Coder version : 9.4 (R2020b) 29-Jul-2020 * C/C++ source code generated on : Sat Jan 8 15:44:11 2022 * * Target selection: ert.tlc * Embedded hardware selection: ARM Compatible->ARM Cortex-M * Code generation objectives: * 1. Execution efficiency * 2. RAM efficiency * Validation result: Not run */ #include "Shunt_Three_Sample_Point.h" /* Include model header file for global data */ #include "PMSM_Controller.h" #include "PMSM_Controller_private.h" /* Output and update for atomic system: '/Shunt_Three_Sample_Point' */ void Shunt_Three_Sample_Point(uint16_T rtu_low, uint16_T rtu_midle, uint8_T rtu_i_sector, uint16_T rtu_half_pwm_count, uint16_T rtu_t_adc, uint16_T rtu_t_dead, uint16_T rtu_t_samp_before, uint16_T *rty_o_samp_p1, uint16_T *rty_o_samp_p2, uint8_T *rty_o_sector) { uint32_T qY; uint32_T qY_0; uint32_T tmp; uint32_T tmp_0; uint16_T qY_1; *rty_o_sector = rtu_i_sector; tmp_0 = rtu_half_pwm_count + 1U; if (rtu_half_pwm_count + 1U > 65535U) { tmp_0 = 65535U; } *rty_o_samp_p1 = (uint16_T)tmp_0; tmp_0 = rtu_half_pwm_count + 1U; if (rtu_half_pwm_count + 1U > 65535U) { tmp_0 = 65535U; } *rty_o_samp_p2 = (uint16_T)tmp_0; tmp_0 = (uint32_T)rtu_t_adc + rtu_t_dead; tmp = tmp_0; if (tmp_0 > 65535U) { tmp = 65535U; } tmp += rtu_t_samp_before; if (tmp > 65535U) { tmp = 65535U; } qY_0 = (uint32_T)rtu_half_pwm_count - /*MW:OvSatOk*/ rtu_low; if (qY_0 > rtu_half_pwm_count) { qY_0 = 0U; } qY = (uint32_T)rtu_half_pwm_count - /*MW:OvSatOk*/ rtu_midle; if (qY > rtu_half_pwm_count) { qY = 0U; } if ((uint16_T)qY_0 > 32767) { qY_1 = MAX_uint16_T; } else { qY_1 = (uint16_T)((uint16_T)qY_0 << 1); } if (qY_1 >= (uint16_T)tmp) { if (tmp_0 > 65535U) { tmp_0 = 65535U; } if ((uint16_T)qY_0 >= (int32_T)tmp_0) { qY_0 = rtu_half_pwm_count - /*MW:OvSatOk*/ 1U; if (rtu_half_pwm_count - 1U > rtu_half_pwm_count) { qY_0 = 0U; } *rty_o_samp_p1 = (uint16_T)qY_0; *rty_o_sector = 1U; } else { tmp_0 = (uint32_T)rtu_low + rtu_t_samp_before; if (tmp_0 > 65535U) { tmp_0 = 65535U; } if ((uint16_T)tmp_0 >= rtu_half_pwm_count) { if (rtu_half_pwm_count > 32767) { qY_1 = MAX_uint16_T; } else { qY_1 = (uint16_T)(rtu_half_pwm_count << 1); } qY_0 = (uint32_T)qY_1 - /*MW:OvSatOk*/ (uint16_T)tmp_0; if (qY_0 > qY_1) { qY_0 = 0U; } qY = qY_0 - /*MW:OvSatOk*/ 1U; if (qY_0 - 1U > qY_0) { qY = 0U; } *rty_o_samp_p2 = (uint16_T)qY; } else { *rty_o_samp_p1 = (uint16_T)tmp_0; } } } else { if ((uint16_T)qY > 32767) { qY_1 = MAX_uint16_T; } else { qY_1 = (uint16_T)((uint16_T)qY << 1); } if (qY_1 >= (uint16_T)tmp) { if (tmp_0 > 65535U) { tmp_0 = 65535U; } if ((uint16_T)qY >= (int32_T)tmp_0) { qY_0 = rtu_half_pwm_count - /*MW:OvSatOk*/ 1U; if (rtu_half_pwm_count - 1U > rtu_half_pwm_count) { qY_0 = 0U; } *rty_o_samp_p1 = (uint16_T)qY_0; } else { tmp_0 = (uint32_T)rtu_midle + rtu_t_samp_before; if (tmp_0 > 65535U) { tmp_0 = 65535U; } if ((uint16_T)tmp_0 >= rtu_half_pwm_count) { if (rtu_half_pwm_count > 32767) { qY_1 = MAX_uint16_T; } else { qY_1 = (uint16_T)(rtu_half_pwm_count << 1); } qY_0 = (uint32_T)qY_1 - /*MW:OvSatOk*/ (uint16_T)tmp_0; if (qY_0 > qY_1) { qY_0 = 0U; } qY = qY_0 - /*MW:OvSatOk*/ 1U; if (qY_0 - 1U > qY_0) { qY = 0U; } *rty_o_samp_p2 = (uint16_T)qY; } else { *rty_o_samp_p1 = (uint16_T)tmp_0; } } } } } /* * File trailer for generated code. * * [EOF] */