/*********************************************************************************
 * Copyright(C),Ningbo Joyson Preh Car Connect Co.,Ltd.
 * FileName:    Gpio_drv.h
 * Author:      Zheng shijie
 * Version :    Ver0.1
 * Date:        2020-10-09
 * Description:
 *
 *********************************************************************************/

#ifndef DRIVER_GPIO_GPIO_DRV_H_
#define DRIVER_GPIO_GPIO_DRV_H_

#include "S32K148.h"

/*GPIO Port ID define*/
#define PIN_INDEX_0  (0)
#define PIN_INDEX_1  (1)
#define PIN_INDEX_2  (2)
#define PIN_INDEX_3  (3)
#define PIN_INDEX_4  (4)
#define PIN_INDEX_5  (5)
#define PIN_INDEX_6  (6)
#define PIN_INDEX_7  (7)
#define PIN_INDEX_8  (8)
#define PIN_INDEX_9  (9)
#define PIN_INDEX_10 (10)
#define PIN_INDEX_11 (11)
#define PIN_INDEX_12 (12)
#define PIN_INDEX_13 (13)
#define PIN_INDEX_14 (14)
#define PIN_INDEX_15 (15)
#define PIN_INDEX_16 (16)
#define PIN_INDEX_17 (17)
#define PIN_INDEX_18 (18)
#define PIN_INDEX_19 (19)
#define PIN_INDEX_20 (20)
#define PIN_INDEX_21 (21)
#define PIN_INDEX_22 (22)
#define PIN_INDEX_23 (23)
#define PIN_INDEX_24 (24)
#define PIN_INDEX_25 (25)
#define PIN_INDEX_26 (26)
#define PIN_INDEX_27 (27)
#define PIN_INDEX_28 (28)
#define PIN_INDEX_29 (29)
#define PIN_INDEX_30 (30)
#define PIN_INDEX_31 (31)
#define PIN_INDEX_32 (32)
#define PIN_INDEX_33 (33)
#define PIN_INDEX_34 (34)
#define PIN_INDEX_35 (35)
#define PIN_INDEX_36 (36)

/*GPIO PIN Function define*/
#define PIN_FUNCTION_ALT0  (0x00)/*pin disable*/
#define PIN_FUNCTION_ALT1  (0x01)/*gpio*/
#define PIN_FUNCTION_ALT2  (0x02)/*chip-specific*/
#define PIN_FUNCTION_ALT3  (0x03)/*chip-specific*/
#define PIN_FUNCTION_ALT4  (0x04)/*chip-specific*/
#define PIN_FUNCTION_ALT5  (0x05)/*chip-specific*/
#define PIN_FUNCTION_ALT6  (0x06)/*chip-specific*/
#define PIN_FUNCTION_ALT7  (0x07)/*chip-specific*/

/*GPIO Lev define*/
#define PORT_HIGH  (1)
#define PORT_LOW   (0)

/*GPIO DIR define*/
#define DIR_INPUT   (0)
#define DIR_OUTPUT  (1)

/*GPIO CLK define*/
#define CLK_ENABLE	(1)
#define CLK_DISABLE	(0)

/*GPIO INT Function define*/
#if 0
typedef enum
{
    PORT_DMA_INT_DISABLED = 0x0U,  /*Interrupt Status Flag (ISF) is disabled.*/
    PORT_DMA_RISING_EDGE  = 0x1U,  /*DMA request on rising edge.*/
    PORT_DMA_FALLING_EDGE = 0x2U,  /*DMA request on falling edge.*/
    PORT_DMA_EITHER_EDGE  = 0x3U,  /*DMA request on either edge.*/
    PORT_INT_LOGIC_ZERO   = 0x8U,  /*Interrupt when logic zero. */
    PORT_INT_RISING_EDGE  = 0x9U,  /*Interrupt on rising edge. */
    PORT_INT_FALLING_EDGE = 0xAU,  /*Interrupt on falling edge. */
    PORT_INT_EITHER_EDGE  = 0xBU,  /*Interrupt on either edge. */
    PORT_INT_LOGIC_ONE    = 0xCU   /*nterrupt when logic one. */
}Port_INT;
#endif
extern void GPIO_Port_Clk_Enable(uint8_t group_index, uint8_t state);
extern void GPIO_Port_Function_Set(PORT_Type *port_index, uint8_t pin_index, uint8_t pin_function);
extern void GPIO_Port_Dir_Set(GPIO_Type *port_index, uint8_t pin_index, uint8_t dir);
extern void GPIO_Port_Lev_Set(GPIO_Type *port_index, uint8_t pin_index, uint8_t lev);
extern uint8_t GPIO_INPUT_Port_Lev_Read(GPIO_Type *port_index, uint8_t pin_index);


#endif /* DRIVER_GPIO_GPIO_DRV_H_ */
