当前位置: 首页>>代码示例>>C++>>正文


C++ Usb_reset_endpoint_fifo_access函数代码示例

本文整理汇总了C++中Usb_reset_endpoint_fifo_access函数的典型用法代码示例。如果您正苦于以下问题:C++ Usb_reset_endpoint_fifo_access函数的具体用法?C++ Usb_reset_endpoint_fifo_access怎么用?C++ Usb_reset_endpoint_fifo_access使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Usb_reset_endpoint_fifo_access函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: USB_CCID_GetDataFromUSB

static void USB_CCID_GetDataFromUSB (void)
{
    int i;
    int USB_Datalen_s32;

    // Bool cbw_error;

    Usb_reset_endpoint_fifo_access (EP_CCID_OUT);

    // Get all data from USB
    USB_CCID_data_st.CCID_datalen = 0;

    while (Is_usb_out_received (EP_CCID_OUT))
    {
        Usb_reset_endpoint_fifo_access (EP_CCID_OUT);

        USB_Datalen_s32 = Usb_byte_count (EP_CCID_OUT);
        USB_Log_st.CCID_WriteCalls_u32++;
        USB_Log_st.CCID_BytesWrite_u32 += USB_Datalen_s32;

        // CI_TickLocalPrintf ("Get CCID USB block %3d byte - %3d\n",USB_Datalen_s32,USB_CCID_data_st.CCID_datalen);

        if (CCID_MAX_XFER_LENGTH <= USB_Datalen_s32 + USB_CCID_data_st.CCID_datalen)    // Check for oversize
        {
            CI_LocalPrintf ("*** CCID buffer to small %d ***\n", CCID_MAX_XFER_LENGTH);
            Usb_ack_out_received_free (EP_CCID_OUT);
            return;
        }

        for (i = 0; i < USB_Datalen_s32; i++)
        {
            USB_CCID_data_st.USB_data[USB_CCID_data_st.CCID_datalen] = Usb_read_endpoint_data (EP_CCID_OUT, 8);
            USB_CCID_data_st.CCID_datalen++;
        }

        Usb_ack_out_received_free (EP_CCID_OUT);
        DelayMs (1);
    }

    LED_RedOn ();

//    USB_CCID_Datalen_s32 = USB_CCID_data_st.CCID_datalen;

    USB_to_CRD_DispatchUSBMessage_v (&USB_CCID_data_st);

//    memset (USB_CCID_data_st.USB_data,0,USB_Datalen_s32);
    LED_RedOff ();

    // Usb_ack_out_received_free(EP_CCID_OUT);

}
开发者ID:chenhuang511,项目名称:nitrokey-storage-firmware,代码行数:51,代码来源:USB_CCID_task.c

示例2: usb_mass_storage_csw

//!
//! @brief USB Command Status Wrapper (CSW) management
//!
//! This function sends the status in relation with the last CBW.
//!
static void usb_mass_storage_csw(void)
{
  while (Is_usb_endpoint_stall_requested(EP_MS_IN))
  {
    if (Is_usb_setup_received()) usb_process_request();
  }

  while (Is_usb_endpoint_stall_requested(EP_MS_OUT))
  {
    if (Is_usb_setup_received()) usb_process_request();
  }

  while (!Is_usb_in_ready(EP_MS_IN));

  Usb_reset_endpoint_fifo_access(EP_MS_IN);

  //! Write CSW Signature
  Usb_write_endpoint_data(EP_MS_IN, 32, *(U32 *)&"USBS");

  //! Write stored CBW Tag
  Usb_write_endpoint_data(EP_MS_IN, 32, dCBWTag);

  //! Write data residual value
  Usb_write_endpoint_data(EP_MS_IN, 32,
                          usb_format_mcu_to_usb_data(32, g_scsi_data_remaining));

  //! Write command status
  Usb_write_endpoint_data(EP_MS_IN, 8, g_scsi_status);

  Usb_ack_in_ready_send(EP_MS_IN);
}
开发者ID:AndreyMostovov,项目名称:asf,代码行数:36,代码来源:device_mass_storage_task.c

