add TIM,I2C,SPI macros and core board defintion
This commit is contained in:
parent
75658c2c1a
commit
1bd4aef976
122
global.h
122
global.h
|
@ -31,7 +31,6 @@
|
|||
/** concatenate 4 arguments */
|
||||
#define CAT4(w,x,y,z) w##x##y##z
|
||||
|
||||
|
||||
/** @defgroup reg_macro macros to define values based on other defines values
|
||||
* @note used when the value is calculated or isn't a value
|
||||
* @{
|
||||
|
@ -54,29 +53,29 @@
|
|||
#define TIM_CH_PIN(x,y) CAT4(GPIO_TIM,x,_CH,y)
|
||||
/** get RCC for port based on TIMx_CHy identifier */
|
||||
#define RCC_TIM_CH(x,y) CAT4(RCC_TIM,x,_CH,y)
|
||||
#define RCC_TIM1_CH1 RCC_GPIOA
|
||||
#define RCC_TIM1_CH2 RCC_GPIOA
|
||||
#define RCC_TIM1_CH3 RCC_GPIOA
|
||||
#define RCC_TIM1_CH4 RCC_GPIOA
|
||||
#define RCC_TIM1_CH1N RCC_GPIOB
|
||||
#define RCC_TIM1_CH2N RCC_GPIOB
|
||||
#define RCC_TIM1_CH3N RCC_GPIOB
|
||||
#define RCC_TIM2_CH1_ETR RCC_GPIOA
|
||||
#define RCC_TIM2_CH2 RCC_GPIOA
|
||||
#define RCC_TIM2_CH3 RCC_GPIOA
|
||||
#define RCC_TIM2_CH4 RCC_GPIOA
|
||||
#define RCC_TIM3_CH1 RCC_GPIOA
|
||||
#define RCC_TIM3_CH2 RCC_GPIOA
|
||||
#define RCC_TIM3_CH3 RCC_GPIOB
|
||||
#define RCC_TIM3_CH4 RCC_GPIOB
|
||||
#define RCC_TIM4_CH1 RCC_GPIOB
|
||||
#define RCC_TIM4_CH2 RCC_GPIOB
|
||||
#define RCC_TIM4_CH3 RCC_GPIOB
|
||||
#define RCC_TIM4_CH4 RCC_GPIOB
|
||||
#define RCC_TIM5_CH1 RCC_GPIOA
|
||||
#define RCC_TIM5_CH2 RCC_GPIOA
|
||||
#define RCC_TIM5_CH3 RCC_GPIOA
|
||||
#define RCC_TIM5_CH4 RCC_GPIOA
|
||||
#define RCC_TIM1_CH1 RCC_GPIOA /**< RCC for port for on TIM1_CH1 */
|
||||
#define RCC_TIM1_CH2 RCC_GPIOA /**< RCC for port for on TIM1_CH2 */
|
||||
#define RCC_TIM1_CH3 RCC_GPIOA /**< RCC for port for on TIM1_CH3 */
|
||||
#define RCC_TIM1_CH4 RCC_GPIOA /**< RCC for port for on TIM1_CH4 */
|
||||
#define RCC_TIM1_CH1N RCC_GPIOB /**< RCC for port for on TIM1_CH1N */
|
||||
#define RCC_TIM1_CH2N RCC_GPIOB /**< RCC for port for on TIM1_CH2N */
|
||||
#define RCC_TIM1_CH3N RCC_GPIOB /**< RCC for port for on TIM1_CH3N */
|
||||
#define RCC_TIM2_CH1_ETR RCC_GPIOA /**< RCC for port for on TIM2_CH1_ETR */
|
||||
#define RCC_TIM2_CH2 RCC_GPIOA /**< RCC for port for on TIM2_CH2 */
|
||||
#define RCC_TIM2_CH3 RCC_GPIOA /**< RCC for port for on TIM2_CH3 */
|
||||
#define RCC_TIM2_CH4 RCC_GPIOA /**< RCC for port for on TIM2_CH4 */
|
||||
#define RCC_TIM3_CH1 RCC_GPIOA /**< RCC for port for on TIM3_CH1 */
|
||||
#define RCC_TIM3_CH2 RCC_GPIOA /**< RCC for port for on TIM3_CH2 */
|
||||
#define RCC_TIM3_CH3 RCC_GPIOB /**< RCC for port for on TIM3_CH3 */
|
||||
#define RCC_TIM3_CH4 RCC_GPIOB /**< RCC for port for on TIM3_CH4 */
|
||||
#define RCC_TIM4_CH1 RCC_GPIOB /**< RCC for port for on TIM4_CH1 */
|
||||
#define RCC_TIM4_CH2 RCC_GPIOB /**< RCC for port for on TIM4_CH2 */
|
||||
#define RCC_TIM4_CH3 RCC_GPIOB /**< RCC for port for on TIM4_CH3 */
|
||||
#define RCC_TIM4_CH4 RCC_GPIOB /**< RCC for port for on TIM4_CH4 */
|
||||
#define RCC_TIM5_CH1 RCC_GPIOA /**< RCC for port for on TIM5_CH1 */
|
||||
#define RCC_TIM5_CH2 RCC_GPIOA /**< RCC for port for on TIM5_CH2 */
|
||||
#define RCC_TIM5_CH3 RCC_GPIOA /**< RCC for port for on TIM5_CH3 */
|
||||
#define RCC_TIM5_CH4 RCC_GPIOA /**< RCC for port for on TIM5_CH4 */
|
||||
/** get TIM_IC based on CHx identifier */
|
||||
#define TIM_IC(x) CAT2(TIM_IC,x)
|
||||
/** get TIM_IC_IN_TI based on CHx identifier */
|
||||
|
@ -193,16 +192,76 @@
|
|||
#define RCC_ADC12_IN15 RCC_GPIOC /**< ADC12_IN15 is on PC5 */
|
||||
/** get channel based on ADC12_IN identifier */
|
||||
#define ADC_CHANNEL(x) CAT2(ADC_CHANNEL,x)
|
||||
/** get I2C based on I2C identifier */
|
||||
#define I2C(x) CAT2(I2C,x)
|
||||
/** get RCC for I2C based on I2C identifier */
|
||||
#define RCC_I2C(x) CAT2(RCC_I2C,x)
|
||||
/** get RCC for GPIO port for SCL based on I2C identifier */
|
||||
#define RCC_I2C_SCL_PORT(x) CAT3(RCC_I2C,x,_PORT)
|
||||
#define RCC_I2C1_PORT RCC_GPIOB /**< RCC for GPIO port for SCL for I2C1 */
|
||||
#define RCC_I2C2_PORT RCC_GPIOB /**< RCC for GPIO port for SCL for I2C2 */
|
||||
/** get RCC for GPIO port for SCL based on I2C identifier */
|
||||
#define RCC_I2C_SDA_PORT(x) CAT3(RCC_I2C,x,_PORT)
|
||||
#define RCC_I2C1_SDA_PORT RCC_GPIOB /**< RCC for GPIO port for SDA for I2C1 */
|
||||
#define RCC_I2C2_SDA_PORT RCC_GPIOB /**< RCC for GPIO port for SDA for I2C2 */
|
||||
/** get I2C port for SCL pin based on I2C identifier */
|
||||
#define I2C_SCL_PORT(x) CAT3(GPIO_BANK_I2C,x,_SCL)
|
||||
/** get I2C port for SDA pin based on I2C identifier */
|
||||
#define I2C_SDA_PORT(x) CAT3(GPIO_BANK_I2C,x,_SDA)
|
||||
/** get I2C pin for SCL pin based on I2C identifier */
|
||||
#define I2C_SCL_PIN(x) CAT3(GPIO_I2C,x,_SCL)
|
||||
/** get I2C port for SDA pin based on I2C identifier */
|
||||
#define I2C_SDA_PIN(x) CAT3(GPIO_I2C,x,_SDA)
|
||||
/** get SPI based on SPI identifier */
|
||||
#define SPI(x) CAT2(SPI,x)
|
||||
/** get RCC for SPI based on SPI identifier */
|
||||
#define RCC_SPI(x) CAT2(RCC_SPI,x)
|
||||
/** get RCC for GPIO port for SPI NSS signals */
|
||||
#define RCC_SPI_NSS_PORT(x) CAT3(RCC_SPI,x,_NSS_PORT)
|
||||
#define RCC_SPI1_NSS_PORT RCC_GPIOA /**< RCC for GPIO port for NSS for SPI1 */
|
||||
#define RCC_SPI1_RE_NSS_PORT RCC_GPIOA /**< RCC for GPIO port for NSS for SPI1_RE */
|
||||
#define RCC_SPI2_NSS_PORT RCC_GPIOB /**< RCC for GPIO port for NSS for SPI2 */
|
||||
/** get RCC for GPIO port for SPI SCK signals */
|
||||
#define RCC_SPI_SCK_PORT(x) CAT3(RCC_SPI,x,_SCK_PORT)
|
||||
#define RCC_SPI1_SCK_PORT RCC_GPIOA /**< RCC for GPIO port for NSS for SPI1 */
|
||||
#define RCC_SPI1_RE_SCK_PORT RCC_GPIOB /**< RCC for GPIO port for NSS for SPI1_RE */
|
||||
#define RCC_SPI2_SCK_PORT RCC_GPIOB /**< RCC for GPIO port for NSS for SPI2 */
|
||||
/** get RCC for GPIO port for SPI MISO signals */
|
||||
#define RCC_SPI_MISO_PORT(x) CAT3(RCC_SPI,x,_MISO_PORT)
|
||||
#define RCC_SPI1_MISO_PORT RCC_GPIOA /**< RCC for GPIO port for NSS for SPI1 */
|
||||
#define RCC_SPI1_RE_MISO_PORT RCC_GPIOB /**< RCC for GPIO port for NSS for SPI1_RE */
|
||||
#define RCC_SPI2_MISO_PORT RCC_GPIOB /**< RCC for GPIO port for NSS for SPI2 */
|
||||
/** get RCC for GPIO port for SPI MOSI signals */
|
||||
#define RCC_SPI_MOSI_PORT(x) CAT3(RCC_SPI,x,_MOSI_PORT)
|
||||
#define RCC_SPI1_MOSI_PORT RCC_GPIOA /**< RCC for GPIO port for NSS for SPI1 */
|
||||
#define RCC_SPI1_RE_MOSI_PORT RCC_GPIOB /**< RCC for GPIO port for NSS for SPI1_RE */
|
||||
#define RCC_SPI2_MOSI_PORT RCC_GPIOB /**< RCC for GPIO port for NSS for SPI2 */
|
||||
/** get SPI port for NSS signal based on SPI identifier */
|
||||
#define SPI_NSS_PORT(x) CAT3(GPIO_BANK_SPI,x,_NSS)
|
||||
/** get SPI port for SCK signal based on SPI identifier */
|
||||
#define SPI_SCK_PORT(x) CAT3(GPIO_BANK_SPI,x,_SCK)
|
||||
/** get SPI port for MISO signal based on SPI identifier */
|
||||
#define SPI_MISO_PORT(x) CAT3(GPIO_BANK_SPI,x,_MISO)
|
||||
/** get SPI port for MOSI signal based on SPI identifier */
|
||||
#define SPI_MOSI_PORT(x) CAT3(GPIO_BANK_SPI,x,_MOSI)
|
||||
/** get SPI pin for NSS signal based on SPI identifier */
|
||||
#define SPI_NSS_PIN(x) CAT3(GPIO_SPI,x,_NSS)
|
||||
/** get SPI pin for SCK signal based on SPI identifier */
|
||||
#define SPI_SCK_PIN(x) CAT3(GPIO_SPI,x,_SCK)
|
||||
/** get SPI pin for MISO signal based on SPI identifier */
|
||||
#define SPI_MISO_PIN(x) CAT3(GPIO_SPI,x,_MISO)
|
||||
/** get SPI pin for MOSI signal based on SPI identifier */
|
||||
#define SPI_MOSI_PIN(x) CAT3(GPIO_SPI,x,_MOSI)
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @defgroup board_led board LED GPIO
|
||||
* @{
|
||||
*/
|
||||
#if defined(SYSTEM_BOARD)
|
||||
/* on system board LED is on pin 11/PA1 */
|
||||
#define LED_PORT A /**< GPIO port (port A on system board) */
|
||||
#define LED_PIN 1 /**< GPIO pin (pin PA1 on system board) */
|
||||
#if defined(SYSTEM_BOARD) || defined(CORE_BOARD)
|
||||
/* on system and core board LED is on pin 11/PA1 */
|
||||
#define LED_PORT A /**< GPIO port (port A) */
|
||||
#define LED_PIN 1 /**< GPIO pin (pin PA1) */
|
||||
#elif defined(BLUE_PILL)
|
||||
/* on minimum system LED is on pin 2/PC13 */
|
||||
#define LED_PORT C /**< GPIO port (port C on blue pill) */
|
||||
|
@ -221,14 +280,15 @@
|
|||
/* on maple mini user button is on 32/PB8 */
|
||||
#define BUTTON_PORT B /**< GPIO port (port B on maple mini) */
|
||||
#define BUTTON_PIN 8 /**< GPIO pin (pin PB8 on maple mini) */
|
||||
#elif defined(CORE_BOARD)
|
||||
/* on core board user button is on PA8 */
|
||||
#define BUTTON_PORT A /**< GPIO port (port A) */
|
||||
#define BUTTON_PIN 8 /**< GPIO pin (pin PA8) */
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
extern volatile bool button_flag; /**< flag set when board user button has been pressed/released */
|
||||
|
||||
/** default printf output */
|
||||
int _write(int file, char *ptr, int len);
|
||||
|
||||
/** get binary representation of a number
|
||||
* @param[in] binary number to represent in binary
|
||||
* @param[in] rjust justify representation with leading zeros
|
||||
|
|
Loading…
Reference in New Issue