Merge pull request #11198 from SteveCEvans/sce_rc2
[betaflight.git] / src / main / vcp_hal / usbd_cdc_interface.h
blob4a4d81d0ca6cc9d7f13bfcc8a1fb5ab48155831d
1 /**
2 ******************************************************************************
3 * @file USB_Device/CDC_Standalone/Inc/usbd_cdc_interface.h
4 * @author MCD Application Team
5 * @version V1.0.0
6 * @date 22-April-2016
7 * @brief Header for usbd_cdc_interface.c file.
8 ******************************************************************************
9 * @attention
11 * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics International N.V.
12 * All rights reserved.</center></h2>
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted, provided that the following conditions are met:
17 * 1. Redistribution of source code must retain the above copyright notice,
18 * this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright notice,
20 * this list of conditions and the following disclaimer in the documentation
21 * and/or other materials provided with the distribution.
22 * 3. Neither the name of STMicroelectronics nor the names of other
23 * contributors to this software may be used to endorse or promote products
24 * derived from this software without specific written permission.
25 * 4. This software, including modifications and/or derivative works of this
26 * software, must execute solely and exclusively on microcontroller or
27 * microprocessor devices manufactured by or for STMicroelectronics.
28 * 5. Redistribution and use of this software other than as permitted under
29 * this license is void and will automatically terminate your rights under
30 * this license.
32 * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
33 * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
35 * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
36 * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
37 * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
38 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
39 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
40 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
41 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
42 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
43 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 ******************************************************************************
48 /* Define to prevent recursive inclusion -------------------------------------*/
49 #ifndef __USBD_CDC_IF_H
50 #define __USBD_CDC_IF_H
52 /* Includes ------------------------------------------------------------------*/
54 #include "usbd_cdc.h"
55 #include "usbd_core.h"
56 #include "usbd_desc.h"
58 /* Definition for TIMx clock resources */
59 #define TIMusb TIM7
60 #if defined(STM32G4)
61 #define TIMx_IRQn TIM7_DAC_IRQn
62 #define TIMx_IRQHandler TIM7_DAC_IRQHandler
63 #else
64 #define TIMx_IRQn TIM7_IRQn
65 #define TIMx_IRQHandler TIM7_IRQHandler
66 #endif
67 #define TIMx_CLK_ENABLE __HAL_RCC_TIM7_CLK_ENABLE
69 /* Periodically, the state of the buffer "UserTxBuffer" is checked.
70 The period depends on CDC_POLLING_INTERVAL */
71 #define CDC_POLLING_INTERVAL 5 /* in ms. The max is 65 and the min is 1 */
73 /* Exported typef ------------------------------------------------------------*/
74 /* The following structures groups all needed parameters to be configured for the
75 ComPort. These parameters can modified on the fly by the host through CDC class
76 command class requests. */
77 typedef struct __attribute__ ((packed))
79 uint32_t bitrate;
80 uint8_t format;
81 uint8_t paritytype;
82 uint8_t datatype;
83 } LINE_CODING;
85 extern USBD_CDC_ItfTypeDef USBD_CDC_fops;
87 uint32_t CDC_Send_DATA(const uint8_t *ptrBuffer, uint32_t sendLength);
88 uint32_t CDC_Send_FreeBytes(void);
89 uint32_t CDC_Receive_DATA(uint8_t* recvBuf, uint32_t len);
90 uint32_t CDC_Receive_BytesAvailable(void);
91 uint8_t usbIsConfigured(void);
92 uint8_t usbIsConnected(void);
93 uint32_t CDC_BaudRate(void);
94 void CDC_SetCtrlLineStateCb(void (*cb)(void *context, uint16_t ctrlLineState), void *context);
95 void CDC_SetBaudRateCb(void (*cb)(void *context, uint32_t baud), void *context);
97 /* Exported macro ------------------------------------------------------------*/
98 /* Exported functions ------------------------------------------------------- */
99 #endif /* __USBD_CDC_IF_H */
101 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/