示例3: audio_speaker_set_mute

//******* Speaker control
void audio_speaker_set_mute(void)
{
   while(!Is_usb_control_out_received())
   {
     TASKS_SCHEDULE();
   }
   Usb_reset_endpoint_fifo_access(EP_CONTROL);
   b_speaker_mute=Usb_read_endpoint_data(EP_CONTROL, 8);
   audio_mixer_mute_audio(b_speaker_mute);

   if( b_speaker_mute )
   {
     audio_mixer_dacs_set_volume_direct((uint8_t)SPEAKER_VOL_MIN);
   }
   else
   {
     audio_mixer_dacs_set_volume_direct(s16_speaker_volume);
   }

   Usb_ack_control_out_received_free();
   Usb_ack_control_in_ready_send();  // send a ZLP
   while (!Is_usb_control_in_ready())
   {
     TASKS_SCHEDULE();
   }
}
开发者ID:ThucVD2704,项目名称:femto-usb-blink-example,代码行数:27,代码来源:usb_specific_request.c

示例4: audio_speaker_set_volume

void audio_speaker_set_volume(void)
{
   while(!Is_usb_control_out_received())
   {
     TASKS_SCHEDULE();
   }
   Usb_reset_endpoint_fifo_access(EP_CONTROL);
   LSB(s16_usb_speaker_volume)=Usb_read_endpoint_data(EP_CONTROL, 8);
   MSB(s16_usb_speaker_volume)=Usb_read_endpoint_data(EP_CONTROL, 8);

   // Convert USB range volume into the volume range of the application.
   s16_speaker_volume = volume_usb_to_appli(s16_usb_speaker_volume) ;

   Usb_ack_control_out_received_free();
   Usb_ack_control_in_ready_send();  // send a ZLP

   // Ensures good limits of the parameter
   s16_speaker_volume = min( s16_speaker_volume, SPEAKER_VOL_MAX);
   s16_speaker_volume = max( s16_speaker_volume, SPEAKER_VOL_MIN);
   audio_mixer_dacs_set_volume_direct(s16_speaker_volume);
   while (!Is_usb_control_in_ready())
   {
     TASKS_SCHEDULE();
   }
}
开发者ID:ThucVD2704,项目名称:femto-usb-blink-example,代码行数:25,代码来源:usb_specific_request.c

示例5: sbc_read_capacity

Bool sbc_read_capacity (void)
{
    U32 mem_size_nb_sector;

    switch (mem_read_capacity (usb_LUN, &mem_size_nb_sector))
    {
    case CTRL_GOOD:
        Usb_reset_endpoint_fifo_access (g_scsi_ep_ms_in);

        // Return nb block.
        Usb_write_endpoint_data (g_scsi_ep_ms_in, 32, sbc_format_mcu_to_scsi_data (32, mem_size_nb_sector));

        // Return block size (= 512 bytes).
        Usb_write_endpoint_data (g_scsi_ep_ms_in, 32, Sbc_format_mcu_to_scsi_data (32, 512));

        Sbc_valid_write_usb (SBC_READ_CAPACITY_LENGTH);
        sbc_lun_status_is_good ();
        return TRUE;

    case CTRL_NO_PRESENT:
        sbc_lun_status_is_not_present ();
        break;

    case CTRL_BUSY:
        sbc_lun_status_is_busy_or_change ();
        break;

    case CTRL_FAIL:
    default:
        sbc_lun_status_is_fail ();
        break;
    }
    return FALSE;
}
开发者ID:chenhuang511,项目名称:nitrokey-storage-firmware,代码行数:34,代码来源:scsi_decoder.c

示例6: sbc_header_mode_sense

