| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- /*
- * 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: '<S178>/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]
- */
|