cancel
Showing results for 
Search instead for 
Did you mean: 

Any example how to send data with USB PCD device at STM32F3?

DMårt
Lead

Hi!

I have made a large research about USB PCD device and I want to send data from my STM32 and recieve data to my STM32.

I have found PCD Firmware driver API description here at heading 31.2.

Here are these functions. I assume that I first need to call the function HAL_PCD_DevConnect at startup when my STM32 want to connect to my computer.

But what type of functions should I use then? What address should I use?

I know that there a lot of parameter how to use USB CDC with STM32F3, but I'm using STM32F3 with USB PDC. It's a different API.

void STM32_PLC_USB_Connect(PCD_HandleTypeDef *hpcd) {
	HAL_PCD_DevConnect(hpcd);
}
 
void STM32_PLC_USB_Disconnect(PCD_HandleTypeDef *hpcd) {
	HAL_PCD_DevDisconnect(hpcd);
}
 
void STM32_PLC_USB_Set_Address(PCD_HandleTypeDef *hpcd, uint8_t address) {
	HAL_PCD_SetAddress(hpcd, address);
}
 
uint32_t STM32_PLC_USB_GetRxCount(PCD_HandleTypeDef *hpcd, uint8_t ep_addr){
	return HAL_PCD_EP_GetRxCount(hpcd, ep_addr);
}
 
void STM32_PLC_USB_Transmit(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len){
	HAL_PCD_EP_Transmit(hpcd, ep_addr, pBuf, len);
}
 
void STM32_PLC_USB_Receive(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len){
	HAL_PCD_EP_Receive(hpcd, ep_addr, pBuf, len);
}
 
void STM32_PLC_USB_Open(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint16_t ep_mps, uint8_t ep_type){
	HAL_PCD_EP_Open(hpcd, ep_addr, ep_mps, ep_type);
}
 
void STM32_PLC_USB_Close(PCD_HandleTypeDef *hpcd, uint8_t ep_addr){
	HAL_PCD_EP_Close(hpcd, ep_addr);
}
 
void STM32_PLC_USB_Flush(PCD_HandleTypeDef *hpcd, uint8_t ep_addr){
	HAL_PCD_EP_Flush(hpcd, ep_addr);
}
 
void STM32_PLC_USB_Clear_Stall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr){
	HAL_PCD_EP_ClrStall(hpcd, ep_addr);
}
 
void STM32_PLC_USB_Set_Stall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr){
	HAL_PCD_EP_SetStall(hpcd, ep_addr);
}

STM32MP151AAC3 custom board with STM32-OS as operating system: https://github.com/DanielMartensson/STM32-Computer
1 ACCEPTED SOLUTION

Accepted Solutions

Hello @Daniel Mårtensson​ ,

You can refer to following examples available under STM32CubeF3 package (path: Projects\STM32373C_EVAL\Applications\USB_Device ).

You could be inspired by them.

BeST Regards,

Walid

View solution in original post

2 REPLIES 2

Hello @Daniel Mårtensson​ ,

You can refer to following examples available under STM32CubeF3 package (path: Projects\STM32373C_EVAL\Applications\USB_Device ).

You could be inspired by them.

BeST Regards,

Walid

Reminder: The PCD (peripheral control driver) is not specific to any particular device type. All devices, are implemented via the PCD