static void sbc_header_mode_sense (Bool b_sense_10, U8 u8_data_length)
{
    Usb_reset_endpoint_fifo_access (g_scsi_ep_ms_in);

    // Send data length.
    if (b_sense_10)
    {
        Usb_write_endpoint_data (g_scsi_ep_ms_in, 8, 0);
    }
    Usb_write_endpoint_data (g_scsi_ep_ms_in, 8, u8_data_length);

    // Send device type.
    Usb_write_endpoint_data (g_scsi_ep_ms_in, 8, SBC_MEDIUM_TYPE);

    // Write protect status.
    Usb_write_endpoint_data (g_scsi_ep_ms_in, 8, (mem_wr_protect (usb_LUN)) ? SBC_DEV_SPEC_PARAM_WR_PROTECT : SBC_DEV_SPEC_PARAM_WR_ENABLE);

    if (b_sense_10)
    {
        // Reserved.
        Usb_write_endpoint_data (g_scsi_ep_ms_in, 16, 0);
    }

    // Send block descriptor length.
    if (b_sense_10)
    {
        Usb_write_endpoint_data (g_scsi_ep_ms_in, 8, 0);
    }
    Usb_write_endpoint_data (g_scsi_ep_ms_in, 8, SBC_BLOCK_DESCRIPTOR_LENGTH);
}
开发者ID:chenhuang511,项目名称:nitrokey-storage-firmware,代码行数:30,代码来源:scsi_decoder.c

示例7: sd_mmc_mci_write_multiple_sector_callback

void sd_mmc_mci_write_multiple_sector_callback(void *psector)
{
#ifdef USB_DEVICE_VENDOR_ID
   // USB Device Stack V2
   udi_msc_trans_block( false, (uint8_t*)psector, SD_MMC_SECTOR_SIZE, NULL);
#else
  // USB Device Stack V1
  uint16_t data_to_transfer = SD_MMC_SECTOR_SIZE;

  // Transfer sector to write from the USB interface.
  while (data_to_transfer)
  {
    while (!Is_usb_out_received(g_scsi_ep_ms_out))
    {
      if(!Is_usb_endpoint_enabled(g_scsi_ep_ms_out))
         return; // USB Reset
    }

    Usb_reset_endpoint_fifo_access(g_scsi_ep_ms_out);
    data_to_transfer = usb_read_ep_rxpacket(g_scsi_ep_ms_out, psector,
                                            data_to_transfer, &psector);
    Usb_ack_out_received_free(g_scsi_ep_ms_out);
  }
#endif
}
开发者ID:cryptx2,项目名称:cryptx2-firmware,代码行数:25,代码来源:sd_mmc_mci_mem.c

示例8: sd_mmc_mci_read_multiple_sector_callback

void sd_mmc_mci_read_multiple_sector_callback(const void *psector)
{
#ifdef USB_DEVICE_VENDOR_ID
   // USB Device Stack V2
   udi_msc_trans_block( true, (uint8_t*)psector, SD_MMC_SECTOR_SIZE, NULL);
#else
  // USB Device Stack V1
  uint16_t data_to_transfer = SD_MMC_SECTOR_SIZE;

  // Transfer read sector to the USB interface.
  while (data_to_transfer)
  {
    while (!Is_usb_in_ready(g_scsi_ep_ms_in))
    {
      if(!Is_usb_endpoint_enabled(g_scsi_ep_ms_in))
         return; // USB Reset
    }

    Usb_reset_endpoint_fifo_access(g_scsi_ep_ms_in);
    data_to_transfer = usb_write_ep_txpacket(g_scsi_ep_ms_in, psector,
                                             data_to_transfer, &psector);
    Usb_ack_in_ready_send(g_scsi_ep_ms_in);
  }
#endif
}
开发者ID:cryptx2,项目名称:cryptx2-firmware,代码行数:25,代码来源:sd_mmc_mci_mem.c

示例9: sendKeys

