ButterflyMP3

power.c File Reference

Butterfly MP3 Power Routines. More...

#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include "power.h"
#include "main.h"
#include "types.h"
#include "uart.h"
#include "vs1001.h"
#include "lcdgraphics.h"
#include "eeprom.h"
#include "ADC.h"
#include "button.h"
Include dependency graph for power.c:

Go to the source code of this file.

Functions

void Power_save (void)
 Power_save.
void Power_idle (void)
 Power_idle.
void Power_off (void)
 Power_off.
void Power_Init (void)
 Power_Init.
uint16 Power_check (void)
 Power_check.
uint16 Power_pcnt (uint16 voltage)
 Power_pcnt.

Detailed Description

Butterfly MP3 Power Routines.

Author:
Nick Lott
Date:
January 2006
Id:
power.c,v 1.11 2007/12/16 18:42:22 brokentoaster Exp

Copyright (C) 2004 Nick Lott <brokentoaster@users.sf.net> http://butterflymp3.sf.net/

This is the power control software for the ButterflyMP3 project. This file contains all software responsible for controlling the power save modes for the mp3 player.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

Target(s)...: ATmega169

Compiler....: AVR-GCC 3.3.1; avr-libc 1.2

Definition in file power.c.


Function Documentation

uint16 Power_check ( void  )

Power_check.

Check the battery voltage and return level

Returns:
uint8 containing voltage level

Definition at line 205 of file power.c.

References EOL, PRINT, and UART_Printfu16().

Referenced by init_HW(), mainTimer(), and update_LCD().

Here is the call graph for this function:

void Power_idle ( void  )

Power_idle.

Set Butterfly into idle mode when nothing happening Keeps the timers running etc.

Definition at line 76 of file power.c.

Referenced by main().

void Power_Init ( void  )

Power_Init.

Set up ADC for monitoring the battery voltage using the internal 1.1V reference.

Definition at line 179 of file power.c.

References VOLTAGE_SENSOR.

Referenced by init_HW().

void Power_off ( void  )

Power_off.

Shut down all non essential systems and go into low power mode.

Definition at line 91 of file power.c.

References CBI, EOL, getkey(), gPowerSaveTimer, LCD_Sleep(), LCD_Wake(), Power_save(), PRINT, RESET_PIN, RESET_PORT, save_player_options(), save_player_state(), SBI, SCI_MODE, UART_Init(), UART_Shutdown(), vs1001_read(), and vs1001_write().

Referenced by handle_interface(), and main().

Here is the call graph for this function:

uint16 Power_pcnt ( uint16  voltage)

Power_pcnt.

Returns the ammount of percentage remaingin battery time based on experimental values.

mins % ADC ADC ~Voltage
0 100 655 0x28f 4.2
400 66 608 0x260 3.9
1050 12 572 0x23c 3.6
1200 0 445 0x1BD 2.8
Parameters:
voltageuint16 reading from ADC
Returns:
0-100 percentage remaining battery

Definition at line 254 of file power.c.

References PWR_ABS_MIN_V, PWR_GOOD_V, PWR_LOW_V, and PWR_MAX_V.

Referenced by update_LCD().

void Power_save ( void  )

Power_save.

Set Butterfly into powersave mode when nothing happening Keep timer2 and pin change interupts on only.

Definition at line 58 of file power.c.

Referenced by Power_off().

 All Files Functions Variables Typedefs Enumerations Enumerator Defines