/*This file is prepared for Doxygen automatic documentation generation.*/
/*! \file ******************************************************************
 *
 * \brief Audio player configuration file.
 *
 * - Compiler:           IAR EWAVR32 and GNU GCC for AVR32
 * - Supported devices:  All AVR32 devices can be used.
 * - AppNote:
 *
 * \author               Atmel Corporation: http://www.atmel.com \n
 *                       Support and FAQ: http://support.atmel.no/
 *
 ***************************************************************************/

/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * 3. The name of Atmel may not be used to endorse or promote products derived
 * from this software without specific prior written permission.
 *
 * 4. This software may only be redistributed and used in connection with an Atmel
 * AVR product.
 *
 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
 *
 */


#ifndef _CONF_AUDIO_PLAYER_H_
#define _CONF_AUDIO_PLAYER_H_

#include <avr32/io.h>
#include "board.h"
#include "compiler.h"

/*! \name System Clock Frequencies
 */
//! @{
#define FMCK_HZ                           62092800
#define FCPU_HZ                           FMCK_HZ
#define FHSB_HZ                           FCPU_HZ
#define FPBB_HZ                           FMCK_HZ
#define FPBA_HZ                           FMCK_HZ
//! @}

//! Default heap initialization word.
#define DEFAULT_HEAP_INIT_WORD            0xA5A5A5A5

/*! \name Default DAC Settings
 * Please choose beetween:
 * - AUDIO_MIXER_DAC_AIC23B  (external DAC mounted on EVK1105 board)
 * - AUDIO_MIXER_DAC_ABDAC (internal ABDAC with external amplifier tap6130
 *   on EVK1105 and EVK1104)
 */
//! @{
#define DEFAULT_DACS                      AUDIO_MIXER_DAC_AIC23B
#define DEFAULT_DAC_SAMPLE_RATE_HZ        44100
#define DEFAULT_DAC_NUM_CHANNELS          2
#define DEFAULT_DAC_BITS_PER_SAMPLE       16
#define DEFAULT_DAC_SWAP_CHANNELS         FALSE
//! @}

/*! \name Audio player sample bufferization.
 */
#define USE_AUDIO_PLAYER_BUFFERIZATION    ENABLED

/*! \name Audio player features.
 */
//! @{
#define SUPPORT_MP3                       ENABLED
#define SUPPORT_PLAYLISTS                 ENABLED
#define SUPPORT_EMBEDDED_COVER_ARTS       ENABLED
//! @}

/******* Should not be changed, used to support features *******/

/******* Set audio player configuration ************************/

#define SUPPORT_USB_MS                ENABLED



// ***** Mass Storage Support **********************************
#if defined(SUPPORT_USB_MS) && SUPPORT_USB_MS == ENABLED
  #define USB_MS_INCLUDED                         ENABLED
  #define task_init_usb_ms()                      \
  {                                               \
    host_mass_storage_task_init();                \
  }
  #define task_usb_ms()                           \
  {                                               \
    host_mass_storage_task();                     \
  }
  #define USB_MS_VID_PID_TABLE                    ATMEL_VID, 1, MS_EXAMPLE_PID,
  #define USB_MS_SUBCLASS_PROTOCOL                MS_CLASS, SFF8020I_MMC2_SUBCLASS, BULK_PROTOCOL,  \
                                                  MS_CLASS, SFF8070I_SUBCLASS, BULK_PROTOCOL,       \
                                                  MS_CLASS, SCSI_SUBCLASS, BULK_PROTOCOL,
  #define USB_MS_MAX_INTERFACE_SUPPORTED          3
  #define usb_ms_disconnection_action()           \
  {                                               \
    ms_new_device_connected = FALSE;              \
    ms_connected = FALSE;                         \
  }
  #define usb_ms_new_device_connection_action()   \
  {                                               \
    ms_new_device_connected = TRUE;               \
  }
  extern volatile Bool ms_new_device_connected;
  extern volatile Bool ms_connected;
  extern void host_suspend_action(void);
#else
  #define USB_MS_INCLUDED                         DISABLED
  #define task_init_usb_ms()
  #define task_usb_ms()
  #define USB_MS_VID_PID_TABLE
  #define USB_MS_SUBCLASS_PROTOCOL
  #define USB_MS_MAX_INTERFACE_SUPPORTED          0
  #define usb_ms_disconnection_action()
  #define usb_ms_new_device_connection_action()
#endif


// ***** USB Support *******************************************
#if defined(__AVR32_UC3A3256__) || defined(__AVR32_UC3A3128__)      \
  || defined(__AVR32_UC3A364__) || defined(__AVR32_UC3A3256S__)     \
  || defined(__AVR32_UC3A3128S__) || defined(__AVR32_UC3A364S__)    \
  || defined(__AT32UC3A3256__) || defined(__AT32UC3A3128__)         \
  || defined(__AT32UC3A364__) || defined(__AT32UC3A3256S__)         \
  || defined(__AT32UC3A3128S__) || defined(__AT32UC3A364S__)
  #define USB_HIGH_SPEED_SUPPORT      ENABLED
#endif
#if (defined(SUPPORT_USB_MS) && SUPPORT_USB_MS == ENABLED)
  #define VID_PID_TABLE                         \
  {                                             \
    USB_MS_VID_PID_TABLE                        \
  }
  #define CLASS_SUBCLASS_PROTOCOL               \
  {                                             \
    USB_MS_SUBCLASS_PROTOCOL                    \
  }
  #define Host_device_disconnection_action()    \
  {                                             \
    usb_ms_disconnection_action();              \
  }
  #define Host_new_device_connection_action()   \
  {                                             \
    usb_ms_new_device_connection_action();      \
  }
  #define Host_user_check_class_action(x)       \
  {                                             \
  }
  #define MAX_INTERFACE_SUPPORTED               USB_MS_MAX_INTERFACE_SUPPORTED
  #if defined(SUPPORT_USB_MS) && SUPPORT_USB_MS == ENABLED
    #include "host_mass_storage_task.h"
  #endif
  #include "usb_task.h"
  #define task_init_usb()                       \
  {                                             \
    usb_task_init();                            \
  }
  #define task_usb()                            \
  {                                             \
    usb_task();                                 \
  }
#else
  #define task_init_usb()
  #define task_usb()
#endif


// ***** MP3 Support *******************************************
#if defined(SUPPORT_MP3) && SUPPORT_MP3 == ENABLED
  #include "ai_usb_ms_mp3_support.h"
  #define task_mp3()                  \
  {                                   \
    extern void codec_mp3_task(void); \
    codec_mp3_task();                 \
  }
  #define file_format_mp3             MP3_FILE_FORMAT,
#else
  #define task_mp3()
  #define file_format_mp3
#endif

// *************************************************************

#define task_init()                   \
{                                     \
  task_init_usb();                    \
  task_init_usb_ms();                 \
}

#define task()                        \
{                                     \
  task_usb();                         \
  task_usb_ms();                      \
  task_mp3();                         \
}

#define SUPPORTED_FILE_FORMATS        \
{                                     \
  file_format_mp3                     \
}

#undef AI_SYNC_TASK_CALL_BACK
#define AI_SYNC_TASK_CALL_BACK()      \
{                                     \
  task_usb();                         \
}

#endif  // _CONF_AUDIO_PLAYER_H_
