Skip to content

Update to latest F4, F7 firmware and USB host/device middleware #1027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jun 4, 2020
Merged
1 change: 1 addition & 0 deletions cores/arduino/stm32/LL/stm32yyxx_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "stm32yyxx_ll_exti.h"
#include "stm32yyxx_ll_fmac.h"
#include "stm32yyxx_ll_fmc.h"
#include "stm32yyxx_ll_fmpi2c.h"
#include "stm32yyxx_ll_fsmc.h"
#include "stm32yyxx_ll_gpio.h"
#include "stm32yyxx_ll_hrtim.h"
Expand Down
12 changes: 12 additions & 0 deletions cores/arduino/stm32/LL/stm32yyxx_ll_fmpi2c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef _STM32YYXX_LL_FMPI2C_H_
#define _STM32YYXX_LL_FMPI2C_H_
/* LL raised several warnings, ignore them */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wstrict-aliasing"

#ifdef STM32F4xx
#include "stm32f4xx_ll_fmpi2c.h"
#endif
#pragma GCC diagnostic pop
#endif /* _STM32YYXX_LL_FMPI2C_H_ */
747 changes: 356 additions & 391 deletions cores/arduino/stm32/usb/cdc/usbd_cdc.c

Large diffs are not rendered by default.

19 changes: 6 additions & 13 deletions cores/arduino/stm32/usb/cdc/usbd_cdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* http://www.st.com/SLA0044
* www.st.com/SLA0044
*
******************************************************************************
*/
Expand Down Expand Up @@ -95,8 +95,7 @@ typedef struct _USBD_CDC_Itf {
int8_t (* DeInit)(void);
int8_t (* Control)(uint8_t cmd, uint8_t *pbuf, uint16_t length);
int8_t (* Receive)(uint8_t *Buf, uint32_t *Len);
int8_t (* Transferred)(void);

int8_t (* TransmitCplt)(uint8_t *Buf, uint32_t *Len, uint8_t epnum);
} USBD_CDC_ItfTypeDef;


Expand All @@ -111,8 +110,7 @@ typedef struct {

__IO uint32_t TxState;
__IO uint32_t RxState;
}
USBD_CDC_HandleTypeDef;
} USBD_CDC_HandleTypeDef;



Expand Down Expand Up @@ -140,17 +138,12 @@ extern USBD_ClassTypeDef USBD_CDC;
uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev,
USBD_CDC_ItfTypeDef *fops);

uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev,
uint8_t *pbuff,
uint16_t length);

uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev,
uint8_t *pbuff);
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
uint32_t length);

uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff);
uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev);

uint8_t USBD_CDC_ClearBuffer(USBD_HandleTypeDef *pdev);

uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev);
/**
* @}
Expand Down
43 changes: 29 additions & 14 deletions cores/arduino/stm32/usb/cdc/usbd_cdc_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* http://www.st.com/SLA0044
* www.st.com/SLA0044
*
******************************************************************************
*/
Expand Down Expand Up @@ -67,14 +67,14 @@ static int8_t USBD_CDC_Init(void);
static int8_t USBD_CDC_DeInit(void);
static int8_t USBD_CDC_Control(uint8_t cmd, uint8_t *pbuf, uint16_t length);
static int8_t USBD_CDC_Receive(uint8_t *pbuf, uint32_t *Len);
static int8_t USBD_CDC_Transferred(void);
static int8_t USBD_CDC_TransmitCplt(uint8_t *pbuf, uint32_t *Len, uint8_t epnum);

USBD_CDC_ItfTypeDef USBD_CDC_fops = {
USBD_CDC_Init,
USBD_CDC_DeInit,
USBD_CDC_Control,
USBD_CDC_Receive,
USBD_CDC_Transferred
USBD_CDC_TransmitCplt
};

USBD_CDC_LineCodingTypeDef linecoding = {
Expand All @@ -100,7 +100,7 @@ static int8_t USBD_CDC_Init(void)
receivePended = true;
USBD_CDC_SetRxBuffer(&hUSBD_Device_CDC, CDC_ReceiveQueue_ReserveBlock(&ReceiveQueue));

return (USBD_OK);
return ((int8_t)USBD_OK);
}

/**
Expand All @@ -111,7 +111,7 @@ static int8_t USBD_CDC_Init(void)
*/
static int8_t USBD_CDC_DeInit(void)
{
return (USBD_OK);
return ((int8_t)USBD_OK);
}


Expand Down Expand Up @@ -201,7 +201,7 @@ static int8_t USBD_CDC_Control(uint8_t cmd, uint8_t *pbuf, uint16_t length)
break;
}

return (USBD_OK);
return ((int8_t)USBD_OK);
}

/**
Expand All @@ -211,7 +211,7 @@ static int8_t USBD_CDC_Control(uint8_t cmd, uint8_t *pbuf, uint16_t length)
*
* @note
* This function will issue a NAK packet on any OUT packet received on
* USB endpoint untill exiting this function. If you exit this function
* USB endpoint until exiting this function. If you exit this function
* before transfer is complete on CDC interface (ie. using DMA controller)
* it will result in receiving more data while previous ones are still
* not sent.
Expand All @@ -237,16 +237,31 @@ static int8_t USBD_CDC_Receive(uint8_t *Buf, uint32_t *Len)
if (!CDC_resume_receive()) {
USBD_CDC_ClearBuffer(&hUSBD_Device_CDC);
}
return USBD_OK;
return ((int8_t)USBD_OK);
}


static int8_t USBD_CDC_Transferred(void)
/**
* @brief USBD_CDC_TransmitCplt
* Data transmited callback
*
* @note
* This function is IN transfer complete callback used to inform user that
* the submitted Data is successfully sent over USB.
*
* @param Buf: Buffer of data to be received
* @param Len: Number of data received (in bytes)
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
*/
static int8_t USBD_CDC_TransmitCplt(uint8_t *Buf, uint32_t *Len, uint8_t epnum)
{
UNUSED(Buf);
UNUSED(Len);
UNUSED(epnum);
transmitStart = 0;
CDC_TransmitQueue_CommitRead(&TransmitQueue);
CDC_continue_transmit();
return (USBD_OK);
return ((int8_t)USBD_OK);
}

void CDC_init(void)
Expand Down Expand Up @@ -284,9 +299,9 @@ bool CDC_connected()
if (transmitTime) {
transmitTime = HAL_GetTick() - transmitTime;
}
return hUSBD_Device_CDC.dev_state == USBD_STATE_CONFIGURED
&& transmitTime < USB_CDC_TRANSMIT_TIMEOUT
&& lineState;
return ((hUSBD_Device_CDC.dev_state == USBD_STATE_CONFIGURED)
&& (transmitTime < USB_CDC_TRANSMIT_TIMEOUT)
&& lineState);
}

void CDC_continue_transmit(void)
Expand All @@ -296,7 +311,7 @@ void CDC_continue_transmit(void)
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *) hUSBD_Device_CDC.pClassData;
/*
* TS: This method can be called both in the main thread
* (via USBSerial::write) and in the IRQ stream (via USBD_CDC_Transferred),
* (via USBSerial::write) and in the IRQ stream (via USBD_CDC_TransmistCplt),
* BUT the main thread cannot pass this condition while waiting for a IRQ!
* This is not possible because TxState is not zero while waiting for data
* transfer ending! The IRQ thread is uninterrupted, since its priority
Expand Down
2 changes: 1 addition & 1 deletion cores/arduino/stm32/usb/cdc/usbd_cdc_if.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* http://www.st.com/SLA0044
* www.st.com/SLA0044
*
******************************************************************************
*/
Expand Down
Loading