📄 gpio.c
字号:
/*******************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained herein
* is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of INFOMAX COMMUNICATION CO.,LTD.
* * MODULE NAME: GPIO * DESCRIPTION: GPIO API * AUTHOR: Bo-Hung Wu * BEGIN DATE: Oct. 19, 2007 * LAST MODIFICATION: *****************************************************************************//******************************************************************************* Include/header files *******************************************************************************/#include "gpio.h" /******************************************************************************* Constant/Marco*******************************************************************************//******************************************************************************* Structure/Union/Enum/Typedef *******************************************************************************//******************************************************************************* Local function prototype *******************************************************************************/int gpio_query_fast(int GPIO_id);
/******************************************************************************* Global/Local variables *******************************************************************************//******************************************************************************* Function implementation *******************************************************************************//**
@Desc
Description for function_name
@Param parameter 1
Put parameter 1 description here
@Param parameter 2
Put parameter 2 description here
@Return Return value 1 and it description
@Return Return value 1 and it description
*/
int gpio_query_fast(int GPIO_id)
{
int ret_val = 0; //Assume NOT fast by default
if( (GPIO_id >= FAST_GPIO_START) && (GPIO_id <= FAST_GPIO_END) )
{
ret_val = 1;
}
return ret_val;
}
void led_on(int led_no)
{
if( gpio_query_fast(led_no) != 1)
*GPIO_DIO_REG &= ~(1 << led_no);
else
*FGPIO_DIO_REG &= ~(1 << led_no);
}
void led_off(int led_no)
{
if( gpio_query_fast(led_no) != 1)
*GPIO_DIO_REG |= (1 << led_no);
else
*FGPIO_DIO_REG |= (1 << led_no);
}
void toggle_led(int led_no)
{
if( gpio_query_fast(led_no) != 1)
*GPIO_DIO_REG ^= (1 << led_no);
else
*FGPIO_DIO_REG ^= (1 << led_no);
}
void gpio_init_func(UINT32 gpio_func_reg_val)
{
*GPIO_FUN_REG = gpio_func_reg_val; *FGPIO_FUN_REG = gpio_func_reg_val;
}
void gpio_write_io(UINT32 gpio_io_reg_val)
{
*GPIO_DIO_REG = gpio_io_reg_val; *FGPIO_DIO_REG = gpio_io_reg_val;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -