/*******************************************************************************
*
* 代码许可和免责信息
* 武汉芯源半导体有限公司授予您使用所有编程代码示例的非专属的版权许可，您可以由此
* 生成根据您的特定需要而定制的相似功能。根据不能被排除的任何法定保证，武汉芯源半
* 导体有限公司及其程序开发商和供应商对程序或技术支持（如果有）不提供任何明示或暗
* 含的保证或条件，包括但不限于暗含的有关适销性、适用于某种特定用途和非侵权的保证
* 或条件。
* 无论何种情形，武汉芯源半导体有限公司及其程序开发商或供应商均不对下列各项负责，
* 即使被告知其发生的可能性时，也是如此：数据的丢失或损坏；直接的、特别的、附带的
* 或间接的损害，或任何后果性经济损害；或利润、业务、收入、商誉或预期可节省金额的
* 损失。
* 某些司法辖区不允许对直接的、附带的或后果性的损害有任何的排除或限制，因此某些或
* 全部上述排除或限制可能并不适用于您。
*
*******************************************************************************/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CW32L052_GPIO_H__
#define __CW32L052_GPIO_H__

#ifdef __cplusplus
extern "C"
{
#endif

/*****************************************************************************/
/* Include files                                                             */
/*****************************************************************************/
#include "cw32l052.h"
#include "base_types.h"

/*****************************************************************************/
/* Global pre-processor symbols/macros ('#define')                           */
/*****************************************************************************/

typedef struct
{
    uint32_t Pins;
    uint32_t Mode;
    uint32_t IT;
} GPIO_InitTypeDef;

typedef enum
{
    GPIO_Pin_RESET = 0,
    GPIO_Pin_SET
} GPIO_PinState;

//============================================================

void GPIO_SWD2GPIO(void);
void GPIO_GPIO2SWD(void);
void GPIO_LockPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pins);
void GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pins);
void GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init);
void GPIO_ConfigFilter(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pins, uint32_t FltClk);
void GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pins, GPIO_PinState PinState);
void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t Value);
void GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pins);
GPIO_PinState GPIO_ReadPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);
void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pins);
void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pins);    
//============================================================

#define GPIO_MODE_ANALOG                    (0X00)
#define GPIO_MODE_INPUT                     (0x10)
#define GPIO_MODE_INPUT_PULLUP              (0x11)
#define GPIO_MODE_INPUT_PULLDOWN            (0x12)
#define GPIO_MODE_OUTPUT_PP                 (0x20)
#define GPIO_MODE_OUTPUT_OD                 (0x21)

#define GPIO_IT_NONE                        (0x80)
#define GPIO_IT_RISING                      (0x81)
#define GPIO_IT_FALLING                     (0x82)
#define GPIO_IT_HIGH                        (0x84)
#define GPIO_IT_LOW                         (0x88)

//============================================================

#define GPIO_PIN_0                          ((uint16_t)0x0001)   /* Pin 0    selected    */
#define GPIO_PIN_1                          ((uint16_t)0x0002)   /* Pin 1    selected    */
#define GPIO_PIN_2                          ((uint16_t)0x0004)   /* Pin 2    selected    */
#define GPIO_PIN_3                          ((uint16_t)0x0008)   /* Pin 3    selected    */
#define GPIO_PIN_4                          ((uint16_t)0x0010)   /* Pin 4    selected    */
#define GPIO_PIN_5                          ((uint16_t)0x0020)   /* Pin 5    selected    */
#define GPIO_PIN_6                          ((uint16_t)0x0040)   /* Pin 6    selected    */
#define GPIO_PIN_7                          ((uint16_t)0x0080)   /* Pin 7    selected    */
#define GPIO_PIN_8                          ((uint16_t)0x0100)   /* Pin 8    selected    */
#define GPIO_PIN_9                          ((uint16_t)0x0200)   /* Pin 9    selected    */
#define GPIO_PIN_10                         ((uint16_t)0x0400)   /* Pin 10   selected    */
#define GPIO_PIN_11                         ((uint16_t)0x0800)   /* Pin 11   selected    */
#define GPIO_PIN_12                         ((uint16_t)0x1000)   /* Pin 12   selected    */
#define GPIO_PIN_13                         ((uint16_t)0x2000)   /* Pin 13   selected    */
#define GPIO_PIN_14                         ((uint16_t)0x4000)   /* Pin 14   selected    */
#define GPIO_PIN_15                         ((uint16_t)0x8000)   /* Pin 15   selected    */
#define GPIO_PIN_All                        ((uint16_t)0xFFFF)   /* All pins selected    */

//============================================================
//端口滤波定义
#define GPIO_FLTCLK_HCLK2                   (((uint32_t)0) << 16)
#define GPIO_FLTCLK_HCLK4                   (((uint32_t)1) << 16)
#define GPIO_FLTCLK_HCLK8                   (((uint32_t)2) << 16)
#define GPIO_FLTCLK_BTIM1OV                 (((uint32_t)3) << 16)
#define GPIO_FLTCLK_RC150K                  (((uint32_t)4) << 16)
#define GPIO_FLTCLK_LSI                     (((uint32_t)5) << 16)
#define GPIO_FLTCLK_RC10K                   (((uint32_t)6) << 16)
#define GPIO_FLTCLK_LPTIMPWM                (((uint32_t)7) << 16)

//============================================================
//清除CW_GPIO中断标志
#define GPIOA_INTFLAG_CLR(Mask)             ((CW_GPIOA->ICR) = (~((uint32_t)(Mask))))
#define GPIOB_INTFLAG_CLR(Mask)             ((CW_GPIOB->ICR) = (~((uint32_t)(Mask))))
#define GPIOC_INTFLAG_CLR(Mask)             ((CW_GPIOC->ICR) = (~((uint32_t)(Mask))))
#define GPIOD_INTFLAG_CLR(Mask)             ((CW_GPIOD->ICR) = (~((uint32_t)(Mask))))
#define GPIOE_INTFLAG_CLR(Mask)             ((CW_GPIOE->ICR) = (~((uint32_t)(Mask))))
#define GPIOF_INTFLAG_CLR(Mask)             ((CW_GPIOF->ICR) = (~((uint32_t)(Mask))))

//============================================================
//ANALOG OR DIGTAL
#define PA00_DIGTAL_ENABLE()                (CW_GPIOA->ANALOG_f.PIN0  = 0)
#define PA00_ANALOG_ENABLE()                (CW_GPIOA->ANALOG_f.PIN0  = 1)
#define PA01_DIGTAL_ENABLE()                (CW_GPIOA->ANALOG_f.PIN1  = 0)
#define PA01_ANALOG_ENABLE()                (CW_GPIOA->ANALOG_f.PIN1  = 1)
#define PA02_DIGTAL_ENABLE()                (CW_GPIOA->ANALOG_f.PIN2  = 0)
#define PA02_ANALOG_ENABLE()                (CW_GPIOA->ANALOG_f.PIN2  = 1)
#define PA03_DIGTAL_ENABLE()                (CW_GPIOA->ANALOG_f.PIN3  = 0)
#define PA03_ANALOG_ENABLE()                (CW_GPIOA->ANALOG_f.PIN3  = 1)
#define PA04_DIGTAL_ENABLE()                (CW_GPIOA->ANALOG_f.PIN4  = 0)
#define PA04_ANALOG_ENABLE()                (CW_GPIOA->ANALOG_f.PIN4  = 1)
#define PA05_DIGTAL_ENABLE()                (CW_GPIOA->ANALOG_f.PIN5  = 0)
#define PA05_ANALOG_ENABLE()                (CW_GPIOA->ANALOG_f.PIN5  = 1)
#define PA06_DIGTAL_ENABLE()                (CW_GPIOA->ANALOG_f.PIN6  = 0)
#define PA06_ANALOG_ENABLE()                (CW_GPIOA->ANALOG_f.PIN6  = 1)
#define PA07_DIGTAL_ENABLE()                (CW_GPIOA->ANALOG_f.PIN7  = 0)
#define PA07_ANALOG_ENABLE()                (CW_GPIOA->ANALOG_f.PIN7  = 1)
#define PA08_DIGTAL_ENABLE()                (CW_GPIOA->ANALOG_f.PIN8  = 0)
#define PA08_ANALOG_ENABLE()                (CW_GPIOA->ANALOG_f.PIN8  = 1)
#define PA09_DIGTAL_ENABLE()                (CW_GPIOA->ANALOG_f.PIN9  = 0)
#define PA09_ANALOG_ENABLE()                (CW_GPIOA->ANALOG_f.PIN9  = 1)
#define PA10_DIGTAL_ENABLE()                (CW_GPIOA->ANALOG_f.PIN10 = 0)
#define PA10_ANALOG_ENABLE()                (CW_GPIOA->ANALOG_f.PIN10 = 1)
#define PA11_DIGTAL_ENABLE()                (CW_GPIOA->ANALOG_f.PIN11 = 0)
#define PA11_ANALOG_ENABLE()                (CW_GPIOA->ANALOG_f.PIN11 = 1)
#define PA12_DIGTAL_ENABLE()                (CW_GPIOA->ANALOG_f.PIN12 = 0)
#define PA12_ANALOG_ENABLE()                (CW_GPIOA->ANALOG_f.PIN12 = 1)
#define PA13_DIGTAL_ENABLE()                (CW_GPIOA->ANALOG_f.PIN13 = 0)
#define PA13_ANALOG_ENABLE()                (CW_GPIOA->ANALOG_f.PIN13 = 1)
#define PA14_DIGTAL_ENABLE()                (CW_GPIOA->ANALOG_f.PIN14 = 0)
#define PA14_ANALOG_ENABLE()                (CW_GPIOA->ANALOG_f.PIN14 = 1)
#define PA15_DIGTAL_ENABLE()                (CW_GPIOA->ANALOG_f.PIN15 = 0)
#define PA15_ANALOG_ENABLE()                (CW_GPIOA->ANALOG_f.PIN15 = 1)

#define PB00_DIGTAL_ENABLE()                (CW_GPIOB->ANALOG_f.PIN0  = 0)
#define PB00_ANALOG_ENABLE()                (CW_GPIOB->ANALOG_f.PIN0  = 1)
#define PB01_DIGTAL_ENABLE()                (CW_GPIOB->ANALOG_f.PIN1  = 0)
#define PB01_ANALOG_ENABLE()                (CW_GPIOB->ANALOG_f.PIN1  = 1)
#define PB02_DIGTAL_ENABLE()                (CW_GPIOB->ANALOG_f.PIN2  = 0)
#define PB02_ANALOG_ENABLE()                (CW_GPIOB->ANALOG_f.PIN2  = 1)
#define PB03_DIGTAL_ENABLE()                (CW_GPIOB->ANALOG_f.PIN3  = 0)
#define PB03_ANALOG_ENABLE()                (CW_GPIOB->ANALOG_f.PIN3  = 1)
#define PB04_DIGTAL_ENABLE()                (CW_GPIOB->ANALOG_f.PIN4  = 0)
#define PB04_ANALOG_ENABLE()                (CW_GPIOB->ANALOG_f.PIN4  = 1)
#define PB05_DIGTAL_ENABLE()                (CW_GPIOB->ANALOG_f.PIN5  = 0)
#define PB05_ANALOG_ENABLE()                (CW_GPIOB->ANALOG_f.PIN5  = 1)
#define PB06_DIGTAL_ENABLE()                (CW_GPIOB->ANALOG_f.PIN6  = 0)
#define PB06_ANALOG_ENABLE()                (CW_GPIOB->ANALOG_f.PIN6  = 1)
#define PB07_DIGTAL_ENABLE()                (CW_GPIOB->ANALOG_f.PIN7  = 0)
#define PB07_ANALOG_ENABLE()                (CW_GPIOB->ANALOG_f.PIN7  = 1)
#define PB08_DIGTAL_ENABLE()                (CW_GPIOB->ANALOG_f.PIN8  = 0)
#define PB08_ANALOG_ENABLE()                (CW_GPIOB->ANALOG_f.PIN8  = 1)
#define PB09_DIGTAL_ENABLE()                (CW_GPIOB->ANALOG_f.PIN9  = 0)
#define PB09_ANALOG_ENABLE()                (CW_GPIOB->ANALOG_f.PIN9  = 1)
#define PB10_DIGTAL_ENABLE()                (CW_GPIOB->ANALOG_f.PIN10 = 0)
#define PB10_ANALOG_ENABLE()                (CW_GPIOB->ANALOG_f.PIN10 = 1)
#define PB11_DIGTAL_ENABLE()                (CW_GPIOB->ANALOG_f.PIN11 = 0)
#define PB11_ANALOG_ENABLE()                (CW_GPIOB->ANALOG_f.PIN11 = 1)
#define PB12_DIGTAL_ENABLE()                (CW_GPIOB->ANALOG_f.PIN12 = 0)
#define PB12_ANALOG_ENABLE()                (CW_GPIOB->ANALOG_f.PIN12 = 1)
#define PB13_DIGTAL_ENABLE()                (CW_GPIOB->ANALOG_f.PIN13 = 0)
#define PB13_ANALOG_ENABLE()                (CW_GPIOB->ANALOG_f.PIN13 = 1)
#define PB14_DIGTAL_ENABLE()                (CW_GPIOB->ANALOG_f.PIN14 = 0)
#define PB14_ANALOG_ENABLE()                (CW_GPIOB->ANALOG_f.PIN14 = 1)
#define PB15_DIGTAL_ENABLE()                (CW_GPIOB->ANALOG_f.PIN15 = 0)
#define PB15_ANALOG_ENABLE()                (CW_GPIOB->ANALOG_f.PIN15 = 1)

#define PC00_DIGTAL_ENABLE()                (CW_GPIOC->ANALOG_f.PIN0  = 0)
#define PC00_ANALOG_ENABLE()                (CW_GPIOC->ANALOG_f.PIN0  = 1)
#define PC01_DIGTAL_ENABLE()                (CW_GPIOC->ANALOG_f.PIN1  = 0)
#define PC01_ANALOG_ENABLE()                (CW_GPIOC->ANALOG_f.PIN1  = 1)
#define PC02_DIGTAL_ENABLE()                (CW_GPIOC->ANALOG_f.PIN2  = 0)
#define PC02_ANALOG_ENABLE()                (CW_GPIOC->ANALOG_f.PIN2  = 1)
#define PC03_DIGTAL_ENABLE()                (CW_GPIOC->ANALOG_f.PIN3  = 0)
#define PC03_ANALOG_ENABLE()                (CW_GPIOC->ANALOG_f.PIN3  = 1)
#define PC04_DIGTAL_ENABLE()                (CW_GPIOC->ANALOG_f.PIN4  = 0)
#define PC04_ANALOG_ENABLE()                (CW_GPIOC->ANALOG_f.PIN4  = 1)
#define PC05_DIGTAL_ENABLE()                (CW_GPIOC->ANALOG_f.PIN5  = 0)
#define PC05_ANALOG_ENABLE()                (CW_GPIOC->ANALOG_f.PIN5  = 1)
#define PC06_DIGTAL_ENABLE()                (CW_GPIOC->ANALOG_f.PIN6  = 0)
#define PC06_ANALOG_ENABLE()                (CW_GPIOC->ANALOG_f.PIN6  = 1)
#define PC07_DIGTAL_ENABLE()                (CW_GPIOC->ANALOG_f.PIN7  = 0)
#define PC07_ANALOG_ENABLE()                (CW_GPIOC->ANALOG_f.PIN7  = 1)
#define PC08_DIGTAL_ENABLE()                (CW_GPIOC->ANALOG_f.PIN8  = 0)
#define PC08_ANALOG_ENABLE()                (CW_GPIOC->ANALOG_f.PIN8  = 1)
#define PC09_DIGTAL_ENABLE()                (CW_GPIOC->ANALOG_f.PIN9  = 0)
#define PC09_ANALOG_ENABLE()                (CW_GPIOC->ANALOG_f.PIN9  = 1)
#define PC10_DIGTAL_ENABLE()                (CW_GPIOC->ANALOG_f.PIN10 = 0)
#define PC10_ANALOG_ENABLE()                (CW_GPIOC->ANALOG_f.PIN10 = 1)
#define PC11_DIGTAL_ENABLE()                (CW_GPIOC->ANALOG_f.PIN11 = 0)
#define PC11_ANALOG_ENABLE()                (CW_GPIOC->ANALOG_f.PIN11 = 1)
#define PC12_DIGTAL_ENABLE()                (CW_GPIOC->ANALOG_f.PIN12 = 0)
#define PC12_ANALOG_ENABLE()                (CW_GPIOC->ANALOG_f.PIN12 = 1)
#define PC13_DIGTAL_ENABLE()                (CW_GPIOC->ANALOG_f.PIN13 = 0)
#define PC13_ANALOG_ENABLE()                (CW_GPIOC->ANALOG_f.PIN13 = 1)
#define PC14_DIGTAL_ENABLE()                (CW_GPIOC->ANALOG_f.PIN14 = 0)
#define PC14_ANALOG_ENABLE()                (CW_GPIOC->ANALOG_f.PIN14 = 1)
#define PC15_DIGTAL_ENABLE()                (CW_GPIOC->ANALOG_f.PIN15 = 0)
#define PC15_ANALOG_ENABLE()                (CW_GPIOC->ANALOG_f.PIN15 = 1)

#define PD00_DIGTAL_ENABLE()                (CW_GPIOD->ANALOG_f.PIN0  = 0)
#define PD00_ANALOG_ENABLE()                (CW_GPIOD->ANALOG_f.PIN0  = 1)
#define PD01_DIGTAL_ENABLE()                (CW_GPIOD->ANALOG_f.PIN1  = 0)
#define PD01_ANALOG_ENABLE()                (CW_GPIOD->ANALOG_f.PIN1  = 1)
#define PD02_DIGTAL_ENABLE()                (CW_GPIOD->ANALOG_f.PIN2  = 0)
#define PD02_ANALOG_ENABLE()                (CW_GPIOD->ANALOG_f.PIN2  = 1)
#define PD03_DIGTAL_ENABLE()                (CW_GPIOD->ANALOG_f.PIN3  = 0)
#define PD03_ANALOG_ENABLE()                (CW_GPIOD->ANALOG_f.PIN3  = 1)
#define PD04_DIGTAL_ENABLE()                (CW_GPIOD->ANALOG_f.PIN4  = 0)
#define PD04_ANALOG_ENABLE()                (CW_GPIOD->ANALOG_f.PIN4  = 1)
#define PD05_DIGTAL_ENABLE()                (CW_GPIOD->ANALOG_f.PIN5  = 0)
#define PD05_ANALOG_ENABLE()                (CW_GPIOD->ANALOG_f.PIN5  = 1)
#define PD06_DIGTAL_ENABLE()                (CW_GPIOD->ANALOG_f.PIN6  = 0)
#define PD06_ANALOG_ENABLE()                (CW_GPIOD->ANALOG_f.PIN6  = 1)
#define PD07_DIGTAL_ENABLE()                (CW_GPIOD->ANALOG_f.PIN7  = 0)
#define PD07_ANALOG_ENABLE()                (CW_GPIOD->ANALOG_f.PIN7  = 1)
#define PD08_DIGTAL_ENABLE()                (CW_GPIOD->ANALOG_f.PIN8  = 0)
#define PD08_ANALOG_ENABLE()                (CW_GPIOD->ANALOG_f.PIN8  = 1)
#define PD09_DIGTAL_ENABLE()                (CW_GPIOD->ANALOG_f.PIN9  = 0)
#define PD09_ANALOG_ENABLE()                (CW_GPIOD->ANALOG_f.PIN9  = 1)
#define PD10_DIGTAL_ENABLE()                (CW_GPIOD->ANALOG_f.PIN10 = 0)
#define PD10_ANALOG_ENABLE()                (CW_GPIOD->ANALOG_f.PIN10 = 1)
#define PD11_DIGTAL_ENABLE()                (CW_GPIOD->ANALOG_f.PIN11 = 0)
#define PD11_ANALOG_ENABLE()                (CW_GPIOD->ANALOG_f.PIN11 = 1)
#define PD12_DIGTAL_ENABLE()                (CW_GPIOD->ANALOG_f.PIN12 = 0)
#define PD12_ANALOG_ENABLE()                (CW_GPIOD->ANALOG_f.PIN12 = 1)
#define PD13_DIGTAL_ENABLE()                (CW_GPIOD->ANALOG_f.PIN13 = 0)
#define PD13_ANALOG_ENABLE()                (CW_GPIOD->ANALOG_f.PIN13 = 1)
#define PD14_DIGTAL_ENABLE()                (CW_GPIOD->ANALOG_f.PIN14 = 0)
#define PD14_ANALOG_ENABLE()                (CW_GPIOD->ANALOG_f.PIN14 = 1)
#define PD15_DIGTAL_ENABLE()                (CW_GPIOD->ANALOG_f.PIN15 = 0)
#define PD15_ANALOG_ENABLE()                (CW_GPIOD->ANALOG_f.PIN15 = 1)

