Atmel Software Framework

com_task.c File Reference
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include "compiler.h"
#include "board.h"
#include "gpio.h"
#include "intc.h"
#include "pm.h"
#include "cycle_counter.h"
#include "conf_audio_player.h"
#include "audio_interface.h"
#include "audio_mixer.h"
#include "com_task.h"
#include "controller.h"
#include "gui.h"
#include "com_task_struct.h"

Macros

#define ELAPSED_TIME_TIMER_VALUE_MS   1000
 
#define SLEEP_MODE_MS   5000
 

Functions

static void check_device_task (struct state_machine_context *state_m)
 
void com_task (void)
 Entry point of the audio management interface. More...
 
void com_task_init (void)
 Initializes the hardware/software resources required for the task. More...
 
static void command_task (struct state_machine_context *state_m)
 
static void config_task (struct state_machine_context *state_m)
 
static void idle_task (struct state_machine_context *state_m)
 
static enum file_type navigation_get_current_file_type (struct state_machine_context *state_m)
 
static void navigation_task (struct state_machine_context *state_m)
 
static void navigation_update_view (struct state_machine_context *state_m)
 
static void playback_task (struct state_machine_context *state_m)
 
static void track_changed_task (struct state_machine_context *state_m)
 
static void unicode2ascii (char *deststr, const char *srcstr, size_t srcstr_len)
 convert a unicode string to an ascii string. More...
 
static void update_player_status (struct state_machine_context *state_m, Ai_player_flag_t *new_player_status)
 
device_state_t usb_device_get_state (void)
 

Variables

static t_cpu_time sleep_timer
 

#define ELAPSED_TIME_TIMER_VALUE_MS   1000

Referenced by check_device_task(), and playback_task().

#define SLEEP_MODE_MS   5000

void com_task ( void  )

Entry point of the audio management interface.

References ai_async_cmd_out_status(), ai_async_cmd_task(), ai_command_abort(), ai_is_none(), state_machine_context::async_cmd, audio_mixer_dacs_set_volume, check_device_task(), state_machine_context::cmd_status, command_task(), config_task(), controller_init(), controller_shutdown(), cpu_is_timeout(), cpu_ms_2_cy(), cpu_set_timeout(), cpu_stop_timeout(), CPU_TIMER_STATE_STOPPED, state_machine_context::display_list, FCPU_HZ, FHSB_HZ, FPBA_HZ, FPBB_HZ, gui_update(), GUI_UPDATE_ELT_CONNECTED, GUI_UPDATE_ELT_DISCONNECTED, GUI_UPDATE_ELT_IN_PROGRESS, GUI_UPDATE_ELT_NONE, GUI_UPDATE_VIEW_NONE, idle_task(), state_machine_context::in_progress_timer, state_machine_context::info, is_ai_async_cmd_finished(), navigation_task(), playback_task(), state_machine_context::player_status, state_machine_context::state, STATE_CHECK_DEVICE_ENTRY_POINT, STATE_CHECK_DEVICE_UPDATE_STATUS, STATE_COMMAND_PLAY_ANY_SONG, STATE_CONFIG_ENTRY_POINT, STATE_CONFIG_READ_REPEAT_STATE, STATE_CONFIG_READ_SHUFFLE_STATE, STATE_CONFIG_UPDATE_STATES, STATE_CONFIG_WAIT_FOR_EVENT, STATE_DEVICE_CONNECTED, STATE_DEVICE_DISCONNECTED, STATE_IDLE_DRIVE_LOAD, STATE_IDLE_ENTRY_POINT, STATE_IDLE_WAIT_FOR_EVENT, STATE_INITIALIZATION, STATE_NAVIGATION_CD, STATE_NAVIGATION_ENTRY_POINT, STATE_NAVIGATION_GOTOPARENT, STATE_NAVIGATION_GOTOPARENT_ERROR_HANDLING, STATE_NAVIGATION_PLAY_SELECTED_FILE, STATE_NAVIGATION_UPDATE_ISDIR, STATE_NAVIGATION_UPDATE_LIST, STATE_NAVIGATION_UPDATE_LIST_GET_NAME, STATE_NAVIGATION_UPDATE_LIST_STORE_NAME, STATE_NAVIGATION_UPDATE_METADATA_AND_PLAY, STATE_NAVIGATION_UPDATE_STATUS, STATE_NAVIGATION_WAIT_FOR_EVENT, STATE_NAVIGATION_WAIT_FOR_SELECTION, STATE_PLAYBACK_ENTRY_POINT, STATE_PLAYBACK_HANDLE_FAST_MODES, STATE_PLAYBACK_UPDATE_STATUS, STATE_PLAYBACK_UPDATE_TIME, STATE_PLAYBACK_WAIT_FOR_EVENT, STATE_TRACK_CHANGED_ARTIST, STATE_TRACK_CHANGED_ENTRY_POINT, STATE_TRACK_CHANGED_FILE_NAME, STATE_TRACK_CHANGED_IMAGE, STATE_TRACK_CHANGED_RESUME, STATE_TRACK_CHANGED_TITLE, STATE_TRACK_CHANGED_TOTAL_TIME, STATE_TRACK_CHECK_RESUME, t_cpu_time::timer_state, track_changed_task(), state_machine_context::view, and state_machine_context::view_elt.

Referenced by main(), output(), and play_wav().

void com_task_init ( void  )

Initializes the hardware/software resources required for the task.

References cpu_stop_timeout(), FCPU_HZ, FHSB_HZ, FPBA_HZ, FPBB_HZ, and gui_init().

Referenced by main().

static enum file_type navigation_get_current_file_type ( struct state_machine_context state_m)
static
static void navigation_task ( struct state_machine_context state_m)
static

References ai_async_audio_nav_playfile(), ai_async_cmd_out_PtrArrayU8(), ai_async_cmd_out_SizeArrayU8(), ai_async_cmd_out_u32(), ai_async_nav_dir_cd(), ai_async_nav_dir_gotoparent(), ai_async_nav_file_goto(), ai_async_nav_file_isdir(), ai_async_nav_file_name(), state_machine_context::async_cmd, state_machine_context::cmd_status, controller_clear(), controller_navigation_change_directory(), controller_navigation_cursor_next(), controller_navigation_cursor_previous(), controller_navigation_go_to_parent_directory(), controller_navigation_play(), controller_switch_to_config_view(), controller_switch_to_playback_view(), state_machine_context::cursor_pointer, file_elt::file_name, file_list::file_pos, FILE_TYPE_DIRECTORY, FILE_TYPE_FILE, player_info::flags, GUI_UPDATE_ELT_IN_PROGRESS, GUI_UPDATE_ELT_NAVIGATION_CURSOR, GUI_UPDATE_ELT_NAVIGATION_NO_FILES, GUI_UPDATE_VIEW_NAVIGATION, i, if(), file_list::list, state_machine_context::list, MAX_BUFFER_FILE, Min, navigation_get_current_file_type(), navigation_update_view(), file_list::nb_files, file_list::nb_valid_entries, Ai_player_flag_t::new_file_played, state_machine_context::player_status, state_machine_context::recorded_state, state_machine_context::state, STATE_CHECK_DEVICE_ENTRY_POINT, STATE_COMMAND_PLAY_ANY_SONG, STATE_CONFIG_ENTRY_POINT, STATE_NAVIGATION_CD, STATE_NAVIGATION_ENTRY_POINT, STATE_NAVIGATION_GOTOPARENT, STATE_NAVIGATION_GOTOPARENT_ERROR_HANDLING, STATE_NAVIGATION_PLAY_SELECTED_FILE, STATE_NAVIGATION_UPDATE_ISDIR, STATE_NAVIGATION_UPDATE_LIST, STATE_NAVIGATION_UPDATE_LIST_GET_NAME, STATE_NAVIGATION_UPDATE_LIST_STORE_NAME, STATE_NAVIGATION_UPDATE_METADATA_AND_PLAY, STATE_NAVIGATION_WAIT_FOR_EVENT, STATE_NAVIGATION_WAIT_FOR_SELECTION, STATE_PLAYBACK_ENTRY_POINT, STATE_TRACK_CHANGED_ENTRY_POINT, STR_MAX_LENGTH, file_elt::type, unicode2ascii(), file_elt::updated, state_machine_context::view, and state_machine_context::view_elt.

