📄 lh7a400_gpio_driver.c
字号:
*
* Returns: Nothing
*
* Notes:
*
**********************************************************************/
void gpio_interrupt_debounce_enable(UNS_8 port_f_bit)
{
GPIO->gpiodb |= _BIT(port_f_bit);
}
/**********************************************************************
*
* Function: gpio_interrupt_debounce_disable
*
* Purpose:
* disable debounce for a port F interrupt bit
*
* Processing:
* Clear the appropriate bit in the gpiodb register
*
* Parameters:
* port_f_bit: The bit number of the port F bit. For example, for
* PORTF2, use port_f_bit == 2.
*
* Outputs: None
*
* Returns: Nothing
*
* Notes:
*
**********************************************************************/
void gpio_interrupt_debounce_disable(UNS_8 port_f_bit)
{
GPIO->gpiodb &= ~_BIT(port_f_bit);
}
/**********************************************************************
*
* Function: gpio_interrupt_clear
*
* Purpose:
*
* Processing:
*
* Parameters:
* port_f_bit: The bit number of the port F bit. For example, for
* PORTF2, use port_f_bit == 2.
*
* Outputs: None
*
* Returns: Nothing
*
* Notes:
*
**********************************************************************/
void gpio_interrupt_clear(UNS_8 port_f_bit)
{
GPIO->gpiofeoi = _BIT(port_f_bit);
}
/**********************************************************************
*
* Function: gpio_interrupt_pending
*
* Purpose:
* return 1 if there is a pending interrupt on the specified
* port F bit.
*
* Processing:
* AND the intstatus register with 1 << port_f_bit and return
* the result.
*
* Parameters:
* port_f_bit: The bit number of the port F bit. For example, for
* PORTF2, use port_f_bit == 2.
*
* Outputs: None
*
* Returns:
* 0 if there is not a raw interrupt pending on the specified port bit.
* non-0 if there is a raw interrupt pending on the specified port bit.
*
* Notes:
*
**********************************************************************/
INT_32 gpio_interrupt_pending(UNS_8 port_f_bit)
{
return GPIO->intstatus & _BIT(port_f_bit);
}
/**********************************************************************
*
* Function: gpio_raw_interrupt_pending
*
* Purpose:
* return 1 if there is a pending raw interrupt on the specified
* port F bit.
*
* Processing:
* AND the rawintstatus register with 1 << port_f_bit and return
* the result.
*
* Parameters:
* port_f_bit: The bit number of the port F bit. For example, for
* PORTF2, use port_f_bit == 2.
*
* Outputs: None
*
* Returns:
* 0 if there is not a raw interrupt pending on the specified port bit.
* non-0 if there is a raw interrupt pending on the specified port bit.
*
* Notes:
* This function ignores the interrupt mask that is set up by
* the port_f_bit_is_interrupt()/port_f_bit_is_gpio() functions
*
**********************************************************************/
INT_32 gpio_raw_interrupt_pending(UNS_8 port_f_bit)
{
return GPIO->rawintstatus & _BIT(port_f_bit);
}
/**********************************************************************
*
* Function: gpio_interrupt_edge_triggered
*
* Purpose:
* set the port F interrupt bit to edge triggered
*
* Processing:
* Set the specified bit in the inttype1 register
*
* Parameters:
* port_f_bit: The bit number of the port F bit. For example, for
* PORTF2, use port_f_bit == 2.
*
* Outputs: None
*
* Returns: Nothing
*
* Notes:
*
**********************************************************************/
void gpio_interrupt_edge_triggered(UNS_8 port_f_bit)
{
GPIO->inttype1 |= _BIT(port_f_bit);
}
/**********************************************************************
*
* Function: gpio_interrupt_level_triggered
*
* Purpose:
* set the port F interrupt bit to level triggered
*
* Processing:
* Clear the specified bit in the inttype1 register
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
*
* Notes:
*
**********************************************************************/
void gpio_interrupt_level_triggered(UNS_8 port_f_bit)
{
GPIO->inttype1 &= ~_BIT(port_f_bit);
}
/**********************************************************************
*
* Function: gpio_interrupt_active_high
*
* Purpose:
* Make the port F interrupt bit active high
*
* Processing:
* Set the specified bit in the inttype2 register
*
* Parameters:
* port_f_bit: The bit number of the port F bit. For example, for
* PORTF2, use port_f_bit == 2.
*
* Outputs: None
*
* Returns: Nothing
*
* Notes:
*
**********************************************************************/
void gpio_interrupt_active_high(UNS_8 port_f_bit)
{
GPIO->inttype2 |= _BIT(port_f_bit);
}
/**********************************************************************
*
* Function: gpio_interrupt_active_low
*
* Purpose:
* Make the port F interrupt bit active low
*
* Processing:
* Clear the specified bit in the inttype2 register
*
* Parameters:
* port_f_bit: The bit number of the port F bit. For example, for
* PORTF2, use port_f_bit == 2.
*
* Outputs: None
*
* Returns: Nothing
*
* Notes:
*
**********************************************************************/
void gpio_interrupt_active_low(UNS_8 port_f_bit)
{
GPIO->inttype2 &= ~_BIT(port_f_bit);
}
/**********************************************************************
*
* Function: gpio_keyscan_set
*
* Purpose:
* set the 4-bit keyscan value
*
* Processing:
* set the keyscan register to value
*
* Parameters:
* value: the 4-bit value to set.
*
* Outputs: None
*
* Returns: Nothing
*
* Notes:
* If value is greater than 15 (0xf), then only least significant
* four bits of value will be used.
*
**********************************************************************/
void gpio_keyscan_set(UNS_8 value)
{
GPIO->kscan = value;
}
/**********************************************************************
*
* Function: gpio_keyscan_get
*
* Purpose:
* get the 4-bit keyscan value
*
* Processing:
* read the keyscan register and return it.
*
* Parameters: None
*
* Outputs: None
*
* Returns:
* the current contents of the key scan register.
*
* Notes:
*
**********************************************************************/
UNS_8 gpio_keyscan_get(void)
{
return (UNS_8)GPIO->kscan;
}
/**********************************************************************
*
* Function: gpio_port_e_is_gpio
*
* Purpose:
* configure the lower 4 bits of port E as gpio
*
* Processing:
* Set up pinmux register
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
*
* Notes:
*
**********************************************************************/
void gpio_port_e_is_gpio(void)
{
GPIO->pinmux &= ~GPIO_PINMUX_PEOCON;
}
/**********************************************************************
*
* Function: gpio_port_e_is_lcd
*
* Purpose:
* configure the lower 4 bits of port E as lcd data[7:4]
*
* Processing:
* Set up pinmux register
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
*
* Notes:
*
**********************************************************************/
void gpio_port_e_is_lcd(void)
{
GPIO->pinmux |= GPIO_PINMUX_PEOCON;
}
/**********************************************************************
*
* Function: gpio_port_d_is_gpio
*
* Purpose:
* configure all of port D as gpio
*
* Processing:
* Set up pinmux register
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
*
* Notes:
*
**********************************************************************/
void gpio_port_d_is_gpio(void)
{
GPIO->pinmux &= ~GPIO_PINMUX_PDOCON;
}
/**********************************************************************
*
* Function: gpio_port_d_is_lcd
*
* Purpose:
* configure all of port D as LCD data[15:8]
*
* Processing:
* Set up pinmux register
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
*
* Notes:
*
**********************************************************************/
void gpio_port_d_is_lcd(void)
{
GPIO->pinmux |= GPIO_PINMUX_PDOCON;
}
/**********************************************************************
*
* Function: gpio_port_b_has_gpio
*
* Purpose:
* configure port B[5:1] as gpio
*
* Processing:
* Set up pinmux register
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
*
* Notes:
*
**********************************************************************/
void gpio_port_b_has_gpio(void)
{
GPIO->pinmux &= ~GPIO_PINMUX_UART3ON;
}
/**********************************************************************
*
* Function: gpio_port_b_has_uart3
*
* Purpose:
* configure port B[5:1] as UART3 pins
*
* Processing:
* Set up pinmux register
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
*
* Notes:
*
**********************************************************************/
void gpio_port_b_has_uart3(void)
{
GPIO->pinmux |= GPIO_PINMUX_UART3ON;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -