/****************************************************************************** * Shanghai ChipON Micro-Electronic Co.,Ltd ****************************************************************************** * $ File Name $ : Board_GpioCfg.h * $ Author $ : ChipON AE/FAE Group * $ Data $ : 2023-03-20 * $ HW Version $ : KF32A156-MINI-EVB_V1.2 * $ Description $ : This article provides configuration functions for gpio ****************************************************************************** * Copyright (C) by Shanghai ChipON Micro-Electronic Co.,Ltd * All rights reserved. * * This software is copyright protected and proprietary to * Shanghai ChipON Micro-Electronic Co.,Ltd. ****************************************************************************** ****************************************************************************** * REVISON HISTORY ****************************************************************************** * |Data |Version |Author |Description ****************************************************************************** * |2023-03-20 |V3.0 |AE/FAE Group | Rebuild examples *****************************************************************************/ #ifndef BOARD_GPIO_DEFINE_ #define BOARD_GPIO_DEFINE_ /****************************************************************************** ** Include Files ******************************************************************************/ #include "system_init.h" /***************************************************************************** ** Private Macro Definitions *****************************************************************************/ // GPIO #define PD12_LED1_PIN GPIOD_SFR, GPIO_PIN_MASK_12 #define PH3_LED2_PIN GPIOH_SFR, GPIO_PIN_MASK_3 #define PA4_LED3_PIN GPIOA_SFR, GPIO_PIN_MASK_4 #define PF7_LED4_PIN GPIOF_SFR, GPIO_PIN_MASK_7 #define PC0_WKUP2_PIN GPIOC_SFR, GPIO_PIN_MASK_0 #define PC0_KEY2_PIN GPIOC_SFR, GPIO_PIN_MASK_0 #define PE7_USART0_RX_AF3 GPIOE_SFR, GPIO_PIN_MASK_7, GPIO_RMP_AF3 #define PA3_USART0_TX_AF3 GPIOA_SFR, GPIO_PIN_MASK_3, GPIO_RMP_AF3 #define PA8_LIN5_RX_PIN GPIOA_SFR, GPIO_PIN_MASK_8 #define PA7_LIN5_TX_PIN GPIOA_SFR, GPIO_PIN_MASK_7 #define PA8_LIN5_RX_AF13 GPIOA_SFR, 8, GPIO_RMP_AF13 #define PA7_LIN5_TX_AF13 GPIOA_SFR, 7, GPIO_RMP_AF13 #define PA1_ADC_PIN GPIOA_SFR, GPIO_PIN_MASK_1 #define PA1_ADC_CHANNAL ADC_CHANNEL_66 #define PA13_ADC_PIN GPIOA_SFR, GPIO_PIN_MASK_13 #define PA13_ADC_CHANNAL ADC_CHANNEL_72 #define EXAMPLE_ADC_PIN PA13_ADC_PIN #define EXAMPLE_ADC_CHANNAL PA13_ADC_CHANNAL #define PE13_CLKOUT_PIN GPIOE_SFR, GPIO_PIN_MASK_13 #define PE13_CLKOUT_AF0 GPIOE_SFR, GPIO_Pin_Num_13, GPIO_RMP_AF0 #define PD3_SPI2_SCK_PIN GPIOD_SFR, GPIO_PIN_MASK_3 #define PD2_SPI2_SDI_PIN GPIOD_SFR, GPIO_PIN_MASK_2 #define PG15_SPI2_SDO_PIN GPIOG_SFR, GPIO_PIN_MASK_15 #define PG14_SPI2_SS0_PIN GPIOG_SFR, GPIO_PIN_MASK_14 #define PD3_SPI2_SCK_AF4 GPIOD_SFR, GPIO_Pin_Num_3, GPIO_RMP_AF4 #define PD2_SPI2_SDI_AF4 GPIOD_SFR, GPIO_Pin_Num_2, GPIO_RMP_AF4 #define PG15_SPI2_SDO_AF4 GPIOG_SFR, GPIO_Pin_Num_15, GPIO_RMP_AF4 #define PG14_SPI2_SS0_AF4 GPIOG_SFR, GPIO_Pin_Num_14, GPIO_RMP_AF4 /**==================== ECCP-START ====================*/ /** For Compare mode and capture mode */ #define PB0_ECCP5_CH1_PIN GPIOB_SFR, GPIO_PIN_MASK_0 #define PB0_ECCP5_CH1_AF8 GPIOB_SFR, GPIO_Pin_Num_0, GPIO_RMP_AF8 #define PA9_ECCP5_CH2_PIN GPIOA_SFR, GPIO_PIN_MASK_9 #define PA9_ECCP5_CH2_AF1 GPIOA_SFR, GPIO_Pin_Num_9, GPIO_RMP_AF1 #define PA5_T5CK_PIN GPIOA_SFR, GPIO_PIN_MASK_5 #define PA5_T5CK_AF1 GPIOA_SFR, GPIO_Pin_Num_5, GPIO_RMP_AF1 /**For PWM mode*/ #define ECCP5_CH1H_PIN GPIOB_SFR, GPIO_PIN_MASK_14 #define ECCP5_CH1H_AF GPIOB_SFR, GPIO_Pin_Num_14, GPIO_RMP_AF1 #define ECCP5_CH1L_PIN GPIOB_SFR, GPIO_PIN_MASK_1 #define ECCP5_CH1L_AF GPIOB_SFR, GPIO_Pin_Num_1, GPIO_RMP_AF10 #define ECCP5_CH2H_PIN GPIOA_SFR, GPIO_PIN_MASK_11 #define ECCP5_CH2H_AF GPIOA_SFR, GPIO_Pin_Num_11, GPIO_RMP_AF1 #define ECCP5_CH2L_PIN GPIOB_SFR, GPIO_PIN_MASK_0 #define ECCP5_CH2L_AF GPIOB_SFR, GPIO_Pin_Num_0, GPIO_RMP_AF10 #define ECCP5_BKIN_PIN GPIOB_SFR, GPIO_PIN_MASK_15 #define ECCP5_BKIN_AF GPIOB_SFR, GPIO_Pin_Num_15, GPIO_RMP_AF1 /**==================== ECCP-END ====================*/ /**==================== CCP-START ====================*/ #define PG8_CCP18_CH1_PIN GPIOG_SFR, GPIO_PIN_MASK_8 #define PG8_CCP18_CH1_AF2 GPIOG_SFR, GPIO_Pin_Num_8, GPIO_RMP_AF2 #define PA5_T18CK_PIN GPIOE_SFR, GPIO_PIN_MASK_2 #define PA5_T18CK_AF12 GPIOE_SFR, GPIO_Pin_Num_2, GPIO_RMP_AF12 /**==================== CCP-END ====================*/ /**==================== I2C-START ====================*/ #define I2C0_SCL_PIN GPIOG_SFR, GPIO_PIN_MASK_0 #define I2C0_SCL_AF GPIOG_SFR, GPIO_Pin_Num_0, GPIO_RMP_AF5 #define I2C0_SDA_PIN GPIOF_SFR, GPIO_PIN_MASK_15 #define I2C0_SDA_AF GPIOF_SFR, GPIO_Pin_Num_15, GPIO_RMP_AF5 /**==================== I2C-END ====================*/ /**==================== TIM-START ====================*/ #define T6CK_PIN GPIOA_SFR, GPIO_PIN_MASK_6 #define T6CK_AF GPIOA_SFR, GPIO_Pin_Num_6, GPIO_RMP_AF1 #define T14CK_PIN GPIOG_SFR, GPIO_PIN_MASK_2 #define T14CK_AF GPIOG_SFR, GPIO_Pin_Num_2, GPIO_RMP_AF12 #define T18CK_PIN GPIOE_SFR, GPIO_PIN_MASK_2 #define T18CK_AF GPIOE_SFR, GPIO_Pin_Num_2, GPIO_RMP_AF12 /**==================== TIM-END ====================*/ #define LED1_PORT (GPIOD_SFR) #define LED1_PIN (GPIO_PIN_MASK_12) #define LED2_PORT (GPIOH_SFR) #define LED2_PIN (GPIO_PIN_MASK_3) #define LED3_PORT (GPIOA_SFR) #define LED3_PIN (GPIO_PIN_MASK_4) #define LED4_PORT (GPIOF_SFR) #define LED4_PIN (GPIO_PIN_MASK_7) #define WAUP2_PORT (GPIOC_SFR) #define WAUP2_PIN (GPIO_PIN_MASK_0) #define KEY2_PORT (GPIOC_SFR) #define KEY2_PIN (GPIO_PIN_MASK_0) // USART /***************************************************************************** ** Private Variables Definitions *****************************************************************************/ /***************************************************************************** ** Private Functions *****************************************************************************/ /***************************************************************************** ** Global Functions *****************************************************************************/ /****************************************************************************** ** Functional defineition ******************************************************************************/ /** * @brief:GPIOx output initialization configuration * @param in:GPIOx-Gpio port pointer * GpioPin-Pin number * @param out:None * @retval:None */ static inline void GPIOInit_Output_Config(GPIO_SFRmap *GPIOx, uint16_t GpioPin) { GPIO_InitTypeDef GPIO_InitStructure; GPIO_Struct_Init(&GPIO_InitStructure); GPIO_InitStructure.m_Pin = GpioPin; GPIO_InitStructure.m_Speed = GPIO_LOW_SPEED; GPIO_InitStructure.m_Mode = GPIO_MODE_OUT; GPIO_InitStructure.m_PullUp = GPIO_NOPULL; GPIO_InitStructure.m_PullDown = GPIO_NOPULL; GPIO_Configuration(GPIOx, &GPIO_InitStructure); GPIO_Set_Output_Data_Bits(GPIOx, GpioPin, Bit_RESET); } /** * @brief:Gpio Input Config * @param in:GPIOx-Gpio port pointer * GpioPin-Pin number * @param out:None * @retval:None */ static inline void GPIOInit_Input_Config(GPIO_SFRmap *GPIOx, uint16_t GpioPin) { GPIO_InitTypeDef GPIO_InitStructure; GPIO_Struct_Init(&GPIO_InitStructure); GPIO_InitStructure.m_Pin = GpioPin; GPIO_InitStructure.m_Speed = GPIO_LOW_SPEED; GPIO_InitStructure.m_Mode = GPIO_MODE_IN; GPIO_InitStructure.m_PullUp = GPIO_NOPULL; GPIO_InitStructure.m_PullDown = GPIO_NOPULL; GPIO_Configuration(GPIOx, &GPIO_InitStructure); } #endif