From 156cd818c88f739841564ee906dd40c0dbfd5280 Mon Sep 17 00:00:00 2001
From: Sergi Hernandez Juan <shernand@iri.upc.edu>
Date: Sat, 4 May 2024 18:05:16 +0200
Subject: [PATCH] Added conditional definitions to be compatible with the
 simulator.

---
 f4/include/devices/stm32f4xx.h | 4 +++-
 f4/include/stm32f4xx_ll_adc.h  | 6 ++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/f4/include/devices/stm32f4xx.h b/f4/include/devices/stm32f4xx.h
index e8297aa..a23b9c0 100644
--- a/f4/include/devices/stm32f4xx.h
+++ b/f4/include/devices/stm32f4xx.h
@@ -216,7 +216,9 @@ typedef enum
 
 #define CLEAR_REG(REG)        ((REG) = (0x0))
 
-#define WRITE_REG(REG, VAL)   ((REG) = (VAL))
+#ifndef WRITE_REG
+  #define WRITE_REG(REG, VAL)   ((REG) = (VAL))
+#endif
 
 #define READ_REG(REG)         ((REG))
 
diff --git a/f4/include/stm32f4xx_ll_adc.h b/f4/include/stm32f4xx_ll_adc.h
index 808d0b9..7c5b3e8 100644
--- a/f4/include/stm32f4xx_ll_adc.h
+++ b/f4/include/stm32f4xx_ll_adc.h
@@ -293,8 +293,10 @@ extern "C" {
   * @param  __REG_OFFFSET__ Offset to be applied (unit number of registers).
   * @retval Pointer to register address
   */
-#define __ADC_PTR_REG_OFFSET(__REG__, __REG_OFFFSET__)                         \
- ((__IO uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2UL))))
+#ifndef __ADC_PTR_REG_OFFSET
+  #define __ADC_PTR_REG_OFFSET(__REG__, __REG_OFFFSET__)                         \
+   ((__IO uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2UL))))
+#endif
 
 /**
   * @}
-- 
GitLab