1 /* This file has been prepared for Doxygen automatic documentation generation.*/
\r
2 /*! \file *********************************************************************
\r
5 * Structs in common for Slave and Master
\r
7 * Contains struct declarations for ADC.c and battery.c.\n
\r
8 * These are also used in the Master, and have therefore been
\r
9 * put in a separate file for convenience.
\r
11 * \par Application note:
\r
12 * AVR458: Charging Li-Ion Batteries with BC100
\r
14 * \par Documentation:
\r
15 * For comprehensive code documentation, supported compilers, compiler
\r
16 * settings and supported devices see readme.html
\r
19 * Atmel Corporation: http://www.atmel.com \n
\r
20 * Support email: avr@atmel.com \n
\r
25 * $URL: http://svn.norway.atmel.com/AppsAVR8/avr458_Charging_Li-Ion_Batteries_with_BC100/tag/20070904_release_1.0/code/IAR/structs.h $
\r
26 * $Date: 2007-08-10 09:28:35 +0200 (fr, 10 aug 2007) $\n
\r
27 ******************************************************************************/
\r
34 //******************************************************************************
\r
35 // Battery struct declarations
\r
36 //******************************************************************************
\r
37 /*! \brief Holds status and various data for a battery
\r
39 * These data are updated by BatteryStatusRefresh(), RIDLookUp(),
\r
40 * NTCLookUp() and BatteryDataRefresh().
\r
42 struct Batteries_struct
\r
44 unsigned char Present : 1; //!< Battery found. (TRUE/FALSE)
\r
45 unsigned char Charged : 1; //!< Battery fully charged. (TRUE/FALSE)
\r
46 unsigned char Low : 1; //!< Battery low voltage. (TRUE/FALSE)
\r
47 unsigned char Exhausted : 1; //!< Battery exhausted. (TRUE/FALSE)
\r
48 unsigned char HasRID : 1; //!< Battery has resistor ID. (TRUE/FALSE)
\r
49 unsigned char Circuit; //!< Battery safety circuit (family id).
\r
50 signed char Temperature; //!< Battery temperature, in centigrade.
\r
51 unsigned char ADCSteps; //!< ADC steps per half degree.
\r
52 unsigned int Capacity; //!< Capacity, in mAh.
\r
53 unsigned int MaxCurrent; //!< Charge current, in mA.
\r
54 unsigned int MaxTime; //!< Charge cut-off time, in minutes.
\r
55 unsigned int MinCurrent; //!< Cut-off current, in mA.
\r
57 typedef struct Batteries_struct Batteries_t; //!< For convenience.
\r
60 // KMR: These definitions are in structs.h because they are a conversion
\r
61 // of Atmel's original IAR code which used a bitfield structs for the
\r
62 // type Battery_t. However, porting to GCC/avr-libc makes the use of a
\r
63 // bitfield struct for acceessing an EEPROM value cumbersome.
\r
64 // So, bitmasks on a uint8_t are now used insteads of a bitfield struct.
\r
65 // These bitmasks could be moved to battery.h, but are left here for easier
\r
66 // comparison to changes in Atmel's IAR code.
\r
67 #define BIT_BATTERY_ENABLED 0x01 //! Battery valid, enabling allowed.
\r
68 #define BIT_BATTERY_DISCONNECT_ALLOWED 0x02 //! Disconnect allowed.
\r
69 #define BIT_BATTERY_CHARGE_INHIBIT 0x04 //! Inhibit charging. \todo Changed by master?
\r
70 typedef uint8_t Battery_t; //!< For convenience.
\r
73 //******************************************************************************
\r
74 // ADC status struct declaration
\r
75 //******************************************************************************
\r
76 /*! \brief Holds ADC-status and samples
\r
78 * Is updated by ADC_ISR().
\r
80 struct ADC_Status_struct
\r
82 unsigned char MUX : 5; //!< Corresponds to ADMUX low bits MUX4..0.
\r
83 unsigned char Flag : 1; //!< ADC cycle complete (TRUE/FALSE).
\r
84 unsigned char Mains : 1; //!< Mains OK? (TRUE/FALSE).
\r
85 unsigned char Halt : 1; //!< Stop A/D-conversions (TRUE/FALSE).
\r
86 unsigned char ADC3_G20_OS : 4; //!< Offset on ADC3 at 20x gain.
\r
87 unsigned char ADC5_G20_OS : 4; //!< Offset on ADC5 at 20x gain.
\r
88 unsigned int rawRID; //!< Raw, unconditioned resistor ID data.
\r
89 unsigned int rawNTC; //!< Raw, unconditioned thermistor data.
\r
90 unsigned int rawVBAT; //!< Raw, unconditioned battery voltage.
\r
91 unsigned int VIN; //!< Supply voltage, in mV.
\r
92 unsigned int VBAT; //!< Battery voltage, in mV.
\r
93 signed int IBAT; //!< Battery current, in mA.
\r
94 signed int discIBAT[4]; //!< Discrete battery current readings, in mA.
\r
95 signed int avgIBAT; //!< Average of the last four IBAT readings, in mA.
\r
97 typedef struct ADC_Status_struct ADC_Status_t; //!< For convenience.
\r
100 #endif // STRUCTS_H
\r