From 2ea5483a6f76f3cfbdf0cb5b1a69747a2cf52def Mon Sep 17 00:00:00 2001 From: Martin Loren <37680207+martinloren@users.noreply.github.com> Date: Wed, 19 Sep 2018 10:01:36 +0800 Subject: [PATCH 1/6] Update pgmspace.h --- STM32/cores/arduino/avr/pgmspace.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/STM32/cores/arduino/avr/pgmspace.h b/STM32/cores/arduino/avr/pgmspace.h index 9b344c9b..b1679f5f 100644 --- a/STM32/cores/arduino/avr/pgmspace.h +++ b/STM32/cores/arduino/avr/pgmspace.h @@ -41,4 +41,24 @@ typedef uint32_t prog_uint32_t; #define pgm_read_dword_far(addr) pgm_read_dword(addr) #define pgm_read_float_far(addr) pgm_read_float(addr) +#define memcmp_P memcmp +#define memccpy_P memccpy +#define memmem_P memmem +#define memcpy_P memcpy +#define strcpy_P strcpy +#define strncpy_P strncpy +#define strcat_P strcat +#define strncat_P strncat +#define strcmp_P strcmp +#define strncmp_P strncmp +#define strcasecmp_P strcasecmp +#define strncasecmp_P strncasecmp +#define strlen_P strlen +#define strnlen_P strnlen +#define strstr_P strstr +#define printf_P printf +#define sprintf_P sprintf +#define snprintf_P snprintf +#define vsnprintf_P vsnprintf + #endif From 3ccd6cc206b748c8b122a585af2e46b2e2b352ff Mon Sep 17 00:00:00 2001 From: Martin Loren <37680207+martinloren@users.noreply.github.com> Date: Fri, 21 Sep 2018 11:06:37 +0800 Subject: [PATCH 2/6] Update stm32_dma_F2F4F7.h Added configurations for ADC1,2,3. --- STM32/libraries/stm32_dma/src/stm32_dma_F2F4F7.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/STM32/libraries/stm32_dma/src/stm32_dma_F2F4F7.h b/STM32/libraries/stm32_dma/src/stm32_dma_F2F4F7.h index 4bc9011a..98bcc091 100644 --- a/STM32/libraries/stm32_dma/src/stm32_dma_F2F4F7.h +++ b/STM32/libraries/stm32_dma/src/stm32_dma_F2F4F7.h @@ -26,6 +26,15 @@ const dma_request_to_instance_t dmaRequestToStream[] = { {SPI2, SPI_TX, DMA1_Stream4, DMA_CHANNEL_0, 4, DMA1_Stream4_IRQn}, {SPI2, SPI_RX, DMA1_Stream3, DMA_CHANNEL_0, 3, DMA1_Stream3_IRQn}, + {ADC1, ADC_DMA, DMA2_Stream0, DMA_CHANNEL_0, 0 + 8, DMA2_Stream0_IRQn}, + {ADC1, ADC_DMA, DMA2_Stream4, DMA_CHANNEL_0, 4 + 8, DMA2_Stream4_IRQn}, + + {ADC2, ADC_DMA, DMA2_Stream2, DMA_CHANNEL_1, 2 + 8, DMA2_Stream2_IRQn}, + {ADC2, ADC_DMA, DMA2_Stream3, DMA_CHANNEL_1, 3 + 8, DMA2_Stream3_IRQn}, + + {ADC3, ADC_DMA, DMA2_Stream0, DMA_CHANNEL_2, 0 + 8, DMA2_Stream0_IRQn}, + {ADC3, ADC_DMA, DMA2_Stream1, DMA_CHANNEL_2, 1 + 8, DMA2_Stream1_IRQn}, + #ifdef SPI3 {SPI3, SPI_TX, DMA1_Stream5, DMA_CHANNEL_0, 5, DMA1_Stream5_IRQn}, {SPI3, SPI_RX, DMA1_Stream0, DMA_CHANNEL_0, 0, DMA1_Stream0_IRQn}, From cd45f60055fc41cb8e97e280117c66601032f295 Mon Sep 17 00:00:00 2001 From: Martin Loren <37680207+martinloren@users.noreply.github.com> Date: Sat, 22 Sep 2018 11:16:11 +0800 Subject: [PATCH 3/6] Update stm32_dma.h --- STM32/libraries/stm32_dma/src/stm32_dma.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/STM32/libraries/stm32_dma/src/stm32_dma.h b/STM32/libraries/stm32_dma/src/stm32_dma.h index 6c00a103..5683fd33 100644 --- a/STM32/libraries/stm32_dma/src/stm32_dma.h +++ b/STM32/libraries/stm32_dma/src/stm32_dma.h @@ -26,7 +26,7 @@ #include "stdbool.h" typedef enum { - SPI_TX, SPI_RX, SDIO_RXTX + SPI_TX, SPI_RX, SDIO_RXTX, ADC_DMA } dmaRequest; From 05fd52ee76aac8233f6f0ca5011c4832a933564b Mon Sep 17 00:00:00 2001 From: Martin Loren <37680207+martinloren@users.noreply.github.com> Date: Tue, 29 Jan 2019 09:36:34 +0800 Subject: [PATCH 4/6] Update usbd_core.c Added Vendor Commands management --- STM32/cores/arduino/usb/usbd_core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/STM32/cores/arduino/usb/usbd_core.c b/STM32/cores/arduino/usb/usbd_core.c index ff3ed446..e92153a8 100644 --- a/STM32/cores/arduino/usb/usbd_core.c +++ b/STM32/cores/arduino/usb/usbd_core.c @@ -28,6 +28,9 @@ /* Includes ------------------------------------------------------------------*/ #include "usbd_core.h" +//Handle Vendor Commands on EP0 +__weak void VendorCommand(USBD_SetupReqTypedef* req) { } + /** @addtogroup STM32_USBD_DEVICE_LIBRARY * @{ */ @@ -267,6 +270,15 @@ USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup) pdev->ep0_state = USBD_EP0_SETUP; pdev->ep0_data_len = pdev->request.wLength; + + //Handle Vendor Command with Request Code 0x40 + if ((pdev->request.bmRequest & 0x40) == 0x40) { + VendorCommand(&pdev->request); //Get Vendor setup request (no data) + //If there is data len then must take data or Setup will fail + //Send ACK if no other trasmission required (so dont make Host to fail request) + if (pdev->request.wLength == 0) USBD_CtlSendStatus(pdev); //ACK by sending 0 len packet + return USBD_OK; + } switch (pdev->request.bmRequest & 0x1F) { From 5b7e6f2e0b2eac7c103c33678f942336b0615df9 Mon Sep 17 00:00:00 2001 From: Martin Loren <37680207+martinloren@users.noreply.github.com> Date: Tue, 29 Jan 2019 09:43:19 +0800 Subject: [PATCH 5/6] Update stm32_dma_F2F4F7.h --- STM32/libraries/stm32_dma/src/stm32_dma_F2F4F7.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/STM32/libraries/stm32_dma/src/stm32_dma_F2F4F7.h b/STM32/libraries/stm32_dma/src/stm32_dma_F2F4F7.h index 98bcc091..3c0b92b5 100644 --- a/STM32/libraries/stm32_dma/src/stm32_dma_F2F4F7.h +++ b/STM32/libraries/stm32_dma/src/stm32_dma_F2F4F7.h @@ -28,13 +28,14 @@ const dma_request_to_instance_t dmaRequestToStream[] = { {ADC1, ADC_DMA, DMA2_Stream0, DMA_CHANNEL_0, 0 + 8, DMA2_Stream0_IRQn}, {ADC1, ADC_DMA, DMA2_Stream4, DMA_CHANNEL_0, 4 + 8, DMA2_Stream4_IRQn}, - +#ifdef ADC2 {ADC2, ADC_DMA, DMA2_Stream2, DMA_CHANNEL_1, 2 + 8, DMA2_Stream2_IRQn}, {ADC2, ADC_DMA, DMA2_Stream3, DMA_CHANNEL_1, 3 + 8, DMA2_Stream3_IRQn}, - +#endif +#ifdef ADC3 {ADC3, ADC_DMA, DMA2_Stream0, DMA_CHANNEL_2, 0 + 8, DMA2_Stream0_IRQn}, {ADC3, ADC_DMA, DMA2_Stream1, DMA_CHANNEL_2, 1 + 8, DMA2_Stream1_IRQn}, - +#endif #ifdef SPI3 {SPI3, SPI_TX, DMA1_Stream5, DMA_CHANNEL_0, 5, DMA1_Stream5_IRQn}, {SPI3, SPI_RX, DMA1_Stream0, DMA_CHANNEL_0, 0, DMA1_Stream0_IRQn}, From db3fe5c483ac2aa18990043fd89b046a734bb09d Mon Sep 17 00:00:00 2001 From: Martin Loren <37680207+martinloren@users.noreply.github.com> Date: Tue, 29 Jan 2019 19:08:01 +0800 Subject: [PATCH 6/6] Update stm32_dma_F0F1F3L1.h Added DMA configuration for ADC1 (ADC2 use the same DMA of ADC1 --- STM32/libraries/stm32_dma/src/stm32_dma_F0F1F3L1.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/STM32/libraries/stm32_dma/src/stm32_dma_F0F1F3L1.h b/STM32/libraries/stm32_dma/src/stm32_dma_F0F1F3L1.h index 0103bf8a..949c74a0 100644 --- a/STM32/libraries/stm32_dma/src/stm32_dma_F0F1F3L1.h +++ b/STM32/libraries/stm32_dma/src/stm32_dma_F0F1F3L1.h @@ -5,6 +5,7 @@ // F3 RM0316 http://www.st.com/content/ccc/resource/technical/document/reference_manual/4a/19/6e/18/9d/92/43/32/DM00043574.pdf/files/DM00043574.pdf/jcr:content/translations/en.DM00043574.pdf#page=272 // L1 RM0038 http://www.st.com/content/ccc/resource/technical/document/reference_manual/cc/f9/93/b2/f0/82/42/57/CD00240193.pdf/files/CD00240193.pdf/jcr:content/translations/en.CD00240193.pdf#page=255 +//These works just for L0 and F0, not for F1 (cannot compile) -> TO CHECK #ifndef DMA1_Channel2_IRQn #define DMA1_Channel2_IRQn DMA1_Channel2_3_IRQn #define DMA1_Channel3_IRQn DMA1_Channel2_3_IRQn @@ -30,6 +31,8 @@ const dma_request_to_instance_t dmaRequestToStream[] = { {SPI1, SPI_TX, DMA1_Channel3, 3, DMA1_Channel3_IRQn}, {SPI1, SPI_RX, DMA1_Channel2, 2, DMA1_Channel2_IRQn}, + + {ADC1, ADC_DMA, DMA1_Channel1, 1, DMA1_Channel1_IRQn}, #ifdef SPI2 {SPI2, SPI_TX, DMA1_Channel5, 5, DMA1_Channel5_IRQn},