|
关于这部分,我们后面会根据客户的需求提供相关测试例程。我们这边使用GPIO17做了测试。SOM-TL665x的GPIO17,原用作TIMI;核心板设置4.7K下拉,如果客户需用作外部中断,需要给予足够的上拉电阻,建议值:1K。相关代码可以参考如下:
/****************************************************************************/
/* */
/* 广州创龙电子科技有限公司 */
/* */
/* Copyright (C) 2014-2019 Guangzhou Tronlong Electronic Technology Co.,Ltd */
/* */
/****************************************************************************/
/****************************************************************************/
/* */
/* TL665x[F]-EasyEVM 测试程序(SYS/BIOS) */
/* */
/****************************************************************************/
/*
* - 希望缄默(bin wang)
* - bin@tronlong.com
* - DSP C665x 项目组
*
* 官网 www.tronlong.com
* 论坛 51dsp.net
*
*/
#include <xdc/std.h>
#include <xdc/cfg/global.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/family/c64p/Hwi.h>
#include <ti/sysbios/family/c66/tci66xx/CpIntc.h>
#include <Tronlong/Driver/_UART.h>
#include <Tronlong/Support/Drivers/Include/hw/soc_c66x.h>
#include <Tronlong/Support/Drivers/Include/gpio.h>
/****************************************************************************/
/* */
/* 宏定义 */
/* */
/****************************************************************************/
#define ConsoleWrite(format, ...) \
do { \
_UART_printf(_UART0, format, ##__VA_ARGS__ ); \
} while (0)
/****************************************************************************/
/* */
/* 全局变量 */
/* */
/****************************************************************************/
// 版本
char AppVerStr[16] = "1.00.0805";
/****************************************************************************/
/* */
/* GPIO 线程 */
/* */
/****************************************************************************/
Void GPIO17Hwi(UArg arg)
{
ConsoleWrite("GPIO17 Interrupt.\r\n");
}
/****************************************************************************/
/* */
/* 外设初始化 */
/* */
/****************************************************************************/
Void PerihInit()
{
/* GPIO 外设中断配置 */
KickUnlock();
// 管脚复用配置
GPIOPinMuxSet(SOC_DSC_BASE_REGS + SOC_DSC_PIN_CONTROL_0, GPIO17_TIMI1, GPIO_NORMAL_ENABLED);
// 管脚方向配置
GPIODirModeSet(SOC_GPIO_0_REGS, GPIO17_TIMI1, GPIO_DIR_INPUT);
// 中断触发类型
GPIOIntTypeSet(SOC_GPIO_0_REGS, GPIO17_TIMI1, GPIO_INT_TYPE_FALLEDGE);
// 使能 GPIO 中断
HWREG(SOC_GPIO_0_REGS + GPIO_BINTEN) |= (1 << 1);
}
/****************************************************************************/
/* */
/* 线程初始化 */
/* */
/****************************************************************************/
Void ThreadInit()
{
// GPIO Hwi 线程配置
// CIC0 映射系统中断 1 到主机中断 1
CpIntc_mapSysIntToHostInt(0, 1, 1);
// 配置系统中断 1 Hwi 线程
CpIntc_dispatchPlug(1, &GPIO17Hwi, 1, TRUE);
// 使能主机中断 0
CpIntc_enableHostInt(0, 1);
// 配置 CPU 中断
Hwi_Params hwiParams;
Hwi_Params_init(&hwiParams);
hwiParams.eventId = CpIntc_getEventId(1);
hwiParams.arg = 1;
hwiParams.enableInt = TRUE;
Hwi_create(4, &CpIntc_dispatch, &hwiParams, NULL);
}
/****************************************************************************/
/* */
/* 主函数 */
/* */
/****************************************************************************/
Int main()
{
// 初始化
PerihInit();
ThreadInit();
// 启动消息
ConsoleWrite("\r\n\r\nDSP GPIO Interrupt Application\r\n");
ConsoleWrite("Build on %s %s %d Version %s\r\n\r\n", __DATE__, __TIME__, __TI_COMPILER_VERSION__, AppVerStr);
// 启动 SYS/BIOS 系统调度
BIOS_start();
return(0);
}
|
|