|
|
@ -119,9 +119,6 @@ bool ZGPIO::enableClock() { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void regIRQGPIO(ZGPIO *gpio) { |
|
|
|
for (int i = 0; i < s_irqGPIO_num; i++) { |
|
|
|
if (s_irqGPIO[i] == gpio) { |
|
|
@ -144,27 +141,36 @@ void ZGPIO::initAsInput(Pin_t pin, GPIOMode_t mode, GPIOIrqType_t irqtype, bool |
|
|
|
m_gpio = chip_get_gpio(pin); |
|
|
|
m_pinoff = chip_get_pinoff(pin); |
|
|
|
|
|
|
|
uint32_t pulluptype = 0; |
|
|
|
if (mode == kMode_nopull) { |
|
|
|
pulluptype = GPIO_NOPULL; |
|
|
|
} else if (mode == kMode_pullup) { |
|
|
|
pulluptype = GPIO_PULLUP; |
|
|
|
} else if (mode == kMode_pulldown) { |
|
|
|
pulluptype = GPIO_PULLDOWN; |
|
|
|
} |
|
|
|
|
|
|
|
enableClock(); |
|
|
|
GPIO_InitTypeDef m_GPIO_InitStruct = {0}; |
|
|
|
if (m_irqtype == kIRQ_noIrq) { |
|
|
|
m_GPIO_InitStruct.Pin = m_pinoff; |
|
|
|
m_GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
|
|
|
m_GPIO_InitStruct.Pull = 0; |
|
|
|
m_GPIO_InitStruct.Pull = pulluptype; |
|
|
|
m_GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
|
|
|
} else if (m_irqtype == kIRQ_risingIrq) { |
|
|
|
m_GPIO_InitStruct.Pin = m_pinoff; |
|
|
|
m_GPIO_InitStruct.Mode = m_mirror ? GPIO_MODE_IT_FALLING : GPIO_MODE_IT_RISING; |
|
|
|
m_GPIO_InitStruct.Pull = 0; |
|
|
|
m_GPIO_InitStruct.Pull = pulluptype; |
|
|
|
m_GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
|
|
|
} else if (m_irqtype == kIRQ_fallingIrq) { |
|
|
|
m_GPIO_InitStruct.Pin = m_pinoff; |
|
|
|
m_GPIO_InitStruct.Mode = !m_mirror ? GPIO_MODE_IT_FALLING : GPIO_MODE_IT_RISING; |
|
|
|
m_GPIO_InitStruct.Pull = 0; |
|
|
|
m_GPIO_InitStruct.Pull = pulluptype; |
|
|
|
m_GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
|
|
|
} else if (m_irqtype == kIRQ_risingAndFallingIrq) { |
|
|
|
m_GPIO_InitStruct.Pin = m_pinoff; |
|
|
|
m_GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; |
|
|
|
m_GPIO_InitStruct.Pull = 0; |
|
|
|
m_GPIO_InitStruct.Pull = pulluptype; |
|
|
|
m_GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
|
|
|
} |
|
|
|
|
|
|
|