www.pudn.com > LTC2440.rar > LTC2440.C, change:2013-03-30,size:1667b


   	#include "stm32f10x.h" 
	#include<stdio.h> 
	#include"LCD12864.H" 
	#include"LTC2440.H" 
 
 
//	PA3-LED 
#define GPIOA_ODR (*((volatile unsigned int *)(0x40010800+0x0c))) // 
 
 
//system clock set 
void SystemClockInit(void) 
{ 
 RCC->CR = 0x01010000;	  //开外部时钟,开PLL 
 RCC->CFGR = 0x061c3000;	 //	 选用外部高速时钟,	PLLx9 	, APB2 8分频 
 //RCC->APB2ENR = 0x00000004; //enable GPIOA Clock 
 RCC->APB2ENR = 0x00005E7D;		   //GPIO ABCDE 
 
} 
 
//--------------------GPIO Init---------------------// 
void GPIOInit() 
{ 
 //IO时钟配置 
 GPIOA->CRL = 0x00001000; 
 GPIOA->CRH = 0x00000000;//输出,10MHZ 
 
 GPIOB->CRL = 0X00000000; 
 GPIOB->CRH = 0X33333333; 
  
} 
//LED set 
//unsigned int* x=(unsigned int* )(0x40010800+0x0c); 
 
 
void SetLed() 
{ 
 //GPIOA->ODR = 0x0000;  
 //*x= 0x0000;  
    GPIOA_ODR|=0x0008;  
} 
// 
void ResetLed() 
{ 
// GPIOA->ODR = 0x0008; 
 //*x= 0x0008; 
   
    GPIOA_ODR&=~0x0008;;  
} 
 
 
	void int1(void) 
	{ 
	   
	} 
	   
     
int main(void) 
{	  char XX=2; 
	  uint32 ad; 
	   char f; 
		 float a,b; 
		 long aa,bb; 
	 SystemClockInit(); 
	 GPIOInit();    
	 lcd_init(); 
	 WriteStr(0x80,"hello stm32!"); 
	 AFIO->MAPR|=AFIO_MAPR_SWJ_CFG_DISABLE; 
 
	LTC2440Init() ; 
 
	while(1) 
	{ 
		if(TEST_EOC()) 
		{	 
			ad=READLTC2440(0X17); 
			 
			SetLed() ; 
		//	a= (15*a)>>4+(ad>>5)>>4; 
		aa=	(ad&0X1FFFFFFF)<<3;  
		bb=aa/256; 
		a= ((XX-1)*a)/XX+(bb)/XX; 
		} 
		else 
		 	ResetLed()	 ; 
		  
		if(ad&0x20000000) 
			WriteStr(0x90,"1"); 
		else 
			WriteStr(0x90,"0"); 
 
		HEX32(0x98,ad);// ;HEX8(0x99,(ad>>16)&0xff) ;	 HEX8(0x9a,(ad>>8)&0xff) ;	 HEX8(0x9b,(ad)&0xff) ; 
 
		LCD_S32(0X88,a); 
 
 
 
	} 
}