/**
 * @brief  GPIO初始化配置
 * @code
 *    //初始化配置PORTB端口的10引脚为推挽输出引脚
 *    GPIO_InitTypeDef GPIO_InitStruct1;      //申请一个结构变量
 *    GPIO_InitStruct1.instance = HW_GPIOB;   //选择PORTB端口
 *    GPIO_InitStruct1.mode = kGPIO_Mode_OPP; //推挽输出
 *    GPIO_InitStruct1.pinx = 10;             //选择10引脚
 *    //调用初始化GPIO函数 
 *    GPIO_Init(&GPIO_InitStruct1);
 * @endcode
 * @param  GPIO_InitStruct: GPIO初始化结构体,包含了引脚状态参数  
           GPIO_InitStruct.instance   :端口号 HW_GPIOA ~ HW_GPIOE
 * @retval None
 */
void GPIO_Init(GPIO_InitTypeDef * GPIO_InitStruct)
{
    /* param check */
    assert_param(IS_GPIO_ALL_INSTANCE(GPIO_InitStruct->instance));
    assert_param(IS_PORT_ALL_INSTANCE(GPIO_InitStruct->instance));
    assert_param(IS_GPIO_ALL_PIN(GPIO_InitStruct->pinx));
    /* config state */
    switch(GPIO_InitStruct->mode)
    {
        case kGPIO_Mode_IFT:
            PORT_PinPullConfig(GPIO_InitStruct->instance, GPIO_InitStruct->pinx, kPullDisabled);
            GPIO_PinConfig(GPIO_InitStruct->instance, GPIO_InitStruct->pinx, kInput);
            break;
        case kGPIO_Mode_IPD:
            PORT_PinPullConfig(GPIO_InitStruct->instance, GPIO_InitStruct->pinx, kPullDown);
            GPIO_PinConfig(GPIO_InitStruct->instance, GPIO_InitStruct->pinx, kInput);
            break;
        case kGPIO_Mode_IPU:
            PORT_PinPullConfig(GPIO_InitStruct->instance, GPIO_InitStruct->pinx, kPullUp);
            GPIO_PinConfig(GPIO_InitStruct->instance, GPIO_InitStruct->pinx, kInput);
            break;
        case kGPIO_Mode_OPP:
            PORT_PinPullConfig(GPIO_InitStruct->instance, GPIO_InitStruct->pinx, kPullDisabled);
            GPIO_PinConfig(GPIO_InitStruct->instance, GPIO_InitStruct->pinx, kOutput);
            break;
        default:
            break;					
    }
    /* config pinMux */
    PORT_PinMuxConfig(GPIO_InitStruct->instance, GPIO_InitStruct->pinx, kPinAlt1);
}
Ejemplo n.º 2
0
//====================================================
void MARK_Init(void)
{uint16_t	Pin_MARK  = Pin_MARK0
#ifdef Pin_MARK1
 					  | Pin_MARK1
#endif
#ifdef Pin_MARK2					  
 					  | Pin_MARK2
#endif
#ifdef Pin_MARK3
 					  | Pin_MARK3
#endif
#ifdef Pin_MARK4
 					  | Pin_MARK4
#endif
#ifdef Pin_MARK5
 					  | Pin_MARK5
#endif			
										;
// uint16_t	Pin_LED = Pin_LED1 | Pin_LED2			;

// RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
 GPIO_Enable(GPIO_MARK)								;
// GPIO_Enable(GPIO_LED)								;
#ifdef	Pin_KEYA
 GPIO_Enable(GPIO_KEYA)								;
#endif
#ifdef	Pin_KEYB
 GPIO_Enable(GPIO_KEYB)								;
#endif
 
 GPIO_PinConfig(GPIO_MARK,Pin_MARK,GPIO_Mode_OUT)	;
// GPIO_PinConfig(GPIO_LED ,Pin_LED ,GPIO_Mode_OUT)	;
#ifdef	Pin_KEYA
 GPIO_PinConfig(GPIO_KEYA,Pin_KEYA,GPIO_Mode_IN_FLOATING);
#endif
#ifdef	Pin_KEYB
 GPIO_PinConfig(GPIO_KEYB,Pin_KEYB,GPIO_Mode_IN_FLOATING);
#endif 
// Это для контроля TIM3_CH1 !!!! это запуск ADC3.
// GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE)	;
// GPIO_PinRemapConfig(GPIO_PartialRemap_TIM3, ENABLE)	;
// GPIO_PinConfig(GPIOB,GPIO_Pin_4,GPIO_Mode_AF_PP)		;

// GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_15		;
// GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_	;
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz	;
// GPIO_Init(GPIOA, &GPIO_InitStructure)				;
}