From 5bd04984242e4fd9481dda8b2f52e09bcc074bc3 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Sameti Date: Mon, 25 Jul 2022 19:45:46 +0430 Subject: Add PlatformIO support --- demo/cdc_loop.c | 2 +- demo/cdc_startup.c | 2 +- inc/stm32_compat.h | 59 ++++++++++++++++++++++++++++++++++++++++++++++ library.json | 18 ++++++++++++++ src/usbd_stm32f103_devfs.c | 2 +- src/usbd_stm32f105_otgfs.c | 2 +- src/usbd_stm32f429_otgfs.c | 2 +- src/usbd_stm32f429_otghs.c | 2 +- src/usbd_stm32f446_otgfs.c | 2 +- src/usbd_stm32f446_otghs.c | 2 +- src/usbd_stm32h743_otgfs.c | 2 +- src/usbd_stm32l052_devfs.c | 2 +- src/usbd_stm32l100_devfs.c | 2 +- src/usbd_stm32l433_devfs.c | 2 +- src/usbd_stm32l476_otgfs.c | 2 +- src/usbd_stm32wb55_devfs.c | 2 +- 16 files changed, 91 insertions(+), 14 deletions(-) create mode 100644 inc/stm32_compat.h create mode 100644 library.json diff --git a/demo/cdc_loop.c b/demo/cdc_loop.c index cea9171..986a7ba 100644 --- a/demo/cdc_loop.c +++ b/demo/cdc_loop.c @@ -16,7 +16,7 @@ #include #include #include -#include "stm32.h" +#include "stm32_compat.h" #include "usb.h" #include "usb_cdc.h" #include "usb_hid.h" diff --git a/demo/cdc_startup.c b/demo/cdc_startup.c index 68ce0ae..612b64f 100644 --- a/demo/cdc_startup.c +++ b/demo/cdc_startup.c @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "stm32.h" +#include "stm32_compat.h" static void cdc_init_rcc (void) { #if defined(STM32L0) diff --git a/inc/stm32_compat.h b/inc/stm32_compat.h new file mode 100644 index 0000000..1564567 --- /dev/null +++ b/inc/stm32_compat.h @@ -0,0 +1,59 @@ +#ifndef _STM32_COMPAT_H_ +#define _STM32_COMPAT_H_ + +#ifndef PLATFORMIO + +#include + +#else // PLATFORMIO +/* modify bitfield */ +#define _BMD(reg, msk, val) (reg) = (((reg) & ~(msk)) | (val)) +/* set bitfield */ +#define _BST(reg, bits) (reg) = ((reg) | (bits)) +/* clear bitfield */ +#define _BCL(reg, bits) (reg) = ((reg) & ~(bits)) +/* wait until bitfield set */ +#define _WBS(reg, bits) while(((reg) & (bits)) == 0) +/* wait until bitfield clear */ +#define _WBC(reg, bits) while(((reg) & (bits)) != 0) +/* wait for bitfield value */ +#define _WVL(reg, msk, val) while(((reg) & (msk)) != (val)) +/* bit value */ +#define _BV(bit) (0x01 << (bit)) + +#if defined(STM32F0xx) + #include +#elif defined(STM32F1xx) + #include +#elif defined(STM32F2xx) + #include +#elif defined(STM32F3xx) + #include +#elif defined(STM32F4xx) + #include +#elif defined(STM32F7xx) + #include +#elif defined(STM32H7xx) + #include +#elif defined(STM32L0xx) + #include +#elif defined(STM32L1xx) + #include +#elif defined(STM32L4xx) + #include +#elif defined(STM32L5xx) + #include +#elif defined(STM32G0xx) + #include +#elif defined(STM32G4xx) + #include +#elif defined(STM32WBxx) + #include +#else + #error "STM32 family not defined" +#endif + +#endif // PLATFORMIO + + +#endif // _STM32_COMPAT_H_ \ No newline at end of file diff --git a/library.json b/library.json new file mode 100644 index 0000000..dfa2fa3 --- /dev/null +++ b/library.json @@ -0,0 +1,18 @@ +{ + "name": "libusb_stm32", + "description": "Lightweight USB Device Stack", + "version": "0.1.0", + "keywords": "stm32, usb", + "authors": { + "name": "Dmitry Filimonchuk", + "email": "dmitrystu@gmail.com" + }, + "repository": { + "type": "git", + "url": "https://github.com/dmitrystu/libusb_stm32.git" + }, + "frameworks": [ "cmsis", "stm32cube" ], + "platforms": [ "ststm32" ], + "headers": ["stm32_compat.h", "usb.h"], + "build": { "includeDir": "inc" } +} diff --git a/src/usbd_stm32f103_devfs.c b/src/usbd_stm32f103_devfs.c index 8601994..2e81435 100644 --- a/src/usbd_stm32f103_devfs.c +++ b/src/usbd_stm32f103_devfs.c @@ -16,7 +16,7 @@ #include #include -#include "stm32.h" +#include "stm32_compat.h" #include "usb.h" #if defined(USBD_STM32F103) diff --git a/src/usbd_stm32f105_otgfs.c b/src/usbd_stm32f105_otgfs.c index 90ddf09..e3c0f4b 100644 --- a/src/usbd_stm32f105_otgfs.c +++ b/src/usbd_stm32f105_otgfs.c @@ -16,7 +16,7 @@ #include #include -#include "stm32.h" +#include "stm32_compat.h" #include "usb.h" #if defined(USBD_STM32F105) diff --git a/src/usbd_stm32f429_otgfs.c b/src/usbd_stm32f429_otgfs.c index ea1b3b4..059a541 100644 --- a/src/usbd_stm32f429_otgfs.c +++ b/src/usbd_stm32f429_otgfs.c @@ -15,7 +15,7 @@ #include #include -#include "stm32.h" +#include "stm32_compat.h" #include "usb.h" #if defined(USBD_STM32F429FS) diff --git a/src/usbd_stm32f429_otghs.c b/src/usbd_stm32f429_otghs.c index fa0b1d6..996c701 100644 --- a/src/usbd_stm32f429_otghs.c +++ b/src/usbd_stm32f429_otghs.c @@ -15,7 +15,7 @@ #include #include -#include "stm32.h" +#include "stm32_compat.h" #include "usb.h" #if defined(USBD_STM32F429HS) diff --git a/src/usbd_stm32f446_otgfs.c b/src/usbd_stm32f446_otgfs.c index 32a78e4..ea1d586 100644 --- a/src/usbd_stm32f446_otgfs.c +++ b/src/usbd_stm32f446_otgfs.c @@ -15,7 +15,7 @@ #include #include -#include "stm32.h" +#include "stm32_compat.h" #include "usb.h" #if defined(USBD_STM32F446FS) diff --git a/src/usbd_stm32f446_otghs.c b/src/usbd_stm32f446_otghs.c index 2473286..4e4a8b3 100644 --- a/src/usbd_stm32f446_otghs.c +++ b/src/usbd_stm32f446_otghs.c @@ -15,7 +15,7 @@ #include #include -#include "stm32.h" +#include "stm32_compat.h" #include "usb.h" #if defined(USBD_STM32F446HS) diff --git a/src/usbd_stm32h743_otgfs.c b/src/usbd_stm32h743_otgfs.c index b5de2c8..7ea6236 100644 --- a/src/usbd_stm32h743_otgfs.c +++ b/src/usbd_stm32h743_otgfs.c @@ -15,7 +15,7 @@ #include #include -#include "stm32.h" +#include "stm32_compat.h" #include "usb.h" #if defined(USBD_STM32H743FS) diff --git a/src/usbd_stm32l052_devfs.c b/src/usbd_stm32l052_devfs.c index b6b3689..e2ba11e 100644 --- a/src/usbd_stm32l052_devfs.c +++ b/src/usbd_stm32l052_devfs.c @@ -15,7 +15,7 @@ #include #include -#include "stm32.h" +#include "stm32_compat.h" #include "usb.h" #if defined(USBD_STM32L052) diff --git a/src/usbd_stm32l100_devfs.c b/src/usbd_stm32l100_devfs.c index 6764bfb..77488ed 100644 --- a/src/usbd_stm32l100_devfs.c +++ b/src/usbd_stm32l100_devfs.c @@ -15,7 +15,7 @@ #include #include -#include "stm32.h" +#include "stm32_compat.h" #include "usb.h" #if defined(USBD_STM32L100) diff --git a/src/usbd_stm32l433_devfs.c b/src/usbd_stm32l433_devfs.c index 171ee24..133624c 100644 --- a/src/usbd_stm32l433_devfs.c +++ b/src/usbd_stm32l433_devfs.c @@ -15,7 +15,7 @@ #include #include -#include "stm32.h" +#include "stm32_compat.h" #include "usb.h" #if defined(USBD_STM32L433) diff --git a/src/usbd_stm32l476_otgfs.c b/src/usbd_stm32l476_otgfs.c index 7aa54dc..66294bc 100644 --- a/src/usbd_stm32l476_otgfs.c +++ b/src/usbd_stm32l476_otgfs.c @@ -15,7 +15,7 @@ #include #include -#include "stm32.h" +#include "stm32_compat.h" #include "usb.h" #if defined(USBD_STM32L476) diff --git a/src/usbd_stm32wb55_devfs.c b/src/usbd_stm32wb55_devfs.c index fd1142b..07a50b0 100644 --- a/src/usbd_stm32wb55_devfs.c +++ b/src/usbd_stm32wb55_devfs.c @@ -15,7 +15,7 @@ #include #include -#include "stm32.h" +#include "stm32_compat.h" #include "usb.h" #if defined(USBD_STM32WB55) -- cgit v1.2.3