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

📄 bluetooth_lib2_sfun_c5.c

📁 在matlab的simulink中实现的无线蓝牙模块
💻 C
📖 第 1 页 / 共 2 页
字号:
#include "bluetooth_lib2_sfun.h"
#include "bluetooth_lib2_sfun_c5.h"
#define mexPrintf                       sf_mex_printf
#ifdef printf
#undef printf
#endif
#define printf                          sf_mex_printf
#define CHARTINSTANCE_CHARTNUMBER       (chartInstance->chartNumber)
#define CHARTINSTANCE_INSTANCENUMBER    (chartInstance->instanceNumber)
#include "bluetooth_lib2_sfun_debug_macros.h"
#define IN_NO_ACTIVE_CHILD              (0)
#define IN_m1_c5_s1_ACL_Packets         1
#define IN_m1_c5_s4_Idle                2
#define IN_m1_c5_s5_SCO_Packets         3
#define IN_m1_c5_s2_Re_Transmit_Packet  1
#define IN_m1_c5_s3_Transmit_New_Packet 2
#define InputData_m1_c5_d1_Device_Type  (((real_T *)(ssGetInputPortSignal(chartInstance->S,0)))[0])
#define InputData_m1_c5_d2_Packet_Type  (((real_T *)(ssGetInputPortSignal(chartInstance->S,1)))[0])
#define InputData_m1_c5_d3_ARQN         (((real_T *)(ssGetInputPortSignal(chartInstance->S,2)))[0])
#define OutputData_m1_c5_d4_Get_New_Packet (((real_T *)(ssGetOutputPortSignal(chartInstance->S,1)))[0])
#define OutputData_m1_c5_d5_Enable_Audio (((real_T *)(ssGetOutputPortSignal(chartInstance->S,2)))[0])

static void
exit_atomic_m1_c5_s2_Re_Transmit_Packet(SFbluetooth_lib2_sfun_c5InstanceStruct
 *chartInstance);
static void
enter_atomic_m1_c5_s3_Transmit_New_Packet(SFbluetooth_lib2_sfun_c5InstanceStruct
 *chartInstance);
static void
exit_atomic_m1_c5_s3_Transmit_New_Packet(SFbluetooth_lib2_sfun_c5InstanceStruct
 *chartInstance);
static void exit_atomic_m1_c5_s4_Idle(SFbluetooth_lib2_sfun_c5InstanceStruct
 *chartInstance);
