add RCC macros

This commit is contained in:
King Kévin 2016-08-16 11:55:25 +02:00
parent 4c1a3c74a3
commit 2f9dcd0ff7
1 changed files with 37 additions and 0 deletions

View File

@ -25,6 +25,43 @@
/** get the length of an array */
#define LENGTH(x) (sizeof(x) / sizeof((x)[0]))
/** @defgroup reg_macro macros to get define values based on other defines values
* @{
*/
/** get RCC for GPIO based on GPIO */
#define RCC_GPIO(x) switch (x) { \
case GPIOA: RCC_GPIOA; break; \
case GPIOB: RCC_GPIOB; break; \
case GPIOC: RCC_GPIOC; break; \
case GPIOD: RCC_GPIOD; break; \
case GPIOE: RCC_GPIOE; break; \
case GPIOF: RCC_GPIOF; break; \
case GPIOG: RCC_GPIOG; break; \
default: 0; break; \
}
/** get RCC for timer based on TIM */
#define RCC_TIM(x) switch (x) { \
case TIM1: RCC_TIM1; break; \
case TIM2: RCC_TIM2; break; \
case TIM3: RCC_TIM3; break; \
case TIM4: RCC_TIM4; break; \
case TIM5: RCC_TIM5; break; \
case TIM6: RCC_TIM6; break; \
case TIM7: RCC_TIM7; break; \
case TIM8: RCC_TIM8; break; \
case TIM9: RCC_TIM9; break; \
case TIM10: RCC_TIM10; break; \
case TIM11: RCC_TIM11; break; \
case TIM12: RCC_TIM12; break; \
case TIM13: RCC_TIM13; break; \
case TIM14: RCC_TIM14; break; \
case TIM15: RCC_TIM15; break; \
case TIM16: RCC_TIM16; break; \
case TIM17: RCC_TIM17; break; \
default: 0; break; \
}
/** @} */
/** @defgroup board_led board LED GPIO
* @{
*/