// 外部中断模块
// 杭州秒寻科技有限公司
// 周涛
// 2023-11-14

#ifndef EXTI_H
#define EXTI_H

#include "sysdef.h"

// 收到PPS信号次数计数器
#define EXTI_SYNC_SEND_COUNTER 3

// 北斗模块
#define EXTI_BD_RCC_PERIPH RCC_AHB1Periph_GPIOB
#define EXTI_BD_GPIO_PORT GPIOB
#define EXTI_BD_GPIO_PIN GPIO_Pin_0
#define EXTI_BD_SOURCE_PORT EXTI_PortSourceGPIOB
#define EXTI_BD_SOURCE_PIN EXTI_PinSource0
#define EXTI_BD_LINE EXTI_Line0
#define EXTI_BD_IRQ_CHANNEL EXTI0_IRQn

// cpld模块
#define EXTI_CPLD_RCC_PERIPH RCC_AHB1Periph_GPIOA
#define EXTI_CPLD_GPIO_PORT GPIOA
#define EXTI_CPLD_GPIO_PIN GPIO_Pin_1
#define EXTI_CPLD_SOURCE_PORT EXTI_PortSourceGPIOA
#define EXTI_CPLD_SOURCE_PIN EXTI_PinSource1
#define EXTI_CPLD_LINE EXTI_Line1
#define EXTI_CPLD_IRQ_CHANNEL EXTI1_IRQn

// 同步信号模块
#define EXTI_SYNC_RCC_PERIPH RCC_AHB1Periph_GPIOD
#define EXTI_SYNC_GPIO_PORT GPIOD
#define EXTI_SYNC_GPIO_PIN GPIO_Pin_4
#define EXTI_SYNC_SOURCE_PORT EXTI_PortSourceGPIOD
#define EXTI_SYNC_SOURCE_PIN EXTI_PinSource4
#define EXTI_SYNC_LINE EXTI_Line4
#define EXTI_SYNC_IRQ_CHANNEL EXTI4_IRQn

// 供外部使用接口
void exti_init();
void exti_enable_sync_tx_int();
void exti_disable_sync_tx_int();
void exti_set_sync_timer_enabled_flag(uint8 byFlag);

// 内部接口
void exti_init_pps_bd();
void exti_init_pps_cpld();
void exti_init_tx_sync();

#endif