ADLINK CM1-86DX2 User Manual
Page 67

Using the Module
61
CM1-86DX2
#define ADC_AUX_CHS ADC_BASE_ADDR+0
// AUX channel register
#define ADC_CTRL_REG ADC_BASE_ADDR+1
// ADC control register
#define ADC_STATUS ADC_BASE_ADDR+2
// ADC status register
#define ADC_DATA ADC_BASE_ADDR+4
// ADC data register
#define ADC_READY_MASK 0x01
#define ADC_CH_MASK 0xFF
// bits[15:13] represent the ADC channel
#define ADC_VAL_MASK 0x07FF
// bits[10:0] represent the result value
// SB function 0 addresses and offsets
// base address of 32 bit wide On-Chip Device Control Register in South Bridge Function 0
#define ON_CHIP_CTRL_REG 0xBC
#define ADC_DISABLE_TEMPERATURE_SENSOR 0x6FFFFFFF
#define I2C1_DISABLE 0x00020000
// SB function 1 addresses and offsets
// start of 32 bit wide index register for the ADC_BASE_ADDR and Input Channel
// select in South Bridge Function 1
#define SB1_ADC_CONTROL_REG 0xE0
//base address of 16 bit wide 8051A Control Register in the South Bridge Function 1
#define ANALOG_SHARE_REG 0xDE
#define ANALOG_SHARE_DISABLE 0x02
#define ADC_START_ONE_SHOT 0x01
// do an bitwise OR to set
#define ADC_START_AUTOSCAN 0x03
// do an bitwise OR to set
#define ADC_DEVICE_CTRL_MASK 0xEF
// Calibration Settings
#define OFFSET 0.0
// in mV
void
usage
()
{
printf(
"USAGE: ./sai
);
printf(
"
);
printf(
"e. g.: ./sai 3\n");
return;
}
/
*##################################################################
######
# 1. iopl(3) --> gain low level access and check input arguments of the
# command line
########################################################################
*/
int main(
int argc, char ** argv
)
{
double
capturedAdcValue = 0
;
unsigned int
capturedAdcData = 0, capturedAdcRaw = 0,
onChipDeviceControl_value = 0, adc_control_register_value = 0;
unsigned char
capturedAdcChannel = 0, adcChannel = 0;
unsigned char
adc_channel = 0, retVal = 0;
if(argc != 2)
{
usage();
return 2;
}
if (
iopl
(
3
)
!= 0
)
{
printf
("IOPL error\n
");
return
1;