ButterflyMP3

main.c File Reference

Butterfly MP3 main. More...

#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include "main.h"
#include "types.h"
#include "uart.h"
#include "delay.h"
#include "vs1001.h"
#include "mmc.h"
#include "avrfat16.h"
#include "timer0.h"
#include "button.h"
#include "eeprom.h"
#include "lcdgraphics.h"
#include "power.h"
#include "utils.h"
#include "BCD.h"
Include dependency graph for main.c:

Go to the source code of this file.

Functions

const uint8 __attribute__ ((progmem))
 setup volume levels 0 1 2 3 4 5 6 7 8 9
void flush_decoder (char reset_type)
 flush_decoder
void cue_file (void)
 cue_file
void streaming (void)
 Data Streaming.
void handle_interface (void)
 handle_interface
void update_LCD (void)
 update_LCD
void mainTimer (void)
uint8 init_mmc_fat (void)
 init_mmc_fat
uint8 handle_mmc (uint8 MMC_present)
 handle_mmc
void init_HW (void)
 init_HW
uint8 open_Dir (uint32 dir_lba)
uint8 restore_player (void)
 restore_player
void play_track_number (uint8 num)
 play_track_number
void volume_up (void)
void volume_down (void)
int main (void)
 main

Variables

const char VERSIONINFO1[] PROGMEM = "ButterflyMP3_sf_net V0.7"
 tag rom with verion info
uint8 gmusic_vol = 5
 music volume.
volatile uint8 gbass_boost = 0
 bass boost off.
volatile uint8 gFastForward = 0
 Fast forward mode.
uint8 gMode = 0
 mode of player, idle, playing, off, etc
char gLCD_Refresh
 Update LCD.
uint32 gFAT_entry = 0
 global current entry number in FAT table. (aka file number)
uint32 gCluster
 current cluster in song
uint32 gFileSectorSize
 size of current file in complete sectors.
uint32 gFileSectorsPlayed
 number of full sectors played. (aka position)
char gFile_good
 File has been read from Fat and ready to go.
char cluster_pos = 0
 position in cluster
char buff_pos = 16
 position in buffer
volatile uint16 gPlayTimeSeconds
 # of seconds current file has been playing.
uint8 gDisplayTimeOut = 0
 # of seconds+1 before changing display;

Detailed Description

Butterfly MP3 main.

Author:
Nick Lott
Date:
November 2004
Id:
main.c,v 1.60 2009/01/19 23:36:08 brokentoaster Exp

Definition in file main.c.


Function Documentation

const uint8 __attribute__ ( (progmem)  )

setup volume levels 0 1 2 3 4 5 6 7 8 9

Definition at line 96 of file main.c.

Referenced by __attribute__().

void cue_file ( void  )
void flush_decoder ( char  reset_type)

flush_decoder

Resets the decoder and prepares it for a new stream of audio data. all setup params must be resent.

Definition at line 432 of file main.c.

References gbass_boost, gFastForward, gmusic_vol, SCI_CLOCKF, SCI_MODE, SM_SDINEW, vs1001_read(), vs1001_reset(), vs1001_write(), and vs_1001_setvolume().

Referenced by cue_file(), handle_interface(), and streaming().

Here is the call graph for this function:

uint8 handle_mmc ( uint8  MMC_present)

handle_mmc

Check for MMC insertion/removal

Parameters:
oldstatus of MMC
Returns:
new status of MMC

Definition at line 881 of file main.c.

References EOL, FALSE, FAT16_entryMAX, FAT16_entryMIN, gFAT_entry, gFile_good, gLCD_Refresh, gMode, gPowerSaveTimer, init_mmc_fat(), MMC_Check(), MMC_Detect(), MMC_Reset(), MODE_IDLE, MODE_STOP, PRINT, and TRUE.

Referenced by main(), and restore_player().

Here is the call graph for this function:

void init_HW ( void  )
uint8 init_mmc_fat ( void  )

init_mmc_fat

Returns:
error from MMC or fat initialization or 0 for everything okay

initialize the mmc and read fat/partition details from the disk. Needs to be run everytime MMC is changed.

Definition at line 401 of file main.c.

References EOL, FAT16_entryMAX, FAT16_entryMIN, FAT16_root_dir_first_sector, FAT_initFat16(), gFAT_entry, MMC_Reset(), open_Dir(), and UART_Printfu32().

Referenced by handle_mmc().

Here is the call graph for this function:

int main ( void  )

main

The guts.

Returns:
int (never returns)

Definition at line 1294 of file main.c.

References AUTOPOWEROFF_TIMEOUT, DREQ_PIN, DREQ_PORT, gLCD_Refresh, gMode, gPowerSaveTimer, handle_interface(), handle_mmc(), init_HW(), MODE_IDLE, MODE_PLAY, Power_idle(), Power_off(), restore_player(), streaming(), TRUE, and update_LCD().

Here is the call graph for this function:

void mainTimer ( void  )
uint8 open_Dir ( uint32  dir_lba)

Definition at line 314 of file main.c.

References cue_file(), FAT16_entryMIN, FAT_scanDir_lba(), gFAT_entry, LCD_FileName(), LCD_Scanning(), and TRUE.

Referenced by handle_interface(), init_mmc_fat(), and restore_player().

Here is the call graph for this function:

void play_track_number ( uint8  num)

play_track_number

will find and play the track whos filename starts with 'nn' where nn is a number from 00-99 with a leading zero

Definition at line 940 of file main.c.

References CHAR2BCD2(), cue_file(), FAT16_dir_first_sector, FAT_getNumberedSong(), gCurrentSongNum, gFAT_entry, gLCD_Refresh, gMode, MODE_PLAY, SAMPLEMODE_CONTROLOUT_PIN, SAMPLEMODE_CONTROLOUT_PORT, and TRUE.

Referenced by handle_interface().

Here is the call graph for this function:

uint8 restore_player ( void  )

restore_player

Returns:
MMC Card Status

Restore the player state from eeprom if possible

Definition at line 341 of file main.c.

References cue_file(), FALSE, FAT16_entryMIN, FAT_getNextSong(), gCluster, gFAT_entry, gFileSectorsPlayed, gLCD_Refresh, gMode, gPlayTimeSeconds, handle_mmc(), load_player_state(), MODE_IDLE, MODE_PAUSE, open_Dir(), and TRUE.

Referenced by main().

Here is the call graph for this function:

void update_LCD ( void  )

update_LCD

Update the display depending on mode.

Definition at line 1180 of file main.c.

References FALSE, gbass_boost, gDisplayTimeOut, gFAT_entry, gLCD_Refresh, gMode, gmusic_vol, gPlayTimeSeconds, LCD_Battery(), LCD_Blank(), LCD_FileName(), LCD_Pause(), LCD_Play(), LCD_Stop(), LCD_Tester(), LCD_Time(), LCD_Vol(), MODE_IDLE, MODE_PAUSE, MODE_PLAY, MODE_STOP, Power_check(), Power_pcnt(), and STAT_DISPLAY_TIME.

Referenced by main().

Here is the call graph for this function:

void volume_down ( void  )

Definition at line 982 of file main.c.

References gLCD_Refresh, gmusic_vol, TRUE, and vs_1001_setvolume().

Referenced by handle_interface().

Here is the call graph for this function:

void volume_up ( void  )

Definition at line 973 of file main.c.

References gLCD_Refresh, gmusic_vol, TRUE, and vs_1001_setvolume().

Referenced by handle_interface().

Here is the call graph for this function:


Variable Documentation

char buff_pos = 16

position in buffer

Definition at line 84 of file main.c.

Referenced by cue_file(), and streaming().

char cluster_pos = 0

position in cluster

Definition at line 83 of file main.c.

Referenced by cue_file(), and streaming().

volatile uint8 gbass_boost = 0

bass boost off.

Definition at line 71 of file main.c.

Referenced by flush_decoder(), and update_LCD().

current cluster in song

current sector (cluster) in song main.h

Definition at line 79 of file main.c.

Referenced by cue_file(), FAT_Scratch2Cluster(), handle_interface(), restore_player(), save_player_state(), and streaming().

# of seconds+1 before changing display;

Definition at line 93 of file main.c.

Referenced by mainTimer(), and update_LCD().

volatile uint8 gFastForward = 0

Fast forward mode.

Definition at line 72 of file main.c.

Referenced by flush_decoder(), and handle_interface().

global current entry number in FAT table. (aka file number)

Definition at line 78 of file main.c.

Referenced by cue_file(), handle_interface(), handle_mmc(), init_mmc_fat(), open_Dir(), play_track_number(), restore_player(), save_player_state(), streaming(), and update_LCD().

char gFile_good

File has been read from Fat and ready to go.

Definition at line 82 of file main.c.

Referenced by cue_file(), handle_interface(), handle_mmc(), and streaming().

size of current file in complete sectors.

Definition at line 80 of file main.c.

Referenced by cue_file().

number of full sectors played. (aka position)

Definition at line 81 of file main.c.

Referenced by cue_file(), restore_player(), save_player_state(), and streaming().

uint8 gMode = 0

mode of player, idle, playing, off, etc

Definition at line 75 of file main.c.

Referenced by handle_interface(), handle_mmc(), LEDMatrix_timer(), main(), mainTimer(), play_track_number(), restore_player(), save_player_state(), streaming(), and update_LCD().

# of seconds current file has been playing.

Definition at line 92 of file main.c.

Referenced by cue_file(), mainTimer(), restore_player(), save_player_state(), and update_LCD().

const char VERSIONINFO2 [] PROGMEM = "ButterflyMP3_sf_net V0.7"

tag rom with verion info

tag rom with compile date and time

Definition at line 60 of file main.c.

 All Files Functions Variables Typedefs Enumerations Enumerator Defines