#define PF00_DIGTAL_ENABLE()                (CW_GPIOF->ANALOG_f.PIN0  = 0)
#define PF00_ANALOG_ENABLE()                (CW_GPIOF->ANALOG_f.PIN0  = 1)
#define PF01_DIGTAL_ENABLE()                (CW_GPIOF->ANALOG_f.PIN1  = 0)
#define PF01_ANALOG_ENABLE()                (CW_GPIOF->ANALOG_f.PIN1  = 1)
#define PF02_DIGTAL_ENABLE()                (CW_GPIOF->ANALOG_f.PIN2  = 0)
#define PF02_ANALOG_ENABLE()                (CW_GPIOF->ANALOG_f.PIN2  = 1)
#define PF03_DIGTAL_ENABLE()                (CW_GPIOF->ANALOG_f.PIN3  = 0)
#define PF03_ANALOG_ENABLE()                (CW_GPIOF->ANALOG_f.PIN3  = 1)
#define PF04_DIGTAL_ENABLE()                (CW_GPIOF->ANALOG_f.PIN4  = 0)
#define PF04_ANALOG_ENABLE()                (CW_GPIOF->ANALOG_f.PIN4  = 1)
#define PF05_DIGTAL_ENABLE()                (CW_GPIOF->ANALOG_f.PIN5  = 0)
#define PF05_ANALOG_ENABLE()                (CW_GPIOF->ANALOG_f.PIN5  = 1)
#define PF06_DIGTAL_ENABLE()                (CW_GPIOF->ANALOG_f.PIN6  = 0)
#define PF06_ANALOG_ENABLE()                (CW_GPIOF->ANALOG_f.PIN6  = 1)
#define PF07_DIGTAL_ENABLE()                (CW_GPIOF->ANALOG_f.PIN7  = 0)
#define PF07_ANALOG_ENABLE()                (CW_GPIOF->ANALOG_f.PIN7  = 1)
#define PF08_DIGTAL_ENABLE()                (CW_GPIOF->ANALOG_f.PIN8  = 0)
#define PF08_ANALOG_ENABLE()                (CW_GPIOF->ANALOG_f.PIN8  = 1)
#define PF09_DIGTAL_ENABLE()                (CW_GPIOF->ANALOG_f.PIN9  = 0)
#define PF09_ANALOG_ENABLE()                (CW_GPIOF->ANALOG_f.PIN9  = 1)
#define PF10_DIGTAL_ENABLE()                (CW_GPIOF->ANALOG_f.PIN10 = 0)
#define PF10_ANALOG_ENABLE()                (CW_GPIOF->ANALOG_f.PIN10 = 1)

//============================================================
// INPUTAND OUTPUT
#define PA00_DIR_OUTPUT()                   (CW_GPIOA->DIR_f.PIN0  = 0)
#define PA00_DIR_INPUT()                    (CW_GPIOA->DIR_f.PIN0  = 1)
#define PA01_DIR_OUTPUT()                   (CW_GPIOA->DIR_f.PIN1  = 0)
#define PA01_DIR_INPUT()                    (CW_GPIOA->DIR_f.PIN1  = 1)
#define PA02_DIR_OUTPUT()                   (CW_GPIOA->DIR_f.PIN2  = 0)
#define PA02_DIR_INPUT()                    (CW_GPIOA->DIR_f.PIN2  = 1)
#define PA03_DIR_OUTPUT()                   (CW_GPIOA->DIR_f.PIN3  = 0)
#define PA03_DIR_INPUT()                    (CW_GPIOA->DIR_f.PIN3  = 1)
#define PA04_DIR_OUTPUT()                   (CW_GPIOA->DIR_f.PIN4  = 0)
#define PA04_DIR_INPUT()                    (CW_GPIOA->DIR_f.PIN4  = 1)
#define PA05_DIR_OUTPUT()                   (CW_GPIOA->DIR_f.PIN5  = 0)
#define PA05_DIR_INPUT()                    (CW_GPIOA->DIR_f.PIN5  = 1)
#define PA06_DIR_OUTPUT()                   (CW_GPIOA->DIR_f.PIN6  = 0)
#define PA06_DIR_INPUT()                    (CW_GPIOA->DIR_f.PIN6  = 1)
#define PA07_DIR_OUTPUT()                   (CW_GPIOA->DIR_f.PIN7  = 0)
#define PA07_DIR_INPUT()                    (CW_GPIOA->DIR_f.PIN7  = 1)
#define PA08_DIR_OUTPUT()                   (CW_GPIOA->DIR_f.PIN8  = 0)
#define PA08_DIR_INPUT()                    (CW_GPIOA->DIR_f.PIN8  = 1)
#define PA09_DIR_OUTPUT()                   (CW_GPIOA->DIR_f.PIN9  = 0)
#define PA09_DIR_INPUT()                    (CW_GPIOA->DIR_f.PIN9  = 1)
#define PA10_DIR_OUTPUT()                   (CW_GPIOA->DIR_f.PIN10 = 0)
#define PA10_DIR_INPUT()                    (CW_GPIOA->DIR_f.PIN10 = 1)
#define PA11_DIR_OUTPUT()                   (CW_GPIOA->DIR_f.PIN11 = 0)
#define PA11_DIR_INPUT()                    (CW_GPIOA->DIR_f.PIN11 = 1)
#define PA12_DIR_OUTPUT()                   (CW_GPIOA->DIR_f.PIN12 = 0)
#define PA12_DIR_INPUT()                    (CW_GPIOA->DIR_f.PIN12 = 1)
#define PA13_DIR_OUTPUT()                   (CW_GPIOA->DIR_f.PIN13 = 0)
#define PA13_DIR_INPUT()                    (CW_GPIOA->DIR_f.PIN13 = 1)
#define PA14_DIR_OUTPUT()                   (CW_GPIOA->DIR_f.PIN14 = 0)
#define PA14_DIR_INPUT()                    (CW_GPIOA->DIR_f.PIN14 = 1)
#define PA15_DIR_OUTPUT()                   (CW_GPIOA->DIR_f.PIN15 = 0)
#define PA15_DIR_INPUT()                    (CW_GPIOA->DIR_f.PIN15 = 1)

#define PB00_DIR_OUTPUT()                   (CW_GPIOB->DIR_f.PIN0  = 0)
#define PB00_DIR_INPUT()                    (CW_GPIOB->DIR_f.PIN0  = 1)
#define PB01_DIR_OUTPUT()                   (CW_GPIOB->DIR_f.PIN1  = 0)
#define PB01_DIR_INPUT()                    (CW_GPIOB->DIR_f.PIN1  = 1)
#define PB02_DIR_OUTPUT()                   (CW_GPIOB->DIR_f.PIN2  = 0)
#define PB02_DIR_INPUT()                    (CW_GPIOB->DIR_f.PIN2  = 1)
#define PB03_DIR_OUTPUT()                   (CW_GPIOB->DIR_f.PIN3  = 0)
#define PB03_DIR_INPUT()                    (CW_GPIOB->DIR_f.PIN3  = 1)
#define PB04_DIR_OUTPUT()                   (CW_GPIOB->DIR_f.PIN4  = 0)
#define PB04_DIR_INPUT()                    (CW_GPIOB->DIR_f.PIN4  = 1)
#define PB05_DIR_OUTPUT()                   (CW_GPIOB->DIR_f.PIN5  = 0)
#define PB05_DIR_INPUT()                    (CW_GPIOB->DIR_f.PIN5  = 1)
#define PB06_DIR_OUTPUT()                   (CW_GPIOB->DIR_f.PIN6  = 0)
#define PB06_DIR_INPUT()                    (CW_GPIOB->DIR_f.PIN6  = 1)
#define PB07_DIR_OUTPUT()                   (CW_GPIOB->DIR_f.PIN7  = 0)
#define PB07_DIR_INPUT()                    (CW_GPIOB->DIR_f.PIN7  = 1)
#define PB08_DIR_OUTPUT()                   (CW_GPIOB->DIR_f.PIN8  = 0)
#define PB08_DIR_INPUT()                    (CW_GPIOB->DIR_f.PIN8  = 1)
#define PB09_DIR_OUTPUT()                   (CW_GPIOB->DIR_f.PIN9  = 0)
#define PB09_DIR_INPUT()                    (CW_GPIOB->DIR_f.PIN9  = 1)
#define PB10_DIR_OUTPUT()                   (CW_GPIOB->DIR_f.PIN10 = 0)
#define PB10_DIR_INPUT()                    (CW_GPIOB->DIR_f.PIN10 = 1)
#define PB11_DIR_OUTPUT()                   (CW_GPIOB->DIR_f.PIN11 = 0)
#define PB11_DIR_INPUT()                    (CW_GPIOB->DIR_f.PIN11 = 1)
#define PB12_DIR_OUTPUT()                   (CW_GPIOB->DIR_f.PIN12 = 0)
#define PB12_DIR_INPUT()                    (CW_GPIOB->DIR_f.PIN12 = 1)
#define PB13_DIR_OUTPUT()                   (CW_GPIOB->DIR_f.PIN13 = 0)
#define PB13_DIR_INPUT()                    (CW_GPIOB->DIR_f.PIN13 = 1)
#define PB14_DIR_OUTPUT()                   (CW_GPIOB->DIR_f.PIN14 = 0)
#define PB14_DIR_INPUT()                    (CW_GPIOB->DIR_f.PIN14 = 1)
#define PB15_DIR_OUTPUT()                   (CW_GPIOB->DIR_f.PIN15 = 0)
#define PB15_DIR_INPUT()                    (CW_GPIOB->DIR_f.PIN15 = 1)

#define PC00_DIR_OUTPUT()                   (CW_GPIOC->DIR_f.PIN0  = 0)
#define PC00_DIR_INPUT()                    (CW_GPIOC->DIR_f.PIN0  = 1)
#define PC01_DIR_OUTPUT()                   (CW_GPIOC->DIR_f.PIN1  = 0)
#define PC01_DIR_INPUT()                    (CW_GPIOC->DIR_f.PIN1  = 1)
#define PC02_DIR_OUTPUT()                   (CW_GPIOC->DIR_f.PIN2  = 0)
#define PC02_DIR_INPUT()                    (CW_GPIOC->DIR_f.PIN2  = 1)
#define PC03_DIR_OUTPUT()                   (CW_GPIOC->DIR_f.PIN3  = 0)
#define PC03_DIR_INPUT()                    (CW_GPIOC->DIR_f.PIN3  = 1)
#define PC04_DIR_OUTPUT()                   (CW_GPIOC->DIR_f.PIN4  = 0)
#define PC04_DIR_INPUT()                    (CW_GPIOC->DIR_f.PIN4  = 1)
#define PC05_DIR_OUTPUT()                   (CW_GPIOC->DIR_f.PIN5  = 0)
#define PC05_DIR_INPUT()                    (CW_GPIOC->DIR_f.PIN5  = 1)
#define PC06_DIR_OUTPUT()                   (CW_GPIOC->DIR_f.PIN6  = 0)
#define PC06_DIR_INPUT()                    (CW_GPIOC->DIR_f.PIN6  = 1)
#define PC07_DIR_OUTPUT()                   (CW_GPIOC->DIR_f.PIN7  = 0)
#define PC07_DIR_INPUT()                    (CW_GPIOC->DIR_f.PIN7  = 1)
#define PC08_DIR_OUTPUT()                   (CW_GPIOC->DIR_f.PIN8  = 0)
#define PC08_DIR_INPUT()                    (CW_GPIOC->DIR_f.PIN8  = 1)
#define PC09_DIR_OUTPUT()                   (CW_GPIOC->DIR_f.PIN9  = 0)
#define PC09_DIR_INPUT()                    (CW_GPIOC->DIR_f.PIN9  = 1)
#define PC10_DIR_OUTPUT()                   (CW_GPIOC->DIR_f.PIN10 = 0)
#define PC10_DIR_INPUT()                    (CW_GPIOC->DIR_f.PIN10 = 1)
#define PC11_DIR_OUTPUT()                   (CW_GPIOC->DIR_f.PIN11 = 0)
#define PC11_DIR_INPUT()                    (CW_GPIOC->DIR_f.PIN11 = 1)
#define PC12_DIR_OUTPUT()                   (CW_GPIOC->DIR_f.PIN12 = 0)
#define PC12_DIR_INPUT()                    (CW_GPIOC->DIR_f.PIN12 = 1)
#define PC13_DIR_OUTPUT()                   (CW_GPIOC->DIR_f.PIN13 = 0)
#define PC13_DIR_INPUT()                    (CW_GPIOC->DIR_f.PIN13 = 1)
#define PC14_DIR_OUTPUT()                   (CW_GPIOC->DIR_f.PIN14 = 0)
#define PC14_DIR_INPUT()                    (CW_GPIOC->DIR_f.PIN14 = 1)
#define PC15_DIR_OUTPUT()                   (CW_GPIOC->DIR_f.PIN15 = 0)
#define PC15_DIR_INPUT()                    (CW_GPIOC->DIR_f.PIN15 = 1)

#define PD00_DIR_OUTPUT()                   (CW_GPIOD->DIR_f.PIN0  = 0)
#define PD00_DIR_INPUT()                    (CW_GPIOD->DIR_f.PIN0  = 1)
#define PD01_DIR_OUTPUT()                   (CW_GPIOD->DIR_f.PIN1  = 0)
#define PD01_DIR_INPUT()                    (CW_GPIOD->DIR_f.PIN1  = 1)
#define PD02_DIR_OUTPUT()                   (CW_GPIOD->DIR_f.PIN2  = 0)
#define PD02_DIR_INPUT()                    (CW_GPIOD->DIR_f.PIN2  = 1)
#define PD03_DIR_OUTPUT()                   (CW_GPIOD->DIR_f.PIN3  = 0)
#define PD03_DIR_INPUT()                    (CW_GPIOD->DIR_f.PIN3  = 1)
#define PD04_DIR_OUTPUT()                   (CW_GPIOD->DIR_f.PIN4  = 0)
#define PD04_DIR_INPUT()                    (CW_GPIOD->DIR_f.PIN4  = 1)
#define PD05_DIR_OUTPUT()                   (CW_GPIOD->DIR_f.PIN5  = 0)
#define PD05_DIR_INPUT()                    (CW_GPIOD->DIR_f.PIN5  = 1)
#define PD06_DIR_OUTPUT()                   (CW_GPIOD->DIR_f.PIN6  = 0)
#define PD06_DIR_INPUT()                    (CW_GPIOD->DIR_f.PIN6  = 1)
#define PD07_DIR_OUTPUT()                   (CW_GPIOD->DIR_f.PIN7  = 0)
#define PD07_DIR_INPUT()                    (CW_GPIOD->DIR_f.PIN7  = 1)
#define PD08_DIR_OUTPUT()                   (CW_GPIOD->DIR_f.PIN8  = 0)
#define PD08_DIR_INPUT()                    (CW_GPIOD->DIR_f.PIN8  = 1)
#define PD09_DIR_OUTPUT()                   (CW_GPIOD->DIR_f.PIN9  = 0)
#define PD09_DIR_INPUT()                    (CW_GPIOD->DIR_f.PIN9  = 1)
#define PD10_DIR_OUTPUT()                   (CW_GPIOD->DIR_f.PIN10 = 0)
#define PD10_DIR_INPUT()                    (CW_GPIOD->DIR_f.PIN10 = 1)
#define PD11_DIR_OUTPUT()                   (CW_GPIOD->DIR_f.PIN11 = 0)
#define PD11_DIR_INPUT()                    (CW_GPIOD->DIR_f.PIN11 = 1)
#define PD12_DIR_OUTPUT()                   (CW_GPIOD->DIR_f.PIN12 = 0)
#define PD12_DIR_INPUT()                    (CW_GPIOD->DIR_f.PIN12 = 1)
#define PD13_DIR_OUTPUT()                   (CW_GPIOD->DIR_f.PIN13 = 0)
#define PD13_DIR_INPUT()                    (CW_GPIOD->DIR_f.PIN13 = 1)
#define PD14_DIR_OUTPUT()                   (CW_GPIOD->DIR_f.PIN14 = 0)
#define PD14_DIR_INPUT()                    (CW_GPIOD->DIR_f.PIN14 = 1)
#define PD15_DIR_OUTPUT()                   (CW_GPIOD->DIR_f.PIN15 = 0)
#define PD15_DIR_INPUT()                    (CW_GPIOD->DIR_f.PIN15 = 1)

#define PF00_DIR_OUTPUT()                   (CW_GPIOF->DIR_f.PIN0  = 0)
#define PF00_DIR_INPUT()                    (CW_GPIOF->DIR_f.PIN0  = 1)
#define PF01_DIR_OUTPUT()                   (CW_GPIOF->DIR_f.PIN1  = 0)
#define PF01_DIR_INPUT()                    (CW_GPIOF->DIR_f.PIN1  = 1)
#define PF02_DIR_OUTPUT()                   (CW_GPIOF->DIR_f.PIN2  = 0)
#define PF02_DIR_INPUT()                    (CW_GPIOF->DIR_f.PIN2  = 1)
#define PF03_DIR_OUTPUT()                   (CW_GPIOF->DIR_f.PIN3  = 0)
#define PF03_DIR_INPUT()                    (CW_GPIOF->DIR_f.PIN3  = 1)
#define PF04_DIR_OUTPUT()                   (CW_GPIOF->DIR_f.PIN4  = 0)
#define PF04_DIR_INPUT()                    (CW_GPIOF->DIR_f.PIN4  = 1)
#define PF05_DIR_OUTPUT()                   (CW_GPIOF->DIR_f.PIN5  = 0)
#define PF05_DIR_INPUT()                    (CW_GPIOF->DIR_f.PIN5  = 1)
#define PF06_DIR_OUTPUT()                   (CW_GPIOF->DIR_f.PIN6  = 0)
#define PF06_DIR_INPUT()                    (CW_GPIOF->DIR_f.PIN6  = 1)
#define PF07_DIR_OUTPUT()                   (CW_GPIOF->DIR_f.PIN7  = 0)
#define PF07_DIR_INPUT()                    (CW_GPIOF->DIR_f.PIN7  = 1)
#define PF08_DIR_OUTPUT()                   (CW_GPIOF->DIR_f.PIN8  = 0)
#define PF08_DIR_INPUT()                    (CW_GPIOF->DIR_f.PIN8  = 1)
#define PF09_DIR_OUTPUT()                   (CW_GPIOF->DIR_f.PIN9  = 0)
#define PF09_DIR_INPUT()                    (CW_GPIOF->DIR_f.PIN9  = 1)
#define PF10_DIR_OUTPUT()                   (CW_GPIOF->DIR_f.PIN10 = 0)
#define PF10_DIR_INPUT()                    (CW_GPIOF->DIR_f.PIN10 = 1)

