Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
6adcf7bb
Commit
6adcf7bb
authored
May 03, 2017
by
Sylvain Pelissier
Committed by
Damien George
Jun 07, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stmhal: Pass USB handler as parameter to allow more than one USB handler
parent
7ecfbb82
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
24 deletions
+24
-24
stmhal/usbd_cdc_interface.c
stmhal/usbd_cdc_interface.c
+8
-8
stmhal/usbd_hid_interface.c
stmhal/usbd_hid_interface.c
+8
-8
stmhal/usbdev/class/inc/usbd_cdc_msc_hid.h
stmhal/usbdev/class/inc/usbd_cdc_msc_hid.h
+4
-4
stmhal/usbdev/class/src/usbd_cdc_msc_hid.c
stmhal/usbdev/class/src/usbd_cdc_msc_hid.c
+4
-4
No files found.
stmhal/usbd_cdc_interface.c
View file @
6adcf7bb
...
...
@@ -82,10 +82,10 @@ static uint8_t UserTxBufPtrWaitCount = 0; // used to implement a timeout waiting
static
uint8_t
UserTxNeedEmptyPacket
=
0
;
// used to flush the USB IN endpoint if the last packet was exactly the endpoint packet size
/* Private function prototypes -----------------------------------------------*/
static
int8_t
CDC_Itf_Init
(
void
);
static
int8_t
CDC_Itf_Init
(
USBD_HandleTypeDef
*
pdev
);
static
int8_t
CDC_Itf_DeInit
(
void
);
static
int8_t
CDC_Itf_Control
(
uint8_t
cmd
,
uint8_t
*
pbuf
,
uint16_t
length
);
static
int8_t
CDC_Itf_Receive
(
uint8_t
*
pbuf
,
uint32_t
*
Len
);
static
int8_t
CDC_Itf_Receive
(
USBD_HandleTypeDef
*
pdev
,
uint8_t
*
pbuf
,
uint32_t
*
Len
);
const
USBD_CDC_ItfTypeDef
USBD_CDC_fops
=
{
CDC_Itf_Init
,
...
...
@@ -102,7 +102,7 @@ const USBD_CDC_ItfTypeDef USBD_CDC_fops = {
* @param None
* @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
*/
static
int8_t
CDC_Itf_Init
(
void
)
static
int8_t
CDC_Itf_Init
(
USBD_HandleTypeDef
*
pdev
)
{
#if 0
/*##-1- Configure the UART peripheral ######################################*/
...
...
@@ -141,8 +141,8 @@ static int8_t CDC_Itf_Init(void)
#endif
/*##-5- Set Application Buffers ############################################*/
USBD_CDC_SetTxBuffer
(
&
hUSBDDevice
,
UserTxBuffer
,
0
);
USBD_CDC_SetRxBuffer
(
&
hUSBDDevice
,
cdc_rx_packet_buf
);
USBD_CDC_SetTxBuffer
(
pdev
,
UserTxBuffer
,
0
);
USBD_CDC_SetRxBuffer
(
pdev
,
cdc_rx_packet_buf
);
cdc_rx_buf_put
=
0
;
cdc_rx_buf_get
=
0
;
...
...
@@ -317,7 +317,7 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) {
* @note The buffer we are passed here is just cdc_rx_packet_buf, so we are
* free to modify it.
*/
static
int8_t
CDC_Itf_Receive
(
uint8_t
*
Buf
,
uint32_t
*
Len
)
{
static
int8_t
CDC_Itf_Receive
(
USBD_HandleTypeDef
*
pdev
,
uint8_t
*
Buf
,
uint32_t
*
Len
)
{
#if 0
// this sends the data over the UART using DMA
HAL_UART_Transmit_DMA(&UartHandle, Buf, *Len);
...
...
@@ -339,8 +339,8 @@ static int8_t CDC_Itf_Receive(uint8_t* Buf, uint32_t *Len) {
}
// initiate next USB packet transfer
USBD_CDC_SetRxBuffer
(
&
hUSBDDevice
,
cdc_rx_packet_buf
);
USBD_CDC_ReceivePacket
(
&
hUSBDDevice
);
USBD_CDC_SetRxBuffer
(
pdev
,
cdc_rx_packet_buf
);
USBD_CDC_ReceivePacket
(
pdev
);
return
USBD_OK
;
}
...
...
stmhal/usbd_hid_interface.c
View file @
6adcf7bb
...
...
@@ -51,8 +51,8 @@ static uint32_t last_read_len = 0; // length of last read
static
int8_t
current_write_buffer
=
0
;
// which buffer to write to
/* Private function prototypes -----------------------------------------------*/
static
int8_t
HID_Itf_Init
(
void
);
static
int8_t
HID_Itf_Receive
(
uint8_t
*
pbuf
,
uint32_t
Len
);
static
int8_t
HID_Itf_Init
(
USBD_HandleTypeDef
*
pdev
);
static
int8_t
HID_Itf_Receive
(
USBD_HandleTypeDef
*
pdev
,
uint8_t
*
pbuf
,
uint32_t
Len
);
const
USBD_HID_ItfTypeDef
USBD_HID_fops
=
{
HID_Itf_Init
,
...
...
@@ -65,12 +65,12 @@ const USBD_HID_ItfTypeDef USBD_HID_fops = {
* @param None
* @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
*/
static
int8_t
HID_Itf_Init
(
void
)
static
int8_t
HID_Itf_Init
(
USBD_HandleTypeDef
*
pdev
)
{
current_read_buffer
=
0
;
last_read_len
=
0
;
current_write_buffer
=
0
;
USBD_HID_SetRxBuffer
(
&
hUSBDDevice
,
buffer
[
current_write_buffer
]);
USBD_HID_SetRxBuffer
(
pdev
,
buffer
[
current_write_buffer
]);
return
USBD_OK
;
}
...
...
@@ -83,14 +83,14 @@ static int8_t HID_Itf_Init(void)
* @note The buffer we are passed here is just UserRxBuffer, so we are
* free to modify it.
*/
static
int8_t
HID_Itf_Receive
(
uint8_t
*
Buf
,
uint32_t
Len
)
{
static
int8_t
HID_Itf_Receive
(
USBD_HandleTypeDef
*
pdev
,
uint8_t
*
Buf
,
uint32_t
Len
)
{
current_write_buffer
=
!
current_write_buffer
;
last_read_len
=
Len
;
// initiate next USB packet transfer, to append to existing data in buffer
USBD_HID_SetRxBuffer
(
&
hUSBDDevice
,
buffer
[
current_write_buffer
]);
USBD_HID_ReceivePacket
(
&
hUSBDDevice
);
USBD_HID_SetRxBuffer
(
pdev
,
buffer
[
current_write_buffer
]);
USBD_HID_ReceivePacket
(
pdev
);
// Set NAK to indicate we need to process read buffer
USBD_HID_SetNAK
(
&
hUSBDDevice
);
USBD_HID_SetNAK
(
pdev
);
return
USBD_OK
;
}
...
...
stmhal/usbdev/class/inc/usbd_cdc_msc_hid.h
View file @
6adcf7bb
...
...
@@ -28,10 +28,10 @@ typedef struct {
}
USBD_CDC_LineCodingTypeDef
;
typedef
struct
_USBD_CDC_Itf
{
int8_t
(
*
Init
)
(
void
);
int8_t
(
*
Init
)
(
USBD_HandleTypeDef
*
pdev
);
int8_t
(
*
DeInit
)
(
void
);
int8_t
(
*
Control
)
(
uint8_t
,
uint8_t
*
,
uint16_t
);
int8_t
(
*
Receive
)
(
uint8_t
*
,
uint32_t
*
);
int8_t
(
*
Receive
)
(
USBD_HandleTypeDef
*
pdev
,
uint8_t
*
,
uint32_t
*
);
}
USBD_CDC_ItfTypeDef
;
typedef
struct
{
...
...
@@ -48,8 +48,8 @@ typedef struct {
}
USBD_CDC_HandleTypeDef
;
typedef
struct
_USBD_HID_Itf
{
int8_t
(
*
Init
)
(
void
);
int8_t
(
*
Receive
)(
uint8_t
*
,
uint32_t
);
int8_t
(
*
Init
)
(
USBD_HandleTypeDef
*
pdev
);
int8_t
(
*
Receive
)(
USBD_HandleTypeDef
*
pdev
,
uint8_t
*
,
uint32_t
);
}
USBD_HID_ItfTypeDef
;
typedef
struct
_USBD_STORAGE
{
...
...
stmhal/usbdev/class/src/usbd_cdc_msc_hid.c
View file @
6adcf7bb
...
...
@@ -669,7 +669,7 @@ static uint8_t USBD_CDC_MSC_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) {
CDC_CMD_PACKET_SIZE
);
// Init physical Interface components
CDC_fops
->
Init
();
CDC_fops
->
Init
(
pdev
);
// Init Xfer states
CDC_ClassData
.
TxState
=
0
;
...
...
@@ -724,7 +724,7 @@ static uint8_t USBD_CDC_MSC_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) {
USBD_EP_TYPE_INTR
,
mps_out
);
HID_fops
->
Init
();
HID_fops
->
Init
(
pdev
);
// Prepare Out endpoint to receive next packet
USBD_LL_PrepareReceive
(
pdev
,
hid_out_ep
,
HID_ClassData
.
RxBuffer
,
mps_out
);
...
...
@@ -963,7 +963,7 @@ static uint8_t USBD_CDC_MSC_HID_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
/* USB data will be immediately processed, this allow next USB traffic being
NAKed till the end of the application Xfer */
CDC_fops
->
Receive
(
CDC_ClassData
.
RxBuffer
,
&
CDC_ClassData
.
RxLength
);
CDC_fops
->
Receive
(
pdev
,
CDC_ClassData
.
RxBuffer
,
&
CDC_ClassData
.
RxLength
);
return
USBD_OK
;
}
else
if
((
usbd_mode
&
USBD_MODE_MSC
)
&&
epnum
==
(
MSC_OUT_EP
&
0x7f
))
{
...
...
@@ -971,7 +971,7 @@ static uint8_t USBD_CDC_MSC_HID_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
return
USBD_OK
;
}
else
if
((
usbd_mode
&
USBD_MODE_HID
)
&&
epnum
==
(
hid_out_ep
&
0x7f
))
{
HID_ClassData
.
RxLength
=
USBD_LL_GetRxDataSize
(
pdev
,
epnum
);
HID_fops
->
Receive
(
HID_ClassData
.
RxBuffer
,
HID_ClassData
.
RxLength
);
HID_fops
->
Receive
(
pdev
,
HID_ClassData
.
RxBuffer
,
HID_ClassData
.
RxLength
);
}
return
USBD_OK
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment