⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bluetooth_lib2_sfun_c5.c

📁 在matlab的simulink中实现的无线蓝牙模块
💻 C
📖 第 1 页 / 共 2 页
字号:
          _SFD_ST_SUBSTATE_COUNT(2,0);
          _SFD_ST_SUBSTATE_COUNT(4,0);
          _SFD_ST_SUBSTATE_COUNT(0,0);
          _SFD_ST_SUBSTATE_COUNT(1,0);
        }
        _SFD_CV_INIT_CHART(3,1,0,0);
        {
          _SFD_CV_INIT_STATE(3,2,1,0,0,0,NULL,NULL);
        }
        {
          _SFD_CV_INIT_STATE(2,0,0,0,0,0,NULL,NULL);
        }
        {
          _SFD_CV_INIT_STATE(4,0,0,0,0,0,NULL,NULL);
        }
        {
          _SFD_CV_INIT_STATE(0,0,0,0,0,0,NULL,NULL);
        }
        {
          _SFD_CV_INIT_STATE(1,0,0,0,0,0,NULL,NULL);
        }

        {
          static unsigned int sStartGuardMap[] = {1};
          static unsigned int sEndGuardMap[] = {15};
          static int sPostFixPredicateTree[] = {0};
          _SFD_CV_INIT_TRANS(4,1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),1,&(sPostFixPredicateTree[0]));
        }
        {
          static unsigned int sStartGuardMap[] = {1};
          static unsigned int sEndGuardMap[] = {15};
          static int sPostFixPredicateTree[] = {0};
          _SFD_CV_INIT_TRANS(0,1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),1,&(sPostFixPredicateTree[0]));
        }
        _SFD_CV_INIT_TRANS(2,0,NULL,NULL,0,NULL);

        _SFD_CV_INIT_TRANS(1,0,NULL,NULL,0,NULL);

        _SFD_CV_INIT_TRANS(5,0,NULL,NULL,0,NULL);

        {
          static unsigned int sStartGuardMap[] = {1};
          static unsigned int sEndGuardMap[] = {8};
          static int sPostFixPredicateTree[] = {0};
          _SFD_CV_INIT_TRANS(6,1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),1,&(sPostFixPredicateTree[0]));
        }
        {
          static unsigned int sStartGuardMap[] = {1};
          static unsigned int sEndGuardMap[] = {8};
          static int sPostFixPredicateTree[] = {0};
          _SFD_CV_INIT_TRANS(3,1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),1,&(sPostFixPredicateTree[0]));
        }
        _SFD_STATE_COV_WTS(3,2,1,1);
        if(chartAlreadyPresent==0)
        {
          static unsigned int sStartEntryMap[] = {0,12};
          static unsigned int sEndEntryMap[] = {0,27};
          static unsigned int sStartDuringMap[] = {0};
          static unsigned int sEndDuringMap[] = {0};
          static unsigned int sStartExitMap[] = {0};
          static unsigned int sEndExitMap[] = {0};

          _SFD_STATE_COV_MAPS(3,
           2,&(sStartEntryMap[0]),&(sEndEntryMap[0]),
           1,&(sStartDuringMap[0]),&(sEndDuringMap[0]),
           1,&(sStartExitMap[0]),&(sEndExitMap[0]));
        }
        _SFD_STATE_COV_WTS(2,2,2,1);
        if(chartAlreadyPresent==0)
        {
          static unsigned int sStartEntryMap[] = {0,19};
          static unsigned int sEndEntryMap[] = {0,36};
          static unsigned int sStartDuringMap[] = {0,40};
          static unsigned int sEndDuringMap[] = {0,57};
          static unsigned int sStartExitMap[] = {0};
          static unsigned int sEndExitMap[] = {0};

          _SFD_STATE_COV_MAPS(2,
           2,&(sStartEntryMap[0]),&(sEndEntryMap[0]),
           2,&(sStartDuringMap[0]),&(sEndDuringMap[0]),
           1,&(sStartExitMap[0]),&(sEndExitMap[0]));
        }
        _SFD_STATE_COV_WTS(4,2,2,1);
        if(chartAlreadyPresent==0)
        {
          static unsigned int sStartEntryMap[] = {0,20};
          static unsigned int sEndEntryMap[] = {0,37};
          static unsigned int sStartDuringMap[] = {0,41};
          static unsigned int sEndDuringMap[] = {0,58};
          static unsigned int sStartExitMap[] = {0};
          static unsigned int sEndExitMap[] = {0};

          _SFD_STATE_COV_MAPS(4,
           2,&(sStartEntryMap[0]),&(sEndEntryMap[0]),
           2,&(sStartDuringMap[0]),&(sEndDuringMap[0]),
           1,&(sStartExitMap[0]),&(sEndExitMap[0]));
        }
        _SFD_STATE_COV_WTS(0,1,1,1);
        if(chartAlreadyPresent==0)
        {
          static unsigned int sStartEntryMap[] = {0};
          static unsigned int sEndEntryMap[] = {0};
          static unsigned int sStartDuringMap[] = {0};
          static unsigned int sEndDuringMap[] = {0};
          static unsigned int sStartExitMap[] = {0};
          static unsigned int sEndExitMap[] = {0};

          _SFD_STATE_COV_MAPS(0,
           1,&(sStartEntryMap[0]),&(sEndEntryMap[0]),
           1,&(sStartDuringMap[0]),&(sEndDuringMap[0]),
           1,&(sStartExitMap[0]),&(sEndExitMap[0]));
        }
        _SFD_STATE_COV_WTS(1,2,1,1);
        if(chartAlreadyPresent==0)
        {
          static unsigned int sStartEntryMap[] = {0,12};
          static unsigned int sEndEntryMap[] = {0,27};
          static unsigned int sStartDuringMap[] = {0};
          static unsigned int sEndDuringMap[] = {0};
          static unsigned int sStartExitMap[] = {0};
          static unsigned int sEndExitMap[] = {0};

          _SFD_STATE_COV_MAPS(1,
           2,&(sStartEntryMap[0]),&(sEndEntryMap[0]),
           1,&(sStartDuringMap[0]),&(sEndDuringMap[0]),
           1,&(sStartExitMap[0]),&(sEndExitMap[0]));
        }
        _SFD_TRANS_COV_WTS(4,0,1,0,0);
        if(chartAlreadyPresent==0)
        {
          static unsigned int sStartGuardMap[] = {1};
          static unsigned int sEndGuardMap[] = {15};
          _SFD_TRANS_COV_MAPS(4,
           0,NULL,NULL,
           1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),
           0,NULL,NULL,
           0,NULL,NULL);
        }
        _SFD_TRANS_COV_WTS(0,0,1,0,0);
        if(chartAlreadyPresent==0)
        {
          static unsigned int sStartGuardMap[] = {1};
          static unsigned int sEndGuardMap[] = {15};
          _SFD_TRANS_COV_MAPS(0,
           0,NULL,NULL,
           1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),
           0,NULL,NULL,
           0,NULL,NULL);
        }
        _SFD_TRANS_COV_WTS(2,0,0,0,0);
        if(chartAlreadyPresent==0)
        {
          _SFD_TRANS_COV_MAPS(2,
           0,NULL,NULL,
           0,NULL,NULL,
           0,NULL,NULL,
           0,NULL,NULL);
        }
        _SFD_TRANS_COV_WTS(1,0,0,0,0);
        if(chartAlreadyPresent==0)
        {
          _SFD_TRANS_COV_MAPS(1,
           0,NULL,NULL,
           0,NULL,NULL,
           0,NULL,NULL,
           0,NULL,NULL);
        }
        _SFD_TRANS_COV_WTS(5,0,0,0,0);
        if(chartAlreadyPresent==0)
        {
          _SFD_TRANS_COV_MAPS(5,
           0,NULL,NULL,
           0,NULL,NULL,
           0,NULL,NULL,
           0,NULL,NULL);
        }
        _SFD_TRANS_COV_WTS(6,0,1,0,0);
        if(chartAlreadyPresent==0)
        {
          static unsigned int sStartGuardMap[] = {1};
          static unsigned int sEndGuardMap[] = {8};
          _SFD_TRANS_COV_MAPS(6,
           0,NULL,NULL,
           1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),
           0,NULL,NULL,
           0,NULL,NULL);
        }
        _SFD_TRANS_COV_WTS(3,0,1,0,0);
        if(chartAlreadyPresent==0)
        {
          static unsigned int sStartGuardMap[] = {1};
          static unsigned int sEndGuardMap[] = {8};
          _SFD_TRANS_COV_MAPS(3,
           0,NULL,NULL,
           1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),
           0,NULL,NULL,
           0,NULL,NULL);
        }
        _SFD_SET_DATA_VALUE_PTR(1,(void *)(&InputData_m1_c5_d1_Device_Type));
        _SFD_SET_DATA_VALUE_PTR(0,(void *)(&InputData_m1_c5_d2_Packet_Type));
        _SFD_SET_DATA_VALUE_PTR(2,(void *)(&OutputData_m1_c5_d4_Get_New_Packet));
        _SFD_SET_DATA_VALUE_PTR(4,(void *)(&InputData_m1_c5_d3_ARQN));
        _SFD_SET_DATA_VALUE_PTR(3,(void *)(&OutputData_m1_c5_d5_Enable_Audio));
      }
    }else{
      sf_debug_reset_current_state_configuration(_bluetooth_lib2MachineNumber_,chartInstance->chartNumber,chartInstance->instanceNumber);
    }
  }
  {
    /* Call this chart at time zero */
    int previousEvent = _sfEvent_;
    _sfEvent_ = CALL_EVENT;
    bluetooth_lib2_sfun_c5(((ChartInfoStruct *)ssGetUserData((SimStruct
        *)S))->chartInstance);
    _sfEvent_ = previousEvent;
  }
  chartInstance->chartInfo.chartInitialized = 1;
}