//============================================================
//push-pull or opendrain
#define PA00_PUSHPULL_ENABLE()              (CW_GPIOA->OPENDRAIN_f.PIN0  = 0)
#define PA00_OPENDRAIN_ENABLE()             (CW_GPIOA->OPENDRAIN_f.PIN0  = 1)
#define PA01_PUSHPULL_ENABLE()              (CW_GPIOA->OPENDRAIN_f.PIN1  = 0)
#define PA01_OPENDRAIN_ENABLE()             (CW_GPIOA->OPENDRAIN_f.PIN1  = 1)
#define PA02_PUSHPULL_ENABLE()              (CW_GPIOA->OPENDRAIN_f.PIN2  = 0)
#define PA02_OPENDRAIN_ENABLE()             (CW_GPIOA->OPENDRAIN_f.PIN2  = 1)
#define PA03_PUSHPULL_ENABLE()              (CW_GPIOA->OPENDRAIN_f.PIN3  = 0)
#define PA03_OPENDRAIN_ENABLE()             (CW_GPIOA->OPENDRAIN_f.PIN3  = 1)
#define PA04_PUSHPULL_ENABLE()              (CW_GPIOA->OPENDRAIN_f.PIN4  = 0)
#define PA04_OPENDRAIN_ENABLE()             (CW_GPIOA->OPENDRAIN_f.PIN4  = 1)
#define PA05_PUSHPULL_ENABLE()              (CW_GPIOA->OPENDRAIN_f.PIN5  = 0)
#define PA05_OPENDRAIN_ENABLE()             (CW_GPIOA->OPENDRAIN_f.PIN5  = 1)
#define PA06_PUSHPULL_ENABLE()              (CW_GPIOA->OPENDRAIN_f.PIN6  = 0)
#define PA06_OPENDRAIN_ENABLE()             (CW_GPIOA->OPENDRAIN_f.PIN6  = 1)
#define PA07_PUSHPULL_ENABLE()              (CW_GPIOA->OPENDRAIN_f.PIN7  = 0)
#define PA07_OPENDRAIN_ENABLE()             (CW_GPIOA->OPENDRAIN_f.PIN7  = 1)
#define PA08_PUSHPULL_ENABLE()              (CW_GPIOA->OPENDRAIN_f.PIN8  = 0)
#define PA08_OPENDRAIN_ENABLE()             (CW_GPIOA->OPENDRAIN_f.PIN8  = 1)
#define PA09_PUSHPULL_ENABLE()              (CW_GPIOA->OPENDRAIN_f.PIN9  = 0)
#define PA09_OPENDRAIN_ENABLE()             (CW_GPIOA->OPENDRAIN_f.PIN9  = 1)
#define PA10_PUSHPULL_ENABLE()              (CW_GPIOA->OPENDRAIN_f.PIN10 = 0)
#define PA10_OPENDRAIN_ENABLE()             (CW_GPIOA->OPENDRAIN_f.PIN10 = 1)
#define PA11_PUSHPULL_ENABLE()              (CW_GPIOA->OPENDRAIN_f.PIN11 = 0)
#define PA11_OPENDRAIN_ENABLE()             (CW_GPIOA->OPENDRAIN_f.PIN11 = 1)
#define PA12_PUSHPULL_ENABLE()              (CW_GPIOA->OPENDRAIN_f.PIN12 = 0)
#define PA12_OPENDRAIN_ENABLE()             (CW_GPIOA->OPENDRAIN_f.PIN12 = 1)
#define PA13_PUSHPULL_ENABLE()              (CW_GPIOA->OPENDRAIN_f.PIN13 = 0)
#define PA13_OPENDRAIN_ENABLE()             (CW_GPIOA->OPENDRAIN_f.PIN13 = 1)
#define PA14_PUSHPULL_ENABLE()              (CW_GPIOA->OPENDRAIN_f.PIN14 = 0)
#define PA14_OPENDRAIN_ENABLE()             (CW_GPIOA->OPENDRAIN_f.PIN14 = 1)
#define PA15_PUSHPULL_ENABLE()              (CW_GPIOA->OPENDRAIN_f.PIN15 = 0)
#define PA15_OPENDRAIN_ENABLE()             (CW_GPIOA->OPENDRAIN_f.PIN15 = 1)

#define PB00_PUSHPULL_ENABLE()              (CW_GPIOB->OPENDRAIN_f.PIN0  = 0)
#define PB00_OPENDRAIN_ENABLE()             (CW_GPIOB->OPENDRAIN_f.PIN0  = 1)
#define PB01_PUSHPULL_ENABLE()              (CW_GPIOB->OPENDRAIN_f.PIN1  = 0)
#define PB01_OPENDRAIN_ENABLE()             (CW_GPIOB->OPENDRAIN_f.PIN1  = 1)
#define PB02_PUSHPULL_ENABLE()              (CW_GPIOB->OPENDRAIN_f.PIN2  = 0)
#define PB02_OPENDRAIN_ENABLE()             (CW_GPIOB->OPENDRAIN_f.PIN2  = 1)
#define PB03_PUSHPULL_ENABLE()              (CW_GPIOB->OPENDRAIN_f.PIN3  = 0)
#define PB03_OPENDRAIN_ENABLE()             (CW_GPIOB->OPENDRAIN_f.PIN3  = 1)
#define PB04_PUSHPULL_ENABLE()              (CW_GPIOB->OPENDRAIN_f.PIN4  = 0)
#define PB04_OPENDRAIN_ENABLE()             (CW_GPIOB->OPENDRAIN_f.PIN4  = 1)
#define PB05_PUSHPULL_ENABLE()              (CW_GPIOB->OPENDRAIN_f.PIN5  = 0)
#define PB05_OPENDRAIN_ENABLE()             (CW_GPIOB->OPENDRAIN_f.PIN5  = 1)
#define PB06_PUSHPULL_ENABLE()              (CW_GPIOB->OPENDRAIN_f.PIN6  = 0)
#define PB06_OPENDRAIN_ENABLE()             (CW_GPIOB->OPENDRAIN_f.PIN6  = 1)
#define PB07_PUSHPULL_ENABLE()              (CW_GPIOB->OPENDRAIN_f.PIN7  = 0)
#define PB07_OPENDRAIN_ENABLE()             (CW_GPIOB->OPENDRAIN_f.PIN7  = 1)
#define PB08_PUSHPULL_ENABLE()              (CW_GPIOB->OPENDRAIN_f.PIN8  = 0)
#define PB08_OPENDRAIN_ENABLE()             (CW_GPIOB->OPENDRAIN_f.PIN8  = 1)
#define PB09_PUSHPULL_ENABLE()              (CW_GPIOB->OPENDRAIN_f.PIN9  = 0)
#define PB09_OPENDRAIN_ENABLE()             (CW_GPIOB->OPENDRAIN_f.PIN9  = 1)
#define PB10_PUSHPULL_ENABLE()              (CW_GPIOB->OPENDRAIN_f.PIN10 = 0)
#define PB10_OPENDRAIN_ENABLE()             (CW_GPIOB->OPENDRAIN_f.PIN10 = 1)
#define PB11_PUSHPULL_ENABLE()              (CW_GPIOB->OPENDRAIN_f.PIN11 = 0)
#define PB11_OPENDRAIN_ENABLE()             (CW_GPIOB->OPENDRAIN_f.PIN11 = 1)
#define PB12_PUSHPULL_ENABLE()              (CW_GPIOB->OPENDRAIN_f.PIN12 = 0)
#define PB12_OPENDRAIN_ENABLE()             (CW_GPIOB->OPENDRAIN_f.PIN12 = 1)
#define PB13_PUSHPULL_ENABLE()              (CW_GPIOB->OPENDRAIN_f.PIN13 = 0)
#define PB13_OPENDRAIN_ENABLE()             (CW_GPIOB->OPENDRAIN_f.PIN13 = 1)
#define PB14_PUSHPULL_ENABLE()              (CW_GPIOB->OPENDRAIN_f.PIN14 = 0)
#define PB14_OPENDRAIN_ENABLE()             (CW_GPIOB->OPENDRAIN_f.PIN14 = 1)
#define PB15_PUSHPULL_ENABLE()              (CW_GPIOB->OPENDRAIN_f.PIN15 = 0)
#define PB15_OPENDRAIN_ENABLE()             (CW_GPIOB->OPENDRAIN_f.PIN15 = 1)

#define PC00_PUSHPULL_ENABLE()              (CW_GPIOC->OPENDRAIN_f.PIN0  = 0)
#define PC00_OPENDRAIN_ENABLE()             (CW_GPIOC->OPENDRAIN_f.PIN0  = 1)
#define PC01_PUSHPULL_ENABLE()              (CW_GPIOC->OPENDRAIN_f.PIN1  = 0)
#define PC01_OPENDRAIN_ENABLE()             (CW_GPIOC->OPENDRAIN_f.PIN1  = 1)
#define PC02_PUSHPULL_ENABLE()              (CW_GPIOC->OPENDRAIN_f.PIN2  = 0)
#define PC02_OPENDRAIN_ENABLE()             (CW_GPIOC->OPENDRAIN_f.PIN2  = 1)
#define PC03_PUSHPULL_ENABLE()              (CW_GPIOC->OPENDRAIN_f.PIN3  = 0)
#define PC03_OPENDRAIN_ENABLE()             (CW_GPIOC->OPENDRAIN_f.PIN3  = 1)
#define PC04_PUSHPULL_ENABLE()              (CW_GPIOC->OPENDRAIN_f.PIN4  = 0)
#define PC04_OPENDRAIN_ENABLE()             (CW_GPIOC->OPENDRAIN_f.PIN4  = 1)
#define PC05_PUSHPULL_ENABLE()              (CW_GPIOC->OPENDRAIN_f.PIN5  = 0)
#define PC05_OPENDRAIN_ENABLE()             (CW_GPIOC->OPENDRAIN_f.PIN5  = 1)
#define PC06_PUSHPULL_ENABLE()              (CW_GPIOC->OPENDRAIN_f.PIN6  = 0)
#define PC06_OPENDRAIN_ENABLE()             (CW_GPIOC->OPENDRAIN_f.PIN6  = 1)
#define PC07_PUSHPULL_ENABLE()              (CW_GPIOC->OPENDRAIN_f.PIN7  = 0)
#define PC07_OPENDRAIN_ENABLE()             (CW_GPIOC->OPENDRAIN_f.PIN7  = 1)
#define PC08_PUSHPULL_ENABLE()              (CW_GPIOC->OPENDRAIN_f.PIN8  = 0)
#define PC08_OPENDRAIN_ENABLE()             (CW_GPIOC->OPENDRAIN_f.PIN8  = 1)
#define PC09_PUSHPULL_ENABLE()              (CW_GPIOC->OPENDRAIN_f.PIN9  = 0)
#define PC09_OPENDRAIN_ENABLE()             (CW_GPIOC->OPENDRAIN_f.PIN9  = 1)
#define PC10_PUSHPULL_ENABLE()              (CW_GPIOC->OPENDRAIN_f.PIN10 = 0)
#define PC10_OPENDRAIN_ENABLE()             (CW_GPIOC->OPENDRAIN_f.PIN10 = 1)
#define PC11_PUSHPULL_ENABLE()              (CW_GPIOC->OPENDRAIN_f.PIN11 = 0)
#define PC11_OPENDRAIN_ENABLE()             (CW_GPIOC->OPENDRAIN_f.PIN11 = 1)
#define PC12_PUSHPULL_ENABLE()              (CW_GPIOC->OPENDRAIN_f.PIN12 = 0)
#define PC12_OPENDRAIN_ENABLE()             (CW_GPIOC->OPENDRAIN_f.PIN12 = 1)
#define PC13_PUSHPULL_ENABLE()              (CW_GPIOC->OPENDRAIN_f.PIN13 = 0)
#define PC13_OPENDRAIN_ENABLE()             (CW_GPIOC->OPENDRAIN_f.PIN13 = 1)
#define PC14_PUSHPULL_ENABLE()              (CW_GPIOC->OPENDRAIN_f.PIN14 = 0)
#define PC14_OPENDRAIN_ENABLE()             (CW_GPIOC->OPENDRAIN_f.PIN14 = 1)
#define PC15_PUSHPULL_ENABLE()              (CW_GPIOC->OPENDRAIN_f.PIN15 = 0)
#define PC15_OPENDRAIN_ENABLE()             (CW_GPIOC->OPENDRAIN_f.PIN15 = 1)

#define PD00_PUSHPULL_ENABLE()              (CW_GPIOD->OPENDRAIN_f.PIN0  = 0)
#define PD00_OPENDRAIN_ENABLE()             (CW_GPIOD->OPENDRAIN_f.PIN0  = 1)
#define PD01_PUSHPULL_ENABLE()              (CW_GPIOD->OPENDRAIN_f.PIN1  = 0)
#define PD01_OPENDRAIN_ENABLE()             (CW_GPIOD->OPENDRAIN_f.PIN1  = 1)
#define PD02_PUSHPULL_ENABLE()              (CW_GPIOD->OPENDRAIN_f.PIN2  = 0)
#define PD02_OPENDRAIN_ENABLE()             (CW_GPIOD->OPENDRAIN_f.PIN2  = 1)
#define PD03_PUSHPULL_ENABLE()              (CW_GPIOD->OPENDRAIN_f.PIN3  = 0)
#define PD03_OPENDRAIN_ENABLE()             (CW_GPIOD->OPENDRAIN_f.PIN3  = 1)
#define PD04_PUSHPULL_ENABLE()              (CW_GPIOD->OPENDRAIN_f.PIN4  = 0)
#define PD04_OPENDRAIN_ENABLE()             (CW_GPIOD->OPENDRAIN_f.PIN4  = 1)
#define PD05_PUSHPULL_ENABLE()              (CW_GPIOD->OPENDRAIN_f.PIN5  = 0)
#define PD05_OPENDRAIN_ENABLE()             (CW_GPIOD->OPENDRAIN_f.PIN5  = 1)
#define PD06_PUSHPULL_ENABLE()              (CW_GPIOD->OPENDRAIN_f.PIN6  = 0)
#define PD06_OPENDRAIN_ENABLE()             (CW_GPIOD->OPENDRAIN_f.PIN6  = 1)
#define PD07_PUSHPULL_ENABLE()              (CW_GPIOD->OPENDRAIN_f.PIN7  = 0)
#define PD07_OPENDRAIN_ENABLE()             (CW_GPIOD->OPENDRAIN_f.PIN7  = 1)
#define PD08_PUSHPULL_ENABLE()              (CW_GPIOD->OPENDRAIN_f.PIN8  = 0)
#define PD08_OPENDRAIN_ENABLE()             (CW_GPIOD->OPENDRAIN_f.PIN8  = 1)
#define PD09_PUSHPULL_ENABLE()              (CW_GPIOD->OPENDRAIN_f.PIN9  = 0)
#define PD09_OPENDRAIN_ENABLE()             (CW_GPIOD->OPENDRAIN_f.PIN9  = 1)
#define PD10_PUSHPULL_ENABLE()              (CW_GPIOD->OPENDRAIN_f.PIN10 = 0)
#define PD10_OPENDRAIN_ENABLE()             (CW_GPIOD->OPENDRAIN_f.PIN10 = 1)
#define PD11_PUSHPULL_ENABLE()              (CW_GPIOD->OPENDRAIN_f.PIN11 = 0)
#define PD11_OPENDRAIN_ENABLE()             (CW_GPIOD->OPENDRAIN_f.PIN11 = 1)
#define PD12_PUSHPULL_ENABLE()              (CW_GPIOD->OPENDRAIN_f.PIN12 = 0)
#define PD12_OPENDRAIN_ENABLE()             (CW_GPIOD->OPENDRAIN_f.PIN12 = 1)
#define PD13_PUSHPULL_ENABLE()              (CW_GPIOD->OPENDRAIN_f.PIN13 = 0)
#define PD13_OPENDRAIN_ENABLE()             (CW_GPIOD->OPENDRAIN_f.PIN13 = 1)
#define PD14_PUSHPULL_ENABLE()              (CW_GPIOD->OPENDRAIN_f.PIN14 = 0)
#define PD14_OPENDRAIN_ENABLE()             (CW_GPIOD->OPENDRAIN_f.PIN14 = 1)
#define PD15_PUSHPULL_ENABLE()              (CW_GPIOD->OPENDRAIN_f.PIN15 = 0)
#define PD15_OPENDRAIN_ENABLE()             (CW_GPIOD->OPENDRAIN_f.PIN15 = 1)

#define PF00_PUSHPULL_ENABLE()              (CW_GPIOF->OPENDRAIN_f.PIN0  = 0)
#define PF00_OPENDRAIN_ENABLE()             (CW_GPIOF->OPENDRAIN_f.PIN0  = 1)
#define PF01_PUSHPULL_ENABLE()              (CW_GPIOF->OPENDRAIN_f.PIN1  = 0)
#define PF01_OPENDRAIN_ENABLE()             (CW_GPIOF->OPENDRAIN_f.PIN1  = 1)
#define PF02_PUSHPULL_ENABLE()              (CW_GPIOF->OPENDRAIN_f.PIN2  = 0)
#define PF02_OPENDRAIN_ENABLE()             (CW_GPIOF->OPENDRAIN_f.PIN2  = 1)
#define PF03_PUSHPULL_ENABLE()              (CW_GPIOF->OPENDRAIN_f.PIN3  = 0)
#define PF03_OPENDRAIN_ENABLE()             (CW_GPIOF->OPENDRAIN_f.PIN3  = 1)
#define PF04_PUSHPULL_ENABLE()              (CW_GPIOF->OPENDRAIN_f.PIN4  = 0)
#define PF04_OPENDRAIN_ENABLE()             (CW_GPIOF->OPENDRAIN_f.PIN4  = 1)
#define PF05_PUSHPULL_ENABLE()              (CW_GPIOF->OPENDRAIN_f.PIN5  = 0)
#define PF05_OPENDRAIN_ENABLE()             (CW_GPIOF->OPENDRAIN_f.PIN5  = 1)
#define PF06_PUSHPULL_ENABLE()              (CW_GPIOF->OPENDRAIN_f.PIN6  = 0)
#define PF06_OPENDRAIN_ENABLE()             (CW_GPIOF->OPENDRAIN_f.PIN6  = 1)
#define PF07_PUSHPULL_ENABLE()              (CW_GPIOF->OPENDRAIN_f.PIN7  = 0)
#define PF07_OPENDRAIN_ENABLE()             (CW_GPIOF->OPENDRAIN_f.PIN7  = 1)
#define PF08_PUSHPULL_ENABLE()              (CW_GPIOF->OPENDRAIN_f.PIN8  = 0)
#define PF08_OPENDRAIN_ENABLE()             (CW_GPIOF->OPENDRAIN_f.PIN8  = 1)
#define PF09_PUSHPULL_ENABLE()              (CW_GPIOF->OPENDRAIN_f.PIN9  = 0)
#define PF09_OPENDRAIN_ENABLE()             (CW_GPIOF->OPENDRAIN_f.PIN9  = 1)
#define PF10_PUSHPULL_ENABLE()              (CW_GPIOF->OPENDRAIN_f.PIN10 = 0)
#define PF10_OPENDRAIN_ENABLE()             (CW_GPIOF->OPENDRAIN_f.PIN10 = 1)

//============================================================
//PUR
#define PA00_PUR_ENABLE()                   (CW_GPIOA->PUR_f.PIN0  = 1)
#define PA00_PUR_DISABLE()                  (CW_GPIOA->PUR_f.PIN0  = 0)
#define PA01_PUR_ENABLE()                   (CW_GPIOA->PUR_f.PIN1  = 1)
#define PA01_PUR_DISABLE()                  (CW_GPIOA->PUR_f.PIN1  = 0)
#define PA02_PUR_ENABLE()                   (CW_GPIOA->PUR_f.PIN2  = 1)
#define PA02_PUR_DISABLE()                  (CW_GPIOA->PUR_f.PIN2  = 0)
#define PA03_PUR_ENABLE()                   (CW_GPIOA->PUR_f.PIN3  = 1)
#define PA03_PUR_DISABLE()                  (CW_GPIOA->PUR_f.PIN3  = 0)
#define PA04_PUR_ENABLE()                   (CW_GPIOA->PUR_f.PIN4  = 1)
#define PA04_PUR_DISABLE()                  (CW_GPIOA->PUR_f.PIN4  = 0)
#define PA05_PUR_ENABLE()                   (CW_GPIOA->PUR_f.PIN5  = 1)
#define PA05_PUR_DISABLE()                  (CW_GPIOA->PUR_f.PIN5  = 0)
#define PA06_PUR_ENABLE()                   (CW_GPIOA->PUR_f.PIN6  = 1)
#define PA06_PUR_DISABLE()                  (CW_GPIOA->PUR_f.PIN6  = 0)
#define PA07_PUR_ENABLE()                   (CW_GPIOA->PUR_f.PIN7  = 1)
#define PA07_PUR_DISABLE()                  (CW_GPIOA->PUR_f.PIN7  = 0)
#define PA08_PUR_ENABLE()                   (CW_GPIOA->PUR_f.PIN8  = 1)
#define PA08_PUR_DISABLE()                  (CW_GPIOA->PUR_f.PIN8  = 0)
#define PA09_PUR_ENABLE()                   (CW_GPIOA->PUR_f.PIN9  = 1)
#define PA09_PUR_DISABLE()                  (CW_GPIOA->PUR_f.PIN9  = 0)
#define PA10_PUR_ENABLE()                   (CW_GPIOA->PUR_f.PIN10 = 1)
#define PA10_PUR_DISABLE()                  (CW_GPIOA->PUR_f.PIN10 = 0)
#define PA11_PUR_ENABLE()                   (CW_GPIOA->PUR_f.PIN11 = 1)
#define PA11_PUR_DISABLE()                  (CW_GPIOA->PUR_f.PIN11 = 0)
#define PA12_PUR_ENABLE()                   (CW_GPIOA->PUR_f.PIN12 = 1)
#define PA12_PUR_DISABLE()                  (CW_GPIOA->PUR_f.PIN12 = 0)
#define PA13_PUR_ENABLE()                   (CW_GPIOA->PUR_f.PIN13 = 1)
#define PA13_PUR_DISABLE()                  (CW_GPIOA->PUR_f.PIN13 = 0)
#define PA14_PUR_ENABLE()                   (CW_GPIOA->PUR_f.PIN14 = 1)
#define PA14_PUR_DISABLE()                  (CW_GPIOA->PUR_f.PIN14 = 0)
#define PA15_PUR_ENABLE()                   (CW_GPIOA->PUR_f.PIN15 = 1)
#define PA15_PUR_DISABLE()                  (CW_GPIOA->PUR_f.PIN15 = 0)

#define PB00_PUR_ENABLE()                   (CW_GPIOB->PUR_f.PIN0  = 1)
#define PB00_PUR_DISABLE()                  (CW_GPIOB->PUR_f.PIN0  = 0)
#define PB01_PUR_ENABLE()                   (CW_GPIOB->PUR_f.PIN1  = 1)
#define PB01_PUR_DISABLE()                  (CW_GPIOB->PUR_f.PIN1  = 0)
#define PB02_PUR_ENABLE()                   (CW_GPIOB->PUR_f.PIN2  = 1)
#define PB02_PUR_DISABLE()                  (CW_GPIOB->PUR_f.PIN2  = 0)
#define PB03_PUR_ENABLE()                   (CW_GPIOB->PUR_f.PIN3  = 1)
#define PB03_PUR_DISABLE()                  (CW_GPIOB->PUR_f.PIN3  = 0)
#define PB04_PUR_ENABLE()                   (CW_GPIOB->PUR_f.PIN4  = 1)
#define PB04_PUR_DISABLE()                  (CW_GPIOB->PUR_f.PIN4  = 0)
#define PB05_PUR_ENABLE()                   (CW_GPIOB->PUR_f.PIN5  = 1)
#define PB05_PUR_DISABLE()                  (CW_GPIOB->PUR_f.PIN5  = 0)
#define PB06_PUR_ENABLE()                   (CW_GPIOB->PUR_f.PIN6  = 1)
#define PB06_PUR_DISABLE()                  (CW_GPIOB->PUR_f.PIN6  = 0)
#define PB07_PUR_ENABLE()                   (CW_GPIOB->PUR_f.PIN7  = 1)
#define PB07_PUR_DISABLE()                  (CW_GPIOB->PUR_f.PIN7  = 0)
#define PB08_PUR_ENABLE()                   (CW_GPIOB->PUR_f.PIN8  = 1)
#define PB08_PUR_DISABLE()                  (CW_GPIOB->PUR_f.PIN8  = 0)
#define PB09_PUR_ENABLE()                   (CW_GPIOB->PUR_f.PIN9  = 1)
#define PB09_PUR_DISABLE()                  (CW_GPIOB->PUR_f.PIN9  = 0)
#define PB10_PUR_ENABLE()                   (CW_GPIOB->PUR_f.PIN10 = 1)
#define PB10_PUR_DISABLE()                  (CW_GPIOB->PUR_f.PIN10 = 0)
#define PB11_PUR_ENABLE()                   (CW_GPIOB->PUR_f.PIN11 = 1)
#define PB11_PUR_DISABLE()                  (CW_GPIOB->PUR_f.PIN11 = 0)
#define PB12_PUR_ENABLE()                   (CW_GPIOB->PUR_f.PIN12 = 1)
#define PB12_PUR_DISABLE()                  (CW_GPIOB->PUR_f.PIN12 = 0)
#define PB13_PUR_ENABLE()                   (CW_GPIOB->PUR_f.PIN13 = 1)
#define PB13_PUR_DISABLE()                  (CW_GPIOB->PUR_f.PIN13 = 0)
#define PB14_PUR_ENABLE()                   (CW_GPIOB->PUR_f.PIN14 = 1)
#define PB14_PUR_DISABLE()                  (CW_GPIOB->PUR_f.PIN14 = 0)
#define PB15_PUR_ENABLE()                   (CW_GPIOB->PUR_f.PIN15 = 1)
#define PB15_PUR_DISABLE()                  (CW_GPIOB->PUR_f.PIN15 = 0)

#define PC00_PUR_ENABLE()                   (CW_GPIOC->PUR_f.PIN0  = 1)
#define PC00_PUR_DISABLE()                  (CW_GPIOC->PUR_f.PIN0  = 0)
#define PC01_PUR_ENABLE()                   (CW_GPIOC->PUR_f.PIN1  = 1)
#define PC01_PUR_DISABLE()                  (CW_GPIOC->PUR_f.PIN1  = 0)
#define PC02_PUR_ENABLE()                   (CW_GPIOC->PUR_f.PIN2  = 1)
#define PC02_PUR_DISABLE()                  (CW_GPIOC->PUR_f.PIN2  = 0)
#define PC03_PUR_ENABLE()                   (CW_GPIOC->PUR_f.PIN3  = 1)
#define PC03_PUR_DISABLE()                  (CW_GPIOC->PUR_f.PIN3  = 0)
#define PC04_PUR_ENABLE()                   (CW_GPIOC->PUR_f.PIN4  = 1)
#define PC04_PUR_DISABLE()                  (CW_GPIOC->PUR_f.PIN4  = 0)
#define PC05_PUR_ENABLE()                   (CW_GPIOC->PUR_f.PIN5  = 1)
#define PC05_PUR_DISABLE()                  (CW_GPIOC->PUR_f.PIN5  = 0)
#define PC06_PUR_ENABLE()                   (CW_GPIOC->PUR_f.PIN6  = 1)
#define PC06_PUR_DISABLE()                  (CW_GPIOC->PUR_f.PIN6  = 0)
#define PC07_PUR_ENABLE()                   (CW_GPIOC->PUR_f.PIN7  = 1)
#define PC07_PUR_DISABLE()                  (CW_GPIOC->PUR_f.PIN7  = 0)
#define PC08_PUR_ENABLE()                   (CW_GPIOC->PUR_f.PIN8  = 1)
#define PC08_PUR_DISABLE()                  (CW_GPIOC->PUR_f.PIN8  = 0)
#define PC09_PUR_ENABLE()                   (CW_GPIOC->PUR_f.PIN9  = 1)
#define PC09_PUR_DISABLE()                  (CW_GPIOC->PUR_f.PIN9  = 0)
#define PC10_PUR_ENABLE()                   (CW_GPIOC->PUR_f.PIN10 = 1)
#define PC10_PUR_DISABLE()                  (CW_GPIOC->PUR_f.PIN10 = 0)
#define PC11_PUR_ENABLE()                   (CW_GPIOC->PUR_f.PIN11 = 1)
#define PC11_PUR_DISABLE()                  (CW_GPIOC->PUR_f.PIN11 = 0)
#define PC12_PUR_ENABLE()                   (CW_GPIOC->PUR_f.PIN12 = 1)
#define PC12_PUR_DISABLE()                  (CW_GPIOC->PUR_f.PIN12 = 0)
#define PC13_PUR_ENABLE()                   (CW_GPIOC->PUR_f.PIN13 = 1)
#define PC13_PUR_DISABLE()                  (CW_GPIOC->PUR_f.PIN13 = 0)
#define PC14_PUR_ENABLE()                   (CW_GPIOC->PUR_f.PIN14 = 1)
#define PC14_PUR_DISABLE()                  (CW_GPIOC->PUR_f.PIN14 = 0)
#define PC15_PUR_ENABLE()                   (CW_GPIOC->PUR_f.PIN15 = 1)
#define PC15_PUR_DISABLE()                  (CW_GPIOC->PUR_f.PIN15 = 0)

#define PD00_PUR_ENABLE()                   (CW_GPIOD->PUR_f.PIN0  = 1)
#define PD00_PUR_DISABLE()                  (CW_GPIOD->PUR_f.PIN0  = 0)
#define PD01_PUR_ENABLE()                   (CW_GPIOD->PUR_f.PIN1  = 1)
#define PD01_PUR_DISABLE()                  (CW_GPIOD->PUR_f.PIN1  = 0)
#define PD02_PUR_ENABLE()                   (CW_GPIOD->PUR_f.PIN2  = 1)
#define PD02_PUR_DISABLE()                  (CW_GPIOD->PUR_f.PIN2  = 0)
#define PD03_PUR_ENABLE()                   (CW_GPIOD->PUR_f.PIN3  = 1)
#define PD03_PUR_DISABLE()                  (CW_GPIOD->PUR_f.PIN3  = 0)
#define PD04_PUR_ENABLE()                   (CW_GPIOD->PUR_f.PIN4  = 1)
#define PD04_PUR_DISABLE()                  (CW_GPIOD->PUR_f.PIN4  = 0)
#define PD05_PUR_ENABLE()                   (CW_GPIOD->PUR_f.PIN5  = 1)
#define PD05_PUR_DISABLE()                  (CW_GPIOD->PUR_f.PIN5  = 0)
#define PD06_PUR_ENABLE()                   (CW_GPIOD->PUR_f.PIN6  = 1)
#define PD06_PUR_DISABLE()                  (CW_GPIOD->PUR_f.PIN6  = 0)
#define PD07_PUR_ENABLE()                   (CW_GPIOD->PUR_f.PIN7  = 1)
#define PD07_PUR_DISABLE()                  (CW_GPIOD->PUR_f.PIN7  = 0)
#define PD08_PUR_ENABLE()                   (CW_GPIOD->PUR_f.PIN8  = 1)
#define PD08_PUR_DISABLE()                  (CW_GPIOD->PUR_f.PIN8  = 0)
#define PD09_PUR_ENABLE()                   (CW_GPIOD->PUR_f.PIN9  = 1)
#define PD09_PUR_DISABLE()                  (CW_GPIOD->PUR_f.PIN9  = 0)
#define PD10_PUR_ENABLE()                   (CW_GPIOD->PUR_f.PIN10 = 1)
#define PD10_PUR_DISABLE()                  (CW_GPIOD->PUR_f.PIN10 = 0)
#define PD11_PUR_ENABLE()                   (CW_GPIOD->PUR_f.PIN11 = 1)
#define PD11_PUR_DISABLE()                  (CW_GPIOD->PUR_f.PIN11 = 0)
#define PD12_PUR_ENABLE()                   (CW_GPIOD->PUR_f.PIN12 = 1)
#define PD12_PUR_DISABLE()                  (CW_GPIOD->PUR_f.PIN12 = 0)
#define PD13_PUR_ENABLE()                   (CW_GPIOD->PUR_f.PIN13 = 1)
#define PD13_PUR_DISABLE()                  (CW_GPIOD->PUR_f.PIN13 = 0)
#define PD14_PUR_ENABLE()                   (CW_GPIOD->PUR_f.PIN14 = 1)
#define PD14_PUR_DISABLE()                  (CW_GPIOD->PUR_f.PIN14 = 0)
#define PD15_PUR_ENABLE()                   (CW_GPIOD->PUR_f.PIN15 = 1)
#define PD15_PUR_DISABLE()                  (CW_GPIOD->PUR_f.PIN15 = 0)

#define PF00_PUR_ENABLE()                   (CW_GPIOF->PUR_f.PIN0  = 1)
#define PF00_PUR_DISABLE()                  (CW_GPIOF->PUR_f.PIN0  = 0)
#define PF01_PUR_ENABLE()                   (CW_GPIOF->PUR_f.PIN1  = 1)
#define PF01_PUR_DISABLE()                  (CW_GPIOF->PUR_f.PIN1  = 0)
#define PF02_PUR_ENABLE()                   (CW_GPIOF->PUR_f.PIN2  = 1)
#define PF02_PUR_DISABLE()                  (CW_GPIOF->PUR_f.PIN2  = 0)
#define PF03_PUR_ENABLE()                   (CW_GPIOF->PUR_f.PIN3  = 1)
#define PF03_PUR_DISABLE()                  (CW_GPIOF->PUR_f.PIN3  = 0)
#define PF04_PUR_ENABLE()                   (CW_GPIOF->PUR_f.PIN4  = 1)
#define PF04_PUR_DISABLE()                  (CW_GPIOF->PUR_f.PIN4  = 0)
#define PF05_PUR_ENABLE()                   (CW_GPIOF->PUR_f.PIN5  = 1)
#define PF05_PUR_DISABLE()                  (CW_GPIOF->PUR_f.PIN5  = 0)
#define PF06_PUR_ENABLE()                   (CW_GPIOF->PUR_f.PIN6  = 1)
#define PF06_PUR_DISABLE()                  (CW_GPIOF->PUR_f.PIN6  = 0)
#define PF07_PUR_ENABLE()                   (CW_GPIOF->PUR_f.PIN7  = 1)
#define PF07_PUR_DISABLE()                  (CW_GPIOF->PUR_f.PIN7  = 0)
#define PF08_PUR_ENABLE()                   (CW_GPIOF->PUR_f.PIN8  = 1)
#define PF08_PUR_DISABLE()                  (CW_GPIOF->PUR_f.PIN8  = 0)
#define PF09_PUR_ENABLE()                   (CW_GPIOF->PUR_f.PIN9  = 1)
#define PF09_PUR_DISABLE()                  (CW_GPIOF->PUR_f.PIN9  = 0)
#define PF10_PUR_ENABLE()                   (CW_GPIOF->PUR_f.PIN10 = 1)
#define PF10_PUR_DISABLE()                  (CW_GPIOF->PUR_f.PIN10 = 0)

//============================================================
//PDR
#define PA00_PDR_ENABLE()                   (CW_GPIOA->PDR_f.PIN0  = 1)
#define PA00_PDR_DISABLE()                  (CW_GPIOA->PDR_f.PIN0  = 0)
#define PA01_PDR_ENABLE()                   (CW_GPIOA->PDR_f.PIN1  = 1)
#define PA01_PDR_DISABLE()                  (CW_GPIOA->PDR_f.PIN1  = 0)
#define PA02_PDR_ENABLE()                   (CW_GPIOA->PDR_f.PIN2  = 1)
#define PA02_PDR_DISABLE()                  (CW_GPIOA->PDR_f.PIN2  = 0)
#define PA03_PDR_ENABLE()                   (CW_GPIOA->PDR_f.PIN3  = 1)
#define PA03_PDR_DISABLE()                  (CW_GPIOA->PDR_f.PIN3  = 0)
#define PA04_PDR_ENABLE()                   (CW_GPIOA->PDR_f.PIN4  = 1)
#define PA04_PDR_DISABLE()                  (CW_GPIOA->PDR_f.PIN4  = 0)
#define PA05_PDR_ENABLE()                   (CW_GPIOA->PDR_f.PIN5  = 1)
#define PA05_PDR_DISABLE()                  (CW_GPIOA->PDR_f.PIN5  = 0)
#define PA06_PDR_ENABLE()                   (CW_GPIOA->PDR_f.PIN6  = 1)
#define PA06_PDR_DISABLE()                  (CW_GPIOA->PDR_f.PIN6  = 0)
#define PA07_PDR_ENABLE()                   (CW_GPIOA->PDR_f.PIN7  = 1)
#define PA07_PDR_DISABLE()                  (CW_GPIOA->PDR_f.PIN7  = 0)
#define PA08_PDR_ENABLE()                   (CW_GPIOA->PDR_f.PIN8  = 1)
#define PA08_PDR_DISABLE()                  (CW_GPIOA->PDR_f.PIN8  = 0)
#define PA09_PDR_ENABLE()                   (CW_GPIOA->PDR_f.PIN9  = 1)
#define PA09_PDR_DISABLE()                  (CW_GPIOA->PDR_f.PIN9  = 0)
#define PA10_PDR_ENABLE()                   (CW_GPIOA->PDR_f.PIN10 = 1)
#define PA10_PDR_DISABLE()                  (CW_GPIOA->PDR_f.PIN10 = 0)
#define PA11_PDR_ENABLE()                   (CW_GPIOA->PDR_f.PIN11 = 1)
#define PA11_PDR_DISABLE()                  (CW_GPIOA->PDR_f.PIN11 = 0)
#define PA12_PDR_ENABLE()                   (CW_GPIOA->PDR_f.PIN12 = 1)
#define PA12_PDR_DISABLE()                  (CW_GPIOA->PDR_f.PIN12 = 0)
#define PA13_PDR_ENABLE()                   (CW_GPIOA->PDR_f.PIN13 = 1)
#define PA13_PDR_DISABLE()                  (CW_GPIOA->PDR_f.PIN13 = 0)
#define PA14_PDR_ENABLE()                   (CW_GPIOA->PDR_f.PIN14 = 1)
#define PA14_PDR_DISABLE()                  (CW_GPIOA->PDR_f.PIN14 = 0)
#define PA15_PDR_ENABLE()                   (CW_GPIOA->PDR_f.PIN15 = 1)
#define PA15_PDR_DISABLE()                  (CW_GPIOA->PDR_f.PIN15 = 0)

#define PB00_PDR_ENABLE()                   (CW_GPIOB->PDR_f.PIN0  = 1)
#define PB00_PDR_DISABLE()                  (CW_GPIOB->PDR_f.PIN0  = 0)
#define PB01_PDR_ENABLE()                   (CW_GPIOB->PDR_f.PIN1  = 1)
#define PB01_PDR_DISABLE()                  (CW_GPIOB->PDR_f.PIN1  = 0)
#define PB02_PDR_ENABLE()                   (CW_GPIOB->PDR_f.PIN2  = 1)
#define PB02_PDR_DISABLE()                  (CW_GPIOB->PDR_f.PIN2  = 0)
#define PB03_PDR_ENABLE()                   (CW_GPIOB->PDR_f.PIN3  = 1)
#define PB03_PDR_DISABLE()                  (CW_GPIOB->PDR_f.PIN3  = 0)
#define PB04_PDR_ENABLE()                   (CW_GPIOB->PDR_f.PIN4  = 1)
#define PB04_PDR_DISABLE()                  (CW_GPIOB->PDR_f.PIN4  = 0)
#define PB05_PDR_ENABLE()                   (CW_GPIOB->PDR_f.PIN5  = 1)
#define PB05_PDR_DISABLE()                  (CW_GPIOB->PDR_f.PIN5  = 0)
#define PB06_PDR_ENABLE()                   (CW_GPIOB->PDR_f.PIN6  = 1)
#define PB06_PDR_DISABLE()                  (CW_GPIOB->PDR_f.PIN6  = 0)
#define PB07_PDR_ENABLE()                   (CW_GPIOB->PDR_f.PIN7  = 1)
#define PB07_PDR_DISABLE()                  (CW_GPIOB->PDR_f.PIN7  = 0)
#define PB08_PDR_ENABLE()                   (CW_GPIOB->PDR_f.PIN8  = 1)
#define PB08_PDR_DISABLE()                  (CW_GPIOB->PDR_f.PIN8  = 0)
#define PB09_PDR_ENABLE()                   (CW_GPIOB->PDR_f.PIN9  = 1)
#define PB09_PDR_DISABLE()                  (CW_GPIOB->PDR_f.PIN9  = 0)
#define PB10_PDR_ENABLE()                   (CW_GPIOB->PDR_f.PIN10 = 1)
#define PB10_PDR_DISABLE()                  (CW_GPIOB->PDR_f.PIN10 = 0)
#define PB11_PDR_ENABLE()                   (CW_GPIOB->PDR_f.PIN11 = 1)
#define PB11_PDR_DISABLE()                  (CW_GPIOB->PDR_f.PIN11 = 0)
#define PB12_PDR_ENABLE()                   (CW_GPIOB->PDR_f.PIN12 = 1)
#define PB12_PDR_DISABLE()                  (CW_GPIOB->PDR_f.PIN12 = 0)
#define PB13_PDR_ENABLE()                   (CW_GPIOB->PDR_f.PIN13 = 1)
#define PB13_PDR_DISABLE()                  (CW_GPIOB->PDR_f.PIN13 = 0)
#define PB14_PDR_ENABLE()                   (CW_GPIOB->PDR_f.PIN14 = 1)
#define PB14_PDR_DISABLE()                  (CW_GPIOB->PDR_f.PIN14 = 0)
#define PB15_PDR_ENABLE()                   (CW_GPIOB->PDR_f.PIN15 = 1)
#define PB15_PDR_DISABLE()                  (CW_GPIOB->PDR_f.PIN15 = 0)

#define PC00_PDR_ENABLE()                   (CW_GPIOC->PDR_f.PIN0  = 1)
#define PC00_PDR_DISABLE()                  (CW_GPIOC->PDR_f.PIN0  = 0)
#define PC01_PDR_ENABLE()                   (CW_GPIOC->PDR_f.PIN1  = 1)
#define PC01_PDR_DISABLE()                  (CW_GPIOC->PDR_f.PIN1  = 0)
#define PC02_PDR_ENABLE()                   (CW_GPIOC->PDR_f.PIN2  = 1)
#define PC02_PDR_DISABLE()                  (CW_GPIOC->PDR_f.PIN2  = 0)
#define PC03_PDR_ENABLE()                   (CW_GPIOC->PDR_f.PIN3  = 1)
#define PC03_PDR_DISABLE()                  (CW_GPIOC->PDR_f.PIN3  = 0)
#define PC04_PDR_ENABLE()                   (CW_GPIOC->PDR_f.PIN4  = 1)
#define PC04_PDR_DISABLE()                  (CW_GPIOC->PDR_f.PIN4  = 0)
#define PC05_PDR_ENABLE()                   (CW_GPIOC->PDR_f.PIN5  = 1)
#define PC05_PDR_DISABLE()                  (CW_GPIOC->PDR_f.PIN5  = 0)
#define PC06_PDR_ENABLE()                   (CW_GPIOC->PDR_f.PIN6  = 1)
#define PC06_PDR_DISABLE()                  (CW_GPIOC->PDR_f.PIN6  = 0)
#define PC07_PDR_ENABLE()                   (CW_GPIOC->PDR_f.PIN7  = 1)
#define PC07_PDR_DISABLE()                  (CW_GPIOC->PDR_f.PIN7  = 0)
#define PC08_PDR_ENABLE()                   (CW_GPIOC->PDR_f.PIN8  = 1)
#define PC08_PDR_DISABLE()                  (CW_GPIOC->PDR_f.PIN8  = 0)
#define PC09_PDR_ENABLE()                   (CW_GPIOC->PDR_f.PIN9  = 1)
#define PC09_PDR_DISABLE()                  (CW_GPIOC->PDR_f.PIN9  = 0)
#define PC10_PDR_ENABLE()                   (CW_GPIOC->PDR_f.PIN10 = 1)
#define PC10_PDR_DISABLE()                  (CW_GPIOC->PDR_f.PIN10 = 0)
#define PC11_PDR_ENABLE()                   (CW_GPIOC->PDR_f.PIN11 = 1)
#define PC11_PDR_DISABLE()                  (CW_GPIOC->PDR_f.PIN11 = 0)
#define PC12_PDR_ENABLE()                   (CW_GPIOC->PDR_f.PIN12 = 1)
#define PC12_PDR_DISABLE()                  (CW_GPIOC->PDR_f.PIN12 = 0)
#define PC13_PDR_ENABLE()                   (CW_GPIOC->PDR_f.PIN13 = 1)
#define PC13_PDR_DISABLE()                  (CW_GPIOC->PDR_f.PIN13 = 0)
#define PC14_PDR_ENABLE()                   (CW_GPIOC->PDR_f.PIN14 = 1)
#define PC14_PDR_DISABLE()                  (CW_GPIOC->PDR_f.PIN14 = 0)
#define PC15_PDR_ENABLE()                   (CW_GPIOC->PDR_f.PIN15 = 1)
#define PC15_PDR_DISABLE()                  (CW_GPIOC->PDR_f.PIN15 = 0)

#define PD00_PDR_ENABLE()                   (CW_GPIOD->PDR_f.PIN0  = 1)
#define PD00_PDR_DISABLE()                  (CW_GPIOD->PDR_f.PIN0  = 0)
#define PD01_PDR_ENABLE()                   (CW_GPIOD->PDR_f.PIN1  = 1)
#define PD01_PDR_DISABLE()                  (CW_GPIOD->PDR_f.PIN1  = 0)
#define PD02_PDR_ENABLE()                   (CW_GPIOD->PDR_f.PIN2  = 1)
#define PD02_PDR_DISABLE()                  (CW_GPIOD->PDR_f.PIN2  = 0)
#define PD03_PDR_ENABLE()                   (CW_GPIOD->PDR_f.PIN3  = 1)
#define PD03_PDR_DISABLE()                  (CW_GPIOD->PDR_f.PIN3  = 0)
#define PD04_PDR_ENABLE()                   (CW_GPIOD->PDR_f.PIN4  = 1)
#define PD04_PDR_DISABLE()                  (CW_GPIOD->PDR_f.PIN4  = 0)
#define PD05_PDR_ENABLE()                   (CW_GPIOD->PDR_f.PIN5  = 1)
#define PD05_PDR_DISABLE()                  (CW_GPIOD->PDR_f.PIN5  = 0)
#define PD06_PDR_ENABLE()                   (CW_GPIOD->PDR_f.PIN6  = 1)
#define PD06_PDR_DISABLE()                  (CW_GPIOD->PDR_f.PIN6  = 0)
#define PD07_PDR_ENABLE()                   (CW_GPIOD->PDR_f.PIN7  = 1)
#define PD07_PDR_DISABLE()                  (CW_GPIOD->PDR_f.PIN7  = 0)
#define PD08_PDR_ENABLE()                   (CW_GPIOD->PDR_f.PIN8  = 1)
#define PD08_PDR_DISABLE()                  (CW_GPIOD->PDR_f.PIN8  = 0)
#define PD09_PDR_ENABLE()                   (CW_GPIOD->PDR_f.PIN9  = 1)
#define PD09_PDR_DISABLE()                  (CW_GPIOD->PDR_f.PIN9  = 0)
#define PD10_PDR_ENABLE()                   (CW_GPIOD->PDR_f.PIN10 = 1)
#define PD10_PDR_DISABLE()                  (CW_GPIOD->PDR_f.PIN10 = 0)
#define PD11_PDR_ENABLE()                   (CW_GPIOD->PDR_f.PIN11 = 1)
#define PD11_PDR_DISABLE()                  (CW_GPIOD->PDR_f.PIN11 = 0)
#define PD12_PDR_ENABLE()                   (CW_GPIOD->PDR_f.PIN12 = 1)
#define PD12_PDR_DISABLE()                  (CW_GPIOD->PDR_f.PIN12 = 0)
#define PD13_PDR_ENABLE()                   (CW_GPIOD->PDR_f.PIN13 = 1)
#define PD13_PDR_DISABLE()                  (CW_GPIOD->PDR_f.PIN13 = 0)
#define PD14_PDR_ENABLE()                   (CW_GPIOD->PDR_f.PIN14 = 1)
#define PD14_PDR_DISABLE()                  (CW_GPIOD->PDR_f.PIN14 = 0)
#define PD15_PDR_ENABLE()                   (CW_GPIOD->PDR_f.PIN15 = 1)
#define PD15_PDR_DISABLE()                  (CW_GPIOD->PDR_f.PIN15 = 0)

#define PF00_PDR_ENABLE()                   (CW_GPIOF->PDR_f.PIN0  = 1)
#define PF00_PDR_DISABLE()                  (CW_GPIOF->PDR_f.PIN0  = 0)
#define PF01_PDR_ENABLE()                   (CW_GPIOF->PDR_f.PIN1  = 1)
#define PF01_PDR_DISABLE()                  (CW_GPIOF->PDR_f.PIN1  = 0)
#define PF02_PDR_ENABLE()                   (CW_GPIOF->PDR_f.PIN2  = 1)
#define PF02_PDR_DISABLE()                  (CW_GPIOF->PDR_f.PIN2  = 0)
#define PF03_PDR_ENABLE()                   (CW_GPIOF->PDR_f.PIN3  = 1)
#define PF03_PDR_DISABLE()                  (CW_GPIOF->PDR_f.PIN3  = 0)
#define PF04_PDR_ENABLE()                   (CW_GPIOF->PDR_f.PIN4  = 1)
#define PF04_PDR_DISABLE()                  (CW_GPIOF->PDR_f.PIN4  = 0)
#define PF05_PDR_ENABLE()                   (CW_GPIOF->PDR_f.PIN5  = 1)
#define PF05_PDR_DISABLE()                  (CW_GPIOF->PDR_f.PIN5  = 0)
#define PF06_PDR_ENABLE()                   (CW_GPIOF->PDR_f.PIN6  = 1)
#define PF06_PDR_DISABLE()                  (CW_GPIOF->PDR_f.PIN6  = 0)
#define PF07_PDR_ENABLE()                   (CW_GPIOF->PDR_f.PIN7  = 1)
#define PF07_PDR_DISABLE()                  (CW_GPIOF->PDR_f.PIN7  = 0)
#define PF08_PDR_ENABLE()                   (CW_GPIOF->PDR_f.PIN8  = 1)
#define PF08_PDR_DISABLE()                  (CW_GPIOF->PDR_f.PIN8  = 0)
#define PF09_PDR_ENABLE()                   (CW_GPIOF->PDR_f.PIN9  = 1)
#define PF09_PDR_DISABLE()                  (CW_GPIOF->PDR_f.PIN9  = 0)
#define PF10_PDR_ENABLE()                   (CW_GPIOF->PDR_f.PIN10 = 1)
#define PF10_PDR_DISABLE()                  (CW_GPIOF->PDR_f.PIN10 = 0)

//============================================================
// GETVALUE
#define PA00_GETVALUE()                     (!!(CW_GPIOA->IDR & bv0))
#define PA01_GETVALUE()                     (!!(CW_GPIOA->IDR & bv1))
#define PA02_GETVALUE()                     (!!(CW_GPIOA->IDR & bv2))
#define PA03_GETVALUE()                     (!!(CW_GPIOA->IDR & bv3))
#define PA04_GETVALUE()                     (!!(CW_GPIOA->IDR & bv4))
#define PA05_GETVALUE()                     (!!(CW_GPIOA->IDR & bv5))
#define PA06_GETVALUE()                     (!!(CW_GPIOA->IDR & bv6))
#define PA07_GETVALUE()                     (!!(CW_GPIOA->IDR & bv7))
#define PA08_GETVALUE()                     (!!(CW_GPIOA->IDR & bv8))
#define PA09_GETVALUE()                     (!!(CW_GPIOA->IDR & bv9))
#define PA10_GETVALUE()                     (!!(CW_GPIOA->IDR & bv10))
#define PA11_GETVALUE()                     (!!(CW_GPIOA->IDR & bv11))
#define PA12_GETVALUE()                     (!!(CW_GPIOA->IDR & bv12))
#define PA13_GETVALUE()                     (!!(CW_GPIOA->IDR & bv13))
#define PA14_GETVALUE()                     (!!(CW_GPIOA->IDR & bv14))
#define PA15_GETVALUE()                     (!!(CW_GPIOA->IDR & bv15))

#define PB00_GETVALUE()                     (!!(CW_GPIOB->IDR & bv0))
#define PB01_GETVALUE()                     (!!(CW_GPIOB->IDR & bv1))
#define PB02_GETVALUE()                     (!!(CW_GPIOB->IDR & bv2))
#define PB03_GETVALUE()                     (!!(CW_GPIOB->IDR & bv3))
#define PB04_GETVALUE()                     (!!(CW_GPIOB->IDR & bv4))
#define PB05_GETVALUE()                     (!!(CW_GPIOB->IDR & bv5))
#define PB06_GETVALUE()                     (!!(CW_GPIOB->IDR & bv6))
#define PB07_GETVALUE()                     (!!(CW_GPIOB->IDR & bv7))
#define PB08_GETVALUE()                     (!!(CW_GPIOB->IDR & bv8))
#define PB09_GETVALUE()                     (!!(CW_GPIOB->IDR & bv9))
#define PB10_GETVALUE()                     (!!(CW_GPIOB->IDR & bv10))
#define PB11_GETVALUE()                     (!!(CW_GPIOB->IDR & bv11))
#define PB12_GETVALUE()                     (!!(CW_GPIOB->IDR & bv12))
#define PB13_GETVALUE()                     (!!(CW_GPIOB->IDR & bv13))
#define PB14_GETVALUE()                     (!!(CW_GPIOB->IDR & bv14))
#define PB15_GETVALUE()                     (!!(CW_GPIOB->IDR & bv15))

#define PC00_GETVALUE()                     (!!(CW_GPIOC->IDR & bv0))
#define PC01_GETVALUE()                     (!!(CW_GPIOC->IDR & bv1))
#define PC02_GETVALUE()                     (!!(CW_GPIOC->IDR & bv2))
#define PC03_GETVALUE()                     (!!(CW_GPIOC->IDR & bv3))
#define PC04_GETVALUE()                     (!!(CW_GPIOC->IDR & bv4))
#define PC05_GETVALUE()                     (!!(CW_GPIOC->IDR & bv5))
#define PC06_GETVALUE()                     (!!(CW_GPIOC->IDR & bv6))
#define PC07_GETVALUE()                     (!!(CW_GPIOC->IDR & bv7))
#define PC08_GETVALUE()                     (!!(CW_GPIOC->IDR & bv8))
#define PC09_GETVALUE()                     (!!(CW_GPIOC->IDR & bv9))
#define PC10_GETVALUE()                     (!!(CW_GPIOC->IDR & bv10))
#define PC11_GETVALUE()                     (!!(CW_GPIOC->IDR & bv11))
#define PC12_GETVALUE()                     (!!(CW_GPIOC->IDR & bv12))
#define PC13_GETVALUE()                     (!!(CW_GPIOC->IDR & bv13))
#define PC14_GETVALUE()                     (!!(CW_GPIOC->IDR & bv14))
#define PC15_GETVALUE()                     (!!(CW_GPIOC->IDR & bv15))

#define PD00_GETVALUE()                     (!!(CW_GPIOD->IDR & bv0))
#define PD01_GETVALUE()                     (!!(CW_GPIOD->IDR & bv1))
#define PD02_GETVALUE()                     (!!(CW_GPIOD->IDR & bv2))
#define PD03_GETVALUE()                     (!!(CW_GPIOD->IDR & bv3))
#define PD04_GETVALUE()                     (!!(CW_GPIOD->IDR & bv4))
#define PD05_GETVALUE()                     (!!(CW_GPIOD->IDR & bv5))
#define PD06_GETVALUE()                     (!!(CW_GPIOD->IDR & bv6))
#define PD07_GETVALUE()                     (!!(CW_GPIOD->IDR & bv7))
#define PD08_GETVALUE()                     (!!(CW_GPIOD->IDR & bv8))
#define PD09_GETVALUE()                     (!!(CW_GPIOD->IDR & bv9))
#define PD10_GETVALUE()                     (!!(CW_GPIOD->IDR & bv10))
#define PD11_GETVALUE()                     (!!(CW_GPIOD->IDR & bv11))
#define PD12_GETVALUE()                     (!!(CW_GPIOD->IDR & bv12))
#define PD13_GETVALUE()                     (!!(CW_GPIOD->IDR & bv13))
#define PD14_GETVALUE()                     (!!(CW_GPIOD->IDR & bv14))
#define PD15_GETVALUE()                     (!!(CW_GPIOD->IDR & bv15))

#define PF00_GETVALUE()                     (!!(CW_GPIOF->IDR & bv0))
#define PF01_GETVALUE()                     (!!(CW_GPIOF->IDR & bv1))
#define PF02_GETVALUE()                     (!!(CW_GPIOF->IDR & bv2))
#define PF03_GETVALUE()                     (!!(CW_GPIOF->IDR & bv3))
#define PF04_GETVALUE()                     (!!(CW_GPIOF->IDR & bv4))
#define PF05_GETVALUE()                     (!!(CW_GPIOF->IDR & bv5))
#define PF06_GETVALUE()                     (!!(CW_GPIOF->IDR & bv6))
#define PF07_GETVALUE()                     (!!(CW_GPIOF->IDR & bv7))
#define PF08_GETVALUE()                     (!!(CW_GPIOF->IDR & bv8))
#define PF09_GETVALUE()                     (!!(CW_GPIOF->IDR & bv9))
#define PF10_GETVALUE()                     (!!(CW_GPIOF->IDR & bv10))

//============================================================
// SET HIGH AND LOW
#define PA00_SETHIGH()                      (CW_GPIOA->BSRR = bv0)
#define PA00_SETLOW()                       (CW_GPIOA->BRR  = bv0)
#define PA01_SETHIGH()                      (CW_GPIOA->BSRR = bv1)
#define PA01_SETLOW()                       (CW_GPIOA->BRR  = bv1)
#define PA02_SETHIGH()                      (CW_GPIOA->BSRR = bv2)
#define PA02_SETLOW()                       (CW_GPIOA->BRR  = bv2)
#define PA03_SETHIGH()                      (CW_GPIOA->BSRR = bv3)
#define PA03_SETLOW()                       (CW_GPIOA->BRR  = bv3)
#define PA04_SETHIGH()                      (CW_GPIOA->BSRR = bv4)
#define PA04_SETLOW()                       (CW_GPIOA->BRR  = bv4)
#define PA05_SETHIGH()                      (CW_GPIOA->BSRR = bv5)
#define PA05_SETLOW()                       (CW_GPIOA->BRR  = bv5)
#define PA06_SETHIGH()                      (CW_GPIOA->BSRR = bv6)
#define PA06_SETLOW()                       (CW_GPIOA->BRR  = bv6)
#define PA07_SETHIGH()                      (CW_GPIOA->BSRR = bv7)
#define PA07_SETLOW()                       (CW_GPIOA->BRR  = bv7)
#define PA08_SETHIGH()                      (CW_GPIOA->BSRR = bv8)
#define PA08_SETLOW()                       (CW_GPIOA->BRR  = bv8)
#define PA09_SETHIGH()                      (CW_GPIOA->BSRR = bv9)
#define PA09_SETLOW()                       (CW_GPIOA->BRR  = bv9)
#define PA10_SETHIGH()                      (CW_GPIOA->BSRR = bv10)
#define PA10_SETLOW()                       (CW_GPIOA->BRR  = bv10)
#define PA11_SETHIGH()                      (CW_GPIOA->BSRR = bv11)
#define PA11_SETLOW()                       (CW_GPIOA->BRR  = bv11)
#define PA12_SETHIGH()                      (CW_GPIOA->BSRR = bv12)
#define PA12_SETLOW()                       (CW_GPIOA->BRR  = bv12)
#define PA13_SETHIGH()                      (CW_GPIOA->BSRR = bv13)
#define PA13_SETLOW()                       (CW_GPIOA->BRR  = bv13)
#define PA14_SETHIGH()                      (CW_GPIOA->BSRR = bv14)
#define PA14_SETLOW()                       (CW_GPIOA->BRR  = bv14)
#define PA15_SETHIGH()                      (CW_GPIOA->BSRR = bv15)
#define PA15_SETLOW()                       (CW_GPIOA->BRR  = bv15)

#define PB00_SETHIGH()                      (CW_GPIOB->BSRR = bv0)
#define PB00_SETLOW()                       (CW_GPIOB->BRR  = bv0)
#define PB01_SETHIGH()                      (CW_GPIOB->BSRR = bv1)
#define PB01_SETLOW()                       (CW_GPIOB->BRR  = bv1)
#define PB02_SETHIGH()                      (CW_GPIOB->BSRR = bv2)
#define PB02_SETLOW()                       (CW_GPIOB->BRR  = bv2)
#define PB03_SETHIGH()                      (CW_GPIOB->BSRR = bv3)
#define PB03_SETLOW()                       (CW_GPIOB->BRR  = bv3)
#define PB04_SETHIGH()                      (CW_GPIOB->BSRR = bv4)
#define PB04_SETLOW()                       (CW_GPIOB->BRR  = bv4)
#define PB05_SETHIGH()                      (CW_GPIOB->BSRR = bv5)
#define PB05_SETLOW()                       (CW_GPIOB->BRR  = bv5)
#define PB06_SETHIGH()                      (CW_GPIOB->BSRR = bv6)
#define PB06_SETLOW()                       (CW_GPIOB->BRR  = bv6)
#define PB07_SETHIGH()                      (CW_GPIOB->BSRR = bv7)
#define PB07_SETLOW()                       (CW_GPIOB->BRR  = bv7)
#define PB08_SETHIGH()                      (CW_GPIOB->BSRR = bv8)
#define PB08_SETLOW()                       (CW_GPIOB->BRR  = bv8)
#define PB09_SETHIGH()                      (CW_GPIOB->BSRR = bv9)
#define PB09_SETLOW()                       (CW_GPIOB->BRR  = bv9)
#define PB10_SETHIGH()                      (CW_GPIOB->BSRR = bv10)
#define PB10_SETLOW()                       (CW_GPIOB->BRR  = bv10)
#define PB11_SETHIGH()                      (CW_GPIOB->BSRR = bv11)
#define PB11_SETLOW()                       (CW_GPIOB->BRR  = bv11)
#define PB12_SETHIGH()                      (CW_GPIOB->BSRR = bv12)
#define PB12_SETLOW()                       (CW_GPIOB->BRR  = bv12)
#define PB13_SETHIGH()                      (CW_GPIOB->BSRR = bv13)
#define PB13_SETLOW()                       (CW_GPIOB->BRR  = bv13)
#define PB14_SETHIGH()                      (CW_GPIOB->BSRR = bv14)
#define PB14_SETLOW()                       (CW_GPIOB->BRR  = bv14)
#define PB15_SETHIGH()                      (CW_GPIOB->BSRR = bv15)
#define PB15_SETLOW()                       (CW_GPIOB->BRR  = bv15)

#define PC00_SETHIGH()                      (CW_GPIOC->BSRR = bv0)
#define PC00_SETLOW()                       (CW_GPIOC->BRR  = bv0)
#define PC01_SETHIGH()                      (CW_GPIOC->BSRR = bv1)
#define PC01_SETLOW()                       (CW_GPIOC->BRR  = bv1)
#define PC02_SETHIGH()                      (CW_GPIOC->BSRR = bv2)
#define PC02_SETLOW()                       (CW_GPIOC->BRR  = bv2)
#define PC03_SETHIGH()                      (CW_GPIOC->BSRR = bv3)
#define PC03_SETLOW()                       (CW_GPIOC->BRR  = bv3)
#define PC04_SETHIGH()                      (CW_GPIOC->BSRR = bv4)
#define PC04_SETLOW()                       (CW_GPIOC->BRR  = bv4)
#define PC05_SETHIGH()                      (CW_GPIOC->BSRR = bv5)
#define PC05_SETLOW()                       (CW_GPIOC->BRR  = bv5)
#define PC06_SETHIGH()                      (CW_GPIOC->BSRR = bv6)
#define PC06_SETLOW()                       (CW_GPIOC->BRR  = bv6)
#define PC07_SETHIGH()                      (CW_GPIOC->BSRR = bv7)
#define PC07_SETLOW()                       (CW_GPIOC->BRR  = bv7)
#define PC08_SETHIGH()                      (CW_GPIOC->BSRR = bv8)
#define PC08_SETLOW()                       (CW_GPIOC->BRR  = bv8)
#define PC09_SETHIGH()                      (CW_GPIOC->BSRR = bv9)
#define PC09_SETLOW()                       (CW_GPIOC->BRR  = bv9)
#define PC10_SETHIGH()                      (CW_GPIOC->BSRR = bv10)
#define PC10_SETLOW()                       (CW_GPIOC->BRR  = bv10)
#define PC11_SETHIGH()                      (CW_GPIOC->BSRR = bv11)
#define PC11_SETLOW()                       (CW_GPIOC->BRR  = bv11)
#define PC12_SETHIGH()                      (CW_GPIOC->BSRR = bv12)
#define PC12_SETLOW()                       (CW_GPIOC->BRR  = bv12)
#define PC13_SETHIGH()                      (CW_GPIOC->BSRR = bv13)
#define PC13_SETLOW()                       (CW_GPIOC->BRR  = bv13)
#define PC14_SETHIGH()                      (CW_GPIOC->BSRR = bv14)
#define PC14_SETLOW()                       (CW_GPIOC->BRR  = bv14)
#define PC15_SETHIGH()                      (CW_GPIOC->BSRR = bv15)
#define PC15_SETLOW()                       (CW_GPIOC->BRR  = bv15)

#define PD00_SETHIGH()                      (CW_GPIOD->BSRR = bv0)
#define PD00_SETLOW()                       (CW_GPIOD->BRR  = bv0)
#define PD01_SETHIGH()                      (CW_GPIOD->BSRR = bv1)
#define PD01_SETLOW()                       (CW_GPIOD->BRR  = bv1)
#define PD02_SETHIGH()                      (CW_GPIOD->BSRR = bv2)
#define PD02_SETLOW()                       (CW_GPIOD->BRR  = bv2)
#define PD03_SETHIGH()                      (CW_GPIOD->BSRR = bv3)
#define PD03_SETLOW()                       (CW_GPIOD->BRR  = bv3)
#define PD04_SETHIGH()                      (CW_GPIOD->BSRR = bv4)
#define PD04_SETLOW()                       (CW_GPIOD->BRR  = bv4)
#define PD05_SETHIGH()                      (CW_GPIOD->BSRR = bv5)
#define PD05_SETLOW()                       (CW_GPIOD->BRR  = bv5)
#define PD06_SETHIGH()                      (CW_GPIOD->BSRR = bv6)
#define PD06_SETLOW()                       (CW_GPIOD->BRR  = bv6)
#define PD07_SETHIGH()                      (CW_GPIOD->BSRR = bv7)
#define PD07_SETLOW()                       (CW_GPIOD->BRR  = bv7)
#define PD08_SETHIGH()                      (CW_GPIOD->BSRR = bv8)
#define PD08_SETLOW()                       (CW_GPIOD->BRR  = bv8)
#define PD09_SETHIGH()                      (CW_GPIOD->BSRR = bv9)
#define PD09_SETLOW()                       (CW_GPIOD->BRR  = bv9)
#define PD10_SETHIGH()                      (CW_GPIOD->BSRR = bv10)
#define PD10_SETLOW()                       (CW_GPIOD->BRR  = bv10)
#define PD11_SETHIGH()                      (CW_GPIOD->BSRR = bv11)
#define PD11_SETLOW()                       (CW_GPIOD->BRR  = bv11)
#define PD12_SETHIGH()                      (CW_GPIOD->BSRR = bv12)
#define PD12_SETLOW()                       (CW_GPIOD->BRR  = bv12)
#define PD13_SETHIGH()                      (CW_GPIOD->BSRR = bv13)
#define PD13_SETLOW()                       (CW_GPIOD->BRR  = bv13)
#define PD14_SETHIGH()                      (CW_GPIOD->BSRR = bv14)
#define PD14_SETLOW()                       (CW_GPIOD->BRR  = bv14)
#define PD15_SETHIGH()                      (CW_GPIOD->BSRR = bv15)
#define PD15_SETLOW()                       (CW_GPIOD->BRR  = bv15)

#define PF00_SETHIGH()                      (CW_GPIOF->BSRR = bv0)
#define PF00_SETLOW()                       (CW_GPIOF->BRR  = bv0)
#define PF01_SETHIGH()                      (CW_GPIOF->BSRR = bv1)
#define PF01_SETLOW()                       (CW_GPIOF->BRR  = bv1)
#define PF02_SETHIGH()                      (CW_GPIOF->BSRR = bv2)
#define PF02_SETLOW()                       (CW_GPIOF->BRR  = bv2)
#define PF03_SETHIGH()                      (CW_GPIOF->BSRR = bv3)
#define PF03_SETLOW()                       (CW_GPIOF->BRR  = bv3)
#define PF04_SETHIGH()                      (CW_GPIOF->BSRR = bv4)
#define PF04_SETLOW()                       (CW_GPIOF->BRR  = bv4)
#define PF05_SETHIGH()                      (CW_GPIOF->BSRR = bv5)
#define PF05_SETLOW()                       (CW_GPIOF->BRR  = bv5)
#define PF06_SETHIGH()                      (CW_GPIOF->BSRR = bv6)
#define PF06_SETLOW()                       (CW_GPIOF->BRR  = bv6)
#define PF07_SETHIGH()                      (CW_GPIOF->BSRR = bv7)
#define PF07_SETLOW()                       (CW_GPIOF->BRR  = bv7)
#define PF08_SETHIGH()                      (CW_GPIOF->BSRR = bv8)
#define PF08_SETLOW()                       (CW_GPIOF->BRR  = bv8)
#define PF09_SETHIGH()                      (CW_GPIOF->BSRR = bv9)
#define PF09_SETLOW()                       (CW_GPIOF->BRR  = bv9)
#define PF10_SETHIGH()                      (CW_GPIOF->BSRR = bv10)
#define PF10_SETLOW()                       (CW_GPIOF->BRR  = bv10)

//============================================================
// TOG
#define PA00_TOG()                          (CW_GPIOA->TOG = bv0)
#define PA01_TOG()                          (CW_GPIOA->TOG = bv1)
#define PA02_TOG()                          (CW_GPIOA->TOG = bv2)
#define PA03_TOG()                          (CW_GPIOA->TOG = bv3)
#define PA04_TOG()                          (CW_GPIOA->TOG = bv4)
#define PA05_TOG()                          (CW_GPIOA->TOG = bv5)
#define PA06_TOG()                          (CW_GPIOA->TOG = bv6)
#define PA07_TOG()                          (CW_GPIOA->TOG = bv7)
#define PA08_TOG()                          (CW_GPIOA->TOG = bv8)
#define PA09_TOG()                          (CW_GPIOA->TOG = bv9)
#define PA10_TOG()                          (CW_GPIOA->TOG = bv10)
#define PA11_TOG()                          (CW_GPIOA->TOG = bv11)
#define PA12_TOG()                          (CW_GPIOA->TOG = bv12)
#define PA13_TOG()                          (CW_GPIOA->TOG = bv13)
#define PA14_TOG()                          (CW_GPIOA->TOG = bv14)
#define PA15_TOG()                          (CW_GPIOA->TOG = bv15)

#define PB00_TOG()                          (CW_GPIOB->TOG = bv0)
#define PB01_TOG()                          (CW_GPIOB->TOG = bv1)
#define PB02_TOG()                          (CW_GPIOB->TOG = bv2)
#define PB03_TOG()                          (CW_GPIOB->TOG = bv3)
#define PB04_TOG()                          (CW_GPIOB->TOG = bv4)
#define PB05_TOG()                          (CW_GPIOB->TOG = bv5)
#define PB06_TOG()                          (CW_GPIOB->TOG = bv6)
#define PB07_TOG()                          (CW_GPIOB->TOG = bv7)
#define PB08_TOG()                          (CW_GPIOB->TOG = bv8)
#define PB09_TOG()                          (CW_GPIOB->TOG = bv9)
#define PB10_TOG()                          (CW_GPIOB->TOG = bv10)
#define PB11_TOG()                          (CW_GPIOB->TOG = bv11)
#define PB12_TOG()                          (CW_GPIOB->TOG = bv12)
#define PB13_TOG()                          (CW_GPIOB->TOG = bv13)
#define PB14_TOG()                          (CW_GPIOB->TOG = bv14)
#define PB15_TOG()                          (CW_GPIOB->TOG = bv15)

#define PC00_TOG()                          (CW_GPIOC->TOG = bv0)
#define PC01_TOG()                          (CW_GPIOC->TOG = bv1)
#define PC02_TOG()                          (CW_GPIOC->TOG = bv2)
#define PC03_TOG()                          (CW_GPIOC->TOG = bv3)
#define PC04_TOG()                          (CW_GPIOC->TOG = bv4)
#define PC05_TOG()                          (CW_GPIOC->TOG = bv5)
#define PC06_TOG()                          (CW_GPIOC->TOG = bv6)
#define PC07_TOG()                          (CW_GPIOC->TOG = bv7)
#define PC08_TOG()                          (CW_GPIOC->TOG = bv8)
#define PC09_TOG()                          (CW_GPIOC->TOG = bv9)
#define PC10_TOG()                          (CW_GPIOC->TOG = bv10)
#define PC11_TOG()                          (CW_GPIOC->TOG = bv11)
#define PC12_TOG()                          (CW_GPIOC->TOG = bv12)
#define PC13_TOG()                          (CW_GPIOC->TOG = bv13)
#define PC14_TOG()                          (CW_GPIOC->TOG = bv14)
#define PC15_TOG()                          (CW_GPIOC->TOG = bv15)

#define PD00_TOG()                          (CW_GPIOD->TOG = bv0)
#define PD01_TOG()                          (CW_GPIOD->TOG = bv1)
#define PD02_TOG()                          (CW_GPIOD->TOG = bv2)
#define PD03_TOG()                          (CW_GPIOD->TOG = bv3)
#define PD04_TOG()                          (CW_GPIOD->TOG = bv4)
#define PD05_TOG()                          (CW_GPIOD->TOG = bv5)
#define PD06_TOG()                          (CW_GPIOD->TOG = bv6)
#define PD07_TOG()                          (CW_GPIOD->TOG = bv7)
#define PD08_TOG()                          (CW_GPIOD->TOG = bv8)
#define PD09_TOG()                          (CW_GPIOD->TOG = bv9)
#define PD10_TOG()                          (CW_GPIOD->TOG = bv10)
#define PD11_TOG()                          (CW_GPIOD->TOG = bv11)
#define PD12_TOG()                          (CW_GPIOD->TOG = bv12)
#define PD13_TOG()                          (CW_GPIOD->TOG = bv13)
#define PD14_TOG()                          (CW_GPIOD->TOG = bv14)
#define PD15_TOG()                          (CW_GPIOD->TOG = bv15)

#define PF00_TOG()                          (CW_GPIOF->TOG = bv0)
#define PF01_TOG()                          (CW_GPIOF->TOG = bv1)
#define PF02_TOG()                          (CW_GPIOF->TOG = bv2)
#define PF03_TOG()                          (CW_GPIOF->TOG = bv3)
#define PF04_TOG()                          (CW_GPIOF->TOG = bv4)
#define PF05_TOG()                          (CW_GPIOF->TOG = bv5)
#define PF06_TOG()                          (CW_GPIOF->TOG = bv6)
#define PF07_TOG()                          (CW_GPIOF->TOG = bv7)
#define PF08_TOG()                          (CW_GPIOF->TOG = bv8)
#define PF09_TOG()                          (CW_GPIOF->TOG = bv9)
#define PF10_TOG()                          (CW_GPIOF->TOG = bv10)

