使用TI DSP 2407A 进行开发的源代码

源代码在线查看: io.c

软件大小: 129 K
上传用户: a974555392
关键词: 2407A DSP 源代码
下载地址: 免注册下载 普通下载 VIP

相关代码

				
				#include "io.h"
				
				#include "DSP240x_Device.h"
				
				
				
				//本函数配置IO口的功能,参数列表为1.IO口复用控制寄存器,2端口方向与数据控制寄存器
				//3一般IO口似能值,4,端口为输入还是输出,5,如果为输出时的默认值6,输出寄存器值
				
				void IO_Init()
				{
				
				//IO_Status_Init(NO1_MCR,NO1_DATDIR,NO1_ENA,IO_IN,NO1_OUT,IO_LOW,NO1_HIGH);
				
				       IO_Status_Init(CAP1_MCR,CAP1_DATDIR,CAP1_ENA,IO_IN,CAP1_OUT,IO_LOW,CAP1_HIGH);
				       IO_Status_Init(CAP2_MCR,CAP2_DATDIR,CAP2_ENA,IO_IN,CAP2_OUT,IO_LOW,CAP2_HIGH);
				       IO_Status_Init(CAP3_MCR,CAP3_DATDIR,CAP3_ENA,IO_IN,CAP3_OUT,IO_LOW,CAP3_HIGH);
				       IO_Status_Init(CAP4_MCR,CAP4_DATDIR,CAP4_ENA,IO_IN,CAP4_OUT,IO_LOW,CAP4_HIGH);
				
				
				}
				void IO_Status_Init(volatile unsigned int * mcr,volatile unsigned int * datdir,unsigned int X_enable , 
				          unsigned int in_out,unsigned int X_io_out,unsigned int High_Low,unsigned int X_high)
				{
				      volatile unsigned int * temp_mcr;
				      volatile unsigned int * temp_datdir;
				      unsigned int TEMPREG;
				      
				      temp_mcr = mcr;
				      temp_datdir = datdir;
				      
				      TEMPREG = * temp_mcr;
				      TEMPREG &=  ~X_enable;
				      *temp_mcr = TEMPREG;
				      
				      if(in_out == 0)    //0:input
				      {
				         TEMPREG = * temp_datdir;
				         TEMPREG &=  ~ X_io_out;
				         * temp_datdir = TEMPREG;
				      }
				      
				      else                  //1 or other :output
				      {
				      
				         TEMPREG = *temp_datdir;
				         TEMPREG |= X_io_out;
				         
				        if(High_Low)		
							TEMPREG |= X_high;
						else
							TEMPREG &= (~X_high);
							
						*temp_datdir = TEMPREG;
						
					  } 
					  
				 }
				      
				      
				      
				unsigned int IN_Status_Load(volatile unsigned int * datdir,unsigned int X_high)
				{
					unsigned int TEMPREG = 0 ;	
				
					TEMPREG = * datdir;
					TEMPREG &= X_high;
				
					if (TEMPREG >0)
						return 1;
					else
						return 0;
				}
				
				
				
				void OUT_Status_Set(volatile unsigned int * datdir,unsigned High_Low,unsigned int X_high)
				{
					unsigned int TEMPREG;
				
					TEMPREG = * datdir;
					
						if(High_Low)		
							TEMPREG |=X_high;
						else
							TEMPREG &= (~X_high);
					
					 * datdir = TEMPREG;
				
				}
				
				
				
				
				void IO_test()
				{
				   unsigned int temp,i;
				
				   IO_Status_Init(NO1_MCR,NO1_DATDIR,NO1_ENA,IO_IN,NO1_OUT,IO_LOW,NO1_HIGH);
				         
					for (i=0;i					{
					
				    	temp = IN_Status_Load(NO1_DATDIR,NO1_HIGH);
				    	
				    	puts("dfghdfhdf");
				    	 
				    	 printf ("the status is. %d \n",temp);
					
				    	wait_second(3);
						
					}
					
				}
				
				
				
				
				
							

相关资源