static void enable_bluetooth_lib2_sfun_c5( SimStruct *S)
{
}

static void disable_bluetooth_lib2_sfun_c5( SimStruct *S)
{
  ChartInfoStruct *chartInfo = ssGetUserData((SimStruct *)S);
  SFbluetooth_lib2_sfun_c5InstanceStruct *chartInstance =
    chartInfo->chartInstance;
}

void bluetooth_lib2_sfun_c5_sizes_registry(SimStruct *S)
{
  ssSetSFInitOutput(S,1);
  ssSetNumInputPorts((SimStruct *)S, 3);
  ssSetInputPortDataType((SimStruct *)S,0,SS_DOUBLE); /* InputData_m1_c5_d1_Device_Type */
  ssSetInputPortRequiredContiguous(S,0,1);
  ssSetInputPortWidth((SimStruct *)S,0,1);
  ssSetInputPortDirectFeedThrough((SimStruct *)S,0,1);
  ssSetInputPortDataType((SimStruct *)S,1,SS_DOUBLE); /* InputData_m1_c5_d2_Packet_Type */
  ssSetInputPortRequiredContiguous(S,1,1);
  ssSetInputPortWidth((SimStruct *)S,1,1);
  ssSetInputPortDirectFeedThrough((SimStruct *)S,1,1);
  ssSetInputPortDataType((SimStruct *)S,2,SS_DOUBLE); /* InputData_m1_c5_d3_ARQN */
  ssSetInputPortRequiredContiguous(S,2,1);
  ssSetInputPortWidth((SimStruct *)S,2,1);
  ssSetInputPortDirectFeedThrough((SimStruct *)S,2,1);
  ssSetNumOutputPorts((SimStruct *)S, 3);
  ssSetOutputPortDataType((SimStruct *)S,0,SS_DOUBLE);
  ssSetOutputPortWidth((SimStruct *)S,0,1);
  ssSetOutputPortDataType((SimStruct *)S,1,SS_DOUBLE); /* OutputData_m1_c5_d4_Get_New_Packet */
  ssSetOutputPortWidth((SimStruct *)S,1,1);
  ssSetOutputPortDataType((SimStruct *)S,2,SS_DOUBLE); /* OutputData_m1_c5_d5_Enable_Audio */
  ssSetOutputPortWidth((SimStruct *)S,2,1);
  if(sim_mode_is_rtw_gen(S)) {
    int_T chartIsInlinable =
      (int_T)sf_is_chart_inlinable("bluetooth_lib2",5);
    ssSetStateflowIsInlinable((SimStruct *)S,chartIsInlinable);
    if(chartIsInlinable) {
      ssSetInputPortReusable((SimStruct *)S,0,1);
      ssSetInputPortReusable((SimStruct *)S,1,1);
      ssSetInputPortReusable((SimStruct *)S,2,1);
      sf_mark_chart_expressionable_inputs((SimStruct *)S,"bluetooth_lib2",5,3);
      sf_mark_chart_reusable_outputs((SimStruct *)S,"bluetooth_lib2",5,2);
    }
    {
      int dtId;
      char *chartInstanceTypedefName =
        sf_chart_instance_typedef_name("bluetooth_lib2",5);
      dtId = ssRegisterDataType(S, chartInstanceTypedefName);
      if (dtId == INVALID_DTYPE_ID ) return;
      /* Register the size of the udt */
      if (!ssSetDataTypeSize(S, dtId, 8)) return;
      if(!ssSetNumDWork(S,1)) return;
      ssSetDWorkDataType(S, 0, dtId);
      ssSetDWorkWidth(S, 0, 1);
      ssSetDWorkName(S, 0, "ChartInstance"); /*optional name, less than 16 chars*/
    }
  }
  ssSetChecksum0(S,(2008554192U));
  ssSetChecksum1(S,(1378498163U));
  ssSetChecksum2(S,(3423539911U));
  ssSetChecksum3(S,(284218031U));
  ssSetExplicitFCSSCtrl(S,1);
  ssSetOptions(S,ssGetOptions(S)|SS_OPTION_WORKS_WITH_CODE_REUSE);
}

void terminate_bluetooth_lib2_sfun_c5(SimStruct *S)
{
  ChartInfoStruct *chartInfo = ssGetUserData((SimStruct *)S);
  SFbluetooth_lib2_sfun_c5InstanceStruct *chartInstance =
    chartInfo->chartInstance;

  if(chartInfo!=NULL && chartInfo->chartInstance!=NULL) {
    free((void *)(chartInfo->chartInstance));
    ssSetUserData((SimStruct *)S,NULL);
  }
}
static void mdlRTW_bluetooth_lib2_sfun_c5(SimStruct *S)
{
}

void sf_bluetooth_lib2_sfun_c5( void *);
void bluetooth_lib2_sfun_c5_registry(SimStruct *S)
{
  SFbluetooth_lib2_sfun_c5InstanceStruct *chartInstance;
  chartInstance = (SFbluetooth_lib2_sfun_c5InstanceStruct
    *)malloc(sizeof(SFbluetooth_lib2_sfun_c5InstanceStruct));
  if(chartInstance==NULL) {
    sf_mex_error_message("Could not allocate memory for chart instance.");
  }
  chartInstance->chartInfo.chartInstance = chartInstance;
  chartInstance->chartInfo.chartInitialized = 0;
  chartInstance->chartInfo.sFunctionGateway = sf_bluetooth_lib2_sfun_c5;
  chartInstance->chartInfo.initializeChart = initialize_bluetooth_lib2_sfun_c5;
  chartInstance->chartInfo.terminateChart = terminate_bluetooth_lib2_sfun_c5;
  chartInstance->chartInfo.enableChart = enable_bluetooth_lib2_sfun_c5;
  chartInstance->chartInfo.disableChart = disable_bluetooth_lib2_sfun_c5;
  chartInstance->chartInfo.mdlRTW = mdlRTW_bluetooth_lib2_sfun_c5;
  chartInstance->chartInfo.restoreLastMajorStepConfiguration = NULL;
  chartInstance->chartInfo.restoreBeforeLastMajorStepConfiguration = NULL;
  chartInstance->chartInfo.storeCurrentConfiguration = NULL;
  sf_set_error_prefix_string("Stateflow Runtime Error (chart): Error evaluating sample-time expression '-1' for chart 'bluetooth_lib2/BT Device/Tx Controller and data source/Transmit Controller' in the chart's parent workspace.\n");
  sf_mex_assign_from_mx_array(sf_matlab_evalin(CALLER_WORKSPACE,1,"-1"),
   &chartInstance->chartInfo.sampleTime,
   SF_DOUBLE,
   SF_ROW_MAJOR,
   0);
  sf_set_error_prefix_string("Stateflow Runtime Error (chart): ");
  if(chartInstance->chartInfo.sampleTime==CONTINUOUS_SAMPLE_TIME) {
    mexPrintf("Stateflow runtime error in chart bluetooth_lib2/BT Device/Tx Controller and data source/Transmit Controller\n");
    sf_mex_error_message("Runtime value of chart sample time -1 \ncannot be set to 0.0 (continuous). \nPlease change the update method to continuous time  for this chart.\n");
  }
  chartInstance->S = S;
  ssSetUserData((SimStruct *)S,(void *)(&(chartInstance->chartInfo))); /* register the chart instance with simstruct */
  ssSetSampleTime((SimStruct *)S, 0, chartInstance->chartInfo.sampleTime);
  if (chartInstance->chartInfo.sampleTime == INHERITED_SAMPLE_TIME) {
    ssSetOffsetTime((SimStruct *)S, 0, FIXED_IN_MINOR_STEP_OFFSET);
  } else if (chartInstance->chartInfo.sampleTime == CONTINUOUS_SAMPLE_TIME) {
    ssSetOffsetTime((SimStruct *)S, 0, 0.0);
  }
  ssSetCallSystemOutput((SimStruct *)S,0);
}

void sf_bluetooth_lib2_sfun_c5(void *chartInstanceVoidPtr)
{
  SFbluetooth_lib2_sfun_c5InstanceStruct *chartInstance = chartInstanceVoidPtr;
  /* Save current event being processed */
  uint8_T previousEvent;
  previousEvent = _sfEvent_;

  /* Update Stateflow time variable */
  _sfTime_ = ssGetT(chartInstance->S);

  /* Call this chart */
  _sfEvent_ = CALL_EVENT;
  bluetooth_lib2_sfun_c5(chartInstance);
  _sfEvent_ = previousEvent;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -