Skip to content

Commit 6d35237

Browse files
committed
Include SPI / I2C modules only if they are choosed in HAL to save code space
1 parent 485bf01 commit 6d35237

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

cores/arduino/board.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ extern "C"{
1414
#include "digital_io.h"
1515
#include "hal_uart_emul.h"
1616
#include "hw_config.h"
17+
#ifdef HAL_SPI_MODULE_ENABLED
1718
#include "spi_com.h"
19+
#endif
1820
#include "stm32_eeprom.h"
1921
#include "timer.h"
22+
#ifdef HAL_I2HAL_I2C_MODULE_ENABLED
2023
#include "twi.h"
24+
#endif
2125
#include "uart.h"
2226
#include "uart_emul.h"
2327
#ifdef USBCON

cores/arduino/stm32/spi_com.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
/** @addtogroup STM32F4xx_System_Private_Includes
4747
* @{
4848
*/
49+
50+
#ifdef HAL_SPI_MODULE_ENABLED
51+
4952
#include "stm32_def.h"
5053
#include "spi_com.h"
5154
#include "PinAF_STM32F1.h"
@@ -525,4 +528,5 @@ spi_status_e spi_transfer(spi_t *obj, uint8_t * tx_buffer,
525528
}
526529
#endif
527530

531+
#endif
528532
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

cores/arduino/stm32/twi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
/** @addtogroup STM32F4xx_System_Private_Includes
4848
* @{
4949
*/
50+
#ifdef HAL_I2HAL_I2C_MODULE_ENABLED
51+
5052
#include "stm32_def.h"
5153
#include "twi.h"
5254
#include "PinAF_STM32F1.h"
@@ -698,4 +700,5 @@ void I2C4_ER_IRQHandler(void)
698700
}
699701
#endif
700702

703+
#endif
701704
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

0 commit comments

Comments
 (0)