반응형
일단.. 보드는
PA11, PA12로 연결되어 있다.
IOC 설정
이렇게 USB_DEVICE 설정하고...
이젠 모든 진행을 STM32CubeIDE 으로 진행 할 예정입니다.
1. main.c 에서 코딩은...
/* USER CODE BEGIN PV */
uint8_t buffer[64]={NULL};
/* USER CODE END PV */
int _write(int file, char *ptr, int len){
CDC_Transmit_FS(ptr, len);
return (len);
}
/* 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 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
uint8_t buf_len = strlen(buffer);
if(buf_len > 0)
{
printf("->%s",buffer);
memset (buffer, '\0', 64);
}
}
/* USER CODE END 3 */
}
2. usbd_cdc_if.c 에서
extern uint8_t buffer[64];
uint8_t len = (uint8_t)*Len;
memset(buffer, '\0', 64); // clear the buffer
memcpy(buffer, Buf, len); // copy the data to the buffer
memset(Buf, '\0', len); // clear the Buf also
반응형
'공부 > STM32F4' 카테고리의 다른 글
19. [STM32F429] ADC Polling (0) | 2021.09.15 |
---|---|
18. [STM32F429] SPI Master 와 Slave (0) | 2021.09.08 |
stm32cubeIDE (0) | 2020.10.05 |
17. [STM32F429] A4988 스텝모터 구동 (1) | 2020.06.01 |
mpu_arm7.h 에서 에러 (0) | 2020.05.22 |