1 /* This file has been prepared for Doxygen automatic documentation generation.*/
\r
2 /*! \file *********************************************************************
\r
5 * Headerfile for battery.c
\r
7 * Contains definitions for the setup of 1-Wire(R) and behaviour of the
\r
8 * battery data and status refreshing functions.\n
\r
9 * Also contains definitions of default battery data, and declarations
\r
10 * for the RID and NTC lookup tables.
\r
12 * \par Application note:
\r
13 * AVR458: Charging Li-Ion Batteries with BC100
\r
15 * \par Documentation:
\r
16 * For comprehensive code documentation, supported compilers, compiler
\r
17 * settings and supported devices see readme.html
\r
20 * Atmel Corporation: http://www.atmel.com \n
\r
21 * Support email: avr@atmel.com \n
\r
22 * Original author: \n
\r
27 * $URL: http://svn.norway.atmel.com/AppsAVR8/avr458_Charging_Li-Ion_Batteries_with_BC100/tag/20070904_release_1.0/code/IAR/battery.h $
\r
28 * $Date: 2007-08-10 09:28:35 +0200 (fr, 10 aug 2007) $\n
\r
29 ******************************************************************************/
\r
36 //******************************************************************************
\r
37 // Defines for EEPROM reading
\r
38 //******************************************************************************
\r
39 #define OWIBUS OWI_PIN_0 //!< One-wire bus (pin).
\r
41 #define OW_NONE 0x00 //!< One-wire device family code.
\r
42 #define OW_DS2505 0x09 //!< One-wire device family code.
\r
44 #define DS2505_MEM_READ 0xF0 //!< One-wire device command.
\r
45 #define DS2505_STATUS_READ 0xAA //!< One-wire device command.
\r
46 #define DS2505_DATA_READ 0xC3 //!< One-wire device command.
\r
49 //******************************************************************************
\r
50 // RID-less charging (for BatteryStatusRefresh())
\r
51 //******************************************************************************
\r
52 //#define ALLOW_NO_RID //!< Use default battery data if no matching entry found.
\r
54 #define DEF_BAT_CAPACITY 0 //!< Default battery capacity, in mAh.
\r
55 #define DEF_BAT_CURRENT_MAX 0 //!< Default maximum charge current, in mA.
\r
56 #define DEF_BAT_TIME_MAX 0 //!< Default maximum charge time, in minutes.
\r
57 //! Default minimum current to stop charge, in mA.
\r
58 #define DEF_BAT_CURRENT_MIN 0
\r
62 //******************************************************************************
\r
63 // RID and NTC defines and struct declarations
\r
64 //******************************************************************************
\r
65 #define RID_TABLE_SIZE 4 //!< Number of entries in RID table.
\r
66 #define NTC_TABLE_SIZE 20 //!< Number of entries in NTC table.
\r
68 //! \brief Struct for an entry in the resistor ID lookup-table
\r
69 struct RID_Lookup_struct {
\r
70 unsigned int Low; //!< Lowest acceptable ADC value.
\r
71 unsigned int High; //!< Highest acceptable ADC value.
\r
72 unsigned int Resistance; //!< RID resistance, in Ohms.
\r
73 unsigned int Capacity; //!< Associated battery capacity, in mAh.
\r
74 unsigned int Icharge; //!< Associated initial charge current, in mA.
\r
75 unsigned int tCutOff; //!< Associated cut-off time, in minutes.
\r
76 unsigned int ICutOff; //!< Associated cut-off current, in mA.
\r
78 typedef struct RID_Lookup_struct RID_Lookup_t; //!< For convenience.
\r
80 /*! \brief Struct for an entry in the NTC lookup-table
\r
82 * \note Must be sorted in descending ADC order.
\r
84 struct NTC_Lookup_struct
\r
86 unsigned int ADC; //!< Measured NTC.
\r
87 unsigned char ADCsteps; //!< ADC steps per half degree at this temperature.
\r
89 typedef struct NTC_Lookup_struct NTC_Lookup_t; //!< For convenience.
\r
92 //******************************************************************************
\r
94 //******************************************************************************
\r
95 extern __eeprom Battery_t BattControl[];
\r
96 extern Batteries_t BattData;
\r
97 extern __eeprom unsigned char BattEEPROM[][32];
\r
98 extern unsigned char BattActive;
\r
101 //******************************************************************************
\r
102 // Function prototypes
\r
103 //******************************************************************************
\r
104 unsigned char BatteryCheck(void);
\r
105 unsigned char BatteryStatusRefresh(void);
\r
106 unsigned char BatteryDataRefresh(void);
\r
107 void EnableBattery(unsigned char);
\r
108 void DisableBatteries(void);
\r
109 unsigned char RIDLookUp(void);
\r
110 void NTCLookUp(void);
\r
113 #endif // BATTERY_H
\r