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
35 #include <avr/eeprom.h>
\r
38 //******************************************************************************
\r
39 // Defines for EEPROM reading
\r
40 //******************************************************************************
\r
41 #define OWIBUS OWI_PIN_0 //!< One-wire bus (pin).
\r
43 #define OW_NONE 0x00 //!< One-wire device family code.
\r
44 #define OW_DS2505 0x09 //!< One-wire device family code.
\r
46 #define DS2505_MEM_READ 0xF0 //!< One-wire device command.
\r
47 #define DS2505_STATUS_READ 0xAA //!< One-wire device command.
\r
48 #define DS2505_DATA_READ 0xC3 //!< One-wire device command.
\r
51 //******************************************************************************
\r
52 // RID-less charging (for BatteryStatusRefresh())
\r
53 //******************************************************************************
\r
57 #warning "using EasyPack 66590 711 099 (550mAh) settings - mthomas, no warranty!"
\r
58 // RID not connected
\r
59 #define ALLOW_NO_RID //!< Use default battery data if no matching entry found.
\r
60 #define DEF_BAT_CAPACITY 550 //!< Default battery capacity, in mAh.
\r
61 #define DEF_BAT_CURRENT_MAX 260 //!< Default maximum charge current, in mA.
\r
62 #define DEF_BAT_TIME_MAX (5*60) //!< Default maximum charge time, in minutes.
\r
63 //! Default minimum current to stop charge, in mA.
\r
64 #define DEF_BAT_CURRENT_MIN 10
\r
68 //#define ALLOW_NO_RID //!< Use default battery data if no matching entry found.
\r
70 #define DEF_BAT_CAPACITY 0 //!< Default battery capacity, in mAh.
\r
71 #define DEF_BAT_CURRENT_MAX 0 //!< Default maximum charge current, in mA.
\r
72 #define DEF_BAT_TIME_MAX 0 //!< Default maximum charge time, in minutes.
\r
73 //! Default minimum current to stop charge, in mA.
\r
74 #define DEF_BAT_CURRENT_MIN 0
\r
76 #endif /* EASYPACK550 */
\r
79 //******************************************************************************
\r
80 // RID and NTC defines and struct declarations
\r
81 //******************************************************************************
\r
82 #define RID_TABLE_SIZE 4 //!< Number of entries in RID table.
\r
83 #define NTC_TABLE_SIZE 20 //!< Number of entries in NTC table.
\r
85 //! \brief Struct for an entry in the resistor ID lookup-table
\r
86 struct RID_Lookup_struct {
\r
87 unsigned int Low; //!< Lowest acceptable ADC value.
\r
88 unsigned int High; //!< Highest acceptable ADC value.
\r
89 unsigned int Resistance; //!< RID resistance, in Ohms.
\r
90 unsigned int Capacity; //!< Associated battery capacity, in mAh.
\r
91 unsigned int Icharge; //!< Associated initial charge current, in mA.
\r
92 unsigned int tCutOff; //!< Associated cut-off time, in minutes.
\r
93 unsigned int ICutOff; //!< Associated cut-off current, in mA.
\r
95 typedef struct RID_Lookup_struct RID_Lookup_t; //!< For convenience.
\r
97 /*! \brief Struct for an entry in the NTC lookup-table
\r
99 * \note Must be sorted in descending ADC order.
\r
101 struct NTC_Lookup_struct
\r
103 unsigned int ADCV; //!< Measured NTC.
\r
104 unsigned char ADCsteps; //!< ADC steps per half degree at this temperature.
\r
106 typedef struct NTC_Lookup_struct NTC_Lookup_t; //!< For convenience.
\r
109 //******************************************************************************
\r
110 // Global variables
\r
111 //******************************************************************************
\r
112 extern Battery_t EEMEM BattControl[];
\r
113 extern Batteries_t BattData;
\r
114 extern unsigned char EEMEM BattEEPROM[][32];
\r
115 extern unsigned char BattActive;
\r
118 //******************************************************************************
\r
119 // Function prototypes
\r
120 //******************************************************************************
\r
121 unsigned char BatteryCheck(void);
\r
122 unsigned char BatteryStatusRefresh(void);
\r
123 unsigned char BatteryDataRefresh(void);
\r
124 void EnableBattery(unsigned char);
\r
125 void DisableBatteries(void);
\r
126 unsigned char RIDLookUp(void);
\r
127 void NTCLookUp(void);
\r
130 #endif // BATTERY_H
\r