test public

Dependencies:   HttpServer_snapshot_mbed-os

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ssif_if.h Source File

ssif_if.h

00001 /*******************************************************************************
00002 * DISCLAIMER
00003 * This software is supplied by Renesas Electronics Corporation and is only
00004 * intended for use with Renesas products. No other uses are authorized. This
00005 * software is owned by Renesas Electronics Corporation and is protected under
00006 * all applicable laws, including copyright laws.
00007 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
00008 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
00009 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
00010 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
00011 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
00012 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
00013 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
00014 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
00015 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
00016 * Renesas reserves the right, without notice, to make changes to this software
00017 * and to discontinue the availability of this software. By using this software,
00018 * you agree to the additional terms and conditions found by accessing the
00019 * following link:
00020 * http://www.renesas.com/disclaimer
00021 * Copyright (C) 2013-2016 Renesas Electronics Corporation. All rights reserved.
00022 *******************************************************************************/
00023 
00024 /******************************************************************************
00025 * File Name    : ssif_if.h
00026 * $Rev: $
00027 * $Date::                           $
00028 * Description  : SSIF Driver API header
00029 ******************************************************************************/
00030 
00031 #ifndef SSIF_IF_H
00032 #define SSIF_IF_H
00033 
00034 /******************************************************************************
00035 Includes   <System Includes> , "Project Includes"
00036 ******************************************************************************/
00037 
00038 #include "cmsis_os.h"
00039 
00040 #include "r_typedefs.h"
00041 #include "r_errno.h"
00042 #if(1) /* mbed */
00043 #include "misratypes.h"
00044 #include "aioif.h"
00045 #include "R_BSP_mbed_fns.h"
00046 #include "R_BSP_SsifDef.h"
00047 #else  /* not mbed */
00048 #include "ioif_public.h"
00049 #endif /* end mbed */
00050 
00051 #ifdef __cplusplus
00052 extern "C" {
00053 #endif
00054 
00055 #if(1) /* mbed */
00056 /******************************************************************************
00057  Function Prototypes
00058  *****************************************************************************/
00059 
00060 extern RBSP_MBED_FNS* R_SSIF_MakeCbTbl_mbed(void);
00061 #else  /* not mbed */
00062 /******************************************************************************
00063  Defines
00064  *****************************************************************************/
00065 
00066 /******************************************************************************
00067  Constant Macros
00068  *****************************************************************************/
00069 #if defined(TARGET_RZA1H) /* mbed */
00070 #define SSIF_NUM_CHANS       (6u)    /**< Number of SSIF channels */
00071 
00072 #define SSIF_CFG_DISABLE_ROMDEC_DIRECT (0x0u)        /* Disable SSIRDR->STRMDIN0 route */
00073 #define SSIF_CFG_ENABLE_ROMDEC_DIRECT  (0xDEC0DEC1u) /* Enable  SSIRDR->STRMDIN0 route */
00074 #else /* mbed */
00075 #define SSIF_NUM_CHANS       (4u)    /**< Number of SSIF channels */
00076 #endif /* mbed */
00077 
00078 /******************************************************************************
00079  Function Macros
00080  *****************************************************************************/
00081 
00082 
00083 /******************************************************************************
00084  Enumerated Types
00085  *****************************************************************************/
00086 
00087 /** SSICR:CKS(Clock source for oversampling) */
00088 typedef enum
00089 {
00090     SSIF_CFG_CKS_AUDIO_X1  = 0,  /**< select AUDIO_X1   */
00091     SSIF_CFG_CKS_AUDIO_CLK = 1   /**< select AUIDIO_CLK */
00092 } ssif_chcfg_cks_t;
00093 
00094 /** SSICR:CHNL(Audio channels per system word) */
00095 typedef enum
00096 {
00097     SSIF_CFG_MULTI_CH_1 = 0,     /**< 1ch within systemword (on tdm=0) */
00098     SSIF_CFG_MULTI_CH_2 = 1,     /**< 2ch within systemword (on tdm=0) */
00099     SSIF_CFG_MULTI_CH_3 = 2,     /**< 3ch within systemword (on tdm=0) */
00100     SSIF_CFG_MULTI_CH_4 = 3      /**< 4ch within systemword (on tdm=0) */
00101 } ssif_chcfg_multi_ch_t;
00102 
00103 /** SSICR:DWL(Data word length) */
00104 typedef enum
00105 {
00106     SSIF_CFG_DATA_WORD_8  = 0,   /**< Data word length 8  */
00107     SSIF_CFG_DATA_WORD_16 = 1,   /**< Data word length 16 */
00108     SSIF_CFG_DATA_WORD_18 = 2,   /**< Data word length 18 */
00109     SSIF_CFG_DATA_WORD_20 = 3,   /**< Data word length 20 */
00110     SSIF_CFG_DATA_WORD_22 = 4,   /**< Data word length 22 */
00111     SSIF_CFG_DATA_WORD_24 = 5,   /**< Data word length 24 */
00112     SSIF_CFG_DATA_WORD_32 = 6    /**< Data word length 32 */
00113 } ssif_chcfg_data_word_t;
00114 
00115 /** SSICR:SWL(System word length) */
00116 typedef enum
00117 {
00118     SSIF_CFG_SYSTEM_WORD_8   = 0,    /**< System word length 8   */
00119     SSIF_CFG_SYSTEM_WORD_16  = 1,    /**< System word length 16  */
00120     SSIF_CFG_SYSTEM_WORD_24  = 2,    /**< System word length 24  */
00121     SSIF_CFG_SYSTEM_WORD_32  = 3,    /**< System word length 32  */
00122     SSIF_CFG_SYSTEM_WORD_48  = 4,    /**< System word length 48  */
00123     SSIF_CFG_SYSTEM_WORD_64  = 5,    /**< System word length 64  */
00124     SSIF_CFG_SYSTEM_WORD_128 = 6,    /**< System word length 128 */
00125     SSIF_CFG_SYSTEM_WORD_256 = 7     /**< System word length 256 */
00126 } ssif_chcfg_system_word_t;
00127 
00128 /** SSICR:SCKP(Clock polarity) */
00129 typedef enum
00130 {
00131     SSIF_CFG_FALLING = 0,    /**< Falling edge */
00132     SSIF_CFG_RISING  = 1     /**< Rising edge  */
00133 } ssif_chcfg_clock_pol_t;
00134 
00135 /** SSICR:SWSP(Word select polarity) */
00136 typedef enum
00137 {
00138     SSIF_CFG_WS_LOW  = 0,    /**< Low for ther 1st channel(not TDM) */
00139     SSIF_CFG_WS_HIGH = 1     /**< High for the 1st channel(not TDM) */
00140 } ssif_chcfg_ws_pol_t;
00141 
00142 /** SSICR:SPDP(Serial padding polarity) */
00143 typedef enum
00144 {
00145     SSIF_CFG_PADDING_LOW  = 0,   /**< Padding bits are low  */
00146     SSIF_CFG_PADDING_HIGH = 1    /**< Padding bits are high */
00147 } ssif_chcfg_padding_pol_t;
00148 
00149 /** SSICR:SDTA(Serial data alignment) */
00150 typedef enum
00151 {
00152     SSIF_CFG_DATA_FIRST    = 0,  /**< Data first         */
00153     SSIF_CFG_PADDING_FIRST = 1   /**< Padding bits first */
00154 } ssif_chcfg_serial_alignment_t;
00155 
00156 /** SSICR:PDTA(Parallel data alignment) */
00157 typedef enum
00158 {
00159     SSIF_CFG_LEFT  = 0,  /**< Left aligned  */
00160     SSIF_CFG_RIGHT = 1   /**< Right aligned */
00161 } ssif_chcfg_parallel_alignment_t;
00162 
00163 /** SSICR:DEL(Serial data delay) */
00164 typedef enum
00165 {
00166     SSIF_CFG_DELAY    = 0,   /**< 1 clock delay */
00167     SSIF_CFG_NO_DELAY = 1    /**< No delay      */
00168 } ssif_chcfg_ws_delay_t;
00169 
00170 /** SSICR:CKDV(Serial oversampling clock division ratio) */
00171 typedef enum
00172 {
00173     SSIF_CFG_CKDV_BITS_1   = 0,
00174     SSIF_CFG_CKDV_BITS_2   = 1,
00175     SSIF_CFG_CKDV_BITS_4   = 2,
00176     SSIF_CFG_CKDV_BITS_8   = 3,
00177     SSIF_CFG_CKDV_BITS_16  = 4,
00178     SSIF_CFG_CKDV_BITS_32  = 5,
00179     SSIF_CFG_CKDV_BITS_64  = 6,
00180     SSIF_CFG_CKDV_BITS_128 = 7,
00181     SSIF_CFG_CKDV_BITS_6   = 8,
00182     SSIF_CFG_CKDV_BITS_12  = 9,
00183     SSIF_CFG_CKDV_BITS_24  = 10,
00184     SSIF_CFG_CKDV_BITS_48  = 11,
00185     SSIF_CFG_CKDV_BITS_96  = 12
00186 } ssif_chcfg_ckdv_t;
00187 
00188 
00189 /** SNCR:SSIxNL(Serial sound interface channel x noise canceler enable) */
00190 typedef enum
00191 {
00192     SSIF_CFG_DISABLE_NOISE_CANCEL = 0, /**< Not use noise cancel function */
00193     SSIF_CFG_ENABLE_NOISE_CANCEL  = 1  /**< Use noise cancel function     */
00194 } ssif_chcfg_noise_cancel_t;
00195 
00196 
00197 /** SSITDMR:TDM(TDM mode) */
00198 typedef enum
00199 {
00200     SSIF_CFG_DISABLE_TDM = 0,   /**< not TDM mode */
00201     SSIF_CFG_ENABLE_TDM  = 1    /**< set TDM mode */
00202 } ssif_chcfg_tdm_t;
00203 
00204 /******************************************************************************
00205  Structures
00206  *****************************************************************************/
00207 
00208 #if defined(TARGET_RZA1H) /* mbed */
00209 typedef struct
00210 {
00211     uint32_t    mode;               /* Enable/Disable SSIRDR->STRMDIN0 route */
00212     void        (*p_cbfunc)(void);  /* SSIF error callback function          */
00213 } ssif_chcfg_romdec_t;
00214 
00215 #endif /* mbed */
00216 /**< This structure contains the configuration settings */
00217 typedef struct
00218 {
00219     bool_t                          enabled;             /* The enable flag for the channel       */
00220     uint8_t                         int_level;           /* Interrupt priority for the channel    */
00221     bool_t                          slave_mode;          /* Mode of operation                     */
00222     uint32_t                        sample_freq;         /* Audio Sampling frequency(Hz)          */
00223     ssif_chcfg_cks_t                clk_select;          /* SSICR-CKS : Audio clock select        */
00224     ssif_chcfg_multi_ch_t           multi_ch;            /* SSICR-CHNL: Audio channels per system word */
00225     ssif_chcfg_data_word_t          data_word;           /* SSICR-DWL : Data word length          */
00226     ssif_chcfg_system_word_t        system_word;         /* SSICR-SWL : System word length        */
00227     ssif_chcfg_clock_pol_t          bclk_pol;            /* SSICR-SCKP: Bit Clock polarity        */
00228     ssif_chcfg_ws_pol_t             ws_pol;              /* SSICR-SWSP: Word Clock polarity       */
00229     ssif_chcfg_padding_pol_t        padding_pol;         /* SSICR-SPDP: Padding polarity          */
00230     ssif_chcfg_serial_alignment_t   serial_alignment;    /* SSICR-SDTA: Serial data alignment     */
00231     ssif_chcfg_parallel_alignment_t parallel_alignment;  /* SSICR-PDTA: Parallel data alignment   */
00232     ssif_chcfg_ws_delay_t           ws_delay;            /* SSICR-DEL : Serial clock delay        */
00233     ssif_chcfg_noise_cancel_t       noise_cancel;        /* GPIO-SNCR : Noise cancel              */
00234     ssif_chcfg_tdm_t                tdm_mode;            /* SSITDMR-TDM: TDM mode                 */
00235 #if defined(TARGET_RZA1H) /* mbed */
00236     ssif_chcfg_romdec_t             romdec_direct;       /* DMA : SSIRDR->STRMDIN0 route settings */
00237 #endif /* mbed */
00238 } ssif_channel_cfg_t;
00239 
00240 /******************************************************************************
00241  IOCTLS
00242  *****************************************************************************/
00243 
00244 #define SSIF_CONFIG_CHANNEL        (7)
00245 #define SSIF_GET_STATUS           (13)
00246 
00247 
00248 /******************************************************************************
00249  External Data
00250  *****************************************************************************/
00251 
00252 
00253 /******************************************************************************
00254  Function Prototypes
00255  *****************************************************************************/
00256 /**
00257 * @ingroup API
00258 *
00259 * This function returns a pointer to the function table of the SSIF driver.
00260 * This is intended to be used as a parameter in the ioif_start_device function.
00261 *
00262 * @retval IOIF_DRV_API* - Pointer to the table of functions supported by the
00263 * driver.
00264 *
00265 */
00266 extern IOIF_DRV_API *R_SSIF_MakeCbTbl(void);
00267 #endif /* end mbed */
00268 
00269 extern int_t R_SSIF_SWLtoLen(const ssif_chcfg_system_word_t ssicr_swl);
00270 
00271 extern int_t R_SSIF_Userdef_InitPinMux(const uint32_t ssif_ch);
00272 extern int_t R_SSIF_Userdef_SetClockDiv(const ssif_channel_cfg_t* const p_ch_cfg, ssif_chcfg_ckdv_t* const p_clk_div);
00273 
00274 extern uint16_t R_SSIF_GetVersion(void);
00275 
00276 #ifdef __cplusplus
00277 }
00278 #endif
00279 
00280 #endif /* SSIF_IF_H */
00281 /*EOF*/
00282