2019-07-23 05:22 PM
//main.c file
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "usb_device.h"
#include "gpio.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "usbd_cdc_if.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
/* USER CODE BEGIN PFP */
extern USBD_HandleTypeDef hUsbDeviceFS;
//extern uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len);
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USB_Device_Init();
/* USER CODE BEGIN 2 */
char dataOut[256];
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
sprintf(dataOut, "HelloWorld");
//CDC_Transmit_FS(( uint8_t * )dataOut, strlen( dataOut ));
USBD_CDC_SetTxBuffer(&hUsbDeviceFS, ( uint8_t * )dataOut, strlen( dataOut ));
USBD_CDC_TransmitPacket(&hUsbDeviceFS);
HAL_Delay(1000);
}
/* USER CODE END 3 */
}
The mentioned code should send "HelloWorld" every second over USB. I have connected both the USBs to STM32WB. I able to see one port which is used to for debugging/downloading but can't see the other one. Anyone with any idea?
2019-08-06 02:03 AM
Yes, there is an issue in the code generation with this package version.
Try to add 0x00 in the third position in the declaration of USBD_CDC_DeviceDesc in usbd__desc.c file.
2019-08-14 04:02 AM
Hi,
Why not checking the CDC example provided in STM32WBCube package first and then compare it with your generated code ?
If you use one of ST boards (ie. Nucleo or Dongle) then the application would work straight forward.
Basically what you need to check first place is:
I hope it helps.