14 PTE简介
PTE全称Peripheral trigger engine,即外设触发引擎。
其主要作用是使外围设备可以通过其他外围设备或事件独立于CPU进行自主交互。PTE允许外围设备之间可以精确触发。
14.2 使用方法
14.3 编程指南
14.3.1 src&dst外设
当前PTE支持的src外设定义在SYSCTRL_PTE_SRC_INT中:
typedef enum
{
= 0,
SYSCTRL_PTE_I2C0_INT = 1,
SYSCTRL_PTE_I2C1_INT = 2,
SYSCTRL_PTE_SARADC_INT = 3,
SYSCTRL_PTE_I2S_INT = 4,
SYSCTRL_PTE_DMA_INT = 5,
SYSCTRL_PTE_IR_INT = 6,
SYSCTRL_PTE_KEYSCANNER_INT = 7,
SYSCTRL_PTE_PWMC0_INT = 8,
SYSCTRL_PTE_PWMC1_INT = 9,
SYSCTRL_PTE_PWMC2_INT = 10,
SYSCTRL_PTE_TIMER0_INT = 11,
SYSCTRL_PTE_TIMER1_INT = 12,
SYSCTRL_PTE_TIMER2_INT = 13,
SYSCTRL_PTE_GPIO0_INT = 14,
SYSCTRL_PTE_GPIO1_INT = 15,
SYSCTRL_PTE_UART0_INT = 16,
SYSCTRL_PTE_UART1_INT = 17,
SYSCTRL_PTE_SPI0_INT = 18,
SYSCTRL_PTE_SPI1_INT = 19,
SYSCTRL_PTE_SPIFLASH = 20,
SYSCTRL_PTE_RCT_CNT = 21,
SYSCTRL_PTE_IR_WAKEUP = 22,
SYSCTRL_PTE_USB_INT = 23,
SYSCTRL_PTE_QDEC_INT
= 24,
SYSCTRL_PTE_SRC_INT_MAX } SYSCTRL_PTE_SRC_INT;
dst外设定义在SYSCTRL_PTE_DST_EN中:
typedef enum
{
= 0,
SYSCTRL_PTE_I2C0_EN = 1,
SYSCTRL_PTE_I2C1_EN = 2,
SYSCTRL_PTE_SARADC_EN = 3,
SYSCTRL_PTE_I2S_TX_EN = 4,
SYSCTRL_PTE_I2S_RX_EN = 5,
SYSCTRL_PTE_IR_EN = 6,
SYSCTRL_PTE_KEYSCANNER_EN = 7,
SYSCTRL_PTE_PWMC0_EN = 8,
SYSCTRL_PTE_PWMC1_EN = 9,
SYSCTRL_PTE_PWMC2_EN = 10,
SYSCTRL_PTE_TIMER0_CH0_EN = 11,
SYSCTRL_PTE_TIMER0_CH1_EN = 12,
SYSCTRL_PTE_TIMER1_CH0_EN = 13,
SYSCTRL_PTE_TIMER1_CH1_EN = 14,
SYSCTRL_PTE_TIMER2_CH0_EN = 15,
SYSCTRL_PTE_TIMER2_CH1_EN
= 16,
SYSCTRL_PTE_DST_EN_MAX } SYSCTRL_PTE_DST_EN;
14.3.2 驱动接口
PTE_ConnectPeripheral:PTE外设连接接口
PTE_EnableChannel:PTE通道使能接口
PTE_ChannelClose:PTE通道关闭接口
PTE_IrqProcess:PTE标准中断程序接口
PTE_OutPeripheralContinueProcess:dst外设中断标准PTE中继触发接口
PTE_OutPeripheralEndProcess:dst外设中断标准PTE结束接口
14.3.3 代码示例
下面以Timer0通过PTE通道0触发Timer1为例展示PTE的具体使用方法。
src外设和dst外设配置方法不在本文档介绍范围内,我们默认Timer0和Timer1已经配置好并注册好中断。
#define PTE_CH0 SYSCTRL_PTE_CHANNEL_0
uint32_t Timer0Isr(void *user_data)
{
(APB_TMR0);
TMR_IntClrreturn 0;
}
uint32_t Timer1Isr(void *user_data)
{
(APB_TMR1);
TMR_IntClr(PTE_CH0);
PTE_OutPeripheralContinueProcessreturn 0;
}
// 仅供参考,不建议注册PTE中断
uint32_t PTE0Isr(void *user_data)
{
(PTE_CH0);
PTE_IrqProcessreturn 0;
}
void PTE_Test(void)
{
(PTE_CH0,
PTE_ConnectPeripheral,
SYSCTRL_PTE_TIMER0_INT);
SYSCTRL_PTE_TIMER1_CH0_EN(APB_TMR0);
TMR_Enable}
上面示例会保留PTE通道0并等待下一次触发。如果想要触发之后直接关闭通道代码如下:
uint32_t Timer1Isr(void *user_data)
{
(APB_TMR1);
TMR_IntClr(PTE_CH0);
PTE_OutPeripheralEndProcessreturn 0;
}
关闭通道会断开Timer0和Timer1的连接,再次触发需要重新建立连接。