void sendKeys(u8* buffer)
{
  u32 i;
#ifdef NOT_USED
  if (bDeviceState == CONFIGURED)
  {
    while(!PrevXferComplete);
      
    PrevXferComplete = 0;
  /* Use the memory interface function to write to the selected endpoint */
    UserToPMABufferCopy(buffer, ENDP4_TXADDR, 8);
   
  /* Update the data length in the control register */
    SetEPTxCount(ENDP4, 8);
    SetEPTxStatus (ENDP4, EP_TX_VALID);
      
  }
#endif

  while (Is_usb_endpoint_stall_requested(EP_KB_IN))
  {
    if (Is_usb_setup_received())
    {
      usb_process_request();
    }
  }

  // MSC Compliance - Free BAD out receive during SCSI command
  while( Is_usb_out_received(EP_CCID_OUT) ) {
    Usb_ack_out_received_free(EP_CCID_OUT);
  }

  while (!Is_usb_in_ready(EP_KB_IN))
  {
     if(!Is_usb_endpoint_enabled(EP_KB_IN))
     {
       i = 0; // todo USB Reset
     }
  }

  Usb_reset_endpoint_fifo_access(EP_KB_IN);
/*
  Usb_write_endpoint_data(EP_KB_IN, 8, 'D');
  Usb_write_endpoint_data(EP_KB_IN, 8, 'D');
  Usb_write_endpoint_data(EP_KB_IN, 8, 'D');
  Usb_write_endpoint_data(EP_KB_IN, 8, 'D');
*/
  usb_write_ep_txpacket(EP_KB_IN, buffer, 8, NULL);
//  Usb_send_in(EP_CONTROL);

  Usb_ack_in_ready_send(EP_KB_IN);


  // MSC Compliance - Wait end of all transmitions on USB line
  while( 0 != Usb_nb_busy_bank(EP_KB_IN) )
  {
    if (Is_usb_setup_received()) usb_process_request();
  }

}
开发者ID:12019,项目名称:nitrokey-storage-firmware,代码行数:60,代码来源:keyboard.c

示例10: usb_mass_storage_cbw

//!
//! @brief USB Command Block Wrapper (CBW) management
//!
//! This function decodes the CBW command and stores the SCSI command.
//!
static void usb_mass_storage_cbw(void)
{
  bool cbw_error;

  Usb_reset_endpoint_fifo_access(EP_MS_OUT);

  //! Check if dCBWSignature is correct
  cbw_error = (Usb_read_endpoint_data(EP_MS_OUT, 32) != *(U32 *)&"USBC");

  //! Store CBW Tag to be repeated in CSW
  dCBWTag = Usb_read_endpoint_data(EP_MS_OUT, 32);

  g_scsi_data_remaining = Usb_read_endpoint_data(EP_MS_OUT, 32);
  g_scsi_data_remaining = usb_format_usb_to_mcu_data(32, g_scsi_data_remaining);

  //! if (bmCBWFlags.bit7 == 1) {direction = IN;}
  if (Usb_read_endpoint_data(EP_MS_OUT, 8))
  {
    ms_endpoint = EP_MS_IN;
    if (cbw_error)
    {
      Usb_ack_out_received_free(EP_MS_OUT);
      Usb_enable_stall_handshake(EP_MS_IN);
      return;
    }
  }
  else
  {
    ms_endpoint = EP_MS_OUT;
    if (cbw_error)
    {
      Usb_enable_stall_handshake(EP_MS_OUT);
      Usb_ack_out_received_free(EP_MS_OUT);
      return;
    }
  }

  usb_LUN = Usb_read_endpoint_data(EP_MS_OUT, 8);

  if (!ms_multiple_drive)
  {
    usb_LUN = get_cur_lun();
  }

  //! Dummy CBWCBLength read
  Usb_read_endpoint_data(EP_MS_OUT, 8);

  //! Store scsi_command
  usb_read_ep_rxpacket(EP_MS_OUT, g_scsi_command, sizeof(g_scsi_command), NULL);

  Usb_ack_out_received_free(EP_MS_OUT);

  // Take the USB Mutex(i.e. we're allowed to perform a ms cmd).
  /* if( ( pdFALSE == ( xGiveUsbMutex = x_supervisor_SemaphoreTake( xUSBMutex, 0 ) ) ) || ( !scsi_decode_command() && g_scsi_data_remaining ) ) */
  if( ( pdFALSE == (xGiveUsbMutex = x_supervisor_SemaphoreTake( xUSBMutex, 0 ) ) )
      || ( !scsi_decode_command() && g_scsi_data_remaining ) )
  {
    Usb_enable_stall_handshake(ms_endpoint);
  }
}
开发者ID:kerichsen,项目名称:asf,代码行数:65,代码来源:device_mass_storage_task.c

