/* 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 . * */ /** @brief global definitions and methods * @file global.h * @author King Kévin * @date 2016 */ #pragma once #include // GPIO defines #include // interrupt defines #include // external interrupt defines /** get the length of an array */ #define LENGTH(x) (sizeof(x) / sizeof((x)[0])) /* board LED GPIO */ #if defined(SYSTEM_BOARD) /** on system board LED is on pin 11/PA1 */ #define LED_RCC RCC_GPIOA #define LED_PORT GPIOA #define LED_PIN GPIO1 #elif defined(BLUE_PILL) /** on minimum system LED is on pin 2/PC13 */ #define LED_RCC RCC_GPIOC #define LED_PORT GPIOC #define LED_PIN GPIO13 #elif defined (MAPLE_MINI) /** on maple mini LED is on pin 19/PB1 */ #define LED_RCC RCC_GPIOB #define LED_PORT GPIOB #define LED_PIN GPIO1 #endif /* board user button GPIO */ #if defined(MAPLE_MINI) /** on maple mini user button is on 32/PB8 */ #define BUTTON_RCC RCC_GPIOB #define BUTTON_PORT GPIOB #define BUTTON_PIN GPIO8 #define BUTTON_EXTI EXTI8 #define BUTTON_IRQ NVIC_EXTI9_5_IRQ #define BUTTON_ISR exti9_5_isr #endif /** @brief switch on board LED */ void led_on(void); /** @brief switch off board LED */ void led_off(void); /** @brief toggle board LED */ void led_toggle(void); /** @brief default printf output */ int _write(int file, char *ptr, int len); /** @brief get binary representation of a number * @param[in] binary number to represent in binary * @param[in] rjust justify representation with leading zeros * @return string with binary representation of the number */ char* b2s(uint32_t binary, uint8_t rjust);