//============================================================
// AF0 - AF7
#define PA00_AFx_GPIO()                     (CW_GPIOA->AFRL_f.AFR0  = 0)
#define PA00_AFx_UART3CTS()                 (CW_GPIOA->AFRL_f.AFR0  = 1)
#define PA00_AFx_UART2CTS()                 (CW_GPIOA->AFRL_f.AFR0  = 2)
#define PA00_AFx_RTCTAMP()                  (CW_GPIOA->AFRL_f.AFR0  = 3)
#define PA00_AFx_VC1OUT()                   (CW_GPIOA->AFRL_f.AFR0  = 4)
#define PA00_AFx_SPI2MISO()                 (CW_GPIOA->AFRL_f.AFR0  = 5)
#define PA00_AFx_GTIM2CH1()                 (CW_GPIOA->AFRL_f.AFR0  = 6)
#define PA00_AFx_GTIM2ETR()                 (CW_GPIOA->AFRL_f.AFR0  = 7)
#define PA01_AFx_GPIO()                     (CW_GPIOA->AFRL_f.AFR1  = 0)
#define PA01_AFx_UART3RTS()                 (CW_GPIOA->AFRL_f.AFR1  = 1)
#define PA01_AFx_UART2RTS()                 (CW_GPIOA->AFRL_f.AFR1  = 2)
#define PA01_AFx_I2C2SCL()                  (CW_GPIOA->AFRL_f.AFR1  = 3)
#define PA01_AFx_LVDOUT()                   (CW_GPIOA->AFRL_f.AFR1  = 4)
#define PA01_AFx_SPI2MOSI()                 (CW_GPIOA->AFRL_f.AFR1  = 5)
#define PA01_AFx_GTIM2CH2()                 (CW_GPIOA->AFRL_f.AFR1  = 6)
#define PA01_AFx_RTCTAMP()                  (CW_GPIOA->AFRL_f.AFR1  = 7)
#define PA02_AFx_GPIO()                     (CW_GPIOA->AFRL_f.AFR2  = 0)
#define PA02_AFx_UART3TXD()                 (CW_GPIOA->AFRL_f.AFR2  = 1)
#define PA02_AFx_UART2TXD()                 (CW_GPIOA->AFRL_f.AFR2  = 2)
#define PA02_AFx_I2C2SDA()                  (CW_GPIOA->AFRL_f.AFR2  = 3)
#define PA02_AFx_VC2OUT()                   (CW_GPIOA->AFRL_f.AFR2  = 4)
#define PA02_AFx_SPI2SCK()                  (CW_GPIOA->AFRL_f.AFR2  = 5)
#define PA02_AFx_GTIM2CH3()                 (CW_GPIOA->AFRL_f.AFR2  = 6)
#define PA02_AFx_AUTOTRIMETR()              (CW_GPIOA->AFRL_f.AFR2  = 7)
#define PA03_AFx_GPIO()                     (CW_GPIOA->AFRL_f.AFR3  = 0)
#define PA03_AFx_UART3RXD()                 (CW_GPIOA->AFRL_f.AFR3  = 1)
#define PA03_AFx_UART2RXD()                 (CW_GPIOA->AFRL_f.AFR3  = 2)
#define PA03_AFx_GTIM2CH2()                 (CW_GPIOA->AFRL_f.AFR3  = 3)
#define PA03_AFx_PCLKOUT()                  (CW_GPIOA->AFRL_f.AFR3  = 4)
#define PA03_AFx_SPI2CS()                   (CW_GPIOA->AFRL_f.AFR3  = 5)
#define PA03_AFx_GTIM2CH4()                 (CW_GPIOA->AFRL_f.AFR3  = 6)
#define PA03_AFx_ATIMCH3A()                 (CW_GPIOA->AFRL_f.AFR3  = 7)
#define PA04_AFx_GPIO()                     (CW_GPIOA->AFRL_f.AFR4  = 0)
#define PA04_AFx_UART1TXD()                 (CW_GPIOA->AFRL_f.AFR4  = 1)
#define PA04_AFx_UART2CTS()                 (CW_GPIOA->AFRL_f.AFR4  = 2)
#define PA04_AFx_I2C2SCL()                  (CW_GPIOA->AFRL_f.AFR4  = 3)
#define PA04_AFx_HCLKOUT()                  (CW_GPIOA->AFRL_f.AFR4  = 4)
#define PA04_AFx_SPI1CS()                   (CW_GPIOA->AFRL_f.AFR4  = 5)
#define PA04_AFx_GTIM2ETR()                 (CW_GPIOA->AFRL_f.AFR4  = 6)
#define PA04_AFx_ATIMCH2A()                 (CW_GPIOA->AFRL_f.AFR4  = 7)
#define PA05_AFx_GPIO()                     (CW_GPIOA->AFRL_f.AFR5  = 0)
#define PA05_AFx_GTIM2ETR()                 (CW_GPIOA->AFRL_f.AFR5  = 1)
#define PA05_AFx_UART2RTS()                 (CW_GPIOA->AFRL_f.AFR5  = 2)
#define PA05_AFx_I2C2SDA()                  (CW_GPIOA->AFRL_f.AFR5  = 3)
#define PA05_AFx_BTIM2TOGP()                (CW_GPIOA->AFRL_f.AFR5  = 4)
#define PA05_AFx_SPI1SCK()                  (CW_GPIOA->AFRL_f.AFR5  = 5)
#define PA05_AFx_GTIM2CH1()                 (CW_GPIOA->AFRL_f.AFR5  = 6)
#define PA05_AFx_ATIMCH1A()                 (CW_GPIOA->AFRL_f.AFR5  = 7)
#define PA06_AFx_GPIO()                     (CW_GPIOA->AFRL_f.AFR6  = 0)
#define PA06_AFx_GTIM3CH1()                 (CW_GPIOA->AFRL_f.AFR6  = 1)
#define PA06_AFx_UART2TXD()                 (CW_GPIOA->AFRL_f.AFR6  = 2)
#define PA06_AFx_VC1OUT()                   (CW_GPIOA->AFRL_f.AFR6  = 3)
#define PA06_AFx_BTIM2TOGN()                (CW_GPIOA->AFRL_f.AFR6  = 4)
#define PA06_AFx_SPI1MISO()                 (CW_GPIOA->AFRL_f.AFR6  = 5)
#define PA06_AFx_GTIM1CH1()                 (CW_GPIOA->AFRL_f.AFR6  = 6)
#define PA06_AFx_ATIMBK()                   (CW_GPIOA->AFRL_f.AFR6  = 7)
#define PA07_AFx_GPIO()                     (CW_GPIOA->AFRL_f.AFR7  = 0)
#define PA07_AFx_GTIM2CH1()                 (CW_GPIOA->AFRL_f.AFR7  = 1)
#define PA07_AFx_UART2RXD()                 (CW_GPIOA->AFRL_f.AFR7  = 2)
#define PA07_AFx_VC2OUT()                   (CW_GPIOA->AFRL_f.AFR7  = 3)
#define PA07_AFx_BTIM1TOGP()                (CW_GPIOA->AFRL_f.AFR7  = 4)
#define PA07_AFx_SPI1MOSI()                 (CW_GPIOA->AFRL_f.AFR7  = 5)
#define PA07_AFx_GTIM1CH2()                 (CW_GPIOA->AFRL_f.AFR7  = 6)
#define PA07_AFx_ATIMCH1B()                 (CW_GPIOA->AFRL_f.AFR7  = 7)
#define PA08_AFx_GPIO()                     (CW_GPIOA->AFRH_f.AFR8  = 0)
#define PA08_AFx_LPTIMETR()                 (CW_GPIOA->AFRH_f.AFR8  = 1)
#define PA08_AFx_UART1TXD()                 (CW_GPIOA->AFRH_f.AFR8  = 2)
#define PA08_AFx_BTIM2TOGN()                (CW_GPIOA->AFRH_f.AFR8  = 3)
#define PA08_AFx_MCOOUT()                   (CW_GPIOA->AFRH_f.AFR8  = 4)
#define PA08_AFx_LVDOUT()                   (CW_GPIOA->AFRH_f.AFR8  = 5)
#define PA08_AFx_GTIM3ETR()                 (CW_GPIOA->AFRH_f.AFR8  = 6)
#define PA08_AFx_ATIMCH1A()                 (CW_GPIOA->AFRH_f.AFR8  = 7)
#define PA09_AFx_GPIO()                     (CW_GPIOA->AFRH_f.AFR9  = 0)
#define PA09_AFx_UART3TXD()                 (CW_GPIOA->AFRH_f.AFR9  = 1)
#define PA09_AFx_UART1RXD()                 (CW_GPIOA->AFRH_f.AFR9  = 2)
#define PA09_AFx_I2C1SCL()                  (CW_GPIOA->AFRH_f.AFR9  = 3)
#define PA09_AFx_BTIM1TOGP()                (CW_GPIOA->AFRH_f.AFR9  = 4)
#define PA09_AFx_SPI1CS()                   (CW_GPIOA->AFRH_f.AFR9  = 5)
#define PA09_AFx_GTIM3CH1()                 (CW_GPIOA->AFRH_f.AFR9  = 6)
#define PA09_AFx_ATIMCH2A()                 (CW_GPIOA->AFRH_f.AFR9  = 7)
#define PA10_AFx_GPIO()                     (CW_GPIOA->AFRH_f.AFR10 = 0)
#define PA10_AFx_UART3RXD()                 (CW_GPIOA->AFRH_f.AFR10 = 1)
#define PA10_AFx_UART1CTS()                 (CW_GPIOA->AFRH_f.AFR10 = 2)
#define PA10_AFx_I2C1SDA()                  (CW_GPIOA->AFRH_f.AFR10 = 3)
#define PA10_AFx_BTIM1TOGN()                (CW_GPIOA->AFRH_f.AFR10 = 4)
#define PA10_AFx_SPI1SCK()                  (CW_GPIOA->AFRH_f.AFR10 = 5)
#define PA10_AFx_GTIM3CH2()                 (CW_GPIOA->AFRH_f.AFR10 = 6)
#define PA10_AFx_ATIMCH3A()                 (CW_GPIOA->AFRH_f.AFR10 = 7)
#define PA11_AFx_GPIO()                     (CW_GPIOA->AFRH_f.AFR11 = 0)
#define PA11_AFx_UART3CTS()                 (CW_GPIOA->AFRH_f.AFR11 = 1)
#define PA11_AFx_UART1RTS()                 (CW_GPIOA->AFRH_f.AFR11 = 2)
#define PA11_AFx_I2C2SCL()                  (CW_GPIOA->AFRH_f.AFR11 = 3)
#define PA11_AFx_VC1OUT()                   (CW_GPIOA->AFRH_f.AFR11 = 4)
#define PA11_AFx_SPI1MISO()                 (CW_GPIOA->AFRH_f.AFR11 = 5)
#define PA11_AFx_GTIM3CH3()                 (CW_GPIOA->AFRH_f.AFR11 = 6)
#define PA11_AFx_ATIMGATE()                 (CW_GPIOA->AFRH_f.AFR11 = 7)
#define PA12_AFx_GPIO()                     (CW_GPIOA->AFRH_f.AFR12 = 0)
#define PA12_AFx_UART3RTS()                 (CW_GPIOA->AFRH_f.AFR12 = 1)
#define PA12_AFx_BTIMETR()                  (CW_GPIOA->AFRH_f.AFR12 = 2)
#define PA12_AFx_I2C2SDA()                  (CW_GPIOA->AFRH_f.AFR12 = 3)
#define PA12_AFx_VC2OUT()                   (CW_GPIOA->AFRH_f.AFR12 = 4)
#define PA12_AFx_SPI1MOSI()                 (CW_GPIOA->AFRH_f.AFR12 = 5)
#define PA12_AFx_GTIM3CH4()                 (CW_GPIOA->AFRH_f.AFR12 = 6)
#define PA12_AFx_ATIMETR()                  (CW_GPIOA->AFRH_f.AFR12 = 7)
#define PA13_AFx_GPIO()                     (CW_GPIOA->AFRH_f.AFR13 = 0)
#define PA13_AFx_I2C1SDA()                  (CW_GPIOA->AFRH_f.AFR13 = 2)
#define PA13_AFx_UART1RXD()                 (CW_GPIOA->AFRH_f.AFR13 = 3)
#define PA13_AFx_UART2TXD()                 (CW_GPIOA->AFRH_f.AFR13 = 4)
#define PA13_AFx_I2C2SCL()                  (CW_GPIOA->AFRH_f.AFR13 = 5)
#define PA13_AFx_IROUT()                    (CW_GPIOA->AFRH_f.AFR13 = 6)
#define PA14_AFx_GPIO()                     (CW_GPIOA->AFRH_f.AFR14 = 0)
#define PA14_AFx_UART3TXD()                 (CW_GPIOA->AFRH_f.AFR14 = 1)
#define PA14_AFx_I2C1SCL()                  (CW_GPIOA->AFRH_f.AFR14 = 2)
#define PA14_AFx_UART1TXD()                 (CW_GPIOA->AFRH_f.AFR14 = 3)
#define PA14_AFx_UART2RXD()                 (CW_GPIOA->AFRH_f.AFR14 = 4)
#define PA14_AFx_I2C2SDA()                  (CW_GPIOA->AFRH_f.AFR14 = 5)
#define PA15_AFx_GPIO()                     (CW_GPIOA->AFRH_f.AFR15 = 0)
#define PA15_AFx_UART3RXD()                 (CW_GPIOA->AFRH_f.AFR15 = 1)
#define PA15_AFx_GTIM2CH1()                 (CW_GPIOA->AFRH_f.AFR15 = 2)
#define PA15_AFx_UART1RXD()                 (CW_GPIOA->AFRH_f.AFR15 = 3)
#define PA15_AFx_UART2TXD()                 (CW_GPIOA->AFRH_f.AFR15 = 4)
#define PA15_AFx_SPI1CS()                   (CW_GPIOA->AFRH_f.AFR15 = 5)
#define PA15_AFx_GTIM2ETR()                 (CW_GPIOA->AFRH_f.AFR15 = 6)
#define PA15_AFx_ATIMCH1B()                 (CW_GPIOA->AFRH_f.AFR15 = 7)

#define PB00_AFx_GPIO()                     (CW_GPIOB->AFRL_f.AFR0  = 0)
#define PB00_AFx_UART2RXD()                 (CW_GPIOB->AFRL_f.AFR0  = 1)
#define PB00_AFx_UART1CTS()                 (CW_GPIOB->AFRL_f.AFR0  = 2)
#define PB00_AFx_I2C2SCL()                  (CW_GPIOB->AFRL_f.AFR0  = 3)
#define PB00_AFx_BTIM1TOGN()                (CW_GPIOB->AFRL_f.AFR0  = 4)
#define PB00_AFx_HSIOSCOUT()                (CW_GPIOB->AFRL_f.AFR0  = 5)
#define PB00_AFx_GTIM1CH3()                 (CW_GPIOB->AFRL_f.AFR0  = 6)
#define PB00_AFx_ATIMCH2B()                 (CW_GPIOB->AFRL_f.AFR0  = 7)
#define PB01_AFx_GPIO()                     (CW_GPIOB->AFRL_f.AFR1  = 0)
#define PB01_AFx_UART2TXD()                 (CW_GPIOB->AFRL_f.AFR1  = 1)
#define PB01_AFx_UART1RTS()                 (CW_GPIOB->AFRL_f.AFR1  = 2)
#define PB01_AFx_I2C2SDA()                  (CW_GPIOB->AFRL_f.AFR1  = 3)
#define PB01_AFx_GTIM2TOGN()                (CW_GPIOB->AFRL_f.AFR1  = 4)
#define PB01_AFx_BTIM3TOGP()                (CW_GPIOB->AFRL_f.AFR1  = 5)
#define PB01_AFx_GTIM1CH4()                 (CW_GPIOB->AFRL_f.AFR1  = 6)
#define PB01_AFx_ATIMCH3B()                 (CW_GPIOB->AFRL_f.AFR1  = 7)
#define PB02_AFx_GPIO()                     (CW_GPIOB->AFRL_f.AFR2  = 0)
#define PB02_AFx_UART2CTS()                 (CW_GPIOB->AFRL_f.AFR2  = 1)
#define PB02_AFx_UART1TXD()                 (CW_GPIOB->AFRL_f.AFR2  = 2)
#define PB02_AFx_LPTIMOUT()                 (CW_GPIOB->AFRL_f.AFR2  = 3)
#define PB02_AFx_GTIM2TOGP()                (CW_GPIOB->AFRL_f.AFR2  = 4)
#define PB02_AFx_BTIM3TOGN()                (CW_GPIOB->AFRL_f.AFR2  = 5)
#define PB02_AFx_GTIM1ETR()                 (CW_GPIOB->AFRL_f.AFR2  = 6)
#define PB02_AFx_ATIMCH1A()                 (CW_GPIOB->AFRL_f.AFR2  = 7)
#define PB03_AFx_GPIO()                     (CW_GPIOB->AFRL_f.AFR3  = 0)
#define PB03_AFx_UART3RTS()                 (CW_GPIOB->AFRL_f.AFR3  = 1)
#define PB03_AFx_GTIM2CH2()                 (CW_GPIOB->AFRL_f.AFR3  = 2)
#define PB03_AFx_UART1CTS()                 (CW_GPIOB->AFRL_f.AFR3  = 3)
#define PB03_AFx_UART2TXD()                 (CW_GPIOB->AFRL_f.AFR3  = 4)
#define PB03_AFx_SPI1SCK()                  (CW_GPIOB->AFRL_f.AFR3  = 5)
#define PB03_AFx_GTIM1ETR()                 (CW_GPIOB->AFRL_f.AFR3  = 6)
#define PB03_AFx_ATIMCH2B()                 (CW_GPIOB->AFRL_f.AFR3  = 7)
#define PB04_AFx_GPIO()                     (CW_GPIOB->AFRL_f.AFR4  = 0)
#define PB04_AFx_UART3CTS()                 (CW_GPIOB->AFRL_f.AFR4  = 1)
#define PB04_AFx_GTIM2ETR()                 (CW_GPIOB->AFRL_f.AFR4  = 2)
#define PB04_AFx_UART1RTS()                 (CW_GPIOB->AFRL_f.AFR4  = 3)
#define PB04_AFx_UART2RXD()                 (CW_GPIOB->AFRL_f.AFR4  = 4)
#define PB04_AFx_SPI1MISO()                 (CW_GPIOB->AFRL_f.AFR4  = 5)
#define PB04_AFx_GTIM1CH1()                 (CW_GPIOB->AFRL_f.AFR4  = 6)
#define PB04_AFx_ATIMCH3B()                 (CW_GPIOB->AFRL_f.AFR4  = 7)
#define PB05_AFx_GPIO()                     (CW_GPIOB->AFRL_f.AFR5  = 0)
#define PB05_AFx_UART1RXD()                 (CW_GPIOB->AFRL_f.AFR5  = 1)
#define PB05_AFx_GTIM3CH4()                 (CW_GPIOB->AFRL_f.AFR5  = 2)
#define PB05_AFx_LPTIMCH1()                 (CW_GPIOB->AFRL_f.AFR5  = 3)
#define PB05_AFx_UART2RTS()                 (CW_GPIOB->AFRL_f.AFR5  = 4)
#define PB05_AFx_SPI1MOSI()                 (CW_GPIOB->AFRL_f.AFR5  = 5)
#define PB05_AFx_GTIM1CH2()                 (CW_GPIOB->AFRL_f.AFR5  = 6)
#define PB05_AFx_ATIMCH1A()                 (CW_GPIOB->AFRL_f.AFR5  = 7)
#define PB06_AFx_GPIO()                     (CW_GPIOB->AFRL_f.AFR6  = 0)
#define PB06_AFx_UART3TXD()                 (CW_GPIOB->AFRL_f.AFR6  = 1)
#define PB06_AFx_GTIM3CH3()                 (CW_GPIOB->AFRL_f.AFR6  = 2)
#define PB06_AFx_LPTIMETR()                 (CW_GPIOB->AFRL_f.AFR6  = 3)
#define PB06_AFx_I2C1SCL()                  (CW_GPIOB->AFRL_f.AFR6  = 4)
#define PB06_AFx_SPI2MOSI()                 (CW_GPIOB->AFRL_f.AFR6  = 5)
#define PB06_AFx_GTIM1TOGP()                (CW_GPIOB->AFRL_f.AFR6  = 6)
#define PB06_AFx_ATIMCH2A()                 (CW_GPIOB->AFRL_f.AFR6  = 7)
#define PB07_AFx_GPIO()                     (CW_GPIOB->AFRL_f.AFR7  = 0)
#define PB07_AFx_UART3RXD()                 (CW_GPIOB->AFRL_f.AFR7  = 1)
#define PB07_AFx_GTIM3CH2()                 (CW_GPIOB->AFRL_f.AFR7  = 2)
#define PB07_AFx_LPTIMCH2()                 (CW_GPIOB->AFRL_f.AFR7  = 3)
#define PB07_AFx_I2C1SDA()                  (CW_GPIOB->AFRL_f.AFR7  = 4)
#define PB07_AFx_SPI2MISO()                 (CW_GPIOB->AFRL_f.AFR7  = 5)
#define PB07_AFx_GTIM1TOGP()                (CW_GPIOB->AFRL_f.AFR7  = 6)
#define PB07_AFx_ATIMCH3A()                 (CW_GPIOB->AFRL_f.AFR7  = 7)
#define PB08_AFx_GPIO()                     (CW_GPIOB->AFRH_f.AFR8  = 0)
#define PB08_AFx_I2C1SCL()                  (CW_GPIOB->AFRH_f.AFR8  = 1)
#define PB08_AFx_GTIM3CH1()                 (CW_GPIOB->AFRH_f.AFR8  = 2)
#define PB08_AFx_UART2TXD()                 (CW_GPIOB->AFRH_f.AFR8  = 3)
#define PB08_AFx_GTIM2CH2()                 (CW_GPIOB->AFRH_f.AFR8  = 4)
#define PB08_AFx_SPI2SCK()                  (CW_GPIOB->AFRH_f.AFR8  = 5)
#define PB08_AFx_GTIM1CH3()                 (CW_GPIOB->AFRH_f.AFR8  = 6)
#define PB08_AFx_ATIMETR()                  (CW_GPIOB->AFRH_f.AFR8  = 7)
#define PB09_AFx_GPIO()                     (CW_GPIOB->AFRH_f.AFR9  = 0)
#define PB09_AFx_I2C1SDA()                  (CW_GPIOB->AFRH_f.AFR9  = 1)
#define PB09_AFx_GTIM2CH1()                 (CW_GPIOB->AFRH_f.AFR9  = 2)
#define PB09_AFx_UART2RXD()                 (CW_GPIOB->AFRH_f.AFR9  = 3)
#define PB09_AFx_IROUT()                    (CW_GPIOB->AFRH_f.AFR9  = 4)
#define PB09_AFx_SPI2CS()                   (CW_GPIOB->AFRH_f.AFR9  = 5)
#define PB09_AFx_GTIM1CH4()                 (CW_GPIOB->AFRH_f.AFR9  = 6)
#define PB09_AFx_ATIMBK()                   (CW_GPIOB->AFRH_f.AFR9  = 7)
#define PB10_AFx_GPIO()                     (CW_GPIOB->AFRH_f.AFR10 = 0)
#define PB10_AFx_UART2RTS()                 (CW_GPIOB->AFRH_f.AFR10 = 1)
#define PB10_AFx_UART1RXD()                 (CW_GPIOB->AFRH_f.AFR10 = 2)
#define PB10_AFx_I2C1SCL()                  (CW_GPIOB->AFRH_f.AFR10 = 3)
#define PB10_AFx_I2C2SCL()                  (CW_GPIOB->AFRH_f.AFR10 = 4)
#define PB10_AFx_SPI2SCK()                  (CW_GPIOB->AFRH_f.AFR10 = 5)
#define PB10_AFx_GTIM2CH3()                 (CW_GPIOB->AFRH_f.AFR10 = 6)
#define PB10_AFx_ATIMCH2A()                 (CW_GPIOB->AFRH_f.AFR10 = 7)
#define PB11_AFx_GPIO()                     (CW_GPIOB->AFRH_f.AFR11 = 0)
#define PB11_AFx_GTIM3ETR()                 (CW_GPIOB->AFRH_f.AFR11 = 1)
#define PB11_AFx_UART1TXD()                 (CW_GPIOB->AFRH_f.AFR11 = 2)
#define PB11_AFx_I2C1SDA()                  (CW_GPIOB->AFRH_f.AFR11 = 3)
#define PB11_AFx_I2C2SDA()                  (CW_GPIOB->AFRH_f.AFR11 = 4)
#define PB11_AFx_BTIMETR()                  (CW_GPIOB->AFRH_f.AFR11 = 5)
#define PB11_AFx_GTIM2CH4()                 (CW_GPIOB->AFRH_f.AFR11 = 6)
#define PB11_AFx_ATIMCH3A()                 (CW_GPIOB->AFRH_f.AFR11 = 7)
#define PB12_AFx_GPIO()                     (CW_GPIOB->AFRH_f.AFR12 = 0)
#define PB12_AFx_GTIM2TOGN()                (CW_GPIOB->AFRH_f.AFR12 = 1)
#define PB12_AFx_GTIM3CH4()                 (CW_GPIOB->AFRH_f.AFR12 = 2)
#define PB12_AFx_LSEOUT()                   (CW_GPIOB->AFRH_f.AFR12 = 3)
#define PB12_AFx_SPI2CS()                   (CW_GPIOB->AFRH_f.AFR12 = 4)
#define PB12_AFx_SPI1CS()                   (CW_GPIOB->AFRH_f.AFR12 = 5)
#define PB12_AFx_GTIM1TOGN()                (CW_GPIOB->AFRH_f.AFR12 = 6)
#define PB12_AFx_ATIMBK()                   (CW_GPIOB->AFRH_f.AFR12 = 7)
#define PB13_AFx_GPIO()                     (CW_GPIOB->AFRH_f.AFR13 = 0)
#define PB13_AFx_GTIM2TOGP()                (CW_GPIOB->AFRH_f.AFR13 = 1)
#define PB13_AFx_GTIM3CH3()                 (CW_GPIOB->AFRH_f.AFR13 = 2)
#define PB13_AFx_I2C2SCL()                  (CW_GPIOB->AFRH_f.AFR13 = 3)
#define PB13_AFx_SPI2SCK()                  (CW_GPIOB->AFRH_f.AFR13 = 4)
#define PB13_AFx_SPI1SCK()                  (CW_GPIOB->AFRH_f.AFR13 = 5)
#define PB13_AFx_GTIM1TOGP()                (CW_GPIOB->AFRH_f.AFR13 = 6)
#define PB13_AFx_ATIMCH1B()                 (CW_GPIOB->AFRH_f.AFR13 = 7)
#define PB14_AFx_GPIO()                     (CW_GPIOB->AFRH_f.AFR14 = 0)
#define PB14_AFx_GTIM2CH1()                 (CW_GPIOB->AFRH_f.AFR14 = 1)
#define PB14_AFx_GTIM3CH2()                 (CW_GPIOB->AFRH_f.AFR14 = 2)
#define PB14_AFx_I2C2SDA()                  (CW_GPIOB->AFRH_f.AFR14 = 3)
#define PB14_AFx_SPI2MISO()                 (CW_GPIOB->AFRH_f.AFR14 = 4)
#define PB14_AFx_SPI1MISO()                 (CW_GPIOB->AFRH_f.AFR14 = 5)
#define PB14_AFx_RTCOUT()                   (CW_GPIOB->AFRH_f.AFR14 = 6)
#define PB14_AFx_ATIMCH2B()                 (CW_GPIOB->AFRH_f.AFR14 = 7)
#define PB15_AFx_GPIO()                     (CW_GPIOB->AFRH_f.AFR15 = 0)
#define PB15_AFx_GTIM2CH2()                 (CW_GPIOB->AFRH_f.AFR15 = 1)
#define PB15_AFx_GTIM3CH1()                 (CW_GPIOB->AFRH_f.AFR15 = 2)
#define PB15_AFx_BTIM2TOGP()                (CW_GPIOB->AFRH_f.AFR15 = 3)
#define PB15_AFx_SPI2MOSI()                 (CW_GPIOB->AFRH_f.AFR15 = 4)
#define PB15_AFx_SPI1MOSI()                 (CW_GPIOB->AFRH_f.AFR15 = 5)
#define PB15_AFx_RTC1Hz()                   (CW_GPIOB->AFRH_f.AFR15 = 6)
#define PB15_AFx_ATIMCH3B()                 (CW_GPIOB->AFRH_f.AFR15 = 7)

