Atmel Software Framework

audio_interface.c File Reference
#include <string.h>
#include "compiler.h"
#include "conf_audio_interface.h"
#include "audio_interface.h"

Macros

#define AI_CALL(fct_set, macro)   AI_CALL_##fct_set(macro);
 
#define AI_CALL_AI_HID_CLASS(macro)
 
#define AI_CALL_AI_SD_MMC(macro)
 
#define AI_CALL_AI_USB_MS(macro)
 
#define AI_CMD_RETRY_RELOAD   3
 
#define AI_GET_DEVICE_STATUS(fct_set)
 
#define AI_HID_CLASS   2
 
#define AI_NONE   0
 
#define AI_PRIORITY0(macro)
 
#define AI_PRIORITY1(macro)   AI_PRIORITY0(macro) AI_CALL(AI_USB_MS, macro)
 
#define AI_PRIORITY2(macro)   AI_PRIORITY1(macro) AI_CALL(AI_HID_CLASS, macro)
 
#define AI_PRIORITY3(macro)   AI_PRIORITY2(macro) AI_CALL(AI_SD_MMC, macro)
 
#define AI_PRIORITY_CALL(macro)   AI_PRIORITY3(macro)
 
#define AI_SD_MMC   3
 
#define AI_SYNC_FUNC_MALLOC(ret_type, func_name, pp_arg, err_ret)
 
#define AI_SYNC_FUNC_RET_STRUCT(ret_type, func_name, arg_type, arg_val, err_ret)
 -----— SYNCHRONOUS routines -----— More...
 
#define AI_SYNC_FUNC_RET_VALUE(ret_type, func_name, arg_type, arg_val, err_ret)
 
#define AI_SYNC_FUNC_RET_VOID(func_name, arg_type, arg_val)
 
#define AI_SYNC_TASK_CALL_BACK()
 
#define AI_TASK_SELECT_FCT_SET(cur_fct_set)
 
#define AI_USB_MS   1
 

Functions

void ai_async_cmd_out_free_ArrayU8 (void)
 Free the allocated buffer which holds the extra-result. More...
 
char * ai_async_cmd_out_PtrArrayU8 (void)
 Returns the pointer on extra result of the last asynchronous command executed. More...
 
uint16_t ai_async_cmd_out_SizeArrayU8 (void)
 Returns the size of the extra result (no size limit) of the last asynchronous executed command. More...
 
uint8_t ai_async_cmd_out_status (void)
 Returns the status of the last asynchronous command executed. More...
 
uint32_t ai_async_cmd_out_u32 (void)
 Return the result (max 32bits) of the last asynchronous command executed. More...
 
uint64_t ai_async_cmd_out_u64 (void)
 Return the result (max 64 bits) of the last asynchronous command executed. More...
 
bool ai_async_cmd_put (cmd_ai_id_t cmd_id, uint32_t u32_in, uint16_t u16_arg_size, char *u8_arg_in, bool need_extra_buffer)
 This routine may be used to send directly a command values from a communication port to audio interface. More...
 
void ai_async_cmd_task (void)
 -----— ASYNCHRONOUS routines -----— note: to use these routines, you must call specific routine to know the end of execution and take the result More...
 
bool ai_async_context_pop (ai_async_context_t *ctx)
 Pop a context from the stack. More...
 
bool ai_async_context_push (ai_async_context_t *ctx)
 Push a new context into the stack. More...
 
void ai_async_update_cmd_status (ai_async_status_t *cmd_ai_status)
 Update the current command status. More...
 
void * ai_audio_context_save (uint8_t *status, uint16_t *size)
 Give complete audio context (player state, play time, repeat, shuffle, file played, explorer mode ) More...
 
void * ai_audio_nav_file_info_image (ai_image_size_t *size)
 Returns a pointer and image information of the embedded image of the selected track. More...
 
void ai_command_abort (void)
 Aborts the current command. More...
 
ai_device_status_t ai_get_device_status (void)
 Here is the list of the SYNCHRONOUS functions. More...
 
void ai_init (void)
 Initialize the audio interface. More...
 
bool ai_is_hid_class (void)
 Returns true if the application is using hid class; false otherwise. More...
 
bool ai_is_none (void)
 Returns true if no devices are connected. More...
 
bool ai_is_sd_mmc (void)
 Returns true if the application is using sd/mmc card support; false otherwise. More...
 
bool ai_is_usb_ms (void)
 Returns true if the current device is a USB mass storage device; false otherwise. More...
 
void * ai_nav_file_info_image (ai_image_size_t *size)
 Returns a pointer and image information of the embedded image of the selected track. More...
 
bool ai_read_string (bool(*fcnt_read_string)(char *, uint8_t), char **string, uint16_t *size_string)
 
uint16_t ai_song_read_info (uint16_t(*fcnt_song_read_info)(char **), char **string)
 
static bool ai_specific_async_cmd_task (cmd_ai_id_t cmd_id, uint32_t u32_in, uint16_t *u16_arg_size, char **u8_arg_in, uint32_t *u32_out, uint64_t *u64_out)
 
 AI_SYNC_FUNC_MALLOC (uint16_t, get_serial_number, pp_sz_sn, 0)
 
 AI_SYNC_FUNC_MALLOC (uint16_t, nav_dir_name, ppstring, 0)
 
 AI_SYNC_FUNC_MALLOC (uint16_t, nav_file_name, ppstring, 0)
 
 AI_SYNC_FUNC_MALLOC (uint16_t, nav_file_info_title, ppsz_title, 0)
 
 AI_SYNC_FUNC_MALLOC (uint16_t, nav_file_info_artist, ppsz_artist, 0)
 
 AI_SYNC_FUNC_MALLOC (uint16_t, nav_file_info_album, ppsz_album, 0)
 
 AI_SYNC_FUNC_MALLOC (uint16_t, nav_file_info_genre, ppsz_genre, 0)
 
 AI_SYNC_FUNC_MALLOC (uint16_t, audio_nav_getname, ppstring, 0)
 
 AI_SYNC_FUNC_MALLOC (uint16_t, audio_nav_file_info_title, ppsz_title, 0)
 
 AI_SYNC_FUNC_MALLOC (uint16_t, audio_nav_file_info_artist, ppsz_artist, 0)
 
 AI_SYNC_FUNC_MALLOC (uint16_t, audio_nav_file_info_album, ppsz_album, 0)
 
 AI_SYNC_FUNC_MALLOC (uint16_t, audio_nav_file_info_genre, ppsz_genre, 0)
 
 AI_SYNC_FUNC_RET_STRUCT (St_ai_info_version, nav_file_info_version, void,, 0)
 
 AI_SYNC_FUNC_RET_STRUCT (St_ai_info_version, audio_nav_file_info_version, void,, 0)
 
 AI_SYNC_FUNC_RET_STRUCT (Ai_player_flag_t, audio_ctrl_status, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (uint16_t, get_product_id, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (uint16_t, get_vendor_id, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (uint8_t, nav_drive_nb, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, nav_drive_set, uint8_t, u8_number, 0)
 
 AI_SYNC_FUNC_RET_VALUE (uint8_t, nav_drive_get, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, nav_drive_mount, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (uint64_t, nav_drive_total_space, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (uint64_t, nav_drive_free_space, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, nav_dir_root, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, nav_dir_cd, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, nav_dir_gotoparent, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, nav_file_isdir, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, nav_file_next, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, nav_file_previous, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, nav_file_goto, uint32_t, u32_newpos, 0)
 
 AI_SYNC_FUNC_RET_VALUE (uint16_t, nav_file_pos, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (uint16_t, nav_file_nb, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (uint16_t, nav_dir_nb, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (uint16_t, nav_playlist_nb, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (uint32_t, nav_file_info_type, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (uint16_t, nav_file_info_year, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (uint32_t, nav_file_info_track, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (uint32_t, nav_file_info_duration, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, nav_getplayfile, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, audio_nav_playfile, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, audio_context_restore, void *, ctx, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, audio_nav_next, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, audio_nav_previous, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, audio_nav_eof_occur, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (uint16_t, audio_nav_nb, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (uint16_t, audio_nav_getpos, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, audio_nav_setpos, uint16_t, u16_pos, 0)
 
 AI_SYNC_FUNC_RET_VALUE (Ai_repeat_mode, audio_nav_repeat_get, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (Ai_shuffle_mode, audio_nav_shuffle_get, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (Ai_explorer_mode, audio_nav_expmode_get, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (uint32_t, audio_nav_file_info_type, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (uint16_t, audio_nav_file_info_year, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (uint32_t, audio_nav_file_info_track, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (uint32_t, audio_nav_file_info_duration, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, audio_ctrl_stop, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, audio_ctrl_resume, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, audio_ctrl_pause, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (uint32_t, audio_ctrl_time, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, audio_ctrl_ffw, uint32_t, u32_duration, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, audio_ctrl_frw, uint32_t, u32_duration, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, audio_ctrl_start_ffw, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, audio_ctrl_start_frw, void,, 0)
 
 AI_SYNC_FUNC_RET_VALUE (bool, audio_ctrl_stop_ffw_frw, void,, 0)
 
 AI_SYNC_FUNC_RET_VOID (audio_nav_repeat_set, Ai_repeat_mode, repeat_mode)
 
 AI_SYNC_FUNC_RET_VOID (audio_nav_shuffle_set, Ai_shuffle_mode, shuffle)
 
 AI_SYNC_FUNC_RET_VOID (audio_nav_expmode_set, Ai_explorer_mode, exp_mode)
 
void ai_task (void)
 Task for the internal behaviors of the Audio Interface. More...
 
bool is_ai_async_cmd_finished (void)
 Tests if the current asynchronous routine is finished. More...
 

Variables

const ai_fct_set ai_default_fct_set
 
const ai_fct_setai_fct_set_tab [4]
 
uint8_t current_ai_fct_set = AI_NONE
 
static char * g_ai_char_arg
 
ai_async_status_t g_ai_cmd_execution_status
 
static cmd_ai_id_t g_ai_cmdid
 
static uint8_t g_ai_status
 
static uint16_t g_ai_u16_arg_size
 
static uint32_t g_ai_u32_in
 
static uint32_t g_ai_u32_out
 
static uint64_t g_ai_u64_out
 
volatile bool g_b_ai_cmd_received
 
uint8_t g_retry_cnt
 Number of retries before aborting the command. More...
 

#define AI_CALL (   fct_set,
  macro 
)    AI_CALL_##fct_set(macro);
#define AI_CALL_AI_HID_CLASS (   macro)
#define AI_CALL_AI_SD_MMC (   macro)
#define AI_CALL_AI_USB_MS (   macro)
#define AI_CMD_RETRY_RELOAD   3

Referenced by ai_async_cmd_put().

#define AI_GET_DEVICE_STATUS (   fct_set)
Value:
{ \
ai_async_status_t async_status; \
device_status = ai_fct_set_tab[fct_set]->get_device_status(&async_status); \
}
ai_device_status_t(* get_device_status)(ai_async_status_t *)
Definition: audio_interface.h:281
return
Definition: avr32/applications/uc3-audio-player/main.c:244
if(Is_usb_id_transition()&&Is_usb_id_interrupt_enabled())
Definition: applications/uc3-audio-player/usb_task.c:395
ai_device_status_t
Definition: audio_interface.h:269
static U8 device_status
Definition: usb_standard_request.c:99
Definition: audio_interface.h:271
const ai_fct_set * ai_fct_set_tab[4]
Definition: audio_interface.c:159
ai_async_status_t
Structure Context which includes all information about audio.
Definition: audio_interface.h:245

Referenced by ai_get_device_status().

#define AI_HID_CLASS   2

Referenced by ai_init(), and ai_is_hid_class().

#define AI_NONE   0

Referenced by ai_init(), ai_is_none(), and ai_task().

#define AI_PRIORITY0 (   macro)
#define AI_PRIORITY1 (   macro)    AI_PRIORITY0(macro) AI_CALL(AI_USB_MS, macro)
#define AI_PRIORITY2 (   macro)    AI_PRIORITY1(macro) AI_CALL(AI_HID_CLASS, macro)
#define AI_PRIORITY3 (   macro)    AI_PRIORITY2(macro) AI_CALL(AI_SD_MMC, macro)
#define AI_PRIORITY_CALL (   macro)    AI_PRIORITY3(macro)

Referenced by ai_get_device_status(), and ai_task().

#define AI_SD_MMC   3

Referenced by ai_init(), and ai_is_sd_mmc().

#define AI_SYNC_FUNC_MALLOC (   ret_type,
  func_name,
  pp_arg,
  err_ret 
)
Value:
ret_type ai_##func_name ( char** pp_arg ) \
{ \
if( !ai_async_##func_name() ) \
return (err_ret); \
\
do \
{ \
}while( !is_ai_async_cmd_finished() ); \
\
}
bool is_ai_async_cmd_finished(void)
Tests if the current asynchronous routine is finished.
Definition: audio_interface.c:651
#define AI_SYNC_TASK_CALL_BACK()
Definition: audio_interface.c:136
uint16_t ai_async_cmd_out_SizeArrayU8(void)
Returns the size of the extra result (no size limit) of the last asynchronous executed command...
Definition: audio_interface.c:683
return
Definition: avr32/applications/uc3-audio-player/main.c:244
if(Is_usb_id_transition()&&Is_usb_id_interrupt_enabled())
Definition: applications/uc3-audio-player/usb_task.c:395
char * ai_async_cmd_out_PtrArrayU8(void)
Returns the pointer on extra result of the last asynchronous command executed.
Definition: audio_interface.c:688
do
Definition: jquant1.c:201
void ai_async_cmd_task(void)
-----— ASYNCHRONOUS routines -----— note: to use these routines, you must call specific routine to kn...
Definition: audio_interface.c:328
#define AI_SYNC_FUNC_RET_STRUCT (   ret_type,
  func_name,
  arg_type,
  arg_val,
  err_ret 
)
Value:
ret_type ai_##func_name ( arg_type arg_val ) \
{ \
ret_type var; \
var.all=(err_ret); \
if( !ai_async_##func_name(arg_val) ) \
return var; \
\
do \
{ \
}while( !is_ai_async_cmd_finished() ); \
\
return var; \
}
bool is_ai_async_cmd_finished(void)
Tests if the current asynchronous routine is finished.
Definition: audio_interface.c:651
uint32_t ai_async_cmd_out_u32(void)
Return the result (max 32bits) of the last asynchronous command executed.
Definition: audio_interface.c:663
#define AI_SYNC_TASK_CALL_BACK()
Definition: audio_interface.c:136
return
Definition: avr32/applications/uc3-audio-player/main.c:244
if(Is_usb_id_transition()&&Is_usb_id_interrupt_enabled())
Definition: applications/uc3-audio-player/usb_task.c:395
do
Definition: jquant1.c:201
void ai_async_cmd_task(void)
-----— ASYNCHRONOUS routines -----— note: to use these routines, you must call specific routine to kn...
Definition: audio_interface.c:328

-----— SYNCHRONOUS routines -----—

#define AI_SYNC_FUNC_RET_VALUE (   ret_type,
  func_name,
  arg_type,
  arg_val,
  err_ret 
)
Value:
ret_type ai_##func_name ( arg_type arg_val ) \
{ \
if( !ai_async_##func_name(arg_val) ) \
return (err_ret); \
\
do \
{ \
}
bool is_ai_async_cmd_finished(void)
Tests if the current asynchronous routine is finished.
Definition: audio_interface.c:651
uint32_t ai_async_cmd_out_u32(void)
Return the result (max 32bits) of the last asynchronous command executed.
Definition: audio_interface.c:663
#define AI_SYNC_TASK_CALL_BACK()
Definition: audio_interface.c:136
return
Definition: avr32/applications/uc3-audio-player/main.c:244
if(Is_usb_id_transition()&&Is_usb_id_interrupt_enabled())
Definition: applications/uc3-audio-player/usb_task.c:395
do
Definition: jquant1.c:201
void ai_async_cmd_task(void)
-----— ASYNCHRONOUS routines -----— note: to use these routines, you must call specific routine to kn...
Definition: audio_interface.c:328
#define AI_SYNC_FUNC_RET_VOID (   func_name,
  arg_type,
  arg_val 
)
Value:
void ai_##func_name ( arg_type arg_val ) \
{ \
if( !ai_async_##func_name(arg_val) ) \
\
do \
{ \
}while( !is_ai_async_cmd_finished() ); \
}
bool is_ai_async_cmd_finished(void)
Tests if the current asynchronous routine is finished.
Definition: audio_interface.c:651
#define AI_SYNC_TASK_CALL_BACK()
Definition: audio_interface.c:136
return
Definition: avr32/applications/uc3-audio-player/main.c:244
if(Is_usb_id_transition()&&Is_usb_id_interrupt_enabled())
Definition: applications/uc3-audio-player/usb_task.c:395
do
Definition: jquant1.c:201
void ai_async_cmd_task(void)
-----— ASYNCHRONOUS routines -----— note: to use these routines, you must call specific routine to kn...
Definition: audio_interface.c:328
#define AI_TASK_SELECT_FCT_SET (   cur_fct_set)
Value:
if (ai_fct_set_tab[cur_fct_set]->get_device_status(&status) == AI_DEVICE_STATUS_CONNECTED) \
{ \
current_ai_fct_set = cur_fct_set; \
}
return
Definition: avr32/applications/uc3-audio-player/main.c:244
uint16_t status
Definition: spi_master_example.c:91
Definition: audio_interface.h:275
const ai_fct_set * ai_fct_set_tab[4]
Definition: audio_interface.c:159
uint8_t current_ai_fct_set
Definition: audio_interface.c:161

Referenced by ai_task().

#define AI_USB_MS   1

Referenced by ai_init(), and ai_is_usb_ms().

void ai_async_cmd_out_free_ArrayU8 ( void  )

Free the allocated buffer which holds the extra-result.

This shall be done when the "extra results" are no more needed by the application.

References g_ai_char_arg, g_ai_u16_arg_size, and NULL.

Referenced by ai_async_cmd_put().

char* ai_async_cmd_out_PtrArrayU8 ( void  )

Returns the pointer on extra result of the last asynchronous command executed.

Note
this value is valid only if is_ai_async_cmd_finished() return true, and ai_async_cmd_out_SizeArrayU8() return != 0
Returns
pointer on extra result

References g_ai_char_arg.

Referenced by ai_audio_context_save(), navigation_task(), and track_changed_task().

uint16_t ai_async_cmd_out_SizeArrayU8 ( void  )

Returns the size of the extra result (no size limit) of the last asynchronous executed command.

Note
this value is valid only if is_ai_async_cmd_finished() return true
Returns
0 = no extra value, else get pointer on extra result with ai_async_cmd_out_PtrArrayU8() routine

References g_ai_u16_arg_size.

Referenced by ai_audio_context_save(), navigation_task(), and track_changed_task().

uint8_t ai_async_cmd_out_status ( void  )

Returns the status of the last asynchronous command executed.

Note
this value is valid only if is_ai_async_cmd_finished() returns true
Returns
status of command (which value depends on command)

References CMD_ERROR, g_ai_cmd_execution_status, and g_ai_status.

Referenced by ai_audio_context_save(), and com_task().

uint32_t ai_async_cmd_out_u32 ( void  )

Return the result (max 32bits) of the last asynchronous command executed.

Note
this value is valid only if is_ai_async_cmd_finished() returns true.
Returns
result of command (which value depends on command)

References g_ai_u32_out.

Referenced by ai_audio_nav_file_info_image(), ai_nav_file_info_image(), check_device_task(), config_task(), navigation_task(), playback_task(), and track_changed_task().

uint64_t ai_async_cmd_out_u64 ( void  )

Return the result (max 64 bits) of the last asynchronous command executed.

Note
this value is valid only if is_ai_async_cmd_finished() returns true.
Returns
result of command (which value depends on command)

References g_ai_u64_out.

bool ai_async_cmd_put ( cmd_ai_id_t  cmd_id,
uint32_t  u32_in,
uint16_t  u16_arg_size,
char *  u8_arg_in,
bool  need_extra_buffer 
)

This routine may be used to send directly a command values from a communication port to audio interface.

This routine may be use to send directly a command values from a communication port to audio interface.

Note
you can use the ai_async_cmd_put() routine or ai_async_X() routines to send an asynchronous command

References ai_async_cmd_out_free_ArrayU8(), AI_CMD_RETRY_RELOAD, g_ai_char_arg, g_ai_cmdid, g_ai_u16_arg_size, g_ai_u32_in, g_b_ai_cmd_received, and g_retry_cnt.

Referenced by ai_async_audio_context_restore(), ai_async_audio_context_save(), ai_async_audio_ctrl_ffw(), ai_async_audio_ctrl_frw(), 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_status(), ai_async_audio_ctrl_stop(), ai_async_audio_ctrl_stop_ffw_frw(), ai_async_audio_ctrl_time(), ai_async_audio_nav_eof_occur(), ai_async_audio_nav_expmode_get(), ai_async_audio_nav_expmode_set(), ai_async_audio_nav_file_info_album(), ai_async_audio_nav_file_info_artist(), ai_async_audio_nav_file_info_duration(), ai_async_audio_nav_file_info_genre(), ai_async_audio_nav_file_info_image(), ai_async_audio_nav_file_info_title(), ai_async_audio_nav_file_info_track(), ai_async_audio_nav_file_info_type(), ai_async_audio_nav_file_info_version(), ai_async_audio_nav_file_info_year(), ai_async_audio_nav_getname(), ai_async_audio_nav_getpos(), ai_async_audio_nav_nb(), ai_async_audio_nav_next(), ai_async_audio_nav_playfile(), ai_async_audio_nav_previous(), ai_async_audio_nav_repeat_get(), ai_async_audio_nav_repeat_set(), ai_async_audio_nav_setpos(), ai_async_audio_nav_shuffle_get(), ai_async_audio_nav_shuffle_set(), ai_async_get_product_id(), ai_async_get_serial_number(), ai_async_get_vendor_id(), ai_async_is_device_connected(), ai_async_nav_dir_cd(), ai_async_nav_dir_gotoparent(), ai_async_nav_dir_name(), ai_async_nav_dir_nb(), ai_async_nav_dir_root(), ai_async_nav_drive_free_space(), ai_async_nav_drive_get(), ai_async_nav_drive_mount(), ai_async_nav_drive_nb(), ai_async_nav_drive_set(), ai_async_nav_drive_total_space(), ai_async_nav_file_goto(), ai_async_nav_file_info_album(), ai_async_nav_file_info_artist(), ai_async_nav_file_info_duration(), ai_async_nav_file_info_genre(), ai_async_nav_file_info_image(), ai_async_nav_file_info_title(), ai_async_nav_file_info_track(), ai_async_nav_file_info_type(), ai_async_nav_file_info_version(), ai_async_nav_file_info_year(), ai_async_nav_file_isdir(), ai_async_nav_file_name(), ai_async_nav_file_nb(), ai_async_nav_file_next(), ai_async_nav_file_pos(), ai_async_nav_file_previous(), ai_async_nav_getplayfile(), ai_async_nav_playlist_nb(), ai_async_usb_ms_specific_audio_nav_get_folder_name(), ai_async_usb_ms_specific_audio_nav_playlist_play_link(), ai_async_usb_ms_specific_audio_nav_restore(), ai_async_usb_ms_specific_audio_nav_save(), ai_async_usb_ms_specific_nav_get_next_playlist_pos(), ai_async_usb_ms_specific_nav_getplaylistfile(), ai_async_usb_ms_specific_nav_playlist_link_name(), ai_async_usb_ms_specific_nav_playlist_link_nb(), ai_async_usb_ms_specific_nav_restore(), ai_async_usb_ms_specific_nav_save(), ai_async_usb_ms_specific_playlist_nav_restore(), and ai_async_usb_ms_specific_playlist_nav_save().

void ai_async_cmd_task ( void  )

-----— ASYNCHRONOUS routines -----— note: to use these routines, you must call specific routine to know the end of execution and take the result

Launch the execution (it can be a part of the job or its full execution) of the current asynchronous command.

References AI_ASYNC_STACK_NB_ELEMENTS, ai_specific_async_cmd_task(), ai_fct_set::audio_context_restore, ai_fct_set::audio_ctrl_ffw, ai_fct_set::audio_ctrl_frw, ai_fct_set::audio_ctrl_pause, ai_fct_set::audio_ctrl_resume, ai_fct_set::audio_ctrl_start_ffw, ai_fct_set::audio_ctrl_start_frw, ai_fct_set::audio_ctrl_stop, ai_fct_set::audio_ctrl_stop_ffw_frw, ai_fct_set::audio_ctrl_time, ai_fct_set::audio_nav_eof_occur, ai_fct_set::audio_nav_expmode_get, ai_fct_set::audio_nav_expmode_set, ai_fct_set::audio_nav_file_info_album, ai_fct_set::audio_nav_file_info_artist, ai_fct_set::audio_nav_file_info_duration, ai_fct_set::audio_nav_file_info_genre, ai_fct_set::audio_nav_file_info_title, ai_fct_set::audio_nav_file_info_track, ai_fct_set::audio_nav_file_info_type, ai_fct_set::audio_nav_file_info_version, ai_fct_set::audio_nav_file_info_year, ai_fct_set::audio_nav_getname, ai_fct_set::audio_nav_getpos, ai_fct_set::audio_nav_nb, ai_fct_set::audio_nav_next, ai_fct_set::audio_nav_playfile, ai_fct_set::audio_nav_previous, ai_fct_set::audio_nav_repeat_get, ai_fct_set::audio_nav_repeat_set, ai_fct_set::audio_nav_setpos, ai_fct_set::audio_nav_shuffle_get, ai_fct_set::audio_nav_shuffle_set, CMD_AI_AUDIO_CONTEXT_RESTORE, CMD_AI_AUDIO_CONTEXT_SAVE, CMD_AI_AUDIO_CTRL_FFW, CMD_AI_AUDIO_CTRL_FRW, CMD_AI_AUDIO_CTRL_PAUSE, CMD_AI_AUDIO_CTRL_RESUME, CMD_AI_AUDIO_CTRL_START_FFW, CMD_AI_AUDIO_CTRL_START_FRW, CMD_AI_AUDIO_CTRL_STATUS, CMD_AI_AUDIO_CTRL_STOP, CMD_AI_AUDIO_CTRL_STOP_FFW_FRW, CMD_AI_AUDIO_CTRL_TIME, CMD_AI_AUDIO_NAV_EOF_OCCUR, CMD_AI_AUDIO_NAV_EXPMODE_GET, CMD_AI_AUDIO_NAV_EXPMODE_SET, CMD_AI_AUDIO_NAV_GETNAME, CMD_AI_AUDIO_NAV_GETPOS, CMD_AI_AUDIO_NAV_INFO_ALBUM, CMD_AI_AUDIO_NAV_INFO_ARTIST, CMD_AI_AUDIO_NAV_INFO_DURATION, CMD_AI_AUDIO_NAV_INFO_GENRE, CMD_AI_AUDIO_NAV_INFO_IMAGE, CMD_AI_AUDIO_NAV_INFO_TITLE, CMD_AI_AUDIO_NAV_INFO_TRACK, CMD_AI_AUDIO_NAV_INFO_TYPE, CMD_AI_AUDIO_NAV_INFO_VERSION, CMD_AI_AUDIO_NAV_INFO_YEAR, CMD_AI_AUDIO_NAV_NB, CMD_AI_AUDIO_NAV_NEXT, CMD_AI_AUDIO_NAV_PLAYFILE, CMD_AI_AUDIO_NAV_PREV, CMD_AI_AUDIO_NAV_REPEAT_GET, CMD_AI_AUDIO_NAV_REPEAT_SET, CMD_AI_AUDIO_NAV_SETPOS, CMD_AI_AUDIO_NAV_SHUFFLE_GET, CMD_AI_AUDIO_NAV_SHUFFLE_SET, CMD_AI_GET_DEVICE_STATUS, CMD_AI_GET_PRODUCT_ID, CMD_AI_GET_SERIAL_NUMBER, CMD_AI_GET_VENDOR_ID, CMD_AI_NAV_DIR_CD, CMD_AI_NAV_DIR_GOTOPARENT, CMD_AI_NAV_DIR_NAME, CMD_AI_NAV_DIR_NB, CMD_AI_NAV_DIR_ROOT, CMD_AI_NAV_DRIVE_FREE_SPACE, CMD_AI_NAV_DRIVE_GET, CMD_AI_NAV_DRIVE_MOUNT, CMD_AI_NAV_DRIVE_NB, CMD_AI_NAV_DRIVE_SET, CMD_AI_NAV_DRIVE_TOTAL_SPACE, CMD_AI_NAV_FILE_GOTO, CMD_AI_NAV_FILE_ISDIR, CMD_AI_NAV_FILE_NAME, CMD_AI_NAV_FILE_NB, CMD_AI_NAV_FILE_NEXT, CMD_AI_NAV_FILE_POS, CMD_AI_NAV_FILE_PREVIOUS, CMD_AI_NAV_GETPLAYFILE, CMD_AI_NAV_INFO_ALBUM, CMD_AI_NAV_INFO_ARTIST, CMD_AI_NAV_INFO_DURATION, CMD_AI_NAV_INFO_GENRE, CMD_AI_NAV_INFO_IMAGE, CMD_AI_NAV_INFO_TITLE, CMD_AI_NAV_INFO_TRACK, CMD_AI_NAV_INFO_TYPE, CMD_AI_NAV_INFO_VERSION, CMD_AI_NAV_INFO_YEAR, CMD_AI_NAV_PLAYLIST_NB, CMD_ERROR, CMD_EXECUTING, current_ai_fct_set, St_ai_info_version::digit, g_ai_char_arg, g_ai_cmd_execution_status, g_ai_cmdid, g_ai_status, g_ai_u16_arg_size, g_ai_u32_in, g_ai_u32_out, g_ai_u64_out, g_b_ai_cmd_received, ai_fct_set::get_product_id, ai_fct_set::get_serial_number, ai_fct_set::get_vendor_id, St_ai_info_version::major, St_ai_info_version::minor, ai_fct_set::nav_dir_cd, ai_fct_set::nav_dir_gotoparent, ai_fct_set::nav_dir_name, ai_fct_set::nav_dir_nb, ai_fct_set::nav_dir_root, ai_fct_set::nav_drive_free_space, ai_fct_set::nav_drive_get, ai_fct_set::nav_drive_mount, ai_fct_set::nav_drive_nb, ai_fct_set::nav_drive_set, ai_fct_set::nav_drive_total_space, ai_fct_set::nav_file_goto, ai_fct_set::nav_file_info_album, ai_fct_set::nav_file_info_artist, ai_fct_set::nav_file_info_duration, ai_fct_set::nav_file_info_genre, ai_fct_set::nav_file_info_title, ai_fct_set::nav_file_info_track, ai_fct_set::nav_file_info_type, ai_fct_set::nav_file_info_version, ai_fct_set::nav_file_info_year, ai_fct_set::nav_file_isdir, ai_fct_set::nav_file_name, ai_fct_set::nav_file_nb, ai_fct_set::nav_file_next, ai_fct_set::nav_file_pos, ai_fct_set::nav_file_previous, ai_fct_set::nav_getplayfile, ai_fct_set::nav_playlist_nb, NULL, and St_ai_info_version::revision.

Referenced by ai_audio_context_save(), ai_audio_nav_file_info_image(), ai_nav_file_info_image(), codec_mp3_task(), codec_wav_task(), and com_task().

bool ai_async_context_pop ( ai_async_context_t ctx)

Pop a context from the stack.

Parameters
ctxA pointer on an empty context structure to store the new context.
Returns
true if the command succeed,
false otherwise.

References AI_ASYNC_STACK_NB_ELEMENTS.

Referenced by ai_usb_ms_audio_nav_mov().

bool ai_async_context_push ( ai_async_context_t ctx)

Push a new context into the stack.

Parameters
ctxThe new context to push.
Returns
true if the command succeed,
false otherwise.

Referenced by ai_usb_ms_audio_nav_mov().

void ai_async_update_cmd_status ( ai_async_status_t cmd_ai_status)

Update the current command status.

Parameters
cmd_ai_statusThe current command status to update

References AI_ASYNC_STACK_NB_ELEMENTS, CMD_DONE, CMD_ERROR, ctx, and ai_async_context_t::status.

Referenced by ai_usb_ms_audio_nav_mov().

void* ai_audio_context_save ( uint8_t *  status,
uint16_t *  size 
)

Give complete audio context (player state, play time, repeat, shuffle, file played, explorer mode )

Note
May be interesting before a power OFF.
Returns
ctx structure with all information about the current context

References ai_async_audio_context_save(), ai_async_cmd_out_PtrArrayU8(), ai_async_cmd_out_SizeArrayU8(), ai_async_cmd_out_status(), ai_async_cmd_task(), AI_SYNC_TASK_CALL_BACK, is_ai_async_cmd_finished(), and NULL.

void* ai_audio_nav_file_info_image ( ai_image_size_t size)

Returns a pointer and image information of the embedded image of the selected track.

Parameters
sizeThe desire width and height of the decoded image.
sizeThe actual width and height of the decoded image.
Returns
pointer on the image data. NULL in case of error.

References ai_async_audio_nav_file_info_image(), ai_async_cmd_out_u32(), ai_async_cmd_task(), AI_SYNC_TASK_CALL_BACK, is_ai_async_cmd_finished(), and NULL.

void ai_command_abort ( void  )

Aborts the current command.

References CMD_ERROR, g_ai_cmd_execution_status, g_ai_status, and g_b_ai_cmd_received.

Referenced by com_task().

ai_device_status_t ai_get_device_status ( void  )

Here is the list of the SYNCHRONOUS functions.

Tells the status of the device connected.

Tells if a device is connected or not

Returns
true if a device is connected, false otherwise.

References AI_DEVICE_STATUS_NOT_PRESENT, AI_GET_DEVICE_STATUS, and AI_PRIORITY_CALL.

Referenced by usb_device_get_state().

void ai_init ( void  )
bool ai_is_hid_class ( void  )

Returns true if the application is using hid class; false otherwise.

References AI_HID_CLASS.

bool ai_is_none ( void  )

Returns true if no devices are connected.

References AI_NONE.

Referenced by com_task().

bool ai_is_sd_mmc ( void  )

Returns true if the application is using sd/mmc card support; false otherwise.

References AI_SD_MMC.

bool ai_is_usb_ms ( void  )

Returns true if the current device is a USB mass storage device; false otherwise.

References AI_USB_MS.

void* ai_nav_file_info_image ( ai_image_size_t size)

Returns a pointer and image information of the embedded image of the selected track.

Parameters
sizeThe desire width and height of the decoded image.
sizeThe actual width and height of the decoded image.
Returns
pointer on the image data. NULL in case of error.

References ai_async_cmd_out_u32(), ai_async_cmd_task(), ai_async_nav_file_info_image(), AI_SYNC_TASK_CALL_BACK, is_ai_async_cmd_finished(), and NULL.

bool ai_read_string ( bool(*)(char *, uint8_t)  fcnt_read_string,
char **  string,
uint16_t *  size_string 
)
uint16_t ai_song_read_info ( uint16_t(*)(char **)  fcnt_song_read_info,
char **  string 
)
static bool ai_specific_async_cmd_task ( cmd_ai_id_t  cmd_id,
uint32_t  u32_in,
uint16_t *  u16_arg_size,
char **  u8_arg_in,
uint32_t *  u32_out,
uint64_t *  u64_out 
)
static
AI_SYNC_FUNC_MALLOC ( uint16_t  ,
get_serial_number  ,
pp_sz_sn  ,
 
)
AI_SYNC_FUNC_MALLOC ( uint16_t  ,
nav_dir_name  ,
ppstring  ,
 
)
AI_SYNC_FUNC_MALLOC ( uint16_t  ,
nav_file_name  ,
ppstring  ,
 
)
AI_SYNC_FUNC_MALLOC ( uint16_t  ,
nav_file_info_title  ,
ppsz_title  ,
 
)
AI_SYNC_FUNC_MALLOC ( uint16_t  ,
nav_file_info_artist  ,
ppsz_artist  ,
 
)
AI_SYNC_FUNC_MALLOC ( uint16_t  ,
nav_file_info_album  ,
ppsz_album  ,
 
)
AI_SYNC_FUNC_MALLOC ( uint16_t  ,
nav_file_info_genre  ,
ppsz_genre  ,
 
)
AI_SYNC_FUNC_MALLOC ( uint16_t  ,
audio_nav_getname  ,
ppstring  ,
 
)
AI_SYNC_FUNC_MALLOC ( uint16_t  ,
audio_nav_file_info_title  ,
ppsz_title  ,
 
)
AI_SYNC_FUNC_MALLOC ( uint16_t  ,
audio_nav_file_info_artist  ,
ppsz_artist  ,
 
)
AI_SYNC_FUNC_MALLOC ( uint16_t  ,
audio_nav_file_info_album  ,
ppsz_album  ,
 
)
AI_SYNC_FUNC_MALLOC ( uint16_t  ,
audio_nav_file_info_genre  ,
ppsz_genre  ,
 
)
AI_SYNC_FUNC_RET_STRUCT ( St_ai_info_version  ,
nav_file_info_version  ,
void  ,
 
)
AI_SYNC_FUNC_RET_STRUCT ( St_ai_info_version  ,
audio_nav_file_info_version  ,
void  ,
 
)
AI_SYNC_FUNC_RET_STRUCT ( Ai_player_flag_t  ,
audio_ctrl_status  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( uint16_t  ,
get_product_id  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( uint16_t  ,
get_vendor_id  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( uint8_t  ,
nav_drive_nb  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
nav_drive_set  ,
uint8_t  ,
u8_number  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( uint8_t  ,
nav_drive_get  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
nav_drive_mount  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( uint64_t  ,
nav_drive_total_space  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( uint64_t  ,
nav_drive_free_space  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
nav_dir_root  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
nav_dir_cd  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
nav_dir_gotoparent  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
nav_file_isdir  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
nav_file_next  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
nav_file_previous  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
nav_file_goto  ,
uint32_t  ,
u32_newpos  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( uint16_t  ,
nav_file_pos  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( uint16_t  ,
nav_file_nb  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( uint16_t  ,
nav_dir_nb  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( uint16_t  ,
nav_playlist_nb  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( uint32_t  ,
nav_file_info_type  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( uint16_t  ,
nav_file_info_year  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( uint32_t  ,
nav_file_info_track  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( uint32_t  ,
nav_file_info_duration  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
nav_getplayfile  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
audio_nav_playfile  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
audio_context_restore  ,
void *  ,
ctx  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
audio_nav_next  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
audio_nav_previous  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
audio_nav_eof_occur  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( uint16_t  ,
audio_nav_nb  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( uint16_t  ,
audio_nav_getpos  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
audio_nav_setpos  ,
uint16_t  ,
u16_pos  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( Ai_repeat_mode  ,
audio_nav_repeat_get  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( Ai_shuffle_mode  ,
audio_nav_shuffle_get  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( Ai_explorer_mode  ,
audio_nav_expmode_get  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( uint32_t  ,
audio_nav_file_info_type  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( uint16_t  ,
audio_nav_file_info_year  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( uint32_t  ,
audio_nav_file_info_track  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( uint32_t  ,
audio_nav_file_info_duration  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
audio_ctrl_stop  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
audio_ctrl_resume  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
audio_ctrl_pause  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( uint32_t  ,
audio_ctrl_time  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
audio_ctrl_ffw  ,
uint32_t  ,
u32_duration  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
audio_ctrl_frw  ,
uint32_t  ,
u32_duration  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
audio_ctrl_start_ffw  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
audio_ctrl_start_frw  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VALUE ( bool  ,
audio_ctrl_stop_ffw_frw  ,
void  ,
 
)
AI_SYNC_FUNC_RET_VOID ( audio_nav_repeat_set  ,
Ai_repeat_mode  ,
repeat_mode   
)
AI_SYNC_FUNC_RET_VOID ( audio_nav_shuffle_set  ,
Ai_shuffle_mode  ,
shuffle   
)
AI_SYNC_FUNC_RET_VOID ( audio_nav_expmode_set  ,
Ai_explorer_mode  ,
exp_mode   
)
void ai_task ( void  )

Task for the internal behaviors of the Audio Interface.

References AI_NONE, AI_PRIORITY_CALL, AI_TASK_SELECT_FCT_SET, and status.

Referenced by main().

bool is_ai_async_cmd_finished ( void  )

Tests if the current asynchronous routine is finished.

Returns
true when the current asynchronous command is finished, false when the asynchronous command is still running.

References g_b_ai_cmd_received.

Referenced by ai_audio_context_save(), ai_audio_nav_file_info_image(), ai_nav_file_info_image(), codec_mp3_task(), codec_wav_task(), and com_task().

const ai_fct_set ai_default_fct_set

Referenced by ai_init().

const ai_fct_set* ai_fct_set_tab[4]
uint8_t current_ai_fct_set = AI_NONE
cmd_ai_id_t g_ai_cmdid
static
uint8_t g_ai_status
static
uint32_t g_ai_u32_in
static
uint32_t g_ai_u32_out
static
uint64_t g_ai_u64_out
static
uint8_t g_retry_cnt

Number of retries before aborting the command.

Referenced by ai_async_cmd_put().