/* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ /** global definitions and methods (API) * @file global.h * @author King Kévin * @date 2016 */ #pragma once /** get the length of an array */ #define LENGTH(x) (sizeof(x) / sizeof((x)[0])) /** concatenate 2 arguments (used to defer concatenation) */ #define CAT2(x,y) x##y /** concatenate 3 arguments (used to defer concatenation) */ #define CAT3(x,y,z) x##y##z /** @defgroup reg_table get register address based on identifier * @note used when the value is not calculated * @{ */ /** get GPIO port based on port identifier (0=A, ...) */ extern const uint32_t GPIO_PORT[]; /** get RCC for GPIO based on GPIO identifier */ extern const uint32_t RCC_GPIO[]; /** get TIM based on TIM identifier */ extern const uint32_t TIM[]; /** get RCC for timer based on TIM */ extern const uint32_t RCC_TIM[]; /** get NVIC IRQ for timer base on TIM */ extern const uint8_t NVIC_TIM_IRQ[]; /** get NVIC IRQ for external interrupt base on external interrupt/pin */ extern const uint8_t NVIC_EXTI_IRQ[]; /** @} */ /** @defgroup reg_macro macros to get define values based on other defines values * @note used when the value is calculated or isn't a value * @{ */ /** get GPIO pin based on pin identifier */ #define GPIO_PIN(x) (1<