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

📄 controller.c

📁 本程序为ST公司开发的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
      // re-init capture      controller_internal_flags |= CTR_INTERNAL_CAPTURE_RUN;      cap_cmd_event.did = DEV_CD_ID;      cap_cmd_event.command = CAP_CMD_INIT;      cap_cmd(&cap_cmd_event);      // re-init decoder      controller_internal_flags |= CTR_INTERNAL_DECODER_RUN;      CTR_decoder_cmd_event.command = DECODER_CMD_INIT;      decoder_task_cmd(&CTR_decoder_cmd_event);      // re-init file system task      controller_internal_flags |= CTR_INTERNAL_FILESYS_RUN;      filesys_cmd_event.command = FILESYS_CMD_INIT;      filesys_cmd(&filesys_cmd_event);      controller_active_transitions |= CTR_TRANSITION_INIT;      break;  }}*/// ************************* ctr_stop_FILESYS_transition ******************************* //uint16 ctr_stop_filesys_transition(void){  RETVAL ctr_child_status;  t_filesys_cmd_event filesys_cmd_event;  print_fsm(&controller_stop_filesys_fsm);  switch (controller_stop_filesys_fsm.transition)  {  case 0:    // stop TAG or MOUNT or both    filesys_cmd_event.params.stop_params.flags = controller_stop_filesys_fsm_params.flags;    filesys_cmd_event.command = FILESYS_CMD_STOP;    ctr_child_status = filesys_cmd(&filesys_cmd_event);    if (ctr_child_status == READY)    {      controller_stop_filesys_fsm.state = FSM_DONE;      if (controller_stop_filesys_fsm.parent_notify)      {        event_set_controller(READY);      }      return CTR_TRANSITION_STOP_FYSESYS;    }    controller_stop_filesys_fsm.transition = 1;    break;  case 1:    if (IS_FILESYS_STOP_EVENT)    { // stopped or error      event_in_clear(FILESYS_STOP_EVENT);      controller_stop_filesys_fsm.state = filesys_fsm_stop.state;      if (filesys_fsm_stop.state == FSM_ERROR)      { // error - signal upwards        controller_stop_filesys_fsm.error_reason = filesys_fsm_stop.error_reason;        if (controller_stop_filesys_fsm.parent_notify)        {          event_set_controller((controller_stop_filesys_fsm.error_reason & 0xFFFF));          return 0;        }      }      else      {        if (controller_stop_filesys_fsm.parent_notify)        {          event_set_controller(READY);          return 0;        }      }      return CTR_TRANSITION_STOP_FYSESYS; // resume without semaphore_signal    }  }  return 0;}// ************************* ctr_stop_DECODER_transition ******************************* //uint16 ctr_stop_decoder_transition(void){  RETVAL ctr_child_status;  print_fsm(&controller_stop_decoder_fsm);  switch (controller_stop_decoder_fsm.transition)  {  case 0:    CTR_decoder_cmd_event.command = DECODER_CMD_STOP;    ctr_child_status = decoder_task_cmd(&CTR_decoder_cmd_event);    if (ctr_child_status == READY)    {      controller_stop_decoder_fsm.state = FSM_DONE;      if (controller_stop_decoder_fsm.parent_notify)      {        event_set_controller(READY);        return 0;      }      return CTR_TRANSITION_STOP_DECODER;    }    controller_stop_decoder_fsm.transition = 1;    break;  case 1:    if (IS_DECODER_STOP_EVENT_READY)    {      event_in_clear(DECODER_STOP_EVENT);      controller_stop_decoder_fsm.state = FSM_DONE;      if (controller_stop_decoder_fsm.parent_notify)      {        event_set_controller(READY);        return 0;      }      return CTR_TRANSITION_STOP_DECODER; // resume without semaphore_signal    }  }  return 0;}#if (0 != HAVE_USB)// ************************* ctr_stop_USB_transition ******************************* //uint16 ctr_stop_USB_transition(void){  RETVAL ctr_child_status;  t_child_cmd_event USB_stop_cmd;  ctr_active_transitions |= DEV_USB_ID;  if (ctr_stop_flag & DEV_USB_ID)  { //USB stop required    if (EVENT_USB_IS_STOP)    { //USB task stopped      controller_stop_USB_fsm.state = FSM_ERROR;      controller_stop_USB_fsm.error_reason = STOP_ERROR_REASON;      return CTR_TRANSITION_STOP_USB;    }    return 0;  }  print_fsm(&controller_stop_USB_fsm);  switch (controller_stop_USB_fsm.transition)  {  case 0:    USB_stop_cmd.did = DEV_USB_ID;    USB_stop_cmd.command = CHILD_CMD_STOP;    ctr_child_status = usb_cmd(&USB_stop_cmd);    if (ctr_child_status == READY)    {      controller_stop_USB_fsm.state = FSM_DONE;      if (controller_stop_USB_fsm.parent_notify)      {        event_set_controller(READY);      }      return CTR_TRANSITION_STOP_USB;    }    controller_stop_USB_fsm.transition = 1;    break;  case 1:    if (EVENT_USB_IS_STOP)    { // tag was successfully decoded or error      // event_in_clear(USB_STOP_EVENT);      controller_stop_USB_fsm.state = FSM_DONE;      if (controller_stop_USB_fsm.parent_notify)      {        event_set_controller(READY);      }      return CTR_TRANSITION_STOP_USB;    }  }  return 0;}#endif // (0 != HAVE_USB)// ************************* ctr_stop_CD_transition ******************************* //uint16 ctr_stop_CD_transition(void){  RETVAL ctr_child_status;  t_cap_cmd_event CD_stop_cmd;  ctr_active_transitions |= DEV_CD_ID;  if (ctr_stop_flag & DEV_CD_ID)  { //CD stop required    if (IS_CAPTURE_EVENT)    { //Capture task stopped      controller_stop_CD_fsm.state = FSM_ERROR;      controller_stop_CD_fsm.error_reason = STOP_ERROR_REASON;      return CTR_TRANSITION_STOP_CD;    }    return 0;  }  print_fsm(&controller_stop_CD_fsm);  switch (controller_stop_CD_fsm.transition)  {  case 0:    if (Read_Request_Pending)    { //there is some read request unfinished      //dprintf("Wait read ready\r\n");#ifdef WAIT_4_READ_READY      return 0;#endif          }    //no read request unfinished, pass through  case 1:    CD_stop_cmd.did = DEV_CD_ID;    CD_stop_cmd.command = CAP_CMD_STOP;    //clear all responses for cmd in event_in: ready and PRE EOS    //all responses for cmd in event_pending are cleared at the end of CTR task    event_in_clear(CAPTURE_STATUS_EVENT);    event_in_clear(CAPTURE_PRE_ENDPLAY_EVENT);    ctr_child_status = cap_cmd(&CD_stop_cmd);    if (ctr_child_status == READY)    {      controller_stop_CD_fsm.state = FSM_DONE;      if (controller_stop_CD_fsm.parent_notify)      {        event_set_controller(READY);      }      return CTR_TRANSITION_STOP_CD;    }    controller_stop_CD_fsm.transition = 2;    break;  case 2:    if (IS_CAPTURE_EVENT)    {      if (IS_CAPTURE_EVENT_READY)      {        controller_stop_CD_fsm.state = FSM_DONE;        if (controller_stop_CD_fsm.parent_notify)        {          event_set_controller(READY);        }      }      else if (IS_CAPTURE_EVENT_ERROR)      {        controller_stop_CD_fsm.state = FSM_ERROR;        controller_stop_CD_fsm.error_reason = CAPTURE_STATUS;        if (controller_stop_CD_fsm.parent_notify)        {          event_set_controller((controller_stop_CD_fsm.error_reason & 0xFFFF));          event_in_clear(CAPTURE_STATUS_EVENT);          return 0;        }      }      event_in_clear(CAPTURE_STATUS_EVENT);      return CTR_TRANSITION_STOP_CD;    }  }  return 0;}#if (0 != HAVE_SDC)// ************************* ctr_stop_SDC_transition ******************************* //uint16 ctr_stop_SDC_transition(void){  ctr_active_transitions |= DEV_SDC_ID;  print_fsm(&controller_stop_SDC_fsm);  controller_stop_SDC_fsm.state = FSM_DONE;  if (controller_stop_SDC_fsm.parent_notify)  {    event_set_controller(READY);  }  return 0;}#endif /* HAVE_SDC */// ****************************** ctr_stop_transition ************************************ //uint16 ctr_stop_transition(void){  // stop activated on play command with forced execution, no parent_notify  uint32 EXPECTED_STOP_EVENT;  ctr_active_transitions |= controller_stop_fsm_params.did;  switch (controller_stop_fsm_params.did)  {#if (0 != HAVE_USB)  case DEV_USB_ID:    EXPECTED_STOP_EVENT = USB_STOP_EVENT;    break;#endif#if (0 != HAVE_SDC)  case DEV_SDC_ID:    EXPECTED_STOP_EVENT = SDC_STOP_EVENT;    break;#endif /* HAVE_SDC */  default: //case DEV_CD_ID:    EXPECTED_STOP_EVENT = CAPTURE_STATUS_EVENT;    break;  }  if (ctr_stop_flag & controller_stop_fsm_params.did)  { //device stop required    if (IS_EXPECTED_STOP_EVENT(EXPECTED_STOP_EVENT))    { //device task stopped      controller_stop_fsm.state = FSM_ERROR;      controller_stop_fsm.error_reason = STOP_ERROR_REASON;      return CTR_TRANSITION_STOP;    }    return 0;  }  if (controller_stop_fsm_params.did & DEV_CD_ID)  {    // clear all Capture inevents    event_in_clear(CAPTURE_STATUS_EVENT);    event_in_clear(CAPTURE_READ_EVENT);    event_in_clear(CAPTURE_SUBCODE_EVENT);    //event_in_clear_subcode(CAPTURE_EVENT_SUBCODE_END_OF_READ);    event_in_clear(CAPTURE_PRE_ENDPLAY_EVENT);  }  while (1)  {    print_fsm(&controller_stop_fsm);    switch (controller_stop_fsm.transition)    {    case 0:      // wait for TAG stop and Decoder stop      if (controller_stop_filesys_fsm.state == FSM_RUN)      {        return 0;      }      else if (controller_stop_filesys_fsm.state == FSM_ERROR)      {        controller_stop_fsm.state = FSM_ERROR;        controller_stop_fsm.error_reason = controller_stop_filesys_fsm.error_reason;        return CTR_TRANSITION_STOP;      }      if (controller_stop_decoder_fsm.state == FSM_RUN)      {        return 0;      }      else if (controller_stop_decoder_fsm.state == FSM_ERROR)      {        controller_stop_fsm.state = FSM_ERROR;        controller_stop_fsm.error_reason = controller_stop_decoder_fsm.error_reason;        return CTR_TRANSITION_STOP;      }      switch (controller_stop_fsm_params.did)      {      case DEV_CD_ID:        FSM_deactivate(&controller_esp_fsm, 0);        FSM_deactivate(&controller_cd_extent_fsm, 0);        FSM_deactivate(&controller_CD_data_for_CTR_fsm, 0);        FSM_deactivate(&controller_CD_data_for_TASK_fsm, 0);        controller_stop_fsm.transition = 1;        break;#if (0 != HAVE_USB)      case DEV_USB_ID:        controller_stop_fsm.transition = 2;        FSM_deactivate(&controller_USB_data_for_CTR_fsm, 0);        FSM_deactivate(&controller_USB_data_for_TASK_fsm, 0);        FSM_activate(&controller_stop_USB_fsm, 0, 0);   // stop USB        break;#endif#if (0 != HAVE_SDC)      case DEV_SDC_ID:        controller_stop_fsm.transition = 3;        break;#endif /* HAVE_SDC */      case DEV_NO_DEVICE:        controller_stop_fsm.transition = 4;        break;      }      break;    case 1: // cd stop      if (controller_stop_CD_fsm.state == FSM_RUN)      {        return 0;      }      else if (controller_stop_CD_fsm.state == FSM_ERROR)      {        controller_stop_fsm.state = FSM_ERROR;        controller_stop_fsm.error_reason = controller_stop_CD_fsm.error_reason;        return CTR_TRANSITION_STOP;      }      else      {        controller_stop_fsm.transition = 4; // [RB] changed from 3 to 4 to introduce SDC        break;      }      // return 0; // statement unreachable    case 2: // usb stop finished#if (0 != HAVE

⌨️ 快捷键说明

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