libpropeller
Making PropellerGCC Easier
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
Public Types | Public Member Functions | List of all members
Max8819 Class Reference

Max8819.h - Max8819 class to allow access to single pins. More...

#include <max8819.h>

Public Types

enum  { HIGH, MEDIUM, LOW, OFF }
 

Public Member Functions

void Start (int CENpin, int CHGpin, int ENpin, int DLIM1pin, int DLIM2pin)
 Create the MAX8819 object, turn the power on, and turn off charging. More...
 
 ~Max8819 ()
 
void On ()
 Turn the power system on. More...
 
void Off ()
 Turn the power system off. More...
 
bool GetCharge ()
 Checks to see if the battery is being charged. More...
 
void SetCharge (int rate)
 Sets the charge rate. More...
 
bool GetPluggedIn (void)
 

Detailed Description

Max8819.h - Max8819 class to allow access to single pins.

The low level interface code is based on Pins.h from David Michael Betz.

Requires a 10k resistor from MAX8819A::CEN to 5V USB.

Todo:
Add support (is it neccessary?) For the "timer fault" condition (figure 3, page 18 of datasheet) when CHG outputs a 2Hz square wave.
Author
SRLM (srlm@.nosp@m.srlm.nosp@m.produ.nosp@m.ctio.nosp@m.ns.co.nosp@m.m)
Date
1-1-2013

Member Enumeration Documentation

anonymous enum
Enumerator
HIGH 
MEDIUM 
LOW 
OFF 

Constructor & Destructor Documentation

Max8819::~Max8819 ( )
inline

Member Function Documentation

bool Max8819::GetCharge ( )
inline

Checks to see if the battery is being charged.

Todo:
If SetCharge is set to off, and it's plugged in, what does GetCharge return?
Returns
the charging status of the battery. True indicates charging, false indicates no charging.
bool Max8819::GetPluggedIn ( void  )
inline
void Max8819::Off ( void  )
inline

Turn the power system off.

Warning
includes Propeller power, so this had better be the last thing in the program.
void Max8819::On ( )
inline

Turn the power system on.

The I/O holds the power on until Off() is called.

void Max8819::SetCharge ( int  rate)
inline

Sets the charge rate.

Valid constants are: -OFF -LOW -MEDIUM -HIGH Note: The rate is set even if there is currently no external power, and stays in effect until next called (possibly during the connection of external power).

Warning
If set to OFF it cuts off all power from the USB port. This means that if there is no battery the system will turn off!
If it's set to something other than OFF then the maximum current from the USB port is limited. If there is no battery then you must make sure that the total current consumed is less than the maximum, otherwise the MAX8819 might reset.

With a 3kOhm CISET resistor, we have the following charge rates: -LOW == 95 mA -MEDIUM == 475 mA -HIGH == 1000 mA

From the datasheet: It is not necessary to limit the charge current based on the capabilities of the expected AC-toDC adapter or USB/DC input current limit, the system load, or thermal limitations of the PCB. The IC automatically lowers the charging current as necessary to accommodate for these factors.

Parameters
ratea constant specifying the rate of charge.
void Max8819::Start ( int  CENpin,
int  CHGpin,
int  ENpin,
int  DLIM1pin,
int  DLIM2pin 
)
inline

Create the MAX8819 object, turn the power on, and turn off charging.

Warning
pmic->SetCharge(Max8819::HIGH); (SRLM): There is some sort of bug where this must be in the code, otherwise it causes a reset.

The pins from the Propeller to the MAX8819 can be connected directly: no need for current limiting resistors.

Parameters
CENpinThe pin connected to Charge Enable on the MAX8819
CHGpinThe pin connected to (is) Charge(ing?) pin on the MAX8819
ENpinThe pin connected to Enable123 pin on the MAX8819
DLIM1pinThe pin connected to DLIM1 pin on the MAX8819
DLIM2pinThe pin connected to DLIM2 pin on the MAX8819

Here is the call graph for this function:


The documentation for this class was generated from the following file: