You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
726 B
27 lines
726 B
#ifndef __A2D__INCLUDED__
|
|
#define __A2D__INCLUDED__
|
|
|
|
#include "StdAfx.h"
|
|
|
|
void ADC0_Init();
|
|
|
|
void ADC0_Start( BYTE bChannel );
|
|
BOOL ADC0_GetValue( PWORD pValue );
|
|
|
|
WORD ADC0_Convert( BYTE bChannel );
|
|
|
|
//LONG ADC0_Adc2Temperature( WORD wValue );
|
|
//WORD ADC0_Temperature2Adc( LONG lTemperature );
|
|
|
|
#define V_REF 30L // 3.0V * 10
|
|
#define PGAIN 1L // ACC amplifier gain
|
|
#define MAX_ADC 4096L
|
|
|
|
#define ADC0_Adc2Temperature( wValue ) \
|
|
( ( ((LONG)(INT)wValue) * V_REF * 1000L - 7760L * MAX_ADC * PGAIN ) / ( 286L * MAX_ADC * PGAIN / 10L ) )
|
|
|
|
#define ADC0_Temperature2Adc( lTemperature ) \
|
|
( (lTemperature * ( 286L * MAX_ADC * PGAIN / 10L ) + 7760L * MAX_ADC * PGAIN) / (V_REF * 1000L) )
|
|
|
|
|
|
#endif
|