diff --git a/meson.build b/meson.build index dd8d2920..2662bbea 100644 --- a/meson.build +++ b/meson.build @@ -80,6 +80,7 @@ openrtx_inc = ['openrtx/include', 'platform/drivers/GPS', 'platform/drivers/SPI', 'platform/drivers/USB', + 'platform/drivers/GPIO', 'platform/drivers/tones', 'platform/drivers/baseband', 'platform/drivers/backlight', @@ -210,7 +211,6 @@ stm32f405_src = ['platform/mcu/STM32F4xx/boot/startup.cpp', 'platform/mcu/STM32F4xx/drivers/usb/usbd_ioreq.c', 'platform/mcu/STM32F4xx/drivers/usb/usbd_req.c', 'platform/mcu/STM32F4xx/drivers/usb/usbd_usr.c', - 'platform/mcu/STM32F4xx/drivers/gpio.c', 'platform/mcu/STM32F4xx/drivers/usb_vcom.c', 'platform/mcu/STM32F4xx/drivers/delays.cpp', 'platform/mcu/STM32F4xx/drivers/rtc.c', @@ -221,6 +221,7 @@ stm32f405_src = ['platform/mcu/STM32F4xx/boot/startup.cpp', 'platform/mcu/STM32F4xx/drivers/i2c_stm32.c', 'platform/mcu/STM32F4xx/drivers/adc_stm32.c', 'platform/drivers/SPI/spi_stm32.c', + 'platform/drivers/GPIO/gpio_stm32.c', 'platform/drivers/audio/stm32_dac.cpp', 'platform/drivers/audio/stm32_adc.cpp', 'platform/drivers/audio/stm32_pwm.cpp', @@ -242,7 +243,6 @@ stm32f405_def = {'STM32F405xx': '', 'HSE_VALUE':'8000000'} mk22fn512_src = ['platform/mcu/MK22FN512xxx12/boot/startup.cpp', 'platform/mcu/MK22FN512xxx12/boot/bsp.cpp', 'platform/mcu/MK22FN512xxx12/boot/libc_integration.cpp', - 'platform/mcu/MK22FN512xxx12/drivers/gpio.c', 'platform/mcu/MK22FN512xxx12/drivers/delays.cpp', 'platform/mcu/MK22FN512xxx12/drivers/I2C0.c', 'platform/mcu/MK22FN512xxx12/drivers/rng.c', @@ -254,6 +254,7 @@ mk22fn512_src = ['platform/mcu/MK22FN512xxx12/boot/startup.cpp', 'platform/mcu/MK22FN512xxx12/drivers/usb/usb_osa_bm.c', 'platform/mcu/MK22FN512xxx12/drivers/usb_vcom.c', 'platform/drivers/SPI/spi_mk22.c', + 'platform/drivers/GPIO/gpio_mk22.c', 'platform/mcu/CMSIS/Device/NXP/MK22FN512xxx12/Source/system_MK22F51212.c'] mk22fn512_inc = ['platform/mcu/CMSIS/Include', diff --git a/platform/drivers/GPIO/gpio-native.h b/platform/drivers/GPIO/gpio-native.h new file mode 100644 index 00000000..2e7a8556 --- /dev/null +++ b/platform/drivers/GPIO/gpio-native.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * Copyright (C) 2024 by Silvano Seva IU2KWO * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, see * + ***************************************************************************/ + +#ifndef GPIO_NATIVE_H +#define GPIO_NATIVE_H + +#if defined(PLATFORM_MD3x0) || defined(PLATFORM_MDUV3x0) \ + || defined(PLATFORM_MD9600) || defined(PLATFORM_MOD17) +#include +#elif defined(PLATFORM_GD77) || defined(PLATFORM_DM1801) +#include +#endif + +#endif /* GPIO_NATIVE_H */ diff --git a/platform/mcu/MK22FN512xxx12/drivers/gpio.c b/platform/drivers/GPIO/gpio_mk22.c similarity index 99% rename from platform/mcu/MK22FN512xxx12/drivers/gpio.c rename to platform/drivers/GPIO/gpio_mk22.c index 9223632c..7c615563 100644 --- a/platform/mcu/MK22FN512xxx12/drivers/gpio.c +++ b/platform/drivers/GPIO/gpio_mk22.c @@ -16,7 +16,7 @@ ***************************************************************************/ #include #include "MK22F51212.h" -#include "gpio-native.h" +#include "gpio_mk22.h" /* * MK22 GPIO management is a bit convoluted: instead of having all the registers diff --git a/platform/mcu/MK22FN512xxx12/drivers/gpio-native.h b/platform/drivers/GPIO/gpio_mk22.h similarity index 97% rename from platform/mcu/MK22FN512xxx12/drivers/gpio-native.h rename to platform/drivers/GPIO/gpio_mk22.h index f5e864c5..0c622950 100644 --- a/platform/mcu/MK22FN512xxx12/drivers/gpio-native.h +++ b/platform/drivers/GPIO/gpio_mk22.h @@ -15,8 +15,8 @@ * along with this program; if not, see * ***************************************************************************/ -#ifndef GPIO_NATIVE_H -#define GPIO_NATIVE_H +#ifndef GPIO_MK22_H +#define GPIO_MK22_H #include #include @@ -109,4 +109,4 @@ static inline uint8_t gpio_readPin(const void *port, const uint8_t pin) } #endif -#endif /* GPIO_NATIVE_H */ +#endif /* GPIO_MK22_H */ diff --git a/platform/mcu/STM32F4xx/drivers/gpio.c b/platform/drivers/GPIO/gpio_stm32.c similarity index 99% rename from platform/mcu/STM32F4xx/drivers/gpio.c rename to platform/drivers/GPIO/gpio_stm32.c index f5cc2935..71c4d13d 100644 --- a/platform/mcu/STM32F4xx/drivers/gpio.c +++ b/platform/drivers/GPIO/gpio_stm32.c @@ -17,7 +17,7 @@ #include #include "stm32f4xx.h" -#include "gpio-native.h" +#include "gpio_stm32.h" static inline void setGpioAf(GPIO_TypeDef *port, uint8_t pin, const uint8_t af) { diff --git a/platform/mcu/STM32F4xx/drivers/gpio-native.h b/platform/drivers/GPIO/gpio_stm32.h similarity index 97% rename from platform/mcu/STM32F4xx/drivers/gpio-native.h rename to platform/drivers/GPIO/gpio_stm32.h index 8bdef617..6c5fdc3f 100644 --- a/platform/mcu/STM32F4xx/drivers/gpio-native.h +++ b/platform/drivers/GPIO/gpio_stm32.h @@ -15,8 +15,8 @@ * along with this program; if not, see * ***************************************************************************/ -#ifndef GPIO_NATIVE_H -#define GPIO_NATIVE_H +#ifndef GPIO_STM32_H +#define GPIO_STM32_H #include #include @@ -111,4 +111,4 @@ static inline uint8_t gpio_readPin(const void *port, const uint8_t pin) } #endif -#endif /* GPIO_NATIVE_H */ +#endif /* GPIO_STM32_H */