DSP

DSP 之看门狗定时器(WDTIM)和主机设备接口(HPI)

2019-07-13 16:38发布

DSP 之看门狗定时器(WDTIM)和主机设备接口(HPI)         看门狗定时器(WDTIM): /* * Copyright (C) 2003 Texas Instruments Incorporated * All Rights Reserved */ #include #include #include int i, pscVal; WDTIM_Config getConfig; /* Structure used to configure a WDTIM device */ WDTIM_Config myConfig = { 0x1000, /* WDPRD Period register(周期寄存器) */ 0x0000, /* WDTCR Control register(控制寄存器) */ 0x1000 /* WDTCR2 Secondary register(辅助寄存器) */ }; void main(void) { /* Initialize CSL Libary */ CSL_init(); printf (" TESTING... "); /* Configures WDTIM using configuration structure */ WDTIM_config(&myConfig); /* Macros to write WDTIM register field values */ WDTIM_FSET(WDTCR, WDOUT, 1); /* Connect to NMI */ WDTIM_FSET(WDTCR, TDDR, 0xF); /* Value to load PSC field */ WDTIM_FSET(WDTCR2, PREMD, 0); /* Set direct mode */ /* Executes the watchdog service sequence */ WDTIM_service(); /* enable watchdog */ while(1) { /* Gets the WDYIM configuration structure for a specified device */ WDTIM_getConfig(&getConfig); /* Macros to read WDTIM register field value */ pscVal = WDTIM_FGET(WDTCR,PSC); printf("pscVal: %x, wdtcr: %x ", pscVal, getConfig.wdtcr); /* write periodically to WDTIMER - when this line is commented out, the watchdog times out, WDFLAG set to 1, indicating that a Watchdog time-out occurred.*/ WDTIM_service(); } } 主机设备接口(HPI): /*-------------------------------------------------------------------------- * Project: HPI.c * Name: zwp * Date: 2014.2 *-------------------------------------------------------------------------*/ #include #include #include ioport Uint16* hpi_ctl; HPI_Config myconfig; DMA_Handle hDma; /* 主机接口设置 */ HPI_Config myConfig = { 0x3, /* HPWREMU, Select FREE = SOFT = 1 */ 0x0, /* HGPIOEN, Disable all GPIO pins */ 0x80, /* HPIC, Reset HPI */ }; int main(void) { Uint16 myregval; Uint16 myvar; /*初始化CSL库*/ CSL_init(); /* Writes to HPI register using values in configuration structure */ HPI_config(&myConfig); /* Reads current HPI configuration */ HPI_getConfig(&myconfig); /* gets the address of an HPI register */ hpi_ctl = HPI_ADDR(HPIC); printf("HPI register's address = %d ", hpi_ctl); /* enable HA[0:7], HD[8:15], HD[0:7] for GPIO */ myregval = HPI_HGPIOEN_RMK (0,1,1,1,0,0,0,0,0); /* set HPI register value */ HPI_RSET(HPIC, 1); /* get HPI register value */ myval = HPI_RGET(HPIC); return 0; }