/***************************************************************************** * Copyright (C) 2008 * ProbeStar Telematics, LLC * All Rights Reserved. Proprietary and Confidential. *============================================================================ * MAX 255 A/D Multiplexor *---------------------------------------------------------------------------- * Details *****************************************************************************/ /***************************************************************************** * includes *****************************************************************************/ #include "system.h" #include "analog.h" #include "delay.h" /***************************************************************************** * defines *****************************************************************************/ /***************************************************************************** * macros *****************************************************************************/ /***************************************************************************** * structs & typedefs *****************************************************************************/ /***************************************************************************** * global constants *****************************************************************************/ /***************************************************************************** * global variables *****************************************************************************/ /***************************************************************************** * static constants *****************************************************************************/ /***************************************************************************** * static variables *****************************************************************************/ /***************************************************************************** * static prototypes *****************************************************************************/ /***************************************************************************** * C functions *****************************************************************************/ #ifdef ADMUX_MAX355 // supports two MAX355 Muxes void AdMax355Mux( BYTE c ) { // call with channel number 0..7 // turn mux off ADMUX_ENABLE0 = 0; #ifdef ADMUX_ENABLE1 ADMUX_ENABLE1 = 0; #endif // wait to transition off DelayNs0400(); // mux off if ( c == 0xff ) return; // select channel ADMUX_A0 = ( c & 1 ) ? 1 : 0; ADMUX_A1 = ( c & 2 ) ? 1 : 0; // wait to switch DelayNs0400(); #ifdef ADMUX_ENABLE1 if ( c & 4 ) ADMUX_ENABLE1 = 1; // 4..7 else ADMUX_ENABLE0 = 1; // 0..3 #else ADMUX_ENABLE0 = 1; #endif // wait to settle DelayNs2000(); } #endif