#define PC00_AFx_GPIO()                     (CW_GPIOC->AFRL_f.AFR0  = 0)
#define PC00_AFx_UART1CTS()                 (CW_GPIOC->AFRL_f.AFR0  = 1)
#define PC00_AFx_GTIM2CH4()                 (CW_GPIOC->AFRL_f.AFR0  = 2)
#define PC00_AFx_SPI1CS()                   (CW_GPIOC->AFRL_f.AFR0  = 3)
#define PC00_AFx_LPTIMCH1()                 (CW_GPIOC->AFRL_f.AFR0  = 4)
#define PC00_AFx_UART2RXD()                 (CW_GPIOC->AFRL_f.AFR0  = 5)
#define PC00_AFx_ATIMCH1A()                 (CW_GPIOC->AFRL_f.AFR0  = 6)
#define PC00_AFx_I2C2SCL()                  (CW_GPIOC->AFRL_f.AFR0  = 7)
#define PC01_AFx_GPIO()                     (CW_GPIOC->AFRL_f.AFR1  = 0)
#define PC01_AFx_UART1RTS()                 (CW_GPIOC->AFRL_f.AFR1  = 1)
#define PC01_AFx_GTIM2CH3()                 (CW_GPIOC->AFRL_f.AFR1  = 2)
#define PC01_AFx_SPI1SCK()                  (CW_GPIOC->AFRL_f.AFR1  = 3)
#define PC01_AFx_LPTIMOUT()                 (CW_GPIOC->AFRL_f.AFR1  = 4)
#define PC01_AFx_UART2TXD()                 (CW_GPIOC->AFRL_f.AFR1  = 5)
#define PC01_AFx_ATIMCH2A()                 (CW_GPIOC->AFRL_f.AFR1  = 6)
#define PC01_AFx_I2C2SDA()                  (CW_GPIOC->AFRL_f.AFR1  = 7)
#define PC02_AFx_GPIO()                     (CW_GPIOC->AFRL_f.AFR2  = 0)
#define PC02_AFx_UART1RXD()                 (CW_GPIOC->AFRL_f.AFR2  = 1)
#define PC02_AFx_GTIM2CH2()                 (CW_GPIOC->AFRL_f.AFR2  = 2)
#define PC02_AFx_SPI1MISO()                 (CW_GPIOC->AFRL_f.AFR2  = 3)
#define PC02_AFx_LPTIMCH2()                 (CW_GPIOC->AFRL_f.AFR2  = 4)
#define PC02_AFx_UART1TXD()                 (CW_GPIOC->AFRL_f.AFR2  = 5)
#define PC02_AFx_ATIMCH3A()                 (CW_GPIOC->AFRL_f.AFR2  = 6)
#define PC03_AFx_GPIO()                     (CW_GPIOC->AFRL_f.AFR3  = 0)
#define PC03_AFx_UART1TXD()                 (CW_GPIOC->AFRL_f.AFR3  = 1)
#define PC03_AFx_GTIM2CH1()                 (CW_GPIOC->AFRL_f.AFR3  = 2)
#define PC03_AFx_SPI1MOSI()                 (CW_GPIOC->AFRL_f.AFR3  = 3)
#define PC03_AFx_LPTIMETR()                 (CW_GPIOC->AFRL_f.AFR3  = 4)
#define PC03_AFx_UART1RXD()                 (CW_GPIOC->AFRL_f.AFR3  = 5)
#define PC03_AFx_ATIMBK()                   (CW_GPIOC->AFRL_f.AFR3  = 6)
#define PC04_AFx_GPIO()                     (CW_GPIOC->AFRL_f.AFR4  = 0)
#define PC04_AFx_UART1TXD()                 (CW_GPIOC->AFRL_f.AFR4  = 1)
#define PC04_AFx_UART3RXD()                 (CW_GPIOC->AFRL_f.AFR4  = 2)
#define PC04_AFx_IROUT()                    (CW_GPIOC->AFRL_f.AFR4  = 3)
#define PC04_AFx_LSIOUT()                   (CW_GPIOC->AFRL_f.AFR4  = 6)
#define PC05_AFx_GPIO()                     (CW_GPIOC->AFRL_f.AFR5  = 0)
#define PC05_AFx_UART1RXD()                 (CW_GPIOC->AFRL_f.AFR5  = 1)
#define PC05_AFx_UART3TXD()                 (CW_GPIOC->AFRL_f.AFR5  = 2)
#define PC05_AFx_MCOOUT()                   (CW_GPIOC->AFRL_f.AFR5  = 3)
#define PC05_AFx_LPTIMETR()                 (CW_GPIOC->AFRL_f.AFR5  = 4)
#define PC05_AFx_LPTIMOUT()                 (CW_GPIOC->AFRL_f.AFR5  = 5)
#define PC06_AFx_GPIO()                     (CW_GPIOC->AFRL_f.AFR6  = 0)
#define PC06_AFx_UART1RXD()                 (CW_GPIOC->AFRL_f.AFR6  = 1)
#define PC06_AFx_UART3TXD()                 (CW_GPIOC->AFRL_f.AFR6  = 2)
#define PC06_AFx_BTIM2TOGP()                (CW_GPIOC->AFRL_f.AFR6  = 3)
#define PC06_AFx_GTIM2CH4()                 (CW_GPIOC->AFRL_f.AFR6  = 5)
#define PC06_AFx_ATIMCH1B()                 (CW_GPIOC->AFRL_f.AFR6  = 6)
#define PC07_AFx_GPIO()                     (CW_GPIOC->AFRL_f.AFR7  = 0)
#define PC07_AFx_UART1TXD()                 (CW_GPIOC->AFRL_f.AFR7  = 1)
#define PC07_AFx_UART3RXD()                 (CW_GPIOC->AFRL_f.AFR7  = 2)
#define PC07_AFx_BTIM2TOGN()                (CW_GPIOC->AFRL_f.AFR7  = 3)
#define PC07_AFx_GTIM2CH3()                 (CW_GPIOC->AFRL_f.AFR7  = 5)
#define PC07_AFx_ATIMCH2B()                 (CW_GPIOC->AFRL_f.AFR7  = 6)
#define PC08_AFx_GPIO()                     (CW_GPIOC->AFRH_f.AFR8  = 0)
#define PC08_AFx_UART1CTS()                 (CW_GPIOC->AFRH_f.AFR8  = 1)
#define PC08_AFx_UART3TXD()                 (CW_GPIOC->AFRH_f.AFR8  = 2)
#define PC08_AFx_GTIM3ETR()                 (CW_GPIOC->AFRH_f.AFR8  = 3)
#define PC08_AFx_GTIM2CH2()                 (CW_GPIOC->AFRH_f.AFR8  = 5)
#define PC08_AFx_ATIMCH3B()                 (CW_GPIOC->AFRH_f.AFR8  = 6)
#define PC09_AFx_GPIO()                     (CW_GPIOC->AFRH_f.AFR9  = 0)
#define PC09_AFx_UART1RTS()                 (CW_GPIOC->AFRH_f.AFR9  = 1)
#define PC09_AFx_UART3RXD()                 (CW_GPIOC->AFRH_f.AFR9  = 2)
#define PC09_AFx_I2C1SDA()                  (CW_GPIOC->AFRH_f.AFR9  = 3)
#define PC09_AFx_GTIM2CH1()                 (CW_GPIOC->AFRH_f.AFR9  = 5)
#define PC09_AFx_ATIMETR()                  (CW_GPIOC->AFRH_f.AFR9  = 6)
#define PC10_AFx_GPIO()                     (CW_GPIOC->AFRH_f.AFR10 = 0)
#define PC10_AFx_UART1TXD()                 (CW_GPIOC->AFRH_f.AFR10 = 1)
#define PC10_AFx_GTIM3CH1()                 (CW_GPIOC->AFRH_f.AFR10 = 2)
#define PC10_AFx_HCLKOUT()                  (CW_GPIOC->AFRH_f.AFR10 = 3)
#define PC10_AFx_BTIM1TOGP()                (CW_GPIOC->AFRH_f.AFR10 = 4)
#define PC10_AFx_VC1OUT()                   (CW_GPIOC->AFRH_f.AFR10 = 5)
#define PC10_AFx_LPTIMCH1()                 (CW_GPIOC->AFRH_f.AFR10 = 6)
#define PC10_AFx_ATIMCH2B()                 (CW_GPIOC->AFRH_f.AFR10 = 7)
#define PC11_AFx_GPIO()                     (CW_GPIOC->AFRH_f.AFR11 = 0)
#define PC11_AFx_UART1RXD()                 (CW_GPIOC->AFRH_f.AFR11 = 1)
#define PC11_AFx_GTIM3CH2()                 (CW_GPIOC->AFRH_f.AFR11 = 2)
#define PC11_AFx_IROUT()                    (CW_GPIOC->AFRH_f.AFR11 = 3)
#define PC11_AFx_BTIM1TOGN()                (CW_GPIOC->AFRH_f.AFR11 = 4)
#define PC11_AFx_VC2OUT()                   (CW_GPIOC->AFRH_f.AFR11 = 5)
#define PC11_AFx_LPTIMCH2()                 (CW_GPIOC->AFRH_f.AFR11 = 6)
#define PC11_AFx_ATIMCH3B()                 (CW_GPIOC->AFRH_f.AFR11 = 7)
#define PC12_AFx_GPIO()                     (CW_GPIOC->AFRH_f.AFR12 = 0)
#define PC12_AFx_UART2TXD()                 (CW_GPIOC->AFRH_f.AFR12 = 1)
#define PC12_AFx_PCLKOUT()                  (CW_GPIOC->AFRH_f.AFR12 = 2)
#define PC12_AFx_LVDOUT()                   (CW_GPIOC->AFRH_f.AFR12 = 3)
#define PC12_AFx_UART3RXD()                 (CW_GPIOC->AFRH_f.AFR12 = 4)
#define PC12_AFx_HSIOSCOUT()                (CW_GPIOC->AFRH_f.AFR12 = 6)
#define PC13_AFx_GPIO()                     (CW_GPIOC->AFRH_f.AFR13 = 0)
#define PC13_AFx_RTC1Hz()                   (CW_GPIOC->AFRH_f.AFR13 = 2)
#define PC13_AFx_UART1CTS()                 (CW_GPIOC->AFRH_f.AFR13 = 3)
#define PC13_AFx_RTCOUT()                   (CW_GPIOC->AFRH_f.AFR13 = 4)
#define PC13_AFx_BTIMETR()                  (CW_GPIOC->AFRH_f.AFR13 = 5)
#define PC13_AFx_GTIM3ETR()                 (CW_GPIOC->AFRH_f.AFR13 = 6)
#define PC13_AFx_RTCTAMP()                  (CW_GPIOC->AFRH_f.AFR13 = 7)
#define PC14_AFx_GPIO()                     (CW_GPIOC->AFRH_f.AFR14 = 0)
#define PC14_AFx_AUTOTRIMETR()              (CW_GPIOC->AFRH_f.AFR14 = 1)
#define PC14_AFx_GTIM1CH4()                 (CW_GPIOC->AFRH_f.AFR14 = 2)
#define PC14_AFx_UART1RTS()                 (CW_GPIOC->AFRH_f.AFR14 = 3)
#define PC14_AFx_UART1TXD()                 (CW_GPIOC->AFRH_f.AFR14 = 4)
#define PC14_AFx_SPI2MISO()                 (CW_GPIOC->AFRH_f.AFR14 = 5)
#define PC14_AFx_GTIM3TOGN()                (CW_GPIOC->AFRH_f.AFR14 = 6)
#define PC14_AFx_GTIM3CH1()                 (CW_GPIOC->AFRH_f.AFR14 = 7)
#define PC15_AFx_GPIO()                     (CW_GPIOC->AFRH_f.AFR15 = 0)
#define PC15_AFx_HSEOUT()                   (CW_GPIOC->AFRH_f.AFR15 = 1)
#define PC15_AFx_GTIM1CH3()                 (CW_GPIOC->AFRH_f.AFR15 = 2)
#define PC15_AFx_GTIM1ETR()                 (CW_GPIOC->AFRH_f.AFR15 = 3)
#define PC15_AFx_UART1RXD()                 (CW_GPIOC->AFRH_f.AFR15 = 4)
#define PC15_AFx_SPI2MOSI()                 (CW_GPIOC->AFRH_f.AFR15 = 5)
#define PC15_AFx_GTIM3TOGP()                (CW_GPIOC->AFRH_f.AFR15 = 6)
#define PC15_AFx_GTIM3CH2()                 (CW_GPIOC->AFRH_f.AFR15 = 7)


#define PD02_AFx_GPIO()                     (CW_GPIOD->AFRL_f.AFR2  = 0)
#define PD02_AFx_UART2RXD()                 (CW_GPIOD->AFRL_f.AFR2  = 1)
#define PD02_AFx_GTIM1CH1()                 (CW_GPIOD->AFRL_f.AFR2  = 2)
#define PD02_AFx_BTIMETR()                  (CW_GPIOD->AFRL_f.AFR2  = 3)
#define PD02_AFx_UART3TXD()                 (CW_GPIOD->AFRL_f.AFR2  = 4)
#define PD02_AFx_RTC1Hz()                   (CW_GPIOD->AFRL_f.AFR2  = 5)
#define PD02_AFx_GTIM3ETR()                 (CW_GPIOD->AFRL_f.AFR2  = 6)
#define PD02_AFx_ATIMETR()                  (CW_GPIOD->AFRL_f.AFR2  = 7)

#define PF00_AFx_GPIO()                     (CW_GPIOF->AFRL_f.AFR0  = 0)
#define PF00_AFx_AUTOTRIMETR()              (CW_GPIOF->AFRL_f.AFR0  = 1)
#define PF00_AFx_GTIM1CH2()                 (CW_GPIOF->AFRL_f.AFR0  = 2)
#define PF00_AFx_I2C1SDA()                  (CW_GPIOF->AFRL_f.AFR0  = 3)
#define PF00_AFx_BTIM1TOGP()                (CW_GPIOF->AFRL_f.AFR0  = 4)
#define PF00_AFx_SPI2SCK()                  (CW_GPIOF->AFRL_f.AFR0  = 5)
#define PF00_AFx_GTIM2TOGN()                (CW_GPIOF->AFRL_f.AFR0  = 6)
#define PF00_AFx_GTIM3CH3()                 (CW_GPIOF->AFRL_f.AFR0  = 7)
#define PF01_AFx_GPIO()                     (CW_GPIOF->AFRL_f.AFR1  = 0)
#define PF01_AFx_LSEOUT()                   (CW_GPIOF->AFRL_f.AFR1  = 1)
#define PF01_AFx_GTIM1CH1()                 (CW_GPIOF->AFRL_f.AFR1  = 2)
#define PF01_AFx_I2C1SCL()                  (CW_GPIOF->AFRL_f.AFR1  = 3)
#define PF01_AFx_BTIM1TOGN()                (CW_GPIOF->AFRL_f.AFR1  = 4)
#define PF01_AFx_SPI2CS()                   (CW_GPIOF->AFRL_f.AFR1  = 5)
#define PF01_AFx_GTIM2TOGP()                (CW_GPIOF->AFRL_f.AFR1  = 6)
#define PF01_AFx_GTIM3CH4()                 (CW_GPIOF->AFRL_f.AFR1  = 7)
#define PF04_AFx_GPIO()                     (CW_GPIOF->AFRL_f.AFR4  = 0)
#define PF04_AFx_UART1TXD()                 (CW_GPIOF->AFRL_f.AFR4  = 1)
#define PF04_AFx_GTIM1CH2()                 (CW_GPIOF->AFRL_f.AFR4  = 2)
#define PF04_AFx_UART2RXD()                 (CW_GPIOF->AFRL_f.AFR4  = 4)
#define PF05_AFx_GPIO()                     (CW_GPIOF->AFRL_f.AFR5  = 0)
#define PF05_AFx_UART1RXD()                 (CW_GPIOF->AFRL_f.AFR5  = 1)
#define PF05_AFx_BTIMETR()                  (CW_GPIOF->AFRL_f.AFR5  = 2)
#define PF05_AFx_UART2TXD()                 (CW_GPIOF->AFRL_f.AFR5  = 4)
#define PF05_AFx_AUTOTRIMETR()              (CW_GPIOF->AFRL_f.AFR5  = 5)
#define PF06_AFx_GPIO()                     (CW_GPIOF->AFRL_f.AFR6  = 0)
#define PF06_AFx_UART3CTS()                 (CW_GPIOF->AFRL_f.AFR6  = 1)
#define PF06_AFx_I2C1SCL()                  (CW_GPIOF->AFRL_f.AFR6  = 2)
#define PF06_AFx_GTIM1TOGN()                (CW_GPIOF->AFRL_f.AFR6  = 3)
#define PF06_AFx_UART2CTS()                 (CW_GPIOF->AFRL_f.AFR6  = 4)
#define PF06_AFx_I2C2SCL()                  (CW_GPIOF->AFRL_f.AFR6  = 5)
#define PF06_AFx_GTIM3TOGN()                (CW_GPIOF->AFRL_f.AFR6  = 6)
#define PF06_AFx_BTIM3TOGP()                (CW_GPIOF->AFRL_f.AFR6  = 7)
#define PF07_AFx_GPIO()                     (CW_GPIOF->AFRL_f.AFR7  = 0)
#define PF07_AFx_UART3RTS()                 (CW_GPIOF->AFRL_f.AFR7  = 1)
#define PF07_AFx_I2C1SDA()                  (CW_GPIOF->AFRL_f.AFR7  = 2)
#define PF07_AFx_GTIM1TOGP()                (CW_GPIOF->AFRL_f.AFR7  = 3)
#define PF07_AFx_UART2RTS()                 (CW_GPIOF->AFRL_f.AFR7  = 4)
#define PF07_AFx_I2C2SDA()                  (CW_GPIOF->AFRL_f.AFR7  = 5)
#define PF07_AFx_GTIM3TOGP()                (CW_GPIOF->AFRL_f.AFR7  = 6)
#define PF07_AFx_BTIM3TOGN()                (CW_GPIOF->AFRL_f.AFR7  = 7)

//============================================================

#ifdef __cplusplus
}
#endif

#endif