void bluetooth_lib2_sfun_c5(SFbluetooth_lib2_sfun_c5InstanceStruct
 *chartInstance)
{
  _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG,1);
  if(chartInstance->State.is_active_bluetooth_lib2_sfun_c5 == 0) {
    _SFD_CC_CALL(CHART_ENTER_ENTRY_FUNCTION_TAG,1);
    chartInstance->State.is_active_bluetooth_lib2_sfun_c5 = 1;
    _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG,1);
    _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,2);
    _SFD_CT_CALL(TRANSITION_WHEN_VALID_TAG,2);
    _SFD_CT_CALL(TRANSITION_INACTIVE_TAG,2);
    _SFD_CS_CALL(STATE_ENTER_ENTRY_FUNCTION_TAG,0);
    _SFD_CCS_CALL(STATE_ENTRY_COVERAGE_TAG,0,0);
    chartInstance->State.is_bluetooth_lib2_sfun_c5 = IN_m1_c5_s4_Idle;
    _SFD_CS_CALL(STATE_ACTIVE_TAG,0);
    _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,0);
  } else {
    switch(chartInstance->State.is_bluetooth_lib2_sfun_c5) {
     case IN_m1_c5_s1_ACL_Packets:
      CV_CHART_EVAL(1,0,1);
      _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,3);
      _SFD_CCS_CALL(STATE_DURING_COVERAGE_TAG,3,0);
      switch(chartInstance->State.is_m1_c5_s1_ACL_Packets) {
       case IN_m1_c5_s2_Re_Transmit_Packet:
        CV_STATE_EVAL(3,0,1);
        _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,2);
        _SFD_CCS_CALL(STATE_DURING_COVERAGE_TAG,2,0);
        _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG,6);
        if(CV_TRANSITION_EVAL(6, _SFD_CCP_CALL(6,0,(InputData_m1_c5_d3_ARQN ==
            1.0))) != 0) {
          _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,6);
          _SFD_CT_CALL(TRANSITION_WHEN_VALID_TAG,6);
          _SFD_CT_CALL(TRANSITION_INACTIVE_TAG,6);
          exit_atomic_m1_c5_s2_Re_Transmit_Packet(chartInstance);
          enter_atomic_m1_c5_s3_Transmit_New_Packet(chartInstance);
        } else {
          _SFD_CS_CALL(STATE_BEFORE_DURING_ACTION_TAG,2);
          OutputData_m1_c5_d4_Get_New_Packet = 0.0;
          _SFD_CCS_CALL(STATE_DURING_COVERAGE_TAG,2,1);
          _SFD_CS_CALL(STATE_AFTER_DURING_ACTION_TAG,2);
        }
        _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,2);
        break;
       case IN_m1_c5_s3_Transmit_New_Packet:
        CV_STATE_EVAL(3,0,2);
        _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,4);
        _SFD_CCS_CALL(STATE_DURING_COVERAGE_TAG,4,0);
        _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG,3);
        if(CV_TRANSITION_EVAL(3, _SFD_CCP_CALL(3,0,(InputData_m1_c5_d3_ARQN ==
            0.0))) != 0) {
          _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,3);
          _SFD_CT_CALL(TRANSITION_WHEN_VALID_TAG,3);
          _SFD_CT_CALL(TRANSITION_INACTIVE_TAG,3);
          exit_atomic_m1_c5_s3_Transmit_New_Packet(chartInstance);
          _SFD_CS_CALL(STATE_ENTER_ENTRY_FUNCTION_TAG,2);
          _SFD_CCS_CALL(STATE_ENTRY_COVERAGE_TAG,2,0);
          chartInstance->State.is_m1_c5_s1_ACL_Packets =
            IN_m1_c5_s2_Re_Transmit_Packet;
          _SFD_CS_CALL(STATE_ACTIVE_TAG,2);
          _SFD_CS_CALL(STATE_BEFORE_ENTRY_ACTION_TAG,2);
          OutputData_m1_c5_d4_Get_New_Packet = 0.0;
          _SFD_CCS_CALL(STATE_ENTRY_COVERAGE_TAG,2,1);
          _SFD_CS_CALL(STATE_AFTER_ENTRY_ACTION_TAG,2);
          _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,2);
        } else {
          _SFD_CS_CALL(STATE_BEFORE_DURING_ACTION_TAG,4);
          OutputData_m1_c5_d4_Get_New_Packet = 1.0;
          _SFD_CCS_CALL(STATE_DURING_COVERAGE_TAG,4,1);
          _SFD_CS_CALL(STATE_AFTER_DURING_ACTION_TAG,4);
        }
        _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,4);
        break;
       default:
        CV_STATE_EVAL(3,0,0);
        break;
      }
      _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,3);
      break;
     case IN_m1_c5_s4_Idle:
      CV_CHART_EVAL(1,0,2);
      _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,0);
      _SFD_CCS_CALL(STATE_DURING_COVERAGE_TAG,0,0);
      _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,1);
      _SFD_CT_CALL(TRANSITION_WHEN_VALID_TAG,1);
      _SFD_CT_CALL(TRANSITION_INACTIVE_TAG,1);
      _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG,4);
      if(CV_TRANSITION_EVAL(4, _SFD_CCP_CALL(4,0,(InputData_m1_c5_d2_Packet_Type
          != 4.0))) != 0) {
        if(sf_debug_transition_conflict_check_enabled()) {
          unsigned int transitionList[2];
          unsigned int numTransitions=1;
          transitionList[0] = 4;
          sf_debug_transition_conflict_check_begin();
          if(InputData_m1_c5_d2_Packet_Type == 4.0) {
            transitionList[numTransitions] = 0;
            numTransitions++;
          }
          sf_debug_transition_conflict_check_end();
          if(numTransitions>1) {
            _SFD_TRANSITION_CONFLICT(&(transitionList[0]),numTransitions);
          }
        }
        _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,4);
        _SFD_CT_CALL(TRANSITION_WHEN_VALID_TAG,4);
        _SFD_CT_CALL(TRANSITION_INACTIVE_TAG,4);
        exit_atomic_m1_c5_s4_Idle(chartInstance);
        _SFD_CS_CALL(STATE_ENTER_ENTRY_FUNCTION_TAG,1);
        _SFD_CCS_CALL(STATE_ENTRY_COVERAGE_TAG,1,0);
        chartInstance->State.is_bluetooth_lib2_sfun_c5 = IN_m1_c5_s5_SCO_Packets;
        _SFD_CS_CALL(STATE_ACTIVE_TAG,1);
        _SFD_CS_CALL(STATE_BEFORE_ENTRY_ACTION_TAG,1);
        OutputData_m1_c5_d5_Enable_Audio = 1.0;
        _SFD_CCS_CALL(STATE_ENTRY_COVERAGE_TAG,1,1);
        _SFD_CS_CALL(STATE_AFTER_ENTRY_ACTION_TAG,1);
        _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,1);
      } else {
        _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG,0);
        if(CV_TRANSITION_EVAL(0,
          _SFD_CCP_CALL(0,0,(InputData_m1_c5_d2_Packet_Type == 4.0))) != 0) {
          _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,0);
          _SFD_CT_CALL(TRANSITION_WHEN_VALID_TAG,0);
          _SFD_CT_CALL(TRANSITION_INACTIVE_TAG,0);
          exit_atomic_m1_c5_s4_Idle(chartInstance);
          _SFD_CS_CALL(STATE_ENTER_ENTRY_FUNCTION_TAG,3);
          _SFD_CCS_CALL(STATE_ENTRY_COVERAGE_TAG,3,0);
          chartInstance->State.is_bluetooth_lib2_sfun_c5 =
            IN_m1_c5_s1_ACL_Packets;
          _SFD_CS_CALL(STATE_ACTIVE_TAG,3);
          _SFD_CS_CALL(STATE_BEFORE_ENTRY_ACTION_TAG,3);
          OutputData_m1_c5_d5_Enable_Audio = 0.0;
          _SFD_CCS_CALL(STATE_ENTRY_COVERAGE_TAG,3,1);
          _SFD_CS_CALL(STATE_AFTER_ENTRY_ACTION_TAG,3);
          _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,3);
          _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,5);
          _SFD_CT_CALL(TRANSITION_WHEN_VALID_TAG,5);
          _SFD_CT_CALL(TRANSITION_INACTIVE_TAG,5);
          enter_atomic_m1_c5_s3_Transmit_New_Packet(chartInstance);
        }
      }
      _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,0);
      break;
     case IN_m1_c5_s5_SCO_Packets:
      CV_CHART_EVAL(1,0,3);
      break;
     default:
      CV_CHART_EVAL(1,0,0);
      break;
    }
  }
  _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG,1);
}

static void
exit_atomic_m1_c5_s2_Re_Transmit_Packet(SFbluetooth_lib2_sfun_c5InstanceStruct
 *chartInstance)
{
  _SFD_CS_CALL(STATE_ENTER_EXIT_FUNCTION_TAG,2);
  _SFD_CCS_CALL(STATE_EXIT_COVERAGE_TAG,2,0);
  chartInstance->State.is_m1_c5_s1_ACL_Packets = IN_NO_ACTIVE_CHILD;
  _SFD_CS_CALL(STATE_INACTIVE_TAG,2);
  _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,2);
}

static void
enter_atomic_m1_c5_s3_Transmit_New_Packet(SFbluetooth_lib2_sfun_c5InstanceStruct
 *chartInstance)
{
  _SFD_CS_CALL(STATE_ENTER_ENTRY_FUNCTION_TAG,4);
  _SFD_CCS_CALL(STATE_ENTRY_COVERAGE_TAG,4,0);
  chartInstance->State.is_m1_c5_s1_ACL_Packets = IN_m1_c5_s3_Transmit_New_Packet;
  _SFD_CS_CALL(STATE_ACTIVE_TAG,4);
  _SFD_CS_CALL(STATE_BEFORE_ENTRY_ACTION_TAG,4);
  OutputData_m1_c5_d4_Get_New_Packet = 1.0;
  _SFD_CCS_CALL(STATE_ENTRY_COVERAGE_TAG,4,1);
  _SFD_CS_CALL(STATE_AFTER_ENTRY_ACTION_TAG,4);
  _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,4);
}

static void
exit_atomic_m1_c5_s3_Transmit_New_Packet(SFbluetooth_lib2_sfun_c5InstanceStruct
 *chartInstance)
{
  _SFD_CS_CALL(STATE_ENTER_EXIT_FUNCTION_TAG,4);
  _SFD_CCS_CALL(STATE_EXIT_COVERAGE_TAG,4,0);
  chartInstance->State.is_m1_c5_s1_ACL_Packets = IN_NO_ACTIVE_CHILD;
  _SFD_CS_CALL(STATE_INACTIVE_TAG,4);
  _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,4);
}

