RZ/A1H CMSIS-RTOS RTX BSP for GR-PEACH.

Dependents:   GR-PEACH_Azure_Speech ImageZoomInout_Sample ImageRotaion_Sample ImageScroll_Sample ... more

Fork of R_BSP by Daiki Kato

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers R_BSP_Scux.h Source File

R_BSP_Scux.h

Go to the documentation of this file.
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) 2015 Renesas Electronics Corporation. All rights reserved.
00022 *******************************************************************************/
00023 /**************************************************************************//**
00024 * @file          R_BSP_Scux.h
00025 * @brief         SCUX API
00026 ******************************************************************************/
00027 
00028 #ifndef R_BSP_SCUX_H
00029 #define R_BSP_SCUX_H
00030 
00031 #include "R_BSP_SerialFamily.h"
00032 #include "R_BSP_ScuxDef.h"
00033 
00034 #define SAMPLING_RATE_8000HZ  (8000U)  /* Selects a sampling rate of 8 kHz. */
00035 #define SAMPLING_RATE_11025HZ (11025U) /* Selects a sampling rate of 11.025 kHz. */
00036 #define SAMPLING_RATE_12000HZ (12000U) /* Selects a sampling rate of 12 kHz. */
00037 #define SAMPLING_RATE_16000HZ (16000U) /* Selects a sampling rate of 16 kHz. */
00038 #define SAMPLING_RATE_22050HZ (22050U) /* Selects a sampling rate of 22.05 kHz. */
00039 #define SAMPLING_RATE_24000HZ (24000U) /* Selects a sampling rate of 24 kHz. */
00040 #define SAMPLING_RATE_32000HZ (32000U) /* Selects a sampling rate of 32 kHz. */
00041 #define SAMPLING_RATE_44100HZ (44100U) /* Selects a sampling rate of 44.1 kHz. */
00042 #define SAMPLING_RATE_48000HZ (48000U) /* Selects a sampling rate of 48 kHz. */
00043 #define SAMPLING_RATE_64000HZ (64000U) /* Selects a sampling rate of 64 kHz. */
00044 #define SAMPLING_RATE_88200HZ (88200U) /* Selects a sampling rate of 88.2 kHz. */
00045 #define SAMPLING_RATE_96000HZ (96000U) /* Selects a sampling rate of 96 kHz. */
00046 #define SELECT_IN_DATA_CH_0   (0U)     /* Specifies audio channel 0ch. */
00047 #define SELECT_IN_DATA_CH_1   (1U)     /* Specifies audio channel 1ch. */
00048 
00049 /** SRC parameter information */
00050 typedef struct
00051 {
00052     bool                  src_enable;                       /**< SRC function enable setting */
00053     scux_data_word_len_t  word_len;                         /**< Word length of the audio data to be used
00054                                                                  by the SRC. */
00055     bool                  mode_sync;                        /**< Synchronization mode */
00056     uint32_t              input_rate;                       /**< Input sampling rate */
00057     uint32_t              output_rate;                      /**< Output sampling rate */
00058     uint32_t              select_in_data_ch[SCUX_USE_CH_2]; /**< For SRC's input data position swapping */
00059 } scux_src_usr_cfg_t;
00060 
00061 /** The SCUX module is made up of a sampling rate converter, a digital volume unit, and a mixer.
00062  *  The SCUX driver can perform asynchronous and synchronous sampling rate conversions using the sampling rate
00063  *  converter. 
00064  *  The SCUX driver uses the DMA transfer mode to input and output audio data.
00065  */
00066 class R_BSP_Scux : public R_BSP_SerialFamily {
00067 
00068 public:
00069     /** Constructor: Initializes and opens the channel designated by the SCUX driver.
00070      *
00071      * @param channel SCUX channel number
00072      * @param int_level Transfer interrupt priority level (0x00-0xF7; default = 0x80)
00073      * @param max_write_num Maximum number of writes (1 to 128; default = 16)
00074      * @param max_read_num Maximum number of reads (1 to 128; default = 16)
00075      */
00076     R_BSP_Scux(scux_ch_num_t channel, uint8_t int_level = 0x80, int32_t max_write_num = 16, int32_t max_read_num = 16);
00077 
00078     /** Destructor: Closes the channel designated by the SCUX driver and exits.
00079      *
00080      */
00081     virtual ~R_BSP_Scux(void);
00082 
00083     /** Sets up the SCUX HW and starts operation, then starts accepting write/read requests.
00084      * Allocates a DMA channel for read requests.
00085      * The function also initializes the SCUX HW error state.
00086      *
00087      * @return Returns true if the function is successful. Returns false if the function fails.
00088      */
00089     bool TransStart(void);
00090 
00091     /** Stops accepting write/read requests, flushes out all data in the SCUX that is requested for transfer,
00092      *  then stops the HW operation.
00093      *   If a transfer request is being processed, the function stops accepting write/read requests,
00094      *   then performs preprocessing to stop the HW operation after flushing out all data in the SCUX
00095      *   that is requested for transfer. 
00096      *   If no transfer request is being processed, the function stops accepting write/read requests 
00097      *   before stopping the HW operation.
00098      * The function releases the DMA channel for read requests when the HW operation is stopped.
00099      * It also calls the user-own callback function at the end of the transfer.
00100      *
00101      * @param callback Pointer to the callback function
00102      *                 The SCUX driver places an error code indicating the execution result of FlushStop 
00103      *                 in the argument of the callback function before calling the callback function. 
00104      *                 The error code is set to 0 if FlushStop is successful. A negative number is set 
00105      *                 if FlushStop fails.
00106      * @return Returns true if the function is successful. Returns false if the function fails.
00107      */
00108     bool FlushStop(void (* const callback)(int32_t));
00109 
00110     /** Discards all data in the SCUX that is requested for transfer before stopping the hardware operation
00111      *  and stops accepting write/read requests. 
00112      *  The function releases the DMA channel for read requests when the HW operation is stopped.
00113      *
00114      * @return Returns true if the function is successful. Returns false if the function fails.
00115      */
00116     bool ClearStop(void);
00117 
00118     /** Sets up SRC parameters.
00119      *
00120      * @param p_src_param SRC parameter information
00121      * @return Returns true if the function is successful. Returns false if the function fails.
00122      */
00123     bool SetSrcCfg(const scux_src_usr_cfg_t * const p_src_param);
00124 
00125     /** Obtains the state information of the write request.
00126      *
00127      * @param p_write_stat Status of the write request
00128      *        SCUX_STAT_STOP (0)  Acceptance of requests is stopped.
00129      *        SCUX_STAT_IDLE (1)  Processing of all requests is completed and waiting for a request.
00130      *        SCUX_STAT_TRANS(2)  Transfer in progress
00131      * @return Returns true if the function is successful. Returns false if the function fails.
00132      */
00133     bool GetWriteStat(uint32_t * const p_write_stat);
00134 
00135     /** Obtains the state information of the read request.
00136      *
00137      * @param p_read_stat ead request state
00138      *        SCUX_STAT_STOP (0)  Acceptance of requests is stopped
00139      *        SCUX_STAT_IDLE (1)  Processing of all requests is completed and waiting for a request.
00140      *        SCUX_STAT_TRANS(2)  Transfer in progress
00141      * @return Returns true if the function is successful. Returns false if the function fails.
00142      */
00143     bool GetReadStat(uint32_t * const p_read_stat);
00144 
00145 private:
00146     int32_t scux_ch;
00147 };
00148 #endif /* R_BSP_SCUX_H */