#include "board.h"
|
#define IIC2_READ_SDA gpio_pin_get_val(SDA_PIN)
|
#define SDA_1 gpio_pin_set(SDA_PIN)
|
#define SCL_1 gpio_pin_set(SCL_PIN)
|
|
#define PCA9555_SLA (0x40 >> 1) // ¶¨ÒåPAC9555µÄÆ÷¼þµØÖ·
|
#define PCA9555_REG_IN0 0x00 // ¶¨ÒåÊäÈë¼Ä´æÆ÷0µØÖ·
|
#define PCA9555_REG_IN1 0x01 // ¶¨ÒåÊäÈë¼Ä´æÆ÷1µØÖ·
|
#define PCA9555_REG_OUT0 0x02 // ¶¨ÒåÊä³ö¼Ä´æÆ÷0µØÖ·
|
#define PCA9555_REG_OUT1 0x03 // ¶¨ÒåÊä³ö¼Ä´æÆ÷1µØÖ·
|
#define PCA9555_REG_POL0 0x04 // ¶¨Ò弫ÐÔ·´×ª¼Ä´æÆ÷0µØÖ·
|
#define PCA9555_REG_POL1 0x05 // ¶¨Ò弫ÐÔ·´×ª¼Ä´æÆ÷1µØÖ·
|
#define PCA9555_REG_CFG0 0x06 // ¶¨Òå·½ÏòÅäÖüĴæÆ÷0µØÖ·
|
#define PCA9555_REG_CFG1 0x07 // ¶¨Òå·½ÏòÅäÖüĴæÆ÷1µØÖ·
|
#define PCA9555_DEVICE_ADDR 0x40 // ¶¨ÒåPCA9555µØÖ·
|
#define PCA_OUTPUT_CONFIG_MASK 0x00
|
#define PCA_INPUT_CONFIG_MASK 0xff
|
#define SDA_0 gpio_pin_clr(SDA_PIN)
|
#define SCL_0 gpio_pin_clr(SCL_PIN)
|
#define PCA_INPUT_DETECT IO_PIN_17
|
|
//Êä³öºÍÅäÖÃ
|
#define MAX_GPIO_NUM 16
|
|
////0×é
|
//#define MCU_A 0x01
|
//#define CHG_G 0x02
|
//#define LORA_IRQ 0x03
|
//#define LORA_NRST 0x04
|
//#define ADC_MINIUS 0x05
|
//#define INPUT_5V 0x06
|
//#define PWR_ON 0x07
|
//#define PWR_ENABLE 0x08
|
////1×é
|
//#define GPS_LED 0x09
|
//#define TTS_ENABLE 0x0A
|
//#define WAKE_UP 0x0B
|
//#define AIR780E_ENBALE 0x0C
|
//#define SOS_ENBALE 0x0D
|
//#define GPS_BACKUP 0x0E
|
//#define GPS_POWER 0x0F
|
//#define MAIN_RI 0x10
|
|
//ÖØÐ¶¨Òåºê
|
//0×é
|
#define PWR_GND 0x01
|
#define IN_5V 0x02
|
#define CHGN 0x03
|
#define MOTO 0x04
|
#define BT_IRQ 0x05
|
#define RED_LED 0x06
|
#define GREEN_LED 0x07
|
#define BT_LED 0x08
|
//1×é
|
#define LORA_LED 0x09
|
#define UWB_LED 0x0A
|
#define IO_KONG 0x0B
|
#define LORA_IRQ 0x0C
|
#define LORA_NRST 0x0D
|
#define SOS_ENBALE 0x0E
|
#define WK_UP 0x0F
|
#define BT_EN 0x10
|
|
|
|
|
//ÊäÈë¼Ä´æÆ÷INTÅжÏÊý×é¶ÔӦλÖÃ
|
//input 0×é
|
#define PWR_GND_POSITION (1<<(MAX_GPIO_NUM-PWR_GND))
|
#define IN_5V_POSITION (1<<(MAX_GPIO_NUM-IN_5V))
|
#define CHGN_POSITION (1<<(MAX_GPIO_NUM-CHGN))
|
#define MOTO_POSITION (1<<(MAX_GPIO_NUM-MOTO))
|
#define BT_IRQ_POSITION (1<<(MAX_GPIO_NUM-BT_IRQ))
|
#define RED_LED_POSITION (1<<(MAX_GPIO_NUM-RED_LED))
|
#define GREEN_LED_POSITION (1<<(MAX_GPIO_NUM-GREEN_LED))
|
#define BT_LED_POSITION (1<<(MAX_GPIO_NUM-BT_LED))
|
//input 1×é
|
#define LORA_LED_POSITION (1<<(MAX_GPIO_NUM-LORA_LED))
|
#define UWB_LED_POSITION (1<<(MAX_GPIO_NUM-UWB_LED))
|
#define IO_KONG_POSITION (1<<(MAX_GPIO_NUM-IO_KONG))
|
#define LORA_IRQ_POSITION (1<<(MAX_GPIO_NUM-LORA_IRQ))
|
#define LORA_NRST_POSITION (1<<(MAX_GPIO_NUM-LORA_NRST))
|
#define SOS_ENBALE_POSITION (1<<(MAX_GPIO_NUM-SOS_ENBALE))
|
#define WK_UP_POSITION (1<<(MAX_GPIO_NUM-WK_UP))
|
#define BT_EN_POSITION (1<<(MAX_GPIO_NUM-BT_EN))
|
|
|
#define LORA_LED_ON PCA9555_Set_One_Value_Output(LORA_LED,1)
|
#define LORA_LED_OFF PCA9555_Set_One_Value_Output(LORA_LED,0)
|
|
#define UWB_LED_ON PCA9555_Set_One_Value_Output(UWB_LED,1)
|
#define UWB_LED_OFF PCA9555_Set_One_Value_Output(UWB_LED,0)
|
|
#define RED_LED_ON PCA9555_Set_One_Value_Output(RED_LED,1)
|
#define RED_LED_OFF PCA9555_Set_One_Value_Output(RED_LED,0)
|
|
#define GREEN_LED_ON PCA9555_Set_One_Value_Output(GREEN_LED,1)
|
#define GREEN_LED_OFF PCA9555_Set_One_Value_Output(GREEN_LED,0)
|
|
#define BT_LED_ON PCA9555_Set_One_Value_Output(BT_LED,1)
|
#define BT_LED_OFF PCA9555_Set_One_Value_Output(BT_LED,0)
|
|
#define MOTO_ON PCA9555_Set_One_Value_Output(MOTO,1)
|
#define MOTO_OFF PCA9555_Set_One_Value_Output(MOTO,0)
|
|
#define LORA_NRST_UP PCA9555_Set_One_Value_Output(LORA_NRST,1)
|
#define LORA_NRST_DOWN PCA9555_Set_One_Value_Output(LORA_NRST,0)
|
//uint8_t gps_led_output_state,tts_enbale_output_state,wake_up_output_state,air780e_enable_output_state,sos_enable_output_state,gps_backup_output_state,gps_power_output_state,main_ri_output_state;//1×éoutput IO¿Ú´Ó×óµ½ÓÒ1.0~1.7
|
//uint8_t mcu_a_output_state,chg_g_output_state,lora_irq_output_state,lora_nrst_output_state,adc_minius_output_state,input_5v_output_state,pwr_on_output_state,pwr_enable_output_state;//2×éoutput IO¿Ú´Ó×óµ½ÓÒ0.0~0.7
|
//void IIC_gpio_pca_init(void);
|
void IIC2_pca_Start(void);
|
void IIC_pca_Ready(void);
|
void IIC2_pca_Stop(void);
|
uint8_t IIC2_Wait_pca_Ack(void);
|
void IIC2_pca_send_Ack(void);
|
void IIC2_pca_send_NAck(void);
|
void IIC2_Send_pca_Byte(uint8_t txd);
|
uint8_t IIC2_Read_pca_Byte(unsigned char ack);
|
void IIC_Write_Pca9555(unsigned char addr,unsigned char reg_addr,unsigned char low_byte,unsigned char high_byte);
|
void IIC_Read_Pca9555(uint8_t addr,uint8_t reg_addr,uint8_t* pBuffer,uint16_t num);
|
void PCA9555_write_output_port_data(unsigned char addr,unsigned char data_L,unsigned char data_H);
|
void PCA9555_write_config_port_data(unsigned char addr,unsigned char data_L,unsigned char data_H);
|
void PCA9555_readdata(unsigned char addr,unsigned char* pBuffer);
|
void PCA9555_Set_All_Output(unsigned char value);
|
void PCA9555_Set_One_Value_Output(unsigned char num,unsigned char value);
|
void PCA9555_Set_One_Value_Config(unsigned char num,unsigned char value);
|
void PCA9555_Set_One_Value_Polarity_input(unsigned char num,unsigned char value);
|
void PCA9555_init();
|
//ÍØÕ¹º¯Êý
|
int read_userkey_input_pca_lora();
|
static void pca_input_detect_irq_handler(enum IO_PIN_T pin);
|
//static void pca_handler(enum IO_PIN_T pin);
|
void pca_input_detection_init(GPIO_IRQ_HANDLER_T irq_handler);
|