//////////// Driver for LTC1298 A/D Converter /////////////////////////////// //// //// //// adc_init() Call after power up //// //// //// //// value = read_analog( channel ) Read a analog channel //// //// channel is 0 or 1 //// //// //// //// convert_to_volts( value, string ) Fills in string with //// //// the true voltage in //// //// the form 0.000 //// //// //// ///////////////////////////////////////////////////////////////////////////// //// (C) Copyright 1996,1997 Custom Computer Services //// //// This source code may only be used by licensed users of the CCS C //// //// compiler. This source code may only be distributed to other //// //// licensed users of the CCS C compiler. No other use, reproduction //// //// or distribution is permitted without written permission. //// //// Derivative programs created using this software in object code //// //// form are not restricted in any way. //// //////////////////////////////////////////////////////////////////////////// #ifndef ADC_CS #define ADC_CLK PIN_B0 #define ADC_DOUT PIN_B1 #define ADC_DIN PIN_B2 #define ADC_CS PIN_B3 #endif void adc_init() { output_high(ADC_CS); } void write_adc_byte(byte data_byte, byte number_of_bits) { byte i; delay_us(2); for(i=0; i>1; output_high(ADC_CLK); delay_us(50); output_low(ADC_CLK); delay_us(50); } } byte read_adc_byte(byte number_of_bits) { byte i,data; data=0; for(i=0;i