stm32f4 프로세서를 이용해서 VCP 환경만들기


USB를 사용하기 때문에 케이블과 시리얼 포트가 필요없다. 때문에 앞으로 많이 사용 할 것 같다.

먼저 VCP를 사용하기 위해서는 드라이버가 필요하다.


http://www.st.com/content/st_com/en/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-utilities/stsw-stm32102.html


다운로드를 받고 설치를 하면 

VCP 포트가 활성화 된다.



https://github.com/mfauzi/STM32F4/tree/master/STM32F4%20Discovery%20Software%20Examples/STM32F4xx_USB_Example  << stm32f4 vcp 라이브러리


usbd_cdc_vcp.c 의  VCP_DataTx 를 수정해야한다. 이것 때문에 좀 고생했다.

uint16_t VCP_DataTx(uint8_t *Buf, uint32_t Len)

{

    uint32_t i;


    // Put the data into the buffer. It will be processed by the USB stack.

    for (i=0; i<Len; i++)

    {

        // Add a byte to the buffer

        APP_Rx_Buffer[APP_Rx_ptr_in] = Buf[i];


        // Update the circular buffer index

        APP_Rx_ptr_in++;


        // Loop the index if necessary

        if (APP_Rx_ptr_in == APP_RX_DATA_SIZE)

        {

            APP_Rx_ptr_in = 0;

        }

    }

    return USBD_OK;

}




 

uint8_t Buf[6] = "ABCDE";

VCP_DataTx(Buf, 6);




stm32f4 에 vcp 라이브러리 소스를 다운로드 받고 

ABCDE 를 PC에 전송한다.






PC에 정상적으로 전송되었다. 이로써 시리얼 케이블과 변환기를 연결하는 번거러움 없이 pc에 시리얼 데이터를 보낼 수 있게 되었다. 





'공부 > stm32' 카테고리의 다른 글

can통신 신호 분석  (1) 2016.07.27
stm32f4 can 통신 무작정  (2) 2016.07.25
stm32f4 클럭상태 출력하기  (0) 2016.07.25

+ Recent posts