AP_HAL_ChibiOS: support EXPECTED_CLOCKS and assert on meaningful ones for H7
This commit is contained in:
parent
d9d252a1b7
commit
39b226c46b
@ -45,9 +45,6 @@ static const struct QSPIDriverInfo {
|
||||
QSPIDesc QSPIDeviceManager::device_table[] = { HAL_QSPI_DEVICE_LIST };
|
||||
|
||||
// Check clock sanity during runtime
|
||||
#define XSTR(x) STR(x)
|
||||
#define STR(x) #x
|
||||
|
||||
#if (STM32_QSPICLK < HAL_QSPI1_CLK)
|
||||
#error "Flash speed must not be greater than QSPI Clock"
|
||||
#endif
|
||||
|
@ -58,6 +58,14 @@ mcu = {
|
||||
|
||||
'EXPECTED_CLOCK' : 400000000,
|
||||
|
||||
'EXPECTED_CLOCKS' : [
|
||||
('STM32_SYS_CK', 400000000),
|
||||
('STM32_QSPICLK', 200000000),
|
||||
('STM32_SDMMC1CLK', 80000000),
|
||||
('STM32_SPI45CLK', 100000000),
|
||||
('STM32_FDCANCLK', 80000000),
|
||||
],
|
||||
|
||||
# this MCU has M7 instructions and hardware double precision
|
||||
'CORTEX' : 'cortex-m7',
|
||||
'CPU_FLAGS' : '-mcpu=cortex-m7 -mfpu=fpv5-d16 -mfloat-abi=hard',
|
||||
|
@ -63,6 +63,13 @@ mcu = {
|
||||
|
||||
'EXPECTED_CLOCK' : 400000000,
|
||||
|
||||
'EXPECTED_CLOCKS' : [
|
||||
('STM32_SYS_CK', 400000000),
|
||||
('STM32_QSPICLK', 200000000),
|
||||
('STM32_SDMMC1CLK', 80000000),
|
||||
('STM32_SPI45CLK', 100000000),
|
||||
],
|
||||
|
||||
# this MCU has M7 instructions and hardware double precision
|
||||
'CORTEX' : 'cortex-m7',
|
||||
'CPU_FLAGS' : '-mcpu=cortex-m7 -mfpu=fpv5-d16 -mfloat-abi=hard',
|
||||
|
@ -1082,6 +1082,14 @@ def write_mcu_config(f):
|
||||
elif get_mcu_config('EXPECTED_CLOCK', required=True):
|
||||
f.write('#define HAL_EXPECTED_SYSCLOCK %u\n' % get_mcu_config('EXPECTED_CLOCK'))
|
||||
|
||||
if get_mcu_config('EXPECTED_CLOCKS', required=False):
|
||||
clockrate = get_config('MCU_CLOCKRATE_MHZ', required=False)
|
||||
for mcu_clock, mcu_clock_speed in get_mcu_config('EXPECTED_CLOCKS'):
|
||||
if (mcu_clock == 'STM32_HCLK' or mcu_clock == 'STM32_SYS_CK') and clockrate:
|
||||
f.write('#define HAL_EXPECTED_%s %u\n' % (mcu_clock, int(clockrate) * 1000000))
|
||||
else:
|
||||
f.write('#define HAL_EXPECTED_%s %u\n' % (mcu_clock, mcu_clock_speed))
|
||||
|
||||
env_vars['CORTEX'] = cortex
|
||||
|
||||
if not args.bootloader:
|
||||
|
@ -53,6 +53,26 @@ static_assert(HAL_EXPECTED_SYSCLOCK == STM32_HCLK, "unexpected STM32_HCLK value"
|
||||
#define AP_FAULTHANDLER_DEBUG_VARIABLES_ENABLED 1
|
||||
#endif
|
||||
|
||||
#define QUOTE(str) #str
|
||||
#define EXPAND_AND_QUOTE(str) QUOTE(str)
|
||||
#define ASSERT_CLOCK(clk) static_assert(HAL_EXPECTED_ ##clk == (clk), "unexpected " #clk " value: '" EXPAND_AND_QUOTE(clk) "'")
|
||||
|
||||
#if defined(HAL_EXPECTED_STM32_SYS_CK) && defined(STM32_SYS_CK)
|
||||
ASSERT_CLOCK(STM32_SYS_CK);
|
||||
#endif
|
||||
#if defined(HAL_EXPECTED_STM32_HCLK) && defined(STM32_HCLK)
|
||||
ASSERT_CLOCK(STM32_HCLK);
|
||||
#endif
|
||||
#if defined(HAL_EXPECTED_STM32_SDMMC1CLK) && defined(STM32_SDMMC1CLK)
|
||||
ASSERT_CLOCK(STM32_SDMMC1CLK);
|
||||
#endif
|
||||
#if defined(HAL_EXPECTED_STM32_SPI45CLK) && defined(STM32_SPI45CLK)
|
||||
ASSERT_CLOCK(STM32_SPI45CLK);
|
||||
#endif
|
||||
#if defined(HAL_EXPECTED_STM32_FDCANCLK) && defined(STM32_FDCANCLK)
|
||||
ASSERT_CLOCK(STM32_FDCANCLK);
|
||||
#endif
|
||||
|
||||
extern const AP_HAL::HAL& hal;
|
||||
extern "C"
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user