Referenced by com_task().

static void playback_task ( struct state_machine_context state_m)
static

References ai_async_audio_ctrl_pause(), ai_async_audio_ctrl_resume(), ai_async_audio_ctrl_start_ffw(), ai_async_audio_ctrl_start_frw(), ai_async_audio_ctrl_stop_ffw_frw(), ai_async_audio_ctrl_time(), ai_async_audio_nav_next(), ai_async_audio_nav_playfile(), ai_async_audio_nav_previous(), ai_async_cmd_out_u32(), state_machine_context::async_cmd, audio_mixer_dacs_decrease_volume, audio_mixer_dacs_get_volume, audio_mixer_dacs_increase_volume, state_machine_context::cmd_status, controller_clear(), controller_playback_decrease_volume(), controller_playback_ffw(), controller_playback_frw(), controller_playback_increase_volume(), controller_playback_next_track(), controller_playback_previous_track(), controller_playback_toggle_play_pause(), controller_switch_to_config_view(), controller_switch_to_navigation_view(), cpu_is_timeout(), cpu_ms_2_cy(), cpu_set_timeout(), file_info::elapsed_time, state_machine_context::elapsed_time_timer, ELAPSED_TIME_TIMER_VALUE_MS, FCPU_HZ, player_info::flags, GUI_UPDATE_ELT_NONE, GUI_UPDATE_ELT_PLAYBACK_ARTIST, GUI_UPDATE_ELT_PLAYBACK_COVER_ART, GUI_UPDATE_ELT_PLAYBACK_ELAPSED_TIME, GUI_UPDATE_ELT_PLAYBACK_FFW, GUI_UPDATE_ELT_PLAYBACK_FILE_NAME, GUI_UPDATE_ELT_PLAYBACK_FRW, GUI_UPDATE_ELT_PLAYBACK_PAUSE, GUI_UPDATE_ELT_PLAYBACK_PLAY, GUI_UPDATE_ELT_PLAYBACK_STOP, GUI_UPDATE_ELT_PLAYBACK_TITLE, GUI_UPDATE_ELT_PLAYBACK_TOTAL_TIME, GUI_UPDATE_ELT_PLAYBACK_VOLUME, GUI_UPDATE_VIEW_PLAYBACK, state_machine_context::info, Ai_player_flag_t::new_file_played, PLAYER_FLAG_FFW, PLAYER_FLAG_FRW, PLAYER_FLAG_PAUSE, PLAYER_FLAG_PLAY, PLAYER_FLAG_STOP, state_machine_context::player_status, state_machine_context::recorded_state, state_machine_context::state, STATE_CHECK_DEVICE_ENTRY_POINT, STATE_CONFIG_ENTRY_POINT, STATE_NAVIGATION_ENTRY_POINT, STATE_PLAYBACK_ENTRY_POINT, STATE_PLAYBACK_HANDLE_FAST_MODES, STATE_PLAYBACK_UPDATE_STATUS, STATE_PLAYBACK_UPDATE_TIME, STATE_PLAYBACK_WAIT_FOR_EVENT, STATE_TRACK_CHANGED_ENTRY_POINT, Ai_player_flag_t::status, Ai_player_flag_t::status_fast, state_machine_context::view, state_machine_context::view_elt, and file_info::volume.

Referenced by com_task().

static void unicode2ascii ( char *  deststr,
const char *  srcstr,
size_t  srcstr_len 
)
static

convert a unicode string to an ascii string.

The conversion is done by copying the lower byte of the unicode character to the destination ascii string.

Parameters
srcstrPointer to source unicode string.
deststrPointer to destination ascii string location.
srcstr_lenLength of the source unicode string in characters.

References i, and j.

Referenced by navigation_task(), and track_changed_task().

t_cpu_time sleep_timer
static