static void exit_atomic_m1_c5_s4_Idle(SFbluetooth_lib2_sfun_c5InstanceStruct
 *chartInstance)
{
  _SFD_CS_CALL(STATE_ENTER_EXIT_FUNCTION_TAG,0);
  _SFD_CCS_CALL(STATE_EXIT_COVERAGE_TAG,0,0);
  chartInstance->State.is_bluetooth_lib2_sfun_c5 = IN_NO_ACTIVE_CHILD;
  _SFD_CS_CALL(STATE_INACTIVE_TAG,0);
  _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,0);
}

void sf_bluetooth_lib2_sfun_c5_get_check_sum(mxArray *plhs[])
{
  ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(2008554192U);
  ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(1378498163U);
  ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(3423539911U);
  ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(284218031U);
}
/*
 * Chart initialization function
 */
/* work around the buggy macro in simstruc.h until it is fixed */
#define cdrGetOutputPortReusable(S,port) \
  ( (S)->portInfo.outputs[(port)].attributes.optimOpts != \
   SS_NOT_REUSABLE_AND_GLOBAL )

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

  {
    if(!cdrGetOutputPortReusable(S,1)) {
      OutputData_m1_c5_d4_Get_New_Packet = 0.0;
    }
    if(!cdrGetOutputPortReusable(S,2)) {
      OutputData_m1_c5_d5_Enable_Audio = 0.0;
    }
  }

  /* Initialize chart's state configuration */
  memset((void*)&(chartInstance->State),0,sizeof(chartInstance->State));

  {
    if(ssIsFirstInitCond(S)) {
      /* do this only if simulation is starting */
      {
        unsigned int chartAlreadyPresent;
        chartAlreadyPresent =
          sf_debug_initialize_chart(_bluetooth_lib2MachineNumber_,
          5,
          5,
          7,
          5,
          0,
          0,
          0,
          0,
          &(chartInstance->chartNumber),
          &(chartInstance->instanceNumber),
          ssGetPath((SimStruct *)S),
          (void *)S);
        if(chartAlreadyPresent==0) {
          /* this is the first instance */
          sf_debug_set_chart_disable_implicit_casting(_bluetooth_lib2MachineNumber_,chartInstance->chartNumber,0);
          sf_debug_set_chart_event_thresholds(_bluetooth_lib2MachineNumber_,
           chartInstance->chartNumber,
           0,
           0,
           0);

          _SFD_SET_DATA_PROPS(1,
           1,
           1,
           0,
           SF_DOUBLE,
           0,
           NULL,
           0,
           0.0,
           1.0,
           0);
          _SFD_SET_DATA_PROPS(0,
           1,
           1,
           0,
           SF_DOUBLE,
           0,
           NULL,
           0,
           0.0,
           1.0,
           0);
          _SFD_SET_DATA_PROPS(2,
           2,
           0,
           1,
           SF_DOUBLE,
           0,
           NULL,
           0,
           0.0,
           1.0,
           0);
          _SFD_SET_DATA_PROPS(4,
           1,
           1,
           0,
           SF_DOUBLE,
           0,
           NULL,
           0,
           0.0,
           1.0,
           0);
          _SFD_SET_DATA_PROPS(3,
           2,
           0,
           1,
           SF_DOUBLE,
           0,
           NULL,
           0,
           0.0,
           1.0,
           0);
          _SFD_STATE_INFO(3,0,0);
          _SFD_STATE_INFO(2,0,0);
          _SFD_STATE_INFO(4,0,0);
          _SFD_STATE_INFO(0,0,0);
          _SFD_STATE_INFO(1,0,0);
          _SFD_CH_SUBSTATE_COUNT(3);
          _SFD_CH_SUBSTATE_DECOMP(0);
          _SFD_CH_SUBSTATE_INDEX(0,3);
          _SFD_CH_SUBSTATE_INDEX(1,0);
          _SFD_CH_SUBSTATE_INDEX(2,1);
          _SFD_ST_SUBSTATE_COUNT(3,2);
          _SFD_ST_SUBSTATE_INDEX(3,0,2);
          _SFD_ST_SUBSTATE_INDEX(3,1,4);

⌨️ 快捷键说明

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