novoton-gpio配置+变量转化算法

普通gpio初始化,只需设置输入输出模式和是否使能中断

void GPIO_SetMode(GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode);

* @param[in] port GPIO port. It could be PA, PB, PC, PD, PE or PF.


* @param[in] u32PinMask The single or multiple pins of specified GPIO port.
* It could be BIT0 ~ BIT15 for PA, PB, PC and PD GPIO port.
* It could be BIT0 ~ BIT14 for PE GPIO port.
* It could be BIT0 ~ BIT7 for PF GPIO port.
* @param[in] u32Mode Operation mode. It could be \n


* GPIO_MODE_INPUT, GPIO_MODE_OUTPUT, GPIO_MODE_OPEN_DRAIN, GPIO_MODE_QUASI.

 

void GPIO_EnableInt(GPIO_T *port, uint32_t u32Pin, uint32_t u32IntAttribs);

* @param[in] u32IntAttribs The interrupt attribute of specified GPIO pin. It could be \n
* GPIO_INT_RISING, GPIO_INT_FALLING, GPIO_INT_BOTH_EDGE, GPIO_INT_HIGH, GPIO_INT_LOW.

void GPIO_DisableInt(GPIO_T *port, uint32_t u32Pin);

变量转化算法:

uint32_t i;
volatile uint32_t *ptrLED[_LED_Bar_Count] = {&PB2, &PB3, &PC3, &PC2, &PA9, &PB1, &PC7};

for(i = 0; i < _LED_Bar_Count; i++)
{
  if((Number > i) & 0x01)
    *ptrLED[i] = 0; //LED ON
  else
    *ptrLED[i] = 1; //LED OFF
}

猜你喜欢

转载自www.cnblogs.com/llw2017/p/9067604.html