diff options
author | Sylvain Pelissier <sylvain.pelissier@gmail.com> | 2017-05-03 10:55:02 +0200 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-06-07 15:50:26 +1000 |
commit | 6adcf7bb8288fb6fd0e131f081735dd5cff16b86 (patch) | |
tree | 2b2d58f8190c369748a6ad75a14a9a2885b0d281 /stmhal/usbd_hid_interface.c | |
parent | 7ecfbb8267c050ba5bd5bdf7becfb055f53a4f80 (diff) | |
download | micropython-6adcf7bb8288fb6fd0e131f081735dd5cff16b86.tar.gz micropython-6adcf7bb8288fb6fd0e131f081735dd5cff16b86.zip |
stmhal: Pass USB handler as parameter to allow more than one USB handler
Diffstat (limited to 'stmhal/usbd_hid_interface.c')
-rw-r--r-- | stmhal/usbd_hid_interface.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/stmhal/usbd_hid_interface.c b/stmhal/usbd_hid_interface.c index 7a420c3306..9eee451f3c 100644 --- a/stmhal/usbd_hid_interface.c +++ b/stmhal/usbd_hid_interface.c @@ -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; } |