![ADLINK Technology CM1-86DX2 Скачать руководство пользователя страница 67](http://html.mh-extra.com/html/adlink-technology/cm1-86dx2/cm1-86dx2_technical-manual_2852737067.webp)
Using the Module
61
CM1-86DX2
Analog Input Example
/*
########################################################################
########
#
FILE:
sai.c
#
AUTHOR:
FS for LiPPERT Adlink Technology GmbH
#
DESCRIPTIONActivates the ADC and reads the selected channel once
#
PARAMETERS:channel # (0 ... 7)
#
COMPILENAMEsai
########################################################################
########
*/
#include <sys/io.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include "../../common/pci_conf_space/pcics.c"
#define TRUE 1
// Southbridge: path defines for both functions of device 7
#define SB_PCICS0 "/proc/bus/pci/00/07.0"
#define SB_PCICS1 "/proc/bus/pci/00/07.1"
// ADC specific defines of addresses and offsets
#define ADC_BASE_ADDR 0xFE00
//user defined base address for the ADC
#define ADC_AUX_CHS ADC_BA0
// AUX channel register
#define ADC_CTRL_REG ADC_BA1
// ADC control register
#define ADC_STATUS ADC_BA2
// ADC status register
#define ADC_DATA ADC_BA4
// 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 <channel>\n"
);
printf(
" <channel>: 0 ... 7\n"
);
printf(
"e. g.: ./sai 3\n");
return;
Содержание CM1-86DX2
Страница 6: ...vi ...
Страница 20: ...14 Getting Started ...
Страница 26: ...20 Module Description LVDS Color Mapping ...
Страница 52: ...46 Using the Module ...
Страница 53: ...Using the Module 47 CM1 86DX2 PCIPnP ...
Страница 54: ...48 Using the Module ...
Страница 56: ...50 Using the Module Chipset screen ...
Страница 57: ...Using the Module 51 CM1 86DX2 ...
Страница 58: ...52 Using the Module ...
Страница 59: ...Using the Module 53 CM1 86DX2 Security screen ...