📄 lh7a404_gpio_driver.c
字号:
break;
default:
break;
}
return (UNS_8) data;
}
/***********************************************************************
*
* Function: gpio_kbcol_drive
*
* Purpose: Drive a keyboard column high, low, or hi-z
*
* Processing:
* For the passed keyboard column value (col), set the drive line
* for the column to high, low, or high impediance based on the
* value of kbstate.
*
* Parameters:
* col : Must be an enumeration of type GPIO_KB_COL_T
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void gpio_kbcol_drive(GPIO_KB_COL_T col)
{
GPIO->kscan = (UNS_32) col;
}
/***********************************************************************
*
* Function: gpio_uart3_select
*
* Purpose: Select UART3 (TRUE) or GPIO signals
*
* Processing:
* If select is TRUE, select UART3 operation on GPIO signals B1,
* B2, B3, B4, and B5. Otherwise, these signals are placed in a
* GPIO mode.
*
* Parameters:
* select : TRUE for UART3 mode, FALSE for GPIO mode
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void gpio_uart3_select(BOOL_32 select)
{
if (select == TRUE)
{
GPIO->pinmux |= GPIO_PINMUX_UART3ON;
}
else
{
GPIO->pinmux &= ~GPIO_PINMUX_UART3ON;
}
}
/***********************************************************************
*
* Function: gpio_lcd_signal_select
*
* Purpose: Select LCD data signal multiplexing
*
* Processing:
* Read the GPIO pinmix register and mask off the LCD data muxing
* bits. 'OR' in the new selected bits and update the GPIO pinmux
* register.
*
* Parameters:
* select : Must be an enumeration of type GPIO_LCD_MP_T
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void gpio_lcd_signal_select(GPIO_LCD_MP_T lcdm)
{
UNS_32 pinmux;
/* Read pinmux register and mask off LCD data muxing bits */
pinmux = GPIO->pinmux & ~(GPIO_PINMUX_PEOCON | GPIO_PINMUX_PDOCON);
/* Write selected bits into the pinmux register */
GPIO->pinmux = (pinmux | (UNS_32) lcdm);
}
/***********************************************************************
*
* Function: gpio_codec_ac97_select
*
* Purpose: Select AC97 CODEC (TRUE) or ACI CODEC interface
*
* Processing:
* If select is TRUE, select AC97 (AAC) CODEC operation. Otherwise,
* select ACI CODEC operation.
*
* Parameters:
* select : TRUE for AC97 CODEC mode, FALSE for ACI CODEC mode
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void gpio_codec_ac97_select(BOOL_32 select)
{
if (select == TRUE)
{
GPIO->pinmux |= GPIO_PINMUX_CODECON;
}
else
{
GPIO->pinmux &= GPIO_PINMUX_CODECON;
}
}
/***********************************************************************
*
* Function: gpio_lcd_signal_select
*
* Purpose: Select states of synchronous clocks enables 0/1/2 and
* cs6/cs7
*
* Processing:
* Read the GPIO pinmix register and mask off the synchronous clock
* muxing bits. 'OR' in the new selected bits and update the GPIO
* pinmux register.
*
* Parameters:
* sclke : Must be an enumeration of type GPIO_SCLKE_T
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void gpio_sclke_select(GPIO_SCLKE_T sclke)
{
UNS_32 pinmux;
/* Read pinmux register and mask off clock muxing bits */
pinmux = GPIO->pinmux & ~(GPIO_PINMUX_CLK0EN | GPIO_PINMUX_CLK12EN);
/* Write selected bits into the pinmux register */
GPIO->pinmux = (pinmux | (UNS_32) sclke);
}
/***********************************************************************
*
* Function: gpio_ext_int_config
*
* Purpose: Set an external interrupt's level/edge and high/low active
* mode
*
* Processing:
* If edge is TRUE, configure the appropriate interrupt designated
* by the passed value of intr to an edge triggered interrupt mode.
* Otherwise, configure it for level sensitive mode. If high is
* TRUE, configure the appropriate interrupt for active high mode.
* Otherwise, configure it for level active low mode
*
* Parameters:
* intr : Must be an enumeration of type GPIO_INT_T
* edge : If TRUE, use edge mode, else use level mode
* high : If TRUE, use active high mode, else ude active low mode
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void gpio_ext_int_config(GPIO_INT_T intr,
BOOL_32 edge,
BOOL_32 high)
{
if (edge == TRUE)
{
/* Set interrupt as active on edge */
GPIO->inttype1 |= (UNS_32) intr;
}
else
{
/* Set interrupt as active on level */
GPIO->inttype1 &= ~(UNS_32) intr;
}
if (high == TRUE)
{
/* Set interrupt as active high */
GPIO->inttype2 |= (UNS_32) intr;
}
else
{
/* Set interrupt as active low */
GPIO->inttype2 &= ~(UNS_32) intr;
}
}
/***********************************************************************
*
* Function: gpio_clear_int
*
* Purpose: Clear a pending external (edge) interrupt
*
* Processing:
* Clear the approproate edge triggered interrupt by setting the
* end-of-interrupt bit for that interrupt.
*
* Parameters:
* intr : Must be an enumeration of type GPIO_INT_T
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void gpio_clear_int(GPIO_INT_T intr)
{
GPIO->gpiofeoi = (UNS_32) intr;
}
/***********************************************************************
*
* Function: gpio_ext_int_enable
*
* Purpose: Enable or disable an external interrupt
*
* Processing:
* If enable is TRUE, enable the port F external interrupt for the
* passed value of intr by setting the appropriate bit in the
* interrupt enable register. If enable is FALSE, disable the
* interrupt and return functionality of the port to a GPIO.
*
* Parameters:
* intr : Must be an enumeration of type GPIO_INT_T
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void gpio_ext_int_enable(GPIO_INT_T intr,
BOOL_32 enable)
{
if (enable == TRUE)
{
GPIO->gpiointen |= (UNS_32)intr;
}
else
{
GPIO->gpiointen &= ~(UNS_32)intr;
}
}
/***********************************************************************
*
* Function: gpio_interrupt_pending
*
* Purpose: Return pending state of an external interrupt
*
* Processing:
* Check the interrupt status bit for the specified interrupt based
* on intr. If the bit is set, return TRUE to the caller. Otherwise,
* return FALSE to the caller.
*
* Parameters:
* intr : Must be an enumeration of type GPIO_INT_T
*
* Outputs: None
*
* Returns: TRUE if the specified interrupt is pending, otherwise FALSE
*
* Notes: None
*
**********************************************************************/
BOOL_32 gpio_interrupt_pending(GPIO_INT_T intr)
{
BOOL_32 pending = FALSE;
if ((GPIO->intstatus & ~(UNS_32) intr) != 0)
{
pending = TRUE;
}
return pending;
}
/***********************************************************************
*
* Function: gpio_enable_int_debounce
*
* Purpose: Enable or disable signal debouncing for an external
* interrupt
*
* Processing:
* If enable is TRUE, enable interrupt debouncing for the interrupt
* specified by intr by setting the debounce bit for the interrupt
* in the debounce register. Otherwise, disable the bit to disable
* interrupt signal debouncing.
*
* Parameters:
* intr : Must be an enumeration of type GPIO_INT_T
* enable : If TRUE, enable debouncing for the specific interrupt
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void gpio_enable_int_debounce(GPIO_INT_T intr,
BOOL_32 enable)
{
if (enable == TRUE)
{
GPIO->gpiodb |= (UNS_32)intr;
}
else
{
GPIO->gpiodb &= ~(UNS_32)intr;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -