/**
 * @brief  VCP_Ctrl
 *         Manage the CDC class requests
 * @param  Cmd: Command code
 * @param  Buf: Buffer containing command data (request parameters)
 * @param  Len: Number of data to be sent (in bytes)
 * @retval Result of the opeartion (USBD_OK in all cases)
 */
static uint16_t VCP_Ctrl(uint32_t Cmd, uint8_t* Buf, uint32_t Len)
{
    LINE_CODING* plc = (LINE_CODING*)Buf;

    assert_param(Len>=sizeof(LINE_CODING));

    switch (Cmd) {
       /* Not  needed for this driver, AT modem commands */
      case SEND_ENCAPSULATED_COMMAND:
      case GET_ENCAPSULATED_RESPONSE:
         break;

      // Not needed for this driver
      case SET_COMM_FEATURE:
      case GET_COMM_FEATURE:
      case CLEAR_COMM_FEATURE:
         break;


      //Note - hw flow control on UART 1-3 and 6 only
      case SET_LINE_CODING:
         // If a callback is provided, tell the upper driver of changes in baud rate
         if (plc && (Len == sizeof (*plc))) {
             if (baudRateCb) {
                 baudRateCb(baudRateCbContext, plc->bitrate);
             }
             ust_cpy(&g_lc, plc);           //Copy into structure to save for later
         }
         break;


      case GET_LINE_CODING:
         if (plc && (Len == sizeof (*plc))) {
             ust_cpy(plc, &g_lc);
         }
         break;


      case SET_CONTROL_LINE_STATE:
         // If a callback is provided, tell the upper driver of changes in DTR/RTS state
         if (plc && (Len == sizeof (uint16_t))) {
             if (ctrlLineStateCb) {
                 ctrlLineStateCb(ctrlLineStateCbContext, *((uint16_t *)Buf));
             }
         }
         break;

      case SEND_BREAK:
         /* Not  needed for this driver */
         break;

      default:
         break;
    }

    return USBD_OK;
}
Exemple #2
0
/**
 * @brief  VCP_Ctrl
 *         Manage the CDC class requests
 * @param  Cmd: Command code
 * @param  Buf: Buffer containing command data (request parameters)
 * @param  Len: Number of data to be sent (in bytes)
 * @retval Result of the opeartion (USBD_OK in all cases)
 */
static uint16_t VCP_Ctrl(uint32_t Cmd, uint8_t* Buf, uint32_t Len)
{
   LINE_CODING* plc = (LINE_CODING*)Buf;

   assert_param(Len>=sizeof(LINE_CODING));

   switch (Cmd) {
       /* Not  needed for this driver, AT modem commands */   
      case SEND_ENCAPSULATED_COMMAND:
      case GET_ENCAPSULATED_RESPONSE:
         break;

      // Not needed for this driver
      case SET_COMM_FEATURE:                  
      case GET_COMM_FEATURE:
      case CLEAR_COMM_FEATURE:
         break;

         
      //Note - hw flow control on UART 1-3 and 6 only
      case SET_LINE_CODING: 
         if (!ust_config(DISCOVERY_COM, plc))
            return USBD_FAIL;
         
         ust_cpy(&g_lc, plc);           //Copy into structure to save for later
         break;
         
         
      case GET_LINE_CODING:
         ust_cpy(plc, &g_lc);
         break;

         
      case SET_CONTROL_LINE_STATE:
         /* Not  needed for this driver */
         //RSW - This tells how to set RTS and DTR
         break;

      case SEND_BREAK:
         /* Not  needed for this driver */
         break;

      default:
         break;
	}

   return USBD_OK;
}