示例11: hid_report_in

//! @brief Send data report to Host
//!
void hid_report_in(void)
{

  int joy   =0;
  char* ptr_cram=txbuf;
  int data_to_transfer=0;

  if(!Is_usb_write_enabled(EP_HID_GENERIC_IN))
      return;                                // Not ready to send report

  // Build the Joystick report
  if(is_joystick_up()|| is_joystick_down() || is_joystick_right() || is_joystick_left() )                     //! Check for UP event
  {
    joy=0x01;
  }
  if(joy==last_joy) {
     return;                                // Same report then no send report
  }

  last_joy=joy;
  memset(txbuf, 0, RXBUF_SIZE);
  txbuf[0] = joy;

  // Send report
  data_to_transfer = sizeof(txbuf);
  while (data_to_transfer)
  {
       while (!Is_usb_in_ready(EP_HID_GENERIC_IN));

       Usb_reset_endpoint_fifo_access(EP_HID_GENERIC_IN);
       data_to_transfer = usb_write_ep_txpacket(EP_HID_GENERIC_IN, ptr_cram, data_to_transfer, (const void**)&ptr_cram);
       Usb_ack_in_ready_send(EP_HID_GENERIC_IN);
   }
}
开发者ID:ThucVD2704,项目名称:femto-usb-blink-example,代码行数:36,代码来源:device_generic_hid_task.c

示例12: usb_mass_storage_cbw

// !
// ! @brief USB Command Block Wrapper (CBW) management
// !
// ! This function decodes the CBW command and stores the SCSI command.
// !
static void usb_mass_storage_cbw (void)
{
    Bool cbw_error;

    Usb_reset_endpoint_fifo_access (EP_MS_OUT);

    // ! Check if dCBWSignature is correct
    cbw_error = (Usb_read_endpoint_data (EP_MS_OUT, 32) != *(U32 *) & "USBC");

    // ! Store CBW Tag to be repeated in CSW
    dCBWTag = Usb_read_endpoint_data (EP_MS_OUT, 32);

    g_scsi_data_remaining = Usb_read_endpoint_data (EP_MS_OUT, 32);
    g_scsi_data_remaining = usb_format_usb_to_mcu_data (32, g_scsi_data_remaining);

    /* Show the remaining bytes { U8 Text_u8[20]; CI_StringOut (" - "); itoa ((S32)g_scsi_data_remaining,Text_u8); CI_StringOut (Text_u8);
       CI_StringOut (" - "); } */
    // ! if (bmCBWFlags.bit7 == 1) {direction = IN;}
    if (Usb_read_endpoint_data (EP_MS_OUT, 8))
    {
        ms_endpoint = EP_MS_IN;
        if (cbw_error)
        {
            Usb_ack_out_received_free (EP_MS_OUT);
            Usb_enable_stall_handshake (EP_MS_IN);
            return;
        }
    }
    else
    {
        ms_endpoint = EP_MS_OUT;
        if (cbw_error)
        {
            Usb_enable_stall_handshake (EP_MS_OUT);
            Usb_ack_out_received_free (EP_MS_OUT);
            return;
        }
    }

    usb_LUN = Usb_read_endpoint_data (EP_MS_OUT, 8);

    if (!ms_multiple_drive)
    {
        usb_LUN = get_cur_lun ();
    }

    // ! Dummy CBWCBLength read
    Usb_read_endpoint_data (EP_MS_OUT, 8);

    // ! Store scsi_command
    usb_read_ep_rxpacket (EP_MS_OUT, g_scsi_command, sizeof (g_scsi_command), NULL);

    Usb_ack_out_received_free (EP_MS_OUT);

    if (!scsi_decode_command ())
    {
        Usb_enable_stall_handshake (ms_endpoint);
    }
}
开发者ID:chenhuang511,项目名称:nitrokey-storage-firmware,代码行数:64,代码来源:device_mass_storage_task.c

