103 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			103 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
| /****************************************************************************
 | |
| 
 | |
| Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
 | |
| 
 | |
| This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
 | |
| be copied by any method or incorporated into another program without
 | |
| the express written consent of Aerospace C.Power. This Information or any portion
 | |
| thereof remains the property of Aerospace C.Power. The Information contained herein
 | |
| is believed to be accurate and Aerospace C.Power assumes no responsibility or
 | |
| liability for its use in any way and conveys no license or title under
 | |
| any patent or copyright and makes no representation or warranty that this
 | |
| Information is free from patent or copyright infringement.
 | |
| 
 | |
| ****************************************************************************/
 | |
| /*
 | |
|  * Notice :
 | |
|  * This xxx.h file, belongs to HAL level, holds common structures for HW level.
 | |
|  * The bellows are ready for HW & HAL level, limited for CVG/MAC & APP level.
 | |
|  */
 | |
| #ifndef _GPIO_H_
 | |
| #define _GPIO_H_
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| extern "C" {
 | |
| #endif
 | |
| 
 | |
| /*
 | |
|  * @brief iot_gpio_op_t() - API table to operate GPIO hardware.
 | |
|  */
 | |
| typedef struct
 | |
| {
 | |
|     /*
 | |
|      * @brief gpio_init() - Initialize the hardware part.
 | |
|      * @return ERR_OK if sucsessfully, else failed.
 | |
|      */
 | |
|     int (*gpio_init)(void);
 | |
|     /*
 | |
|      * @brief set_gpio_mode() - Set mode of current GPIO.
 | |
|      * @param gpio: GPIO-NO that starts from 'Zero'.
 | |
|      * @param mode: Mode of current GPIO, see enum gpio_mode.
 | |
|      * @return ERR_OK if sucsessfully, else failed.
 | |
|      */
 | |
|     int (*set_gpio_mode)(int gpio, int mode);
 | |
|     /*
 | |
|      * @brief set_interrupt_mode() - Set interrupt mode of current GPIO.
 | |
|      *  Called only if this GPIO set as GPIO_INTERRUPT.
 | |
|      * @param gpio: GPIO-NO that starts from 'Zero'.
 | |
|      * @param mode: Interrupt mode of current GPIO, see gpio_int_trigger_mode.
 | |
|      * @return ERR_OK if sucsessfully, else failed.
 | |
|      */
 | |
|     int (*set_interrupt_mode)(int gpio, int mode);
 | |
|     /*
 | |
|      * @brief set_value() - Set output value of current GPIO.
 | |
|      *  Called only if this GPIO set as GPIO_OUTPUT.
 | |
|      * @param gpio: GPIO-NO that starts from 'Zero'.
 | |
|      * @param value: 0 - output low, else high.
 | |
|      * @return ERR_OK if sucsessfully, else failed.
 | |
|      */
 | |
|     int (*set_value)(int gpio, int value);
 | |
|     /*
 | |
|      * @brief get_value() - Get input value of current GPIO.
 | |
|      *  Called only if this GPIO set as GPIO_INPUT.
 | |
|      * @param gpio: GPIO-NO that starts from 'Zero'.
 | |
|      * @return value: 0 - output low, else high.
 | |
|      */
 | |
|     int (*get_value)(int gpio);
 | |
|     /*
 | |
|      * @brief get_interrupt_status() - Get interrupt state of current GPIO.
 | |
|      *  Called only if this GPIO set as GPIO_INTERRUPT.
 | |
|      * @param gpio: GPIO-NO that starts from 'Zero'.
 | |
|      * @return value: 0 - No interrupt triggers, else interrupt triggers.
 | |
|      */
 | |
|     int (*get_interrupt_status)(int gpio);
 | |
|     /*
 | |
|      * @brief clear_interrupt_status() - Clear the interrupt of current GPIO.
 | |
|      *  Called only if this GPIO set as GPIO_INTERRUPT.
 | |
|      * @param gpio: GPIO-NO that starts from 'Zero'.
 | |
|      * @return ERR_OK if sucsessfully, else failed.
 | |
|      */
 | |
|     int (*clear_interrupt_status)(int gpio);
 | |
|     /*
 | |
|      * @brief set_gpio_open_drain() - Set open drain of current GPIO.
 | |
|      * @param gpio: GPIO-NO that starts from 'Zero'.
 | |
|      * @param mode: open drain mode, see enum gpio_drain_mode.
 | |
|      * @return ERR_OK if sucsessfully, else failed.
 | |
|      */
 | |
|     int (*set_gpio_open_drain)(int gpio, int mode);
 | |
|     /*
 | |
|      * @brief get_output_value() - Get output value of current GPIO.
 | |
|      *  Called only if this GPIO set as GPIO_OUTPUT.
 | |
|      * @param gpio: GPIO-NO that starts from 'Zero'.
 | |
|      * @param pval: Pointer to get value of output. 0 - output low, else high.
 | |
|      * @return ERR_OK if sucsessfully, else failed.
 | |
|      */
 | |
|     int (*get_output_value)(int gpio, int *pval);
 | |
| } iot_gpio_op_t;
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| }
 | |
| #endif
 | |
| 
 | |
| #endif
 |