pebble/src/fw/mcu.h
2025-01-27 11:38:16 -08:00

58 lines
2 KiB
C

/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//! \file
//! MCU wrapper header
//!
//! Include this header in firmware sources instead of including the header for
//! a specific MCU family.
//!
//! Before including this header, a compatibility matrix must be declared by
//! `#define`-ing the appropriate `_COMPATIBLE` macros.
//!
//! Define `CMSIS_COMPATIBLE` if the source file only requires symbols and
//! macros which are defined by CMSIS.
//!
//! Define `STM32F2_COMPATIBLE` and/or `STM32F4_COMPATIBLE` if the source file
//! is compatible with the STM32F2 or STM32F4 microcontroller families,
//! respectively, and requires the corresponding family's peripheral
//! definitions or library functions.
// Multiple inclusion of this header is allowed.
#if defined(MICRO_FAMILY_STM32F2)
# if !defined(STM32F2_COMPATIBLE) && !defined(CMSIS_COMPATIBLE)
# error "Source is incompatible with the target MCU"
# endif
# include <stm32f2xx.h>
#elif defined(MICRO_FAMILY_STM32F4)
# if !defined(STM32F4_COMPATIBLE) && !defined(CMSIS_COMPATIBLE)
# error "Source is incompatible with the target MCU"
# endif
# include <stm32f4xx.h>
#elif defined(MICRO_FAMILY_STM32F7)
# if !defined(STM32F7_COMPATIBLE) && !defined(CMSIS_COMPATIBLE)
# error "Source is incompatible with the target MCU"
# endif
# include <stm32f7xx.h>
#elif !defined(SDK) && !defined(UNITTEST)
# error "Unknown or missing MICRO_FAMILY_* define"
#endif
#undef CMSIS_COMPATIBLE
#undef STM32F2_COMPATIBLE
#undef STM32F4_COMPATIBLE
#undef STM32F7_COMPATIBLE