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

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

        看门狗定时器(WDTIM):

/*
 * Copyright (C) 2003 Texas Instruments Incorporated
 * All Rights Reserved
 */



#include <csl.h>
#include <csl_wdtim.h> 
#include <stdio.h>



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 ("\nTESTING...\n");
  	
  	/* 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\n", 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 <csl.h>
#include <csl_hpi.h>
#include <csl_dma.h>


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\n", 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;
    
    
	
	
}


 
 
 



 

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值