/****************************************************************************/
/* Copyright 2007 MBARI.                                                    */
/* Monterey Bay Aquarium Research Institute Proprietary Information.        */
/* All rights reserved.       																						  */
/*																																					*/
/* Rev History:																															*/
/* Initial Creation 11/2007		B.Kieft																		    */
/*																																					*/
/*																																					*/
/****************************************************************************/
#ifndef PH_PROBE_H
#define PH_PROBE_H

#define HI  1
#define LO  0

#define ON  1
#define OFF 0

#define MAX_SPI_CHARS 10


//
// Interface Specification Command Definitions:
//
// Control Command definitions
int8 load_power[]="L";
int8 comm_relay[]="C";
int8 write_flash[]="F";

//Read Status Command definitions
int8 read_bus_voltage[]="?V";
int8 read_load_voltage[]= "?v";
int8 read_bus_current[]= "?I";
int8 read_load_current[]= "?i";
int8 read_gf_current[]= "?g";
int8 read_startup_oc_threshold[]= "?O";
int8 read_q_oc_threshold[]= "?o";
int8 read_startup_oc_time[]= "?T";
int8 read_comm_realy_status[]= "?C";
int8 read_device_serial_number[]= "?S";
int8 read_errors[]= "?E";

//Threshold Command definitions
int8 oc_threshold_startup[]="O";
int8 oc_threshold_q[]= "o";
int8 oc_time_startup[]="T";
int8 set_address[]="S";

//
// Interface Specification Parameters
//
int16 startup_oc_threshold = 0;
int16 steady_oc_threshold = 0;
int16 startup_oc_time = 0;
Boolean relay_status_closed = false; // False == open circuit
// *** DEBUG - Error parameters coming soon....

// Constant Definitions
static const float VREF = 4.08;
static const float RSENSE = .200;
static const float CURRDIVISOR = 5.0;
//

float adc_value_glob;                // Stores A/D conversion values for SPI bus transmission
char response_message[40];           // String for storing node response back to MVC

int8 serial_delay_msec = 3;          // delay for clocking 485 bits
int8 spi_data = 0;

Boolean master = true;               // For holding master/slave SPI bus status
Boolean cmd_received = false;        // RS485 command received?
Boolean wdt_reset = false;           // Boot due to WDT reset? 

//*** DEBUG - to be removed
int8 rtos_pin = HI; 
//*** DEBUG - to be removed

// Function Definitions
void do_adc_voltage_calcs(float);
void do_adc_current_calcs(float, float, float);


#endif
