
#pragma SRC
#define AD_REF             3.0          // A/D converter reference voltage
#define AD_CNT_RANGE    1024.0          // count range of the A/D converter
#define VIN_R1          47.5E3          // value of upper resistor in the VIN divider 
#define VIN_R2          10.0E3          // value of lower resistor in the VIN divider
#define VIN_OFF            0.3          // VIN drop through diode to the VIN divider
#define VIN_MIN            6.5          // minimum VIN volts for device operation
#define VIN_MAX           13.5          // maximum VIN volts for device operation
#define VIN_HYS            0.2          // hystersis of VIN voltage for recovery
#define VIN_MIN_CNT ((unsigned int)(((((VIN_MIN - VIN_OFF) * VIN_R2)/(VIN_R1 + VIN_R2))*AD_CNT_RANGE)/AD_REF))
#define VIN_MAX_CNT ((unsigned int)(((((VIN_MAX - VIN_OFF) * VIN_R2)/(VIN_R1 + VIN_R2))*AD_CNT_RANGE)/AD_REF))
#define VIN_HYS_CNT ((unsigned int)((((VIN_HYS * VIN_R2)/(VIN_R1 + VIN_R2))*AD_CNT_RANGE)/AD_REF))

unsigned int code cnt_array[3] = {
                                   VIN_MIN_CNT,
                                   VIN_MAX_CNT,
                                   VIN_HYS_CNT
                                 };
