diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index acbe9a9cc3..1b1d8fd634 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -26,7 +26,7 @@ #include "Arduino.h" #include "HardwareSerial.h" -#if defined(HAL_UART_MODULE_ENABLED) +#if defined(HAL_UART_MODULE_ENABLED) && !defined(HAL_UART_MODULE_ONLY) #if defined(HAVE_HWSERIAL1) || defined(HAVE_HWSERIAL2) || defined(HAVE_HWSERIAL3) ||\ defined(HAVE_HWSERIAL4) || defined(HAVE_HWSERIAL5) || defined(HAVE_HWSERIAL6) ||\ defined(HAVE_HWSERIAL7) || defined(HAVE_HWSERIAL8) || defined(HAVE_HWSERIAL9) ||\ @@ -528,4 +528,4 @@ void HardwareSerial::enableHalfDuplexRx(void) } } -#endif // HAL_UART_MODULE_ENABLED +#endif // HAL_UART_MODULE_ENABLED && !HAL_UART_MODULE_ONLY diff --git a/cores/arduino/HardwareTimer.cpp b/cores/arduino/HardwareTimer.cpp index c82b2e7db2..c3174cc1ba 100644 --- a/cores/arduino/HardwareTimer.cpp +++ b/cores/arduino/HardwareTimer.cpp @@ -26,7 +26,7 @@ #include "Arduino.h" #include "HardwareTimer.h" -#ifdef HAL_TIM_MODULE_ENABLED +#if defined(HAL_TIM_MODULE_ENABLED) && !defined(HAL_TIM_MODULE_ONLY) /* Private Defines */ #define PIN_NOT_USED 0xFF @@ -1472,4 +1472,4 @@ extern "C" { #endif //TIM22_BASE } -#endif // HAL_TIM_MODULE_ENABLED +#endif // HAL_TIM_MODULE_ENABLED && !HAL_TIM_MODULE_ONLY diff --git a/cores/arduino/HardwareTimer.h b/cores/arduino/HardwareTimer.h index 6670d68c56..b67c1253f3 100644 --- a/cores/arduino/HardwareTimer.h +++ b/cores/arduino/HardwareTimer.h @@ -30,7 +30,7 @@ /* Includes ------------------------------------------------------------------*/ #include "timer.h" -#ifdef HAL_TIM_MODULE_ENABLED +#if defined(HAL_TIM_MODULE_ENABLED) && !defined(HAL_TIM_MODULE_ONLY) #define TIMER_CHANNELS 4 // channel5 and channel 6 are not considered here has they don't have gpio output and they don't have interrupt @@ -149,5 +149,5 @@ extern timer_index_t get_timer_index(TIM_TypeDef *htim); #endif /* __cplusplus */ -#endif // HAL_TIM_MODULE_ENABLED +#endif // HAL_TIM_MODULE_ENABLED && !HAL_TIM_MODULE_ONLY #endif // HARDWARETIMER_H_ \ No newline at end of file diff --git a/cores/arduino/Print.cpp b/cores/arduino/Print.cpp index 456927f296..232550011c 100644 --- a/cores/arduino/Print.cpp +++ b/cores/arduino/Print.cpp @@ -200,7 +200,7 @@ extern "C" { __attribute__((weak)) int _write(int file, char *ptr, int len) { -#ifdef HAL_UART_MODULE_ENABLED +#if defined(HAL_UART_MODULE_ENABLED) && !defined(HAL_UART_MODULE_ONLY) switch (file) { case STDOUT_FILENO: case STDERR_FILENO: diff --git a/cores/arduino/Tone.cpp b/cores/arduino/Tone.cpp index 89dfc646c9..e75099db9a 100644 --- a/cores/arduino/Tone.cpp +++ b/cores/arduino/Tone.cpp @@ -22,7 +22,7 @@ #include "Arduino.h" #include "HardwareTimer.h" -#if defined(HAL_TIM_MODULE_ENABLED) && defined(TIMER_TONE) +#if defined(HAL_TIM_MODULE_ENABLED) && defined(TIMER_TONE) && !defined(HAL_TIM_MODULE_ONLY) #define MAX_FREQ 65535 @@ -143,4 +143,4 @@ void noTone(uint8_t _pin) { UNUSED(_pin); } -#endif /* HAL_TIM_MODULE_ENABLED && TIMER_TONE */ +#endif /* HAL_TIM_MODULE_ENABLED && TIMER_TONE && !HAL_TIM_MODULE_ONLY*/ diff --git a/cores/arduino/WSerial.h b/cores/arduino/WSerial.h index a55697b455..753a38c25b 100644 --- a/cores/arduino/WSerial.h +++ b/cores/arduino/WSerial.h @@ -21,7 +21,7 @@ extern void serialEventUSB(void) __attribute__((weak)); #endif /* USBCON && USBD_USE_CDC */ -#if defined(HAL_UART_MODULE_ENABLED) +#if defined(HAL_UART_MODULE_ENABLED) && !defined(HAL_UART_MODULE_ONLY) #if !defined(HWSERIAL_NONE) && defined(SERIAL_UART_INSTANCE) #if SERIAL_UART_INSTANCE == 0 #define ENABLE_HWSERIALLP1 @@ -163,7 +163,7 @@ extern void serialEvent8(void) __attribute__((weak)); extern void serialEvent9(void) __attribute__((weak)); extern void serialEvent10(void) __attribute__((weak)); extern void serialEventLP1(void) __attribute__((weak)); -#endif /* HAL_UART_MODULE_ENABLED */ +#endif /* HAL_UART_MODULE_ENABLED && !HAL_UART_MODULE_ONLY */ extern void serialEventRun(void) __attribute__((weak)); diff --git a/cores/arduino/board.h b/cores/arduino/board.h index b517d19fa1..1b5be5a272 100644 --- a/cores/arduino/board.h +++ b/cores/arduino/board.h @@ -14,10 +14,8 @@ #include "hw_config.h" #include "low_power.h" #include "rtc.h" -#include "spi_com.h" #include "stm32_eeprom.h" #include "timer.h" -#include "twi.h" #include "uart.h" #ifdef __cplusplus diff --git a/cores/arduino/stm32/analog.cpp b/cores/arduino/stm32/analog.cpp index e3473e231d..62f81723f6 100644 --- a/cores/arduino/stm32/analog.cpp +++ b/cores/arduino/stm32/analog.cpp @@ -47,12 +47,13 @@ extern "C" { /* Private_Variables */ -#if defined(HAL_ADC_MODULE_ENABLED) || defined(HAL_DAC_MODULE_ENABLED) +#if (defined(HAL_ADC_MODULE_ENABLED) && !defined(HAL_ADC_MODULE_ONLY)) ||\ + (defined(HAL_DAC_MODULE_ENABLED) && !defined(HAL_DAC_MODULE_ONLY)) static PinName g_current_pin = NC; #endif /* Private_Defines */ -#ifdef HAL_ADC_MODULE_ENABLED +#if defined(HAL_ADC_MODULE_ENABLED) && !defined(HAL_ADC_MODULE_ONLY) #ifndef ADC_SAMPLINGTIME #if defined(ADC_SAMPLETIME_8CYCLES_5) @@ -269,9 +270,9 @@ static uint32_t get_adc_internal_channel(PinName pin) } return channel; } -#endif /* HAL_ADC_MODULE_ENABLED */ +#endif /* HAL_ADC_MODULE_ENABLED && !HAL_ADC_MODULE_ONLY */ -#ifdef HAL_TIM_MODULE_ENABLED +#if defined(HAL_TIM_MODULE_ENABLED) && !defined(HAL_TIM_MODULE_ONLY) uint32_t get_pwm_channel(PinName pin) { uint32_t function = pinmap_function(pin, PinMap_PWM); @@ -295,9 +296,9 @@ uint32_t get_pwm_channel(PinName pin) } return channel; } -#endif /* HAL_TIM_MODULE_ENABLED */ +#endif /* HAL_TIM_MODULE_ENABLED && !HAL_TIM_MODULE_ONLY */ -#ifdef HAL_DAC_MODULE_ENABLED +#if defined(HAL_DAC_MODULE_ENABLED) && !defined(HAL_DAC_MODULE_ONLY) static uint32_t get_dac_channel(PinName pin) { uint32_t function = pinmap_function(pin, PinMap_DAC); @@ -555,9 +556,10 @@ void dac_stop(PinName pin) return; } } -#endif //HAL_DAC_MODULE_ENABLED +#endif //HAL_DAC_MODULE_ENABLED && !HAL_DAC_MODULE_ONLY -#ifdef HAL_ADC_MODULE_ENABLED + +#if defined(HAL_ADC_MODULE_ENABLED) && !defined(HAL_ADC_MODULE_ONLY) ////////////////////////// ADC INTERFACE FUNCTIONS ///////////////////////////// /** @@ -980,9 +982,9 @@ uint16_t adc_read_value(PinName pin) return uhADCxConvertedValue; } -#endif /* HAL_ADC_MODULE_ENABLED */ +#endif /* HAL_ADC_MODULE_ENABLED && !HAL_ADC_MODULE_ONLY*/ -#ifdef HAL_TIM_MODULE_ENABLED +#if defined(HAL_TIM_MODULE_ENABLED) && !defined(HAL_TIM_MODULE_ONLY) ////////////////////////// PWM INTERFACE FUNCTIONS ///////////////////////////// /** @@ -1032,7 +1034,7 @@ void pwm_stop(PinName pin) HT = NULL; } } -#endif /* HAL_TIM_MODULE_ENABLED */ +#endif /* HAL_TIM_MODULE_ENABLED && !HAL_TIM_MODULE_ONLY */ #ifdef __cplusplus } diff --git a/cores/arduino/stm32/low_power.c b/cores/arduino/stm32/low_power.c index 28a37f2e20..bb0de4af93 100644 --- a/cores/arduino/stm32/low_power.c +++ b/cores/arduino/stm32/low_power.c @@ -39,13 +39,13 @@ #include "Arduino.h" #include "low_power.h" -#ifdef HAL_PWR_MODULE_ENABLED +#if defined(HAL_PWR_MODULE_ENABLED) && !defined(HAL_PWR_MODULE_ONLY) #ifdef __cplusplus extern "C" { #endif -#if defined(UART_IT_WUF) && defined(HAL_UART_MODULE_ENABLED) +#if defined(UART_IT_WUF) && defined(HAL_UART_MODULE_ENABLED) && !defined(HAL_UART_MODULE_ONLY) /* Save UART handler for callback */ static UART_HandleTypeDef *WakeUpUart = NULL; #endif @@ -209,7 +209,7 @@ void LowPower_stop(serial_t *obj) { __disable_irq(); -#if defined(UART_IT_WUF) && defined(HAL_UART_MODULE_ENABLED) +#if defined(UART_IT_WUF) && defined(HAL_UART_MODULE_ENABLED) && !defined(HAL_UART_MODULE_ONLY) if (WakeUpUart != NULL) { HAL_UARTEx_EnableStopMode(WakeUpUart); } @@ -232,7 +232,7 @@ void LowPower_stop(serial_t *obj) /* Exit Stop mode reset clocks */ SystemClock_ConfigFromStop(); -#if defined(UART_IT_WUF) && defined(HAL_UART_MODULE_ENABLED) +#if defined(UART_IT_WUF) && defined(HAL_UART_MODULE_ENABLED) && !defined(HAL_UART_MODULE_ONLY) if (WakeUpUart != NULL) { /* In case of WakeUp from UART, reset its clock source to HSI */ uart_config_lowpower(obj); @@ -301,7 +301,7 @@ void LowPower_shutdown() */ void LowPower_EnableWakeUpUart(serial_t *serial, void (*FuncPtr)(void)) { -#if defined(UART_IT_WUF) && defined(HAL_UART_MODULE_ENABLED) +#if defined(UART_IT_WUF) && defined(HAL_UART_MODULE_ENABLED) && !defined(HAL_UART_MODULE_ONLY) UART_WakeUpTypeDef WakeUpSelection; if (serial == NULL) { return; @@ -346,6 +346,6 @@ WEAK void SystemClock_ConfigFromStop(void) } #endif -#endif /* HAL_PWR_MODULE_ENABLED */ +#endif /* HAL_PWR_MODULE_ENABLED && !HAL_PWR_MODULE_ONLY */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/cores/arduino/stm32/low_power.h b/cores/arduino/stm32/low_power.h index 0429ed7a0b..f8cec3e738 100644 --- a/cores/arduino/stm32/low_power.h +++ b/cores/arduino/stm32/low_power.h @@ -43,7 +43,7 @@ #include "stm32_def.h" #include "uart.h" -#ifdef HAL_PWR_MODULE_ENABLED +#if defined(HAL_PWR_MODULE_ENABLED) && !defined(HAL_PWR_MODULE_ONLY) #ifdef __cplusplus extern "C" { @@ -67,6 +67,6 @@ void SystemClock_ConfigFromStop(void); } #endif -#endif /* HAL_PWR_MODULE_ENABLED */ +#endif /* HAL_PWR_MODULE_ENABLED && !HAL_PWR_MODULE_ONLY */ #endif /* __LOW_POWER_H */ diff --git a/cores/arduino/stm32/rtc.c b/cores/arduino/stm32/rtc.c index a2c7ccc2e7..b96ef8914e 100644 --- a/cores/arduino/stm32/rtc.c +++ b/cores/arduino/stm32/rtc.c @@ -38,7 +38,7 @@ #include "rtc.h" -#ifdef HAL_RTC_MODULE_ENABLED +#if defined(HAL_RTC_MODULE_ENABLED) && !defined(HAL_RTC_MODULE_ONLY) #if defined(STM32MP1xx) /** * Currently there is no RTC driver for STM32MP1xx. If RTC is used in the future @@ -704,6 +704,6 @@ void RTC_Alarm_IRQHandler(void) } #endif -#endif /* HAL_RTC_MODULE_ENABLED */ +#endif /* HAL_RTC_MODULE_ENABLED && !HAL_RTC_MODULE_ONLY */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/cores/arduino/stm32/rtc.h b/cores/arduino/stm32/rtc.h index 3614a62d4d..3956294475 100644 --- a/cores/arduino/stm32/rtc.h +++ b/cores/arduino/stm32/rtc.h @@ -45,7 +45,7 @@ #include "backup.h" #include "clock.h" -#ifdef HAL_RTC_MODULE_ENABLED +#if defined(HAL_RTC_MODULE_ENABLED) && !defined(HAL_RTC_MODULE_ONLY) #ifdef __cplusplus extern "C" { @@ -170,7 +170,7 @@ void detachAlarmCallback(void); } #endif -#endif /* HAL_RTC_MODULE_ENABLED */ +#endif /* HAL_RTC_MODULE_ENABLED && !HAL_RTC_MODULE_ONLY */ #endif /* __RTC_H */ diff --git a/cores/arduino/stm32/timer.c b/cores/arduino/stm32/timer.c index 066ee04d70..a27f86ec53 100644 --- a/cores/arduino/stm32/timer.c +++ b/cores/arduino/stm32/timer.c @@ -17,7 +17,7 @@ #ifdef __cplusplus extern "C" { #endif -#ifdef HAL_TIM_MODULE_ENABLED +#if defined(HAL_TIM_MODULE_ENABLED) && !defined(HAL_TIM_MODULE_ONLY) /* Private Functions */ /* Aim of the function is to get _timerObj pointer using htim pointer */ @@ -716,7 +716,7 @@ uint8_t getTimerClkSrc(TIM_TypeDef *tim) } -#endif /* HAL_TIM_MODULE_ENABLED */ +#endif /* HAL_TIM_MODULE_ENABLED && !HAL_TIM_MODULE_ONLY */ #ifdef __cplusplus } diff --git a/cores/arduino/stm32/timer.h b/cores/arduino/stm32/timer.h index 6685427ac4..bda0ae6cdd 100644 --- a/cores/arduino/stm32/timer.h +++ b/cores/arduino/stm32/timer.h @@ -22,7 +22,7 @@ #ifdef __cplusplus extern "C" { #endif -#ifdef HAL_TIM_MODULE_ENABLED +#if defined(HAL_TIM_MODULE_ENABLED) && !defined(HAL_TIM_MODULE_ONLY) /* Exported constants --------------------------------------------------------*/ #ifndef TIM_IRQ_PRIO @@ -254,7 +254,7 @@ uint8_t getTimerClkSrc(TIM_TypeDef *tim); IRQn_Type getTimerUpIrq(TIM_TypeDef *tim); IRQn_Type getTimerCCIrq(TIM_TypeDef *tim); -#endif /* HAL_TIM_MODULE_ENABLED */ +#endif /* HAL_TIM_MODULE_ENABLED && !HAL_TIM_MODULE_ONLY */ #ifdef __cplusplus } diff --git a/cores/arduino/stm32/uart.c b/cores/arduino/stm32/uart.c index d40c849003..42ab69f462 100644 --- a/cores/arduino/stm32/uart.c +++ b/cores/arduino/stm32/uart.c @@ -41,7 +41,7 @@ #ifdef __cplusplus extern "C" { #endif -#if defined(HAL_UART_MODULE_ENABLED) +#if defined(HAL_UART_MODULE_ENABLED) && !defined(HAL_UART_MODULE_ONLY) /* If DEBUG_UART is not defined assume this is the one linked to PIN_SERIAL_TX */ #if !defined(DEBUG_UART) @@ -1066,7 +1066,7 @@ void HAL_UARTEx_WakeupCallback(UART_HandleTypeDef *huart) serial_t *obj = get_serial_obj(huart); HAL_UART_Receive_IT(huart, &(obj->recv), 1); } -#endif /* HAL_UART_MODULE_ENABLED */ +#endif /* HAL_UART_MODULE_ENABLED && !HAL_UART_MODULE_ONLY */ #ifdef __cplusplus } diff --git a/cores/arduino/stm32/uart.h b/cores/arduino/stm32/uart.h index e8e8f29bbc..58097db178 100644 --- a/cores/arduino/stm32/uart.h +++ b/cores/arduino/stm32/uart.h @@ -45,7 +45,7 @@ extern "C" { #endif -#if !defined(HAL_UART_MODULE_ENABLED) +#if !defined(HAL_UART_MODULE_ENABLED) || defined(HAL_UART_MODULE_ONLY) #define serial_t void* #else @@ -186,7 +186,7 @@ void uart_enable_rx(serial_t *obj); size_t uart_debug_write(uint8_t *data, uint32_t size); -#endif /* HAL_UART_MODULE_ENABLED */ +#endif /* HAL_UART_MODULE_ENABLED && !HAL_UART_MODULE_ONLY */ #ifdef __cplusplus } #endif diff --git a/cores/arduino/wiring_analog.c b/cores/arduino/wiring_analog.c index 454f54e751..355da374f4 100644 --- a/cores/arduino/wiring_analog.c +++ b/cores/arduino/wiring_analog.c @@ -23,7 +23,8 @@ extern "C" { #endif -#if defined(HAL_DAC_MODULE_ENABLED) || defined(HAL_TIM_MODULE_ENABLED) +#if (defined(HAL_DAC_MODULE_ENABLED) && !defined(HAL_DAC_MODULE_ONLY)) ||\ + (defined(HAL_TIM_MODULE_ENABLED) && !defined(HAL_TIM_MODULE_ONLY)) //This is the list of the IOs configured uint32_t g_anOutputPinConfigured[MAX_NB_PORT] = {0}; #endif @@ -71,7 +72,7 @@ void analogReference(eAnalogReference ulMode) uint32_t analogRead(uint32_t ulPin) { uint32_t value = 0; -#ifdef HAL_ADC_MODULE_ENABLED +#if defined(HAL_ADC_MODULE_ENABLED) && !defined(HAL_ADC_MODULE_ONLY) PinName p = analogInputToPinName(ulPin); if (p != NC) { value = adc_read_value(p); @@ -94,12 +95,12 @@ void analogOutputInit(void) // to digital output. void analogWrite(uint32_t ulPin, uint32_t ulValue) { -#if defined(HAL_DAC_MODULE_ENABLED) +#if defined(HAL_DAC_MODULE_ENABLED) && !defined(HAL_DAC_MODULE_ONLY) uint8_t do_init = 0; #endif PinName p = digitalPinToPinName(ulPin); if (p != NC) { -#ifdef HAL_DAC_MODULE_ENABLED +#if defined(HAL_DAC_MODULE_ENABLED) && !defined(HAL_DAC_MODULE_ONLY) if (pin_in_pinmap(p, PinMap_DAC)) { if (is_pin_configured(p, g_anOutputPinConfigured) == false) { do_init = 1; @@ -108,8 +109,8 @@ void analogWrite(uint32_t ulPin, uint32_t ulValue) ulValue = mapResolution(ulValue, _writeResolution, DACC_RESOLUTION); dac_write_value(p, ulValue, do_init); } else -#endif //HAL_DAC_MODULE_ENABLED -#ifdef HAL_TIM_MODULE_ENABLED +#endif //HAL_DAC_MODULE_ENABLED && !HAL_DAC_MODULE_ONLY +#if defined(HAL_TIM_MODULE_ENABLED) && !defined(HAL_TIM_MODULE_ONLY) if (pin_in_pinmap(p, PinMap_PWM)) { if (is_pin_configured(p, g_anOutputPinConfigured) == false) { set_pin_configured(p, g_anOutputPinConfigured); @@ -117,7 +118,7 @@ void analogWrite(uint32_t ulPin, uint32_t ulValue) ulValue = mapResolution(ulValue, _writeResolution, PWM_RESOLUTION); pwm_start(p, _writeFreq, ulValue); } else -#endif /* HAL_TIM_MODULE_ENABLED */ +#endif /* HAL_TIM_MODULE_ENABLED && !HAL_TIM_MODULE_ONLY */ { //DIGITAL PIN ONLY // Defaults to digital write diff --git a/cores/arduino/wiring_digital.c b/cores/arduino/wiring_digital.c index 240ac606b9..b0af7e4529 100644 --- a/cores/arduino/wiring_digital.c +++ b/cores/arduino/wiring_digital.c @@ -32,18 +32,19 @@ void pinMode(uint32_t ulPin, uint32_t ulMode) if (p != NC) { // If the pin that support PWM or DAC output, we need to turn it off -#if defined(HAL_DAC_MODULE_ENABLED) || defined(HAL_TIM_MODULE_ENABLED) +#if (defined(HAL_DAC_MODULE_ENABLED) && !defined(HAL_DAC_MODULE_ONLY)) ||\ + (defined(HAL_TIM_MODULE_ENABLED) && !defined(HAL_TIM_MODULE_ONLY)) if (is_pin_configured(p, g_anOutputPinConfigured)) { -#ifdef HAL_DAC_MODULE_ENABLED +#if defined(HAL_DAC_MODULE_ENABLED) && !defined(HAL_DAC_MODULE_ONLY) if (pin_in_pinmap(p, PinMap_DAC)) { dac_stop(p); } else -#endif //HAL_DAC_MODULE_ENABLED -#ifdef HAL_TIM_MODULE_ENABLED +#endif //HAL_DAC_MODULE_ENABLED && !HAL_DAC_MODULE_ONLY +#if defined(HAL_TIM_MODULE_ENABLED) && !defined(HAL_TIM_MODULE_ONLY) if (pin_in_pinmap(p, PinMap_PWM)) { pwm_stop(p); } -#endif //HAL_TIM_MODULE_ENABLED +#endif //HAL_TIM_MODULE_ENABLED && !HAL_TIM_MODULE_ONLY { reset_pin_configured(p, g_anOutputPinConfigured); } diff --git a/libraries/SPI/src/SPI.h b/libraries/SPI/src/SPI.h index 4420e9b85f..8ce8e5b24a 100644 --- a/libraries/SPI/src/SPI.h +++ b/libraries/SPI/src/SPI.h @@ -14,6 +14,9 @@ #include "Arduino.h" #include +extern "C" { +#include "utility/spi_com.h" +} // SPI_HAS_TRANSACTION means SPI has // - beginTransaction() diff --git a/cores/arduino/stm32/spi_com.c b/libraries/SPI/src/utility/spi_com.c similarity index 99% rename from cores/arduino/stm32/spi_com.c rename to libraries/SPI/src/utility/spi_com.c index 62f6696a00..7a1fa006eb 100644 --- a/cores/arduino/stm32/spi_com.c +++ b/libraries/SPI/src/utility/spi_com.c @@ -37,14 +37,13 @@ */ #include "core_debug.h" #include "stm32_def.h" -#include "spi_com.h" +#include "utility/spi_com.h" #include "PinAF_STM32F1.h" #include "pinconfig.h" #ifdef __cplusplus extern "C" { #endif -#if defined(HAL_SPI_MODULE_ENABLED) /* Private Functions */ /** @@ -430,7 +429,6 @@ spi_status_e spi_transfer(spi_t *obj, uint8_t *tx_buffer, return ret; } -#endif /* HAL_SPI_MODULE_ENABLED */ #ifdef __cplusplus } diff --git a/cores/arduino/stm32/spi_com.h b/libraries/SPI/src/utility/spi_com.h similarity index 98% rename from cores/arduino/stm32/spi_com.h rename to libraries/SPI/src/utility/spi_com.h index 1c23b5d9dd..0b15e011c0 100644 --- a/cores/arduino/stm32/spi_com.h +++ b/libraries/SPI/src/utility/spi_com.h @@ -46,7 +46,6 @@ #ifdef __cplusplus extern "C" { #endif -#if defined(HAL_SPI_MODULE_ENABLED) /* Exported types ------------------------------------------------------------*/ @@ -102,7 +101,6 @@ spi_status_e spi_send(spi_t *obj, uint8_t *Data, uint16_t len, uint32_t Timeout) spi_status_e spi_transfer(spi_t *obj, uint8_t *tx_buffer, uint8_t *rx_buffer, uint16_t len, uint32_t Timeout); uint32_t spi_getClkFreq(spi_t *obj); -#endif /* HAL_SPI_MODULE_ENABLED */ #ifdef __cplusplus } diff --git a/libraries/Servo/src/stm32/Servo.cpp b/libraries/Servo/src/stm32/Servo.cpp index 4365767c67..2202d2a6be 100644 --- a/libraries/Servo/src/stm32/Servo.cpp +++ b/libraries/Servo/src/stm32/Servo.cpp @@ -22,7 +22,7 @@ #include #include -#if defined(HAL_TIM_MODULE_ENABLED) && defined(TIMER_SERVO) +#if defined(HAL_TIM_MODULE_ENABLED) && defined(TIMER_SERVO) && !defined(HAL_TIM_MODULE_ONLY) static servo_t servos[MAX_SERVOS]; // static array of servo structures static volatile int8_t timerChannel[_Nbr_16timers] = {-1}; // counter for the servo being pulsed for each timer (or -1 if refresh interval) @@ -231,6 +231,6 @@ int Servo::readMicroseconds() } bool Servo::attached() {} -#endif /* HAL_TIM_MODULE_ENABLED && TIMER_SERVO */ +#endif /* HAL_TIM_MODULE_ENABLED && TIMER_SERVO & !HAL_TIM_MODULE_ONLY */ #endif // ARDUINO_ARCH_STM32 diff --git a/libraries/Wire/src/Wire.h b/libraries/Wire/src/Wire.h index da3bee5da1..816eb89b28 100644 --- a/libraries/Wire/src/Wire.h +++ b/libraries/Wire/src/Wire.h @@ -22,9 +22,11 @@ #ifndef TwoWire_h #define TwoWire_h -#include #include "Stream.h" #include "Arduino.h" +extern "C" { +#include "utility/twi.h" +} #define BUFFER_LENGTH 32 diff --git a/cores/arduino/stm32/twi.c b/libraries/Wire/src/utility/twi.c similarity index 99% rename from cores/arduino/stm32/twi.c rename to libraries/Wire/src/utility/twi.c index 3ee7f7a567..4ea85f29db 100644 --- a/cores/arduino/stm32/twi.c +++ b/libraries/Wire/src/utility/twi.c @@ -36,13 +36,12 @@ ****************************************************************************** */ #include "core_debug.h" -#include "twi.h" +#include "utility/twi.h" #include "PinAF_STM32F1.h" #ifdef __cplusplus extern "C" { #endif -#if defined(HAL_I2C_MODULE_ENABLED) /* Private Defines */ /// @brief I2C timout in tick unit @@ -1254,8 +1253,6 @@ void I2C6_ER_IRQHandler(void) } #endif // I2C6_BASE -#endif /* HAL_I2C_MODULE_ENABLED */ - #ifdef __cplusplus } #endif diff --git a/cores/arduino/stm32/twi.h b/libraries/Wire/src/utility/twi.h similarity index 98% rename from cores/arduino/stm32/twi.h rename to libraries/Wire/src/utility/twi.h index 37881212ff..c686998807 100644 --- a/cores/arduino/stm32/twi.h +++ b/libraries/Wire/src/utility/twi.h @@ -47,7 +47,6 @@ #ifdef __cplusplus extern "C" { #endif -#if defined(HAL_I2C_MODULE_ENABLED) /* Exported types ------------------------------------------------------------*/ /* offsetof is a gcc built-in function, this is the manual implementation */ @@ -137,7 +136,6 @@ i2c_status_e i2c_IsDeviceReady(i2c_t *obj, uint8_t devAddr, uint32_t trials); void i2c_attachSlaveRxEvent(i2c_t *obj, void (*function)(uint8_t *, int)); void i2c_attachSlaveTxEvent(i2c_t *obj, void (*function)(void)); -#endif /* HAL_I2C_MODULE_ENABLED */ #ifdef __cplusplus }