示例13: cdc_flushrx

void cdc_flushrx(void) {		// löscht den Inhalt des Rx
  if (usb_connected) {
    Usb_reset_endpoint_fifo_access(RX_EP);
    Usb_ack_out_received_free(RX_EP);
  }
  cdc_rdpos = cdc_wrpos;
//  cdc_rxfifo_empty = TRUE;
}
开发者ID:dg0tm,项目名称:dv-rptr-fw,代码行数:8,代码来源:usb_func.c

示例14: cdc_transmit

void cdc_transmit(const char *data, int len) {
  if (usb_connected) {
    if (Is_usb_write_enabled(TX_EP)) {
      Usb_reset_endpoint_fifo_access(TX_EP);
      cdc_txbuffer_len = usb_write_ep_txpacket(TX_EP, data, len, (const void **)&cdc_txbuffer);
      Usb_ack_in_ready_send(TX_EP);
    } // fi TX_EP empty
  }
}
开发者ID:dg0tm,项目名称:dv-rptr-fw,代码行数:9,代码来源:usb_func.c

示例15: usb_user_read_request

//! This function is called by the standard USB read request function when
//! the USB request is not supported. This function returns true when the
//! request is processed. This function returns false if the request is not
//! supported. In this case, a STALL handshake will be automatically
//! sent by the standard USB read request function.
//!
bool usb_user_read_request(U8 type, U8 request)
{
  Usb_read_endpoint_data(EP_CONTROL, 8); // string_type
  Usb_read_endpoint_data(EP_CONTROL, 8); // descriptor_type

  switch (request)
  {
#if( EVK1101_CTRL_PANEL_PID==EVK1101_CTRL_PANEL_DEMO_HID_MS_PID )
  case MASS_STORAGE_RESET:
    Usb_ack_setup_received_free();
    Usb_ack_control_in_ready_send();
    return true;

  case GET_MAX_LUN:
    Usb_ack_setup_received_free();
    Usb_reset_endpoint_fifo_access(EP_CONTROL);
    Usb_write_endpoint_data(EP_CONTROL, 8, get_nb_lun() - 1);
    Usb_ack_control_in_ready_send();
    while (!Is_usb_control_in_ready());

    while(!Is_usb_control_out_received());
    Usb_ack_control_out_received_free();
    ms_multiple_drive = true;
    return true;
#endif

  /*
  case HID_SET_REPORT:
    switch (descriptor_type)
    {
    case HID_REPORT_OUTPUT:
      Usb_ack_setup_received_free();
      while (!Is_usb_control_out_received());
      Usb_ack_control_out_received_free();
      Usb_ack_control_in_ready_send();
      while (!Is_usb_control_in_ready());
      return true;

    default:
      break;
    }
    break;

  case HID_SET_IDLE:
    Usb_ack_setup_received_free();
    Usb_ack_control_in_ready_send();
    while (!Is_usb_control_in_ready());
    return true;
*/

  default:
    break;
  }

  return false;
}
开发者ID:Mazetti,项目名称:asf,代码行数:62,代码来源:usb_specific_request.c


注:本文中的Usb_reset_endpoint_fifo_access函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。