Skip to content

Commit 46e38fe

Browse files
committed
ci(variant): enhance I3C support generation
HAL I3C module is enabled only if I3C is available. Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 9233f6f commit 46e38fe

3 files changed

Lines changed: 44 additions & 6 deletions

File tree

‎CI/update/stm32variant.py‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,25 @@ def i2c_pins_variant():
14781478
return dict(sda=sda_pin, scl=scl_pin)
14791479

14801480

1481+
def i3c_pins_variant():
1482+
sda_pin = scl_pin = "PNUM_NOT_DEFINED"
1483+
# Iterate to find match instance if any
1484+
for sda in i3csda_list:
1485+
sda_inst = sda[2].split("_", 1)[0]
1486+
for scl in i3cscl_list:
1487+
scl_inst = scl[2].split("_", 1)[0]
1488+
if sda_inst == scl_inst:
1489+
sda_pin = sda[0].replace("_", "", 1)
1490+
scl_pin = scl[0].replace("_", "", 1)
1491+
break
1492+
else:
1493+
continue
1494+
break
1495+
else:
1496+
print("No I3C found!")
1497+
return dict(sda=sda_pin, scl=scl_pin)
1498+
1499+
14811500
def serial_pins_variant():
14821501
# Manage (LP)U(S)ART pins
14831502
if uarttx_list:
@@ -1591,6 +1610,12 @@ def print_variant(generic_list, alt_syswkup_list):
15911610
# I2C definition
15921611
i2c_pins = i2c_pins_variant()
15931612

1613+
# I3C definition if any
1614+
if i3csda_list and i3cscl_list:
1615+
i3c_pins = i3c_pins_variant()
1616+
else:
1617+
i3c_pins = None
1618+
15941619
# Serial definition
15951620
serial = serial_pins_variant()
15961621

@@ -1660,6 +1685,8 @@ def print_variant(generic_list, alt_syswkup_list):
16601685
hal_modules_list.append("DAC")
16611686
if eth_list:
16621687
hal_modules_list.append("ETH")
1688+
if i3csda_list and i3cscl_list:
1689+
hal_modules_list.append("I3C")
16631690
if xspidata0_list:
16641691
if "OCTOSPI" in xspidata0_list[0][2]:
16651692
hal_modules_list.append("OSPI")
@@ -1681,6 +1708,7 @@ def print_variant(generic_list, alt_syswkup_list):
16811708
num_analog_inputs=len(analog_pins_list),
16821709
spi_pins=spi_pins,
16831710
i2c_pins=i2c_pins,
1711+
i3c_pins=i3c_pins,
16841712
timer=timer,
16851713
serial=serial,
16861714
hal_modules_list=hal_modules_list,

‎CI/update/templates/variant_generic.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@
7575
#ifndef PIN_WIRE_SCL
7676
#define PIN_WIRE_SCL {{i2c_pins.scl}}
7777
#endif
78+
{% if i3c_pins %}
79+
80+
// I3C definitions
81+
#ifndef PIN_I3C_SDA
82+
#define PIN_I3C_SDA {{i3c_pins.sda}}
83+
#endif
84+
#ifndef PIN_I3C_SCL
85+
#define PIN_I3C_SCL {{i3c_pins.scl}}
86+
#endif
87+
{% endif %}
7888

7989
// Timer Definitions
8090
// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin

‎cores/arduino/stm32/stm32yyxx_hal_conf.h‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@
4646
#undef HAL_I2S_MODULE_ENABLED
4747
#endif
4848

49-
#if !defined(HAL_I3C_MODULE_DISABLED)
50-
#define HAL_I3C_MODULE_ENABLED
51-
#else
52-
#undef HAL_I3C_MODULE_ENABLED
53-
#endif
54-
5549
#if !defined(HAL_RTC_MODULE_DISABLED)
5650
#define HAL_RTC_MODULE_ENABLED
5751
#else
@@ -117,6 +111,12 @@
117111
#undef HAL_EXTI_MODULE_ENABLED
118112
#endif
119113

114+
#if !defined(HAL_I3C_MODULE_DISABLED)
115+
/*#define HAL_I3C_MODULE_ENABLED*/
116+
#else
117+
#undef HAL_I3C_MODULE_ENABLED
118+
#endif
119+
120120
#if !defined(HAL_ETH_MODULE_DISABLED)
121121
/*#define HAL_ETH_MODULE_ENABLED*/
122122
#else

0 commit comments

Comments
 (0)