Working with CDC
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
#include "dma.h"
|
||||
#include "i2c.h"
|
||||
#include "tim.h"
|
||||
#include "usart.h"
|
||||
#include "usb_device.h"
|
||||
#include "gpio.h"
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
@@ -30,6 +30,9 @@
|
||||
#include "ws2812_effect.h"
|
||||
#include "ds1307.h"
|
||||
#include "clock.h"
|
||||
|
||||
#include "usbd_cdc_if.h"
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
@@ -60,11 +63,28 @@ extern uint8_t UART_RxBuf[6];
|
||||
void SystemClock_Config(void);
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
void USB_DEVICE_MasterHardReset(void);
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Private user code ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
void USB_DEVICE_MasterHardReset(void){
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_12;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_12,0);
|
||||
|
||||
HAL_Delay(1000);
|
||||
}
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/**
|
||||
@@ -99,7 +119,9 @@ int main(void)
|
||||
MX_DMA_Init();
|
||||
MX_TIM2_Init();
|
||||
MX_I2C1_Init();
|
||||
MX_USART2_UART_Init();
|
||||
|
||||
USB_DEVICE_MasterHardReset();
|
||||
MX_USB_DEVICE_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
HAL_TIM_Base_Start(&htim2);
|
||||
@@ -144,7 +166,14 @@ uint8_t UART_Buff[] = "Hello World\n";
|
||||
|
||||
// ws_Effect_RoudTheClock();
|
||||
|
||||
HAL_UART_Receive_IT(&huart2, UART_RxBuf, sizeof(UART_RxBuf));
|
||||
|
||||
|
||||
//CDC_Transmit_FS(UART_Buff, sizeof(UART_Buff));
|
||||
|
||||
RxCpltCallback();
|
||||
|
||||
|
||||
//HAL_UART_Receive_IT(&huart2, UART_RxBuf, sizeof(UART_RxBuf));
|
||||
|
||||
HAL_GPIO_TogglePin(LED_Green_GPIO_Port, LED_Green_Pin);
|
||||
|
||||
@@ -164,6 +193,7 @@ void SystemClock_Config(void)
|
||||
{
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
|
||||
|
||||
/** Initializes the RCC Oscillators according to the specified parameters
|
||||
* in the RCC_OscInitTypeDef structure.
|
||||
@@ -193,6 +223,12 @@ void SystemClock_Config(void)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
|
||||
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5;
|
||||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 4 */
|
||||
|
||||
Reference in New Issue
Block a user