sd + skpeaker
Dependencies: ST_I2S X_NUCLEO_COMMON
Fork of X_NUCLEO_CCA01M1 by
Revision 0:542c79e7e0ef, committed 2017-02-10
- Comitter:
- davide.aliprandi@st.com
- Date:
- Fri Feb 10 17:29:23 2017 +0100
- Child:
- 1:097d364116d1
- Commit message:
- First version of the library.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/Common/component.h Fri Feb 10 17:29:23 2017 +0100
@@ -0,0 +1,93 @@
+/**
+ ******************************************************************************
+ * @file component.h
+ * @author AST
+ * @version V1.0.0
+ * @date 1 April 2015
+ * @brief Generic header file containing a generic component's definitions
+ * and I/O functions.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
+ *
+ * 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. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
+ *
+ ******************************************************************************
+ */
+
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+
+#ifndef __COMPONENT_H
+#define __COMPONENT_H
+
+
+/* Types ---------------------------------------------------------------------*/
+
+/**
+ * @brief Component's Context structure definition.
+ */
+typedef struct
+{
+ /* Identity. */
+ uint8_t who_am_i;
+
+ /* ACTION ----------------------------------------------------------------*/
+ /* There should be only a unique identifier for each component, which */
+ /* should be the "who_am_i" parameter, hence this parameter is optional. */
+ /* -----------------------------------------------------------------------*/
+ /* Type. */
+ uint8_t type;
+
+ /* Configuration. */
+ uint8_t address;
+
+ /* Pointer to the Data. */
+ void *pData;
+
+ /* Pointer to the Virtual Table. */
+ void *pVTable;
+
+ /* ACTION ----------------------------------------------------------------*/
+ /* There should be only a unique virtual table for each component, which */
+ /* should be the "pVTable" parameter, hence this parameter is optional. */
+ /* -----------------------------------------------------------------------*/
+ /* Pointer to the Extended Virtual Table. */
+ void *pExtVTable;
+} Handle_t;
+
+/**
+ * @brief Component's Status enumerator definition.
+ */
+typedef enum
+{
+ COMPONENT_OK = 0,
+ COMPONENT_ERROR,
+ COMPONENT_TIMEOUT,
+ COMPONENT_NOT_IMPLEMENTED
+} Status_t;
+
+#endif /* __COMPONENT_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/Common/sound_terminal.h Fri Feb 10 17:29:23 2017 +0100
@@ -0,0 +1,103 @@
+/**
+ ******************************************************************************
+ * @file sound_terminal.h
+ * @author Central Labs
+ * @version V1.0.0
+ * @date 18-August-2015
+ * @brief This file contains all the functions prototypes for the Sound Terminal driver.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
+ *
+ * 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. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
+ *
+ ******************************************************************************
+ */
+
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+
+#ifndef __SOUND_TERMINAL_H
+#define __SOUND_TERMINAL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Includes ------------------------------------------------------------------*/
+
+#include "component.h"
+#include <stdint.h>
+
+
+/** @addtogroup BSP
+ * @{
+ */
+
+/** @addtogroup Components
+ * @{
+ */
+
+/** @addtogroup SOUND_TERMINAL
+ * @{
+ */
+
+/** @defgroup SOUND_TERMINAL_Exported_Types
+ * @{
+ */
+
+/**
+* @brief SoundTerminal driver structure definition
+*/
+typedef struct
+{
+ /* General */
+ Status_t (*Init)(void *handle, void *init);
+ Status_t (*ReadID)(void *handle, uint8_t *id);
+ int32_t (*DeInit)(void);
+
+ /* Specific */
+ int32_t (*Play)(uint16_t *pData, uint16_t size);
+ int32_t (*Pause)(void);
+ int32_t (*Resume)(void);
+ int32_t (*Stop)(void);
+ int32_t (*PowerOn)(void);
+ int32_t (*PowerOff)(void);
+ int32_t (*Reset)(void);
+ int32_t (*SetEq)(uint8_t ram_block, uint8_t filter_number, uint32_t *filter_values);
+ int32_t (*SetTone)(uint8_t tone_gain);
+ int32_t (*SetMute)(uint8_t channel, uint8_t state);
+ int32_t (*SetVolume)(uint8_t channel, uint8_t value);
+ int32_t (*SetFrequency)(uint32_t audio_freq);
+ int32_t (*SetDSPOption)(uint8_t option, uint8_t state);
+} SOUND_TERMINAL_VTable_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SOUND_TERMINAL_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/Interfaces/ComponentObject.h Fri Feb 10 17:29:23 2017 +0100
@@ -0,0 +1,75 @@
+/**
+ ******************************************************************************
+ * @file ComponentObject.h
+ * @author AST
+ * @version V1.0.0
+ * @date April 13th, 2015
+ * @brief This file contains the abstract class describing the interface of a
+ * generic component.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
+ *
+ * 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. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
+ *
+ ******************************************************************************
+ */
+
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+
+#ifndef __COMPONENT_OBJECT_CLASS_H
+#define __COMPONENT_OBJECT_CLASS_H
+
+
+/* Includes ------------------------------------------------------------------*/
+
+#include <stdint.h>
+
+
+/* Classes ------------------------------------------------------------------*/
+
+/** An abstract class for Generic components.
+ */
+class ComponentObject
+{
+public:
+ /**
+ * @brief Initializing the component.
+ * @param[in] init pointer to device specific initalization structure.
+ * @retval "0" in case of success, an error code otherwise.
+ */
+ virtual int Init(void *init) = 0;
+
+ /**
+ * @brief Getting the ID of the component.
+ * @param[out] id pointer to an allocated variable to store the ID into.
+ * @retval "0" in case of success, an error code otherwise.
+ */
+ virtual int ReadID(uint8_t *id) = 0;
+};
+
+#endif /* __COMPONENT_OBJECT_CLASS_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/Interfaces/SoundTerminal.h Fri Feb 10 17:29:23 2017 +0100
@@ -0,0 +1,89 @@
+/**
+ ******************************************************************************
+ * @file SoundTerminal.h
+ * @author AST
+ * @version V1.0.0
+ * @date April 13th, 2015
+ * @brief This file contains the abstract class describing the interface of a
+ * sound_terminal component.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
+ *
+ * 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. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
+ *
+ ******************************************************************************
+ */
+
+
+/* Generated with STM32CubeTOO -----------------------------------------------*/
+
+
+/* Revision ------------------------------------------------------------------*/
+/*
+ Repository: http://svn.x-nucleodev.codex.cro.st.com/svnroot/X-NucleoDev
+ Branch/Trunk/Tag: trunk
+ Based on: X-CUBE-SOUNDTER1/trunk/Drivers/BSP/Components/Common/sound_terminal.h
+ Revision: 0
+*/
+
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+
+#ifndef __SOUND_TERMINAL_CLASS_H
+#define __SOUND_TERMINAL_CLASS_H
+
+
+/* Includes ------------------------------------------------------------------*/
+
+#include "ComponentObject.h"
+
+
+/* Classes ------------------------------------------------------------------*/
+
+/** An abstract class for SoundTerminal components.
+ */
+class SoundTerminal : public ComponentObject
+{
+public:
+ /* ACTION 1 --------------------------------------------------------------*
+ * Declare here the interface's methods. *
+ * They should be: *
+ * + Methods with the same name of the C component's virtual table *
+ * (and extended virtual table, if any)'s functions, provided that *
+ * the component's driver implements them (i.e.: the corresponding *
+ * pointer to function is not "0"). *
+ * *
+ * Example: *
+ * virtual int GetValue(float *f) = 0; *
+ *------------------------------------------------------------------------*/
+ virtual int32_t Play(int16_t *pData, uint16_t Size, bool loop) = 0;
+ virtual int32_t Stop(void) = 0;
+ virtual int32_t SetVolume(uint8_t channel, uint8_t value) = 0;
+ virtual int32_t SetFrequency(uint32_t audio_freq) = 0;
+};
+
+#endif /* __SOUND_TERMINAL_CLASS_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/sta350bw/sta350bw.h Fri Feb 10 17:29:23 2017 +0100
@@ -0,0 +1,1005 @@
+/**
+******************************************************************************
+* @file STA350BW.h
+* @author Central Labs
+* @version V1.0.0
+* @date 18-August-2015
+* @brief This file contains definitions for STA350BW.c
+* firmware driver.
+******************************************************************************
+* @attention
+*
+* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
+*
+* 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. Neither the name of STMicroelectronics nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
+*
+******************************************************************************
+*/
+
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+
+#ifndef __STA350BW_H
+#define __STA350BW_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Includes ------------------------------------------------------------------*/
+
+#include "../Common/sound_terminal.h"
+
+ /** @addtogroup BSP
+ * @{
+ */
+
+ /** @addtogroup Components
+ * @{
+ */
+
+ /** @addtogroup STA350BW
+ * @{
+ */
+
+
+ /** @defgroup STA350BW_Exported_Constants
+ * @{
+ */
+
+ /** @defgroup STA350BW_Registers_Mapping
+ * @brief STA350BW register mapping
+ * @{
+ */
+
+#define STA350BW_MAX_REGISTERS ((uint8_t)0x56)
+
+ /**
+ * @brief Configuration Register A
+ * \code
+ * Read/Write
+ * Default value: 0x63
+ * 7 FAULT detect recovery bypass
+ * 6 TWAB Thermal warning adjustable bypass
+ * 5 TWRB Thermal warning recovery bypass
+ * 4,3 IR Interpolatio ratio
+ * [2:0] MCS Master clock selection
+ * \endcode
+ */
+#define STA350BW_CONF_REGA ((uint8_t)0x00) /*Configuration Register A*/
+
+ /**
+ * @brief Configuration Register B
+ * \code
+ * Read/Write
+ * Default value: 0x80
+ * 7 C2IM channel 2 input mapping
+ * 6 C2IM channel 1 input mapping
+ * 5 DSCKE Delay serial clock enable
+ * 4 SAIFB Serial data first bit
+ * [3:0] Serial Input interface format
+ * \endcode
+ */
+#define STA350BW_CONF_REGB ((uint8_t)0x01) /*Configuration Register B*/
+
+
+ /**
+ * @brief Configuration Register C
+ * \code
+ * Read/write
+ * Default value: 0x09F
+ * 7 OCRB Overcurrent warning adjustment bypass
+ * [5:2] CSZx: FFX compensating pulse size
+ * [1:0] OMx: FFX Output mode
+ * 0 Clk_Out: Enable HSE on MCO. 0: MCO disable. 1: MCO enable
+ * \endcode
+ */
+#define STA350BW_CONF_REGC ((uint8_t)0x02) /*Configuration Register C*/
+
+ /**
+ * @brief I2C address Configuration Register D
+ * \code
+ * Read/write
+ * Default value: 0x40
+ * 7 SME soft mute enable
+ * 6 ZDE zero detect enable
+ * 5 DRC DRC or anti-clipping mode
+ * 4 BQL Biquad Link
+ * 3 PSL Post scale Link
+ * 2 DSPB DSP bypass
+ * 1 DEMP De-Emphasys filter
+ * 0 HPB High pass filter bypass
+ * \endcode
+ */
+#define STA350BW_CONF_REGD ((uint8_t)0x03) /*Configuration Register D*/
+
+ /**
+ * @brief I2C address Configuration Register E
+ * \code
+ * Read/write
+ * Default value: 0xC2
+ * 7 SVE soft volume enable
+ * 6 ZCE zero crossing enable
+ * 5 DCCV variable distorsion compensation
+ * 4 PWMS PWM speed
+ * 3 AME AM noise reduction enable
+ * 2 NSBW Noise shaper bandwidth
+ * 1 MPC Max Power correction
+ * 0 MPCV Variable ax power correction
+ * \endcode
+ */
+#define STA350BW_CONF_REGE ((uint8_t)0x04) /*Configuration Register E*/
+
+ /**
+ * @brief I2C address Configuration Register F
+ * \code
+ * Read/write
+ * Default value: 0x5C
+ * 7 EAPD External Amplifier Power Down
+ * 6 PWDN device power down
+ * 5 ECLE Auto EAPD on clock loss
+ * 4 LDTE LRCK double trigger protection
+ * 3 BCLE Binary out mode clock loss detection
+ * 2 IDE Invalid Input Detect
+ * 1,0 OCFG Output configuration
+ * \endcode
+ */
+#define STA350BW_CONF_REGF ((uint8_t)0x05) /*Configuration Register F*/
+
+ /**
+ * @brief I2C address MUTE/Line Out configuration
+ * \code
+ * Read/write
+ * Default value: 0x10
+ * [7:6] LOC line out configuration
+ * [5:4] RESERVED
+ * 3 C3M Channel 3 MUTE
+ * 2 C2M Channel 2 MUTE
+ * 1 C1M Channel 1 MUTE
+ * 0 MMUTE Master Mute
+ * \endcode
+ */
+#define STA350BW_MUTE ((uint8_t)0x06) /* MUTE / Lineout configuration */
+
+ /**
+ * @brief I2C address Master Volume
+ * \code
+ * Read/write
+ * Default value: 0xFF
+ * [7:0] Master volume (default -127.5dB)
+ * \endcode
+ */
+#define STA350BW_MVOL ((uint8_t)0x07) /* Master Volume */
+
+ /**
+ * @brief I2C address Channel 1 Volume
+ * \code
+ * Read/write
+ * Default value: 0x60
+ * [7:0] Master volume (default 0.0dB)
+ * \endcode
+ */
+#define STA350BW_C1VOL ((uint8_t)0x08) /* Channel 1 volume */
+
+ /**
+ * @brief I2C address Channel 2 Volume
+ * \code
+ * Read/write
+ * Default value: 0x60
+ * [7:0] Master volume (default 0.0dB)
+ * \endcode
+ */
+#define STA350BW_C2VOL ((uint8_t)0x09) /* Channel 2 volume */
+
+ /**
+ * @brief I2C address Channel 3 Volume
+ * \code
+ * Read/write
+ * Default value: 0x60
+ * [7:0] Master volume (default 0.0dB)
+ * \endcode
+ */
+#define STA350BW_C3VOL ((uint8_t)0x0A) /* Channel 3 volume */
+
+ /**
+ * @brief I2C address AUTO MODE 1
+ * \code
+ * Read/write
+ * Default value: 0x80
+ * [7:6] RESERVED
+ * [5:4] AMGC Audio Preset Gain compression
+ * [3:0] RESERVED
+ * \endcode
+ */
+#define STA350BW_AUTO1 ((uint8_t)0x0B) /* Audio Preset 1 register */
+
+ /**
+ * @brief I2C address AUTO MODE 2
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:4] XO preset crossover filter
+ * [3:1] AMAMx AM atomode settings
+ * 0 AMAME AM automode enable
+ * \endcode
+ */
+#define STA350BW_AUTO2 ((uint8_t)0x0C) /* Audio Preset 2 register */
+
+ /**
+ * @brief I2C address Channel 1 configuration register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * 7,6 C1OM Channel 1 output mapping
+ * 5,4 C1LS Channel 1 limiter mapping
+ * 3 C1BO Channel 1 Binary output
+ * 2 C1VPB Channel 1 volume bypass
+ * 1 C1EQBP Channel 1 Equalization Bypass
+ * 0 C1TCB Channel 1 Tone/Control Bypass
+ * \endcode
+ */
+#define STA350BW_C1CFG ((uint8_t)0x0E) /* Channel 1 configuration register */
+
+ /**
+ * @brief I2C address Channel 2 configuration register
+ * \code
+ * Read/write
+ * Default value: 0x40
+ * 7,6 C2OM Channel 2 output mapping
+ * 5,4 C2LS Channel 2 limiter mapping
+ * 3 C2BO Channel 2 Binary output
+ * 2 C2VPB Channel 2 volume bypass
+ * 1 C2EQBP Channel 2 Equalization Bypass
+ * 0 C2TCB Channel 2 Tone/Control Bypass
+ * \endcode
+ */
+#define STA350BW_C2CFG ((uint8_t)0x0F) /* Channel 2 configuration register */
+
+ /**
+ * @brief I2C address Channel 3 configuration register
+ * \code
+ * Read/write
+ * Default value: 0x80
+ * 7,6 C2OM Channel 3 output mapping
+ * 5,4 C2LS Channel 3 limiter mapping
+ * 3 C2BO Channel 3 Binary output
+ * 2 C2VPB Channel 3 volume bypass
+ * 1,0 RESERVED
+ * \endcode
+ */
+#define STA350BW_C3CFG ((uint8_t)0x10) /* Channel 3 configuration register */
+
+ /**
+ * @brief I2C address Tone control register
+ * \code
+ * Read/write
+ * Default value: 0x77
+ * [7:4] Treble
+ * [3:0] Bass
+ * \endcode
+ */
+#define STA350BW_TONE ((uint8_t)0x11) /* Tone control register */
+
+ /**
+ * @brief I2C address Limiter 1 Attack/Release rate register
+ * \code
+ * Read/write
+ * Default value: 0x6A
+ * [7:4] Limiter 1 Attack rate
+ * [3:0] Limiter 1 release rate
+ * \endcode
+ */
+#define STA350BW_L1AR ((uint8_t)0x12) /* Limiter 1 Attack/Release rate register */
+
+ /**
+ * @brief I2C address Limiter 1 Attack/Release threshold register
+ * \code
+ * Read/write
+ * Default value: 0x69
+ * [7:4] Limiter 1 Attack threshold
+ * [3:0] Limiter 1 release threshold
+ * \endcode
+ */
+#define STA350BW_L1ATR ((uint8_t)0x13) /* Limiter 1 Attack/Release threshold register */
+
+ /**
+ * @brief I2C address Limiter 2 Attack/Release rate register
+ * \code
+ * Read/write
+ * Default value: 0x6A
+ * [7:4] Limiter 2 Attack rate
+ * [3:0] Limiter 2 Release rate
+ * \endcode
+ */
+#define STA350BW_L2AR ((uint8_t)0x14) /* Limiter 2 Attack/Release rate register */
+
+ /**
+ * @brief I2C address Limiter 2 Attack/Release threshold register
+ * \code
+ * Read/write
+ * Default value: 0x69
+ * [7:4] Limiter 2 Attack threshold
+ * [3:0] Limiter 2 release threshold
+ * \endcode
+ */
+#define STA350BW_L2ATR ((uint8_t)0x15) /* Limiter 2 Attack/Release threshold register */
+
+ /* RAM download*/
+
+ /**
+ * @brief I2C address Coefficient address register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:6] RESERVED
+ * [5:0] RAM address
+ * \endcode
+ */
+#define STA350BW_CFADDR ((uint8_t)0x16) /* Coefficient address register */
+
+ /**
+ * @brief I2C address Coefficient b1 data register bits 23:16
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:0] coefficient b1 bits 23:16
+ * \endcode
+ */
+#define STA350BW_B1CF1 ((uint8_t)0x17) /* Coefficient b1 data register bits 23:16 */
+
+ /**
+ * @brief I2C address Coefficient b1 data register bits 15:8
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:0] coefficient b1 bits 15:8
+ * \endcode
+ */
+#define STA350BW_B1CF2 ((uint8_t)0x18) /* Coefficient b1 data register bits 15:8 */
+
+ /**
+ * @brief I2C address Coefficient b1 data register bits 7:0
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:0] coefficient b1 bits 7:0
+ * \endcode
+ */
+#define STA350BW_B1CF3 ((uint8_t)0x19) /* Coefficient b1 data register bits 7:0 */
+
+ /**
+ * @brief I2C address Coefficient b2 data register bits 23:16
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:0] coefficient b2 bits 23:16
+ * \endcode
+ */
+#define STA350BW_B2CF1 ((uint8_t)0x1A) /* Coefficient b2 data register bits 23:16 */
+
+ /**
+ * @brief I2C address Coefficient b2 data register bits 15:8
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:0] coefficient b2 bits 15:8
+ * \endcode
+ */
+#define STA350BW_B2CF2 ((uint8_t)0x1B) /* Coefficient b2 data register bits 15:8 */
+
+ /**
+ * @brief I2C address Coefficient b2 data register bits 7:0
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:0] Coefficient b2 data bits 7:0
+ * \endcode
+ */
+#define STA350BW_B2CF3 ((uint8_t)0x1C) /* Coefficient b2 data register bits 7:0 */
+
+ /**
+ * @brief I2C address Coefficient a1 data register bits 23:16
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:0] Coefficient a1 data bits 23:16
+ * \endcode
+ */
+#define STA350BW_A1CF1 ((uint8_t)0x1D) /* Coefficient a1 data register bits 23:16 */
+
+ /**
+ * @brief I2C address Coefficient a1 data register bits 15:8
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:0] Coefficient a1 data bits 15:8
+ * \endcode
+ */
+#define STA350BW_A1CF2 ((uint8_t)0x1E) /* Coefficient a1 data register bits 15:8 */
+
+ /**
+ * @brief I2C address Coefficient a1 data register bits 7:0
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:0] Coefficient a1 data bits 7:0
+ * \endcode
+ */
+#define STA350BW_A1CF3 ((uint8_t)0x1F) /* Coefficient a1 data register bits 7:0 */
+
+ /**
+ * @brief I2C address Coefficient a2 data register bits 23:16
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:0] Coefficient a2 data bits 23:16
+ * \endcode
+ */
+#define STA350BW_A2CF1 ((uint8_t)0x20) /* Coefficient a2 data register bits 23:16 */
+
+ /**
+ * @brief I2C address Coefficient a2 data register bits 15:8
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:0] Coefficient a2 data bits 15:8
+ * \endcode
+ */
+#define STA350BW_A2CF2 ((uint8_t)0x21) /* Coefficient a2 data register bits 15:8 */
+
+ /**
+ * @brief I2C address Coefficient a2 data register bits 7:0
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:0] Coefficient a2 data bits 7:0
+ * \endcode
+ */
+#define STA350BW_A2CF3 ((uint8_t)0x22) /* Coefficient a2 data register bits 7:0 */
+
+ /**
+ * @brief I2C address Coefficient b0 data register bits 23:16
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:0] coefficient b0 bits 23:16
+ * \endcode
+ */
+#define STA350BW_B0CF1 ((uint8_t)0x23) /* Coefficient b0 data register bits 23:16 */
+
+ /**
+ * @brief I2C address Coefficient b0 data register bits 15:8
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:0] Coefficient b0 data bits 15:8
+ * \endcode
+ */
+#define STA350BW_B0CF2 ((uint8_t)0x24) /* Coefficient b0 data register bits 15:8 */
+
+ /**
+ * @brief I2C address Coefficient b0 data register bits 7:0
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:0] Coefficient b0 data bits 7:0
+ * \endcode
+ */
+#define STA350BW_B0CF3 ((uint8_t)0x25) /* Coefficient b0 data register bits 7:0 */
+
+ /**
+ * @brief I2C address Coefficient write/read control register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:4] RESERVED
+ * 3 RA read a complete set of coefficient
+ * 2 R1 read only one coefficient
+ * 1 WA write a complete set of coefficient
+ * 0 W1 write only one coefficient
+ * \endcode
+ */
+#define STA350BW_CFUD ((uint8_t)0x26) /* Coefficient write/read control register */
+
+
+ /**
+ * @brief I2C address Variable max power correction 15:8
+ * \code
+ * Read/write
+ * Default value: 0x1A
+ * [7:0] Coefficient for Variable max power correction 15:8
+ * \endcode
+ */
+#define STA350BW_MPCC1 ((uint8_t)0x27) /* Variable max power correction 15:8 register*/
+
+ /**
+ * @brief I2C address Variable max power correction 7:0
+ * \code
+ * Read/write
+ * Default value: 0x30
+ * [7:0] Coefficient for Variable max power correction 7:0
+ * \endcode
+ */
+#define STA350BW_MPCC2 ((uint8_t)0x28) /* Variable max power correction 7:0 register*/
+
+ /**
+ * @brief I2C address Variable distortion compensation 15:8
+ * \code
+ * Read/write
+ * Default value: 0xF3
+ * [7:0] Coefficient for Variable distortion compensation 15:8
+ * \endcode
+ */
+#define STA350BW_DCC1 ((uint8_t)0x29) /* Variable distortion compensation 15:8 */
+
+ /**
+ * @brief I2C address Variable distortion compensation 7:0
+ * \code
+ * Read/write
+ * Default value: 0x33
+ * [7:0] Coefficient for Variable distortion compensation 7:0
+ * \endcode
+ */
+#define STA350BW_DCC2 ((uint8_t)0x2A) /* Variable distortion compensation 7:0 */
+
+ /**
+ * @brief I2C address Fault detect recovery constant register 15:8
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:0] Fault detect recovery constant 15:8
+ * \endcode
+ */
+#define STA350BW_FDRC1 ((uint8_t)0x2B) /* Fault detect recovery constant register 15:8 */
+
+ /**
+ * @brief I2C address Fault detect recovery constant register 7:0
+ * \code
+ * Read/write
+ * Default value: 0xC0
+ * [7:0] Fault detect recovery constant 7:0
+ * \endcode
+ */
+#define STA350BW_FDRC2 ((uint8_t)0x2C) /* Fault detect recovery constant register 7:0 */
+
+ /**
+ * @brief I2C address Status Register
+ * \code
+ * Read
+ * Default value: 0x7F
+ * 7 PLLUL PLL unlock
+ * 6 FAULT Fault detected on bridge
+ * 5 UVFAULT undervoltage fault
+ * 4 OVFAULT overvoltage fault
+ * 3 OCFAULT overcurrent fault
+ * 2 OCWARN overcurrent warning
+ * 1 TFAULT Thermal fault
+ * 0 TWARN thermal warning
+ * \endcode
+ */
+#define STA350BW_STATUS ((uint8_t)0x2D) /* Status Register */
+
+ /**
+ * @brief I2C address EQ coefficients and DRC configuration register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * 7 XOB Crossover filter bypass
+ * [6:5] RESERVED
+ * [4:3] AMGC Anti-clipping and DRC preset
+ * 2 RESERVED
+ * [1:0] EQ RAM bank selector
+ * \endcode
+ */
+#define STA350BW_EQCFG ((uint8_t)0x31) /* EQ coefficients and DRC configuration register */
+
+ /**
+ * @brief I2C address Limiter 1 extended attack threshold register
+ * \code
+ * Read/write
+ * Default value: 0x30
+ * 7 EATHEN1 Limiter 1 Extended Attack threshold enable
+ * [6:0] EATH1 Limiter 1 Extended Attack threshold
+ * \endcode
+ */
+#define STA350BW_EATH1 ((uint8_t)0x32) /* Limiter 1 extended attack threshold register */
+
+ /**
+ * @brief I2C address Limiter 1 extended release threshold register
+ * \code
+ * Read/write
+ * Default value: 0x30
+ * 7 ERTHEN1 Limiter 1 Extended Release threshold enable
+ * [6:0] ERTH1 Limiter 1 Extended Release threshold
+ * \endcode
+ */
+#define STA350BW_ERTH1 ((uint8_t)0x33) /* Limiter 1 extended release threshold register */
+
+ /**
+ * @brief I2C address Limiter 2 extended attack threshold register
+ * \code
+ * Read/write
+ * Default value: 0x30
+ * 7 EATHEN2 Limiter 2 Extended Attack threshold enable
+ * [6:0] EATH2 Limiter 2 Extended Attack threshold
+ * \endcode
+ */
+#define STA350BW_EATH2 ((uint8_t)0x34) /* Limiter 2 extended attack threshold register */
+
+ /**
+ * @brief I2C address Limiter 2 extended release threshold register
+ * \code
+ * Read/write
+ * Default value: 0x30
+ * 7 ERTHEN2 Limiter 2 Extended Release threshold enable
+ * [6:0] ERTH2 Limiter 2 Extended Release threshold
+ * \endcode
+ */
+#define STA350BW_ERTH2 ((uint8_t)0x35) /* Limiter 2 extended release threshold register */
+
+ /**
+ * @brief I2C address Extended configuration register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:6] MDRC MDRC or EQ DRC selector
+ * 5 PS48DB Extended post-scale range
+ * 4 Extended attack rate Limiter 1
+ * 3 Extended attack rate Limiter 2
+ * 2 Biquad 5 enable
+ * 1 Biquad 6 enable
+ * 0 Biquad 7 enable
+ * \endcode
+ */
+#define STA350BW_CONFX ((uint8_t)0x36) /* Extended configuration register */
+
+ /**
+ * @brief I2C address soft-volume up configuration register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:6] RESERVED
+ * 5 SVUPE Soft volume up enable
+ * [4:0] SVUP Soft volume up coefficient
+ * \endcode
+ */
+#define STA350BW_SVCA ((uint8_t)0x37) /* soft-volume up configuration register */
+
+ /**
+ * @brief I2C address soft-volume down configuration register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:6] RESERVED
+ * 5 SVDWE Soft volume down enable
+ * [4:0] SVDW Soft volume down coefficient
+ * \endcode
+ */
+#define STA350BW_SVCB ((uint8_t)0x38) /* soft-volume down configuration register */
+
+
+ /**
+ * @brief I2C address DRC RMS filter coefficient c0 23:16 register
+ * \code
+ * Read/write
+ * Default value: 0x01
+ * [7:0] R_C0 DRC RMS filter coefficient c0 23:16
+ * \endcode
+ */
+#define STA350BW_RMS0A ((uint8_t)0x39) /* DRC RMS filter coefficient c0 23:16 register */
+
+ /**
+ * @brief I2C address DRC RMS filter coefficient c0 15:8 register
+ * \code
+ * Read/write
+ * Default value: 0xEE
+ * [7:0] R_C0 DRC RMS filter coefficient c0 15:8
+ * \endcode
+ */
+#define STA350BW_RMS0B ((uint8_t)0x3A) /* DRC RMS filter coefficient c0 15:8 register */
+
+ /**
+ * @brief I2C address DRC RMS filter coefficient c0 7:0 register
+ * \code
+ * Read/write
+ * Default value: 0xFF
+ * [7:0] R_C0 DRC RMS filter coefficient c0 7:0
+ * \endcode
+ */
+#define STA350BW_RMS0C ((uint8_t)0x3B) /* DRC RMS filter coefficient c0 7:0 register */
+
+ /**
+ * @brief I2C address DRC RMS filter coefficient c1 23:16 register
+ * \code
+ * Read/write
+ * Default value: 0x7E
+ * [7:0] R_C1 DRC RMS filter coefficient c0 23:16
+ * \endcode
+ */
+#define STA350BW_RMS1A ((uint8_t)0x3C) /* DRC RMS filter coefficient c1 23:16 register */
+
+ /**
+ * @brief I2C address DRC RMS filter coefficient c1 15:8 register
+ * \code
+ * Read/write
+ * Default value: 0xC0
+ * [7:0] R_C1 DRC RMS filter coefficient c1 15:8
+ * \endcode
+ */
+#define STA350BW_RMS1B ((uint8_t)0x3D) /* DRC RMS filter coefficient c1 15:8 register */
+
+ /**
+ * @brief I2C address DRC RMS filter coefficient c1 7:0 register
+ * \code
+ * Read/write
+ * Default value: 0x26
+ * [7:0] R_C0 DRC RMS filter coefficient c1 7:0
+ * \endcode
+ */
+#define STA350BW_RMS1C ((uint8_t)0x3E) /* DRC RMS filter coefficient c1 7:0 register */
+
+ /**
+ * @brief I2C address Extra volume resolution configuration register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * 7 VRESEN Extra volume resolution enable
+ * 6 VRESTG Extra volume resolution update
+ * [5:4] C3VR Channel 3 extra volume value
+ * [3:2] C2VR Channel 2 extra volume value
+ * [1:0] C1VR Channel 1 extra volume value
+ * \endcode
+ */
+#define STA350BW_EVOLRES ((uint8_t)0x3F) /* Extra volume resolution configuration register */
+
+ /**
+ * @brief I2C address Quantization error noise correction register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * 7 Quntization Noise shaping enable
+ * 6 Quntization Noise shaping on biquad 7
+ * 5 Quntization Noise shaping on biquad 6
+ * 4 Quntization Noise shaping on biquad 5
+ * 3 Quntization Noise shaping on biquad 4
+ * 2 Quntization Noise shaping on biquad 3
+ * 1 Quntization Noise shaping on biquad 2
+ * 0 Quntization Noise shaping on biquad 1
+ * \endcode
+ */
+#define STA350BW_NSHAPE ((uint8_t)0x48) /* Quantization error noise correction register */
+
+ /**
+ * @brief I2C address Extended coefficient range up to -4...4 biquad 1-4 register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:6] CXTB4 Extended coefficient on biquad 4
+ * [5:4] CXTB3 Extended coefficient on biquad 3
+ * [3:2] CXTB2 Extended coefficient on biquad 2
+ * [1:0] CXTB1 Extended coefficient on biquad 1
+ * \endcode
+ */
+#define STA350BW_CXT_B4B1 ((uint8_t)0x49) /* Extended coefficient range up to -4...4 biquad 1-4 register */
+
+ /**
+ * @brief I2C address Extended coefficient range up to -4...4 biquad 5-7 register
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:6] RESERVED
+ * [5:4] CXTB7 Extended coefficient on biquad 7
+ * [3:2] CXTB6 Extended coefficient on biquad 6
+ * [1:0] CXTB5 Extended coefficient on biquad 5
+ * \endcode
+ */
+#define STA350BW_CXT_B7B5 ((uint8_t)0x4A) /* Extended coefficient range up to -4...4 biquad 5-7 register */
+
+ /**
+ * @brief I2C address Miscellaneous register 1
+ * \code
+ * Read/write
+ * Default value: 0x04
+ * 7 RPDNEN Rate powerdown enable
+ * 6 NSHHPEN Noise shaping feature enable
+ * 5 BRIDGOFF Bridge immediate OFF
+ * [4:3] RESERVED
+ * 2 CPWMEN Channel PWM enable
+ * [1:0] RESERVED
+ * \endcode
+ */
+#define STA350BW_MISC1 ((uint8_t)0x4B) /* Miscellaneous register 1 */
+
+ /**
+ * @brief I2C address Miscellaneous register 2
+ * \code
+ * Read/write
+ * Default value: 0x00
+ * [7:5] RESERVED
+ * [4:2] PNDLSL Power-down delay selector
+ * [1:0] RESERVED
+ * \endcode
+ */
+#define STA350BW_MISC2 ((uint8_t)0x4C) /* Miscellaneous register 2 */
+
+ /**
+ * @}
+ */
+
+
+
+ /** @defgroup STA350BW_Main_parameter
+ * @{
+ */
+#define STA350BW_EAPD_ON ((uint8_t)0x80)
+#define STA350BW_EAPD_OFF ((uint8_t)0x00)
+#define STA350BW_PWDN_OFF ((uint8_t)0x40)
+#define STA350BW_PWDN_ON ((uint8_t)0x00) /* low power consumption */
+
+#define STA350BW_MVOL_0dB ((uint8_t)0x00)
+#define STA350BW_MVOL_MUTE ((uint8_t)0xFF)
+ /**
+ * @}
+ */
+
+
+ /** @defgroup STA350BW_Input_frequency_selection
+ * @{
+ */
+#define STA350BW_Fs_32000 ((uint32_t)32000)
+#define STA350BW_Fs_44100 ((uint32_t)44100)
+#define STA350BW_Fs_48000 ((uint32_t)48000)
+#define STA350BW_Fs_88200 ((uint32_t)88200)
+#define STA350BW_Fs_96000 ((uint32_t)96000)
+
+#define STA350BW_MCLK_256_LR_48K ((uint8_t)0x03)
+#define STA350BW_MCLK_128_LR_48K ((uint8_t)0x04)
+#define STA350BW_MCLK_256_LR_96K ((uint8_t)0x09)
+#define STA350BW_MCLK_128_LR_96K ((uint8_t)0x0B)
+ /**
+ * @}
+ */
+
+
+
+
+
+ /** @defgroup STA350BW_mode_selection
+ * @brief STA350BW mode configuration constants
+ * @{
+ */
+#define STA350BW_STEREO_CONF ((uint8_t)0x00)
+#define STA350BW_2SE_1BTL_CONF ((uint8_t)0x01)
+#define STA350BW_STEREO_EXT_BRIDGE_CONF ((uint8_t)0x00)
+#define STA350BW_MONOBTL_CONF ((uint8_t)0x11)
+#define STA350BW_BINARY_CONF ((uint8_t)0x80) /* on registers 0E, 0F, 10 */
+ /**
+ * @}
+ */
+
+ /** @defgroup STA350BW_DSP_option_selection
+ * @brief STA350BW constants related to data path management
+ * @{
+ */
+#define STA350BW_DSPB ((uint8_t)0x00)
+#define STA350BW_C1EQBP ((uint8_t)0x01)
+#define STA350BW_C2EQBP ((uint8_t)0x02)
+#define STA350BW_C1TCB ((uint8_t)0x03)
+#define STA350BW_C2TCB ((uint8_t)0x04)
+#define STA350BW_C1VBP ((uint8_t)0x05)
+#define STA350BW_C2VBP ((uint8_t)0x06)
+#define STA350BW_HPB ((uint8_t)0x07)
+#define STA350BW_DEMP ((uint8_t)0x08)
+#define STA350BW_BQL ((uint8_t)0x09)
+#define STA350BW_BQ5 ((uint8_t)0x0A)
+#define STA350BW_BQ6 ((uint8_t)0x0B)
+#define STA350BW_BQ7 ((uint8_t)0x0C)
+#define STA350BW_EXT_RANGE_BQ1 ((uint8_t)0x0D)
+#define STA350BW_EXT_RANGE_BQ2 ((uint8_t)0x0E)
+#define STA350BW_EXT_RANGE_BQ3 ((uint8_t)0x0F)
+#define STA350BW_EXT_RANGE_BQ4 ((uint8_t)0x10)
+#define STA350BW_EXT_RANGE_BQ5 ((uint8_t)0x11)
+#define STA350BW_EXT_RANGE_BQ6 ((uint8_t)0x12)
+#define STA350BW_EXT_RANGE_BQ7 ((uint8_t)0x13)
+#define STA350BW_RAM_BANK_SELECT ((uint8_t)0x14)
+ /**
+ * @}
+ */
+
+
+
+#define STA350BW_ERROR ((int32_t)-1)
+#define STA350BW_OK ((int32_t)0)
+
+
+ /** @defgroup STA350BW_state_define STA350BW state define
+ * @brief STA350BW state definitions
+ * @{
+ */
+#define STA350BW_ENABLE ((uint8_t)0x01)
+#define STA350BW_DISABLE ((uint8_t)0x00)
+#define STA350BW_RANGE_ONE ((uint8_t)0x01)
+#define STA350BW_RANGE_TWO ((uint8_t)0x02)
+#define STA350BW_RANGE_FOUR ((uint8_t)0x04)
+ /**
+ * @}
+ */
+
+ /** @defgroup STA350BW_channel_define STA350BW channel define
+ * @brief STA350BW channels definitions
+ * @{
+ */
+#define STA350BW_CHANNEL_MASTER ((uint8_t)0x00)
+#define STA350BW_CHANNEL_1 ((uint8_t)0x01)
+#define STA350BW_CHANNEL_2 ((uint8_t)0x02)
+#define STA350BW_CHANNEL_3 ((uint8_t)0x03)
+ /**
+ * @}
+ */
+
+ /** @defgroup STA350BW_channel_define STA350BW Biq define
+ * @brief STA350BW Biq definitions
+ * @{
+ */
+#define STA350BW_RAM_BANK_FIRST ((uint8_t)0x00)
+#define STA350BW_RAM_BANK_SECOND ((uint8_t)0x01)
+#define STA350BW_RAM_BANK_THIRD ((uint8_t)0x02)
+#define STA350BW_CH1_BQ1 ((uint8_t)0x00)
+#define STA350BW_CH1_BQ2 ((uint8_t)0x01)
+#define STA350BW_CH1_BQ3 ((uint8_t)0x02)
+#define STA350BW_CH1_BQ4 ((uint8_t)0x03)
+#define STA350BW_CH2_BQ1 ((uint8_t)0x04)
+#define STA350BW_CH2_BQ2 ((uint8_t)0x05)
+#define STA350BW_CH2_BQ3 ((uint8_t)0x06)
+#define STA350BW_CH2_BQ4 ((uint8_t)0x07)
+
+ /** @defgroup STA350BW_adsress_define STA350BW address define
+ * @brief STA350BW address definitions
+ * @{
+ */
+#define STA350BW_ADDRESS_1 ((uint8_t)0x38) /* To be used when using I2S1. */
+#define STA350BW_ADDRESS_2 ((uint8_t)0x3A) /* To be used when using I2S2. */
+
+/* Audio processor initialization structure. */
+typedef struct
+{
+ uint32_t frequency; /* Allowed frequency: 32000, 44100, 48000, 88200, 96000. */
+ uint16_t volume; /* Allowed volume: [0..128]. */
+} STA350BW_Init_t;
+
+/* Audio processor extern functions. */
+extern uint8_t STA350BW_IO_Init(void);
+extern uint8_t STA350BW_IO_Read(uint8_t reg, uint8_t *value);
+extern uint8_t STA350BW_IO_Write(uint8_t reg, uint8_t value);
+extern uint8_t STA350BW_IO_ReadMulti(uint8_t *pBuffer, uint8_t reg, uint16_t length);
+extern uint8_t STA350BW_IO_WriteMulti(uint8_t *pBuffer, uint8_t reg, uint16_t length);
+extern uint8_t STA350BW_IO_Delay(uint32_t delay_ms);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*__STA350BW_H*/
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/sta350bw/sta350bw_class.cpp Fri Feb 10 17:29:23 2017 +0100
@@ -0,0 +1,827 @@
+/**
+******************************************************************************
+* @file sta350bw_class.cpp
+* @author Central Labs
+* @version V1.0.0
+* @date 18-August-2015
+* @brief This file provides the STA350BW SOUND TERMINAL audio driver.
+******************************************************************************
+* @attention
+*
+* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
+*
+* 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. Neither the name of STMicroelectronics nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
+*
+******************************************************************************
+*/
+
+
+/* Generated with STM32CubeTOO -----------------------------------------------*/
+
+
+/* Revision ------------------------------------------------------------------*/
+/*
+ Repository: http://svn.x-nucleodev.codex.cro.st.com/svnroot/X-NucleoDev
+ Branch/Trunk/Tag: trunk
+ Based on: X-CUBE-SOUNDTER1/trunk/Drivers/BSP/Components/sta350bw/sta350bw.c
+ Revision: 0
+*/
+
+
+/* Includes ------------------------------------------------------------------*/
+
+#include "sta350bw_class.h"
+
+
+/* Methods -------------------------------------------------------------------*/
+
+/**
+* @brief Initializes the STA350BW and the control interface.
+* @param init: initialization data.
+* @retval COMPONENT_OK if correct setup, COMPONENT_ERROR otherwise
+*/
+int32_t STA350BW::STA350BW_Init(void *init)
+{
+ uint8_t tmp = 0x00;
+
+ /* Reset Audio Device */
+ _reset = 0;
+ wait_ms(100);
+ _reset = 1;
+
+ /* Low level I2C init */
+ STA350BW_IO_Init();
+
+ /* Set Master clock depending on sampling frequency */
+ if (STA350BW_SetFrequency((*((STA350BW_Init_t *) init)).frequency) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+
+ STA350BW_IO_Delay(500);
+
+ /* Read Status Register */
+ if (STA350BW_IO_Read(STA350BW_STATUS, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+
+#if 0
+ if (tmp != 0x7F)
+ {
+ /* Status register highlights undesired behaviour (PLL not locked, ...) */
+ return COMPONENT_ERROR;
+ }
+#else
+ if ((tmp & ~0x80) != 0x7F)
+ {
+ /*Status register highlights undesired behavior
+ (betzw: excluding PLL not locked, ...) */
+ return COMPONENT_ERROR;
+ }
+#endif
+
+ /* Setup Master volume */
+ uint8_t value = (*((STA350BW_Init_t *) init)).volume;
+ if (!(value >= MIN_VOLUME && value <= MAX_VOLUME))
+ return COMPONENT_ERROR;
+ if (STA350BW_SetVolume(STA350BW_CHANNEL_MASTER, (uint8_t) MAX_VOLUME - value) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+
+ if (STA350BW_IO_Read(STA350BW_CONF_REGF, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+
+#if 0
+ tmp &= ~0x80;
+ tmp |= 0x80;
+
+ /* Enable Power Out Stage */
+ if (STA350BW_IO_Write(STA350BW_CONF_REGF, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+#else
+ /*Enable Power Out Stage*/
+ if (STA350BW_PowerOn() != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+
+#endif
+
+ return COMPONENT_OK;
+}
+
+/**
+* @brief Deinitializes the STA350BW and the control interface.
+* @param None.
+* @retval COMPONENT_OK if correct setup, COMPONENT_ERROR otherwise.
+*/
+int32_t STA350BW::STA350BW_DeInit(void)
+{
+ if (STA350BW_PowerOff() != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ return COMPONENT_OK;
+}
+
+/**
+* @brief Read the device ID.
+* @param id: identifier.
+* @retval COMPONENT_OK if correct setup, COMPONENT_ERROR otherwise
+*/
+int32_t STA350BW::STA350BW_ReadID(uint8_t *id)
+{
+ return COMPONENT_OK;
+}
+
+/**
+* @brief Start the audio play.
+* @param *pData: pointer to audio data.
+* @param Size: size of the data buffer.
+* @retval COMPONENT_OK if correct setup, COMPONENT_ERROR otherwise
+*/
+int32_t STA350BW::STA350BW_Play(int16_t *pData, uint16_t Size)
+{
+ return COMPONENT_OK;
+}
+
+/**
+* @brief Pause the audio play.
+* @param None.
+* @retval COMPONENT_OK if correct setup, COMPONENT_ERROR otherwise
+*/
+int32_t STA350BW::STA350BW_Pause(void)
+{
+ /* Mute the output*/
+ if (STA350BW_SetMute(STA350BW_CHANNEL_MASTER, STA350BW_ENABLE) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ return COMPONENT_OK;
+}
+
+/**
+* @brief Resume the audio play.
+* @param None.
+* @retval COMPONENT_OK if correct setup, COMPONENT_ERROR otherwise
+*/
+int32_t STA350BW::STA350BW_Resume(void)
+{
+ /* Unmute the output*/
+ if (STA350BW_SetMute(STA350BW_CHANNEL_MASTER, STA350BW_DISABLE) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ return COMPONENT_OK;
+}
+
+/**
+* @brief Control the mute features of the STA350BW.
+* @param channel: channel to be muted.
+* This parameter can be a value of @ref STA350BW_channel_define
+* @param state: enable disable parameter
+* This parameter can be a value of @ref STA350BW_state_define
+* @retval COMPONENT_OK if correct setup, COMPONENT_ERROR otherwise
+*/
+int32_t STA350BW::STA350BW_SetMute(uint8_t channel, uint8_t state)
+{
+ uint8_t tmp;
+
+ if (STA350BW_IO_Read(STA350BW_MUTE, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ if (state == STA350BW_ENABLE)
+ {
+ tmp |= channel;
+ } else
+ {
+ tmp &= ~channel;
+ }
+
+ if (STA350BW_IO_Write(STA350BW_MUTE, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ return COMPONENT_OK;
+}
+
+/**
+* @brief Control the volume features of the STA350BW.
+* @param channel: channel to be controlled.
+* This parameter can be a value of @ref STA350BW_channel_define
+* @param volume: volume to be set
+* @retval COMPONENT_OK if correct setup, COMPONENT_ERROR otherwise
+*/
+int32_t STA350BW::STA350BW_SetVolume(uint8_t channel, uint8_t value)
+{
+ /*Setup volume */
+ uint8_t tmp = value;
+ if (STA350BW_IO_Write(STA350BW_MVOL + channel, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ return COMPONENT_OK;
+}
+
+/**
+* @brief set the sampling frequency for STA350BW.
+* @param audio_freq: audio frequency to be set.
+* @retval COMPONENT_OK if correct setup, COMPONENT_ERROR otherwise
+*/
+int32_t STA350BW::STA350BW_SetFrequency(uint32_t audio_freq)
+{
+ uint8_t tmp;
+
+ if (STA350BW_IO_Read(STA350BW_CONF_REGA, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+
+ tmp &= ~0x1F;
+
+ if (audio_freq == STA350BW_Fs_32000 || audio_freq == STA350BW_Fs_44100 || audio_freq == STA350BW_Fs_48000)
+ {
+ tmp |= STA350BW_MCLK_256_LR_48K;
+ }
+ else if (audio_freq == STA350BW_Fs_88200 || audio_freq == STA350BW_Fs_96000)
+ {
+ tmp |= STA350BW_MCLK_256_LR_96K;
+ }
+ else
+ return COMPONENT_ERROR;
+
+ if (STA350BW_IO_Write(STA350BW_CONF_REGA, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+
+ /* Set I2S audio frequency. */
+ dev_i2s.audio_frequency(audio_freq);
+
+ return COMPONENT_OK;
+}
+
+/**
+* @brief Set equalization parameters for STA350BW biquad section.
+* @param ram_block: ram block to be set
+* @param filter_number: filter number
+* @param *filter_values: pointer to a uint32_t array containing filter coefficients
+* @retval COMPONENT_OK if correct setup, COMPONENT_ERROR otherwise
+*/
+int32_t STA350BW::STA350BW_SetEq(uint8_t ram_block, uint8_t filter_number, uint32_t * filter_values)
+{
+ /*5 is due to the ram adressing: first filter is on the adresses 0x00 to 0x04; the second is on 0x05 to 0x09 ...*/
+ STA350BW_WriteRAMSet(ram_block, filter_number * 5, (uint8_t *) filter_values);
+ return COMPONENT_OK;
+}
+
+/**
+* @brief Set tone value in the STA350BW tone register.
+* @param tone_gain: gain of the tone control
+* @retval COMPONENT_OK if correct setup, COMPONENT_ERROR otherwise
+*/
+int32_t STA350BW::STA350BW_SetTone(uint8_t tone_gain)
+{
+ uint8_t tmp = tone_gain;
+
+ if (STA350BW_IO_Write(STA350BW_TONE, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ return COMPONENT_OK;
+}
+
+/**
+* @brief Power on the device.
+* @param None.
+* @retval COMPONENT_OK if correct setup, COMPONENT_ERROR otherwise
+*/
+int32_t STA350BW::STA350BW_PowerOn(void)
+{
+ uint8_t tmp;
+ if (STA350BW_IO_Read(STA350BW_CONF_REGF, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp |= 0xC0;
+ if (STA350BW_IO_Write(STA350BW_CONF_REGF, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ return COMPONENT_OK;
+}
+
+/**
+* @brief Power off the device.
+* @param None.
+* @retval COMPONENT_OK if correct setup, COMPONENT_ERROR otherwise
+*/
+int32_t STA350BW::STA350BW_PowerOff(void)
+{
+ uint8_t tmp;
+ if (STA350BW_IO_Read(STA350BW_CONF_REGF, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0xC0;
+ if (STA350BW_IO_Write(STA350BW_CONF_REGF, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ return COMPONENT_OK;
+}
+
+/**
+* @brief Stop audio stream.
+* @param None.
+* @retval COMPONENT_OK if correct setup, COMPONENT_ERROR otherwise
+*/
+int32_t STA350BW::STA350BW_Stop(void)
+{
+ return COMPONENT_OK;
+}
+
+/**
+* @brief Reset device.
+* @param NOne.
+* @retval COMPONENT_OK if correct setup, COMPONENT_ERROR otherwise
+*/
+int32_t STA350BW::STA350BW_Reset(void)
+{
+ return COMPONENT_OK;
+}
+
+/**
+* @brief This function can be used to set advanced DSP options in order to
+* use advanced features on the STA350BW device.
+* @param option: specific option to be setted up
+* This parameter can be a value of @ref STA350BW_DSP_option_selection
+* @param state: state of the option to be controlled. Depending on the selected
+* DSP feature to be controlled, this value can be either ENABLE/DISABLE
+* or a specific numerical parameter related to the specific DSP function.
+* This parameter can be a value of @ref STA350BW_state_define
+* @retval COMPONENT_OK if correct setup, COMPONENT_ERROR otherwise
+*/
+int32_t STA350BW::STA350BW_SetDSPOption(uint8_t option, uint8_t state)
+{
+ uint8_t tmp = 0;
+
+ switch (option)
+ {
+ case STA350BW_DSPB:
+ {
+ if (STA350BW_IO_Read(STA350BW_CONF_REGD, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x04;
+ tmp |= state << 0x02;
+
+ if (STA350BW_IO_Write(STA350BW_CONF_REGD, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ break;
+ }
+ case STA350BW_HPB:
+ {
+ if (STA350BW_IO_Read(STA350BW_CONF_REGD, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x01;
+ tmp |= state << 0x00;
+
+ if (STA350BW_IO_Write(STA350BW_CONF_REGD, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ break;
+ }
+ case STA350BW_DEMP:
+ {
+ if (STA350BW_IO_Read(STA350BW_CONF_REGD, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x02;
+ tmp |= state << 0x01;
+
+ if (STA350BW_IO_Write(STA350BW_CONF_REGD, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ break;
+ }
+ case STA350BW_BQL:
+ {
+ if (STA350BW_IO_Read(STA350BW_CONF_REGD, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x08;
+ tmp |= state << 0x04;
+
+ if (STA350BW_IO_Write(STA350BW_CONF_REGD, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ break;
+ }
+ case STA350BW_BQ5:
+ {
+ if (STA350BW_IO_Read(STA350BW_CONFX, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x04;
+ tmp |= state << 0x02;
+
+ if (STA350BW_IO_Write(STA350BW_CONFX, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ break;
+ }
+ case STA350BW_BQ6:
+ {
+ if (STA350BW_IO_Read(STA350BW_CONFX, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x02;
+ tmp |= state << 0x01;
+
+ if (STA350BW_IO_Write(STA350BW_CONFX, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ break;
+ }
+ case STA350BW_BQ7:
+ {
+ if (STA350BW_IO_Read(STA350BW_CONFX, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x01;
+ tmp |= state << 0x00;
+
+ if (STA350BW_IO_Write(STA350BW_CONFX, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ break;
+ }
+ case STA350BW_C1EQBP:
+ {
+ if (STA350BW_IO_Read(STA350BW_C1CFG, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x02;
+ tmp |= state << 0x01;
+
+ if (STA350BW_IO_Write(STA350BW_C1CFG, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ break;
+ }
+ case STA350BW_C2EQBP:
+ {
+ if (STA350BW_IO_Read(STA350BW_C2CFG, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x02;
+ tmp |= state << 0x01;
+
+ if (STA350BW_IO_Write(STA350BW_C2CFG, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ break;
+ }
+ case STA350BW_C1TCB:
+ {
+ if (STA350BW_IO_Read(STA350BW_C1CFG, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x01;
+ tmp |= state << 0x00;
+
+ if (STA350BW_IO_Write(STA350BW_C1CFG, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ break;
+ }
+ case STA350BW_C2TCB:
+ {
+ if (STA350BW_IO_Read(STA350BW_C2CFG, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x01;
+ tmp |= state << 0x00;
+
+ if (STA350BW_IO_Write(STA350BW_C2CFG, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ break;
+ }
+ case STA350BW_C1VBP:
+ {
+ if (STA350BW_IO_Read(STA350BW_C1CFG, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x04;
+ tmp |= state << 0x02;
+
+ if (STA350BW_IO_Write(STA350BW_C1CFG, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ break;
+ }
+ case STA350BW_C2VBP:
+ {
+ if (STA350BW_IO_Read(STA350BW_C2CFG, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x04;
+ tmp |= state << 0x02;
+
+ if (STA350BW_IO_Write(STA350BW_C2CFG, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ break;
+ }
+ case STA350BW_EXT_RANGE_BQ1:
+ {
+ if (STA350BW_IO_Read(STA350BW_CXT_B4B1, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x03;
+ tmp |= (state>>1);
+
+ if (STA350BW_IO_Write(STA350BW_CXT_B4B1, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ break;
+ }
+ case STA350BW_EXT_RANGE_BQ2:
+ {
+ if (STA350BW_IO_Read(STA350BW_CXT_B4B1, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x0C;
+ tmp |= (state>>1) << 2;
+
+ if (STA350BW_IO_Write(STA350BW_CXT_B4B1, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ break;
+ }
+ case STA350BW_EXT_RANGE_BQ3:
+ {
+ if (STA350BW_IO_Read(STA350BW_CXT_B4B1, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x30;
+ tmp |= (state>>1) << 4;
+
+ if (STA350BW_IO_Write(STA350BW_CXT_B4B1, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ break;
+ }
+ case STA350BW_EXT_RANGE_BQ4:
+ {
+ if (STA350BW_IO_Read(STA350BW_CXT_B4B1, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0xC0;
+ tmp |= (state>>1) << 6;
+
+ if (STA350BW_IO_Write(STA350BW_CXT_B4B1, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ break;
+ }
+ case STA350BW_EXT_RANGE_BQ5:
+ {
+ if (STA350BW_IO_Read(STA350BW_CXT_B7B5, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x03;
+ tmp |= (state>>1);
+
+ if (STA350BW_IO_Write(STA350BW_CXT_B7B5, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ break;
+ }
+ case STA350BW_EXT_RANGE_BQ6:
+ {
+ if (STA350BW_IO_Read(STA350BW_CXT_B7B5, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x0C;
+ tmp |= (state>>1) << 2;
+
+ if (STA350BW_IO_Write(STA350BW_CXT_B7B5, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ break;
+ }
+ case STA350BW_EXT_RANGE_BQ7:
+ {
+ if (STA350BW_IO_Read(STA350BW_CXT_B7B5, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x30;
+ tmp |= (state>>1) << 4;
+
+ if (STA350BW_IO_Write(STA350BW_CXT_B7B5, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ break;
+ }
+ case STA350BW_RAM_BANK_SELECT:
+ {
+ if (STA350BW_IO_Read(STA350BW_EQCFG, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x03;
+ tmp |= state;
+
+ if (STA350BW_IO_Write(STA350BW_EQCFG, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ break;
+ }
+ }
+ return COMPONENT_OK;
+}
+
+/**
+* @brief private function for writing a RAM set.
+* @param RAM_block: ram block to be written.
+* @param RAM_address: ram address to be written.
+* @param *pIn: pointer to the desired value to be write.
+* @retval COMPONENT_OK if correct setup, COMPONENT_ERROR otherwise
+*/
+int32_t STA350BW::STA350BW_WriteRAMSet(uint8_t RAM_block, uint8_t RAM_address, uint8_t * pIn)
+{
+ uint8_t tmp = 0x00;
+ /*choose block*/
+ if (STA350BW_IO_Read(STA350BW_EQCFG, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x03;
+ RAM_block &= 0x03;
+ tmp |= RAM_block;
+ if (STA350BW_IO_Write(STA350BW_EQCFG, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ /*set address*/
+ if (STA350BW_IO_Read(STA350BW_CFADDR, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x3F;
+ RAM_address &= 0x3F;
+ tmp |= RAM_address;
+ if (STA350BW_IO_Write(STA350BW_CFADDR, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ /*write*/
+ if (STA350BW_IO_Write(STA350BW_B1CF1, pIn[2]) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ if (STA350BW_IO_Write(STA350BW_B1CF2, pIn[1]) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ if (STA350BW_IO_Write(STA350BW_B1CF3, pIn[0]) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ if (STA350BW_IO_Write(STA350BW_B2CF1, pIn[6]) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ if (STA350BW_IO_Write(STA350BW_B2CF2, pIn[5]) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ if (STA350BW_IO_Write(STA350BW_B2CF3, pIn[4]) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ if (STA350BW_IO_Write(STA350BW_A1CF1, pIn[10]) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ if (STA350BW_IO_Write(STA350BW_A1CF2, pIn[9]) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ if (STA350BW_IO_Write(STA350BW_A1CF3, pIn[8]) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ if (STA350BW_IO_Write(STA350BW_A2CF1, pIn[14]) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ if (STA350BW_IO_Write(STA350BW_A2CF2, pIn[13]) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ if (STA350BW_IO_Write(STA350BW_A2CF3, pIn[12]) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ if (STA350BW_IO_Write(STA350BW_B0CF1, pIn[18]) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ if (STA350BW_IO_Write(STA350BW_B0CF2, pIn[17]) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ if (STA350BW_IO_Write(STA350BW_B0CF3, pIn[16]) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ /*Set WA PIN*/
+ if (STA350BW_IO_Read(STA350BW_CFUD, &tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ tmp &= ~0x02;
+ tmp = 0x02;
+
+ if (STA350BW_IO_Write(STA350BW_CFUD, tmp) != 0)
+ {
+ return COMPONENT_ERROR;
+ }
+ return COMPONENT_OK;
+}
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/sta350bw/sta350bw_class.h Fri Feb 10 17:29:23 2017 +0100
@@ -0,0 +1,493 @@
+/**
+******************************************************************************
+* @file sta350bw_class.h
+* @author Central Labs
+* @version V1.0.0
+* @date 18-August-2015
+* @brief This file provides the STA350BW SOUND TERMINAL audio driver.
+******************************************************************************
+* @attention
+*
+* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
+*
+* 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. Neither the name of STMicroelectronics nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
+*
+******************************************************************************
+*/
+
+
+/* Generated with STM32CubeTOO -----------------------------------------------*/
+
+
+/* Revision ------------------------------------------------------------------*/
+/*
+ Repository: http://svn.x-nucleodev.codex.cro.st.com/svnroot/X-NucleoDev
+ Branch/Trunk/Tag: trunk
+ Based on: X-CUBE-SOUNDTER1/trunk/Drivers/BSP/Components/sta350bw/sta350bw.h
+ Revision: 0
+*/
+
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+
+#ifndef __STA350BW_CLASS_H
+#define __STA350BW_CLASS_H
+
+
+/* Includes ------------------------------------------------------------------*/
+
+/* ACTION 1 ------------------------------------------------------------------*
+ * Include here platform specific header files. *
+ *----------------------------------------------------------------------------*/
+#include "mbed.h"
+#include "I2S.h"
+#include "DevI2C.h"
+/* ACTION 2 ------------------------------------------------------------------*
+ * Include here component specific header files. *
+ *----------------------------------------------------------------------------*/
+#include "sta350bw.h"
+/* ACTION 3 ------------------------------------------------------------------*
+ * Include here interface specific header files. *
+ * *
+ * Example: *
+ * #include "Humidity_class.h" *
+ * #include "Temperature_class.h" *
+ *----------------------------------------------------------------------------*/
+#include "SoundTerminal.h"
+
+
+/* Definitions ---------------------------------------------------------------*/
+
+#define MIN_VOLUME 0
+#define MAX_VOLUME 128
+
+
+/* Classes -------------------------------------------------------------------*/
+
+/**
+ * @brief Class representing a STA350BW component.
+ */
+class STA350BW : public SoundTerminal
+{
+public:
+
+ /*** Constructor and Destructor Methods ***/
+
+ /**
+ * @brief Constructor.
+ * @param reset pin name of the RESET pin of the component.
+ * @param address I2C address of the component.
+ * @param i2c I2C device to be used for communication.
+ * @param dpin pin name of the DPIN pin of the I2S device to be used for audio transmission.
+ * @param clk pin name of the CLK pin of the I2S device to be used for audio transmission.
+ * @param wsel pin name of the WSEL pin of the I2S device to be used for audio transmission.
+ * @param fdpin pin name of the FDPIN pin of the I2S device to be used for audio transmission.
+ * @param mck pin name of the MCK pin of the I2S device to be used for audio transmission.
+ * @note Initialization depends on the I2S interface you wish to use:
+ * I2S1) address = STA350BW_ADDRESS_1, dpin = PB_15, clk = PB_13, wsel = PB_12, fdpin = NC, mck = PC_6;
+ * I2S2) address = STA350BW_ADDRESS_2, dpin = PC_12, clk = PC_10, wsel = PA_4, fdpin = NC, mck = PC_7.
+ */
+ STA350BW(PinName reset, uint8_t address, DevI2C &i2c, PinName dpin, PinName clk, PinName wsel, PinName fdpin = NC, PinName mck = NC) :
+ SoundTerminal(),
+ _reset(reset),
+ _address(address),
+ _dev_i2c(i2c),
+ dev_i2s(dpin, clk, wsel, fdpin, mck),
+ _PCM_buffer(NULL),
+ _PCM_buffer_bytes(0),
+ _loop(false)
+#ifdef X_NUCLEO_CCA01M1_DEBUG
+ , _i2s_signal(D11)
+#endif
+ {
+ /* ACTION 4 ----------------------------------------------------------*
+ * Initialize here the component's member variables, one variable per *
+ * line. *
+ * *
+ * Example: *
+ * measure = 0; *
+ * instance_id = number_of_instances++; *
+ *--------------------------------------------------------------------*/
+ }
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~STA350BW(void) {}
+
+
+ /*** Public Component Related Methods ***/
+
+ /* ACTION 5 --------------------------------------------------------------*
+ * Implement here the component's public methods, as wrappers of the C *
+ * component's functions. *
+ * They should be: *
+ * + Methods with the same name of the C component's virtual table's *
+ * functions (1); *
+ * + Methods with the same name of the C component's extended virtual *
+ * table's functions, if any (2). *
+ * *
+ * Example: *
+ * virtual int GetValue(float *f) //(1) *
+ * { *
+ * return COMPONENT_GetValue(float *f); *
+ * } *
+ * *
+ * virtual int EnableFeature(void) //(2) *
+ * { *
+ * return COMPONENT_EnableFeature(); *
+ * } *
+ *------------------------------------------------------------------------*/
+ /**
+ * @brief Initializing the STA350BW component.
+ * @param init Pointer to device specific initalization structure.
+ * @retval "0" in case of success, an error code otherwise.
+ */
+ virtual int Init(void *init = NULL)
+ {
+ if (STA350BW_Init((void *) init) != COMPONENT_OK)
+ return COMPONENT_ERROR;
+
+ /* Setting I2S parameters. */
+ dev_i2s.mode(MASTER_TX, true);
+
+ return COMPONENT_OK;
+ }
+
+ /**
+ * @brief Getting the ID of the component.
+ * @param id Pointer to an allocated variable to store the ID into.
+ * @retval "0" in case of success, an error code otherwise.
+ */
+ virtual int ReadID(uint8_t *id = NULL)
+ {
+ return (int) STA350BW_ReadID((uint8_t *) id);
+ }
+
+ /**
+ * @brief De-initializing the STA350BW component.
+ * @param None.
+ * @retval "0" in case of success, an error code otherwise.
+ */
+ virtual int32_t DeInit(void)
+ {
+ return (int32_t) STA350BW_DeInit();
+ }
+
+ /*
+ * @brief Start playing audio.
+ * @param PCM_buffer The buffer of data to be played.
+ * @param PCM_buffer_bytes The size in bytes of the buffer of data to be played.
+ * @param loop Loops indefinitely if true, just once otherwise.
+ * @retval "0" in case of success, an error code otherwise.
+ */
+ virtual int32_t Play(int16_t *PCM_buffer, uint16_t PCM_buffer_bytes, bool loop = false)
+ {
+ /* Storing data. */
+ _PCM_buffer = PCM_buffer;
+ _PCM_buffer_bytes = PCM_buffer_bytes;
+ _loop = loop;
+
+ /* Sending data to the speakers via I2S. */
+ int res = dev_i2s.transfer(
+ (void *) _PCM_buffer, _PCM_buffer_bytes,
+ (void *) NULL, 0,
+ event_callback_t(this, &STA350BW::I2SCallback),
+ I2S_EVENT_ALL
+ );
+ if (res != 0)
+ return COMPONENT_ERROR;
+
+ return COMPONENT_OK;
+ }
+
+ /*
+ * @brief Stop playing audio.
+ * @param None.
+ * @retval None.
+ */
+ virtual int32_t Stop(void)
+ {
+ dev_i2s.abort_all_transfers();
+ return (int32_t) STA350BW_Stop();
+ }
+
+ /*
+ * @brief Set the volume of the audio.
+ * @param channel The channel on which to set the volume of the audio.
+ * @param value The value of the volume in the range [MIN_VOLUME..MAX_VOLUME].
+ * @retval "0" in case of success, an error code otherwise.
+ */
+ virtual int32_t SetVolume(uint8_t channel, uint8_t value)
+ {
+ if (!(value >= MIN_VOLUME && value <= MAX_VOLUME))
+ return COMPONENT_ERROR;
+
+ return (int32_t) STA350BW_SetVolume((uint8_t) channel, (uint8_t) MAX_VOLUME - value);
+ }
+
+ /*
+ * @brief Set the frequency of the audio.
+ * @param audio_freq The frequency of the audio.
+ * @retval "0" in case of success, an error code otherwise.
+ */
+ virtual int32_t SetFrequency(uint32_t audio_freq)
+ {
+ return (int32_t) STA350BW_SetFrequency((uint32_t) audio_freq);
+ }
+
+
+ /*** Public Interrupt Related Methods ***/
+
+ /* ACTION 6 --------------------------------------------------------------*
+ * Implement here interrupt related methods, if any. *
+ * Note that interrupt handling is platform dependent, e.g.: *
+ * + mbed: *
+ * InterruptIn feature_irq(pin); //Interrupt object. *
+ * feature_irq.fall(callback); //Attach a callback. *
+ * feature_irq.mode(PullNone); //Set interrupt mode. *
+ * feature_irq.enable_irq(); //Enable interrupt. *
+ * feature_irq.disable_irq(); //Disable interrupt. *
+ * + Arduino: *
+ * attachInterrupt(pin, callback, RISING); //Attach a callback. *
+ * detachInterrupt(pin); //Detach a callback. *
+ * *
+ * Example (mbed): *
+ * void AttachFeatureIRQ(void (*fptr) (void)) *
+ * { *
+ * feature_irq.fall(fptr); *
+ * } *
+ * *
+ * void EnableFeatureIRQ(void) *
+ * { *
+ * feature_irq.enable_irq(); *
+ * } *
+ * *
+ * void DisableFeatureIRQ(void) *
+ * { *
+ * feature_irq.disable_irq(); *
+ * } *
+ *------------------------------------------------------------------------*/
+
+
+protected:
+
+ /*** Protected Component Related Methods ***/
+
+ /* ACTION 7 --------------------------------------------------------------*
+ * Declare here the component's specific methods. *
+ * They should be: *
+ * + Methods with the same name of the C component's virtual table's *
+ * functions (1); *
+ * + Methods with the same name of the C component's extended virtual *
+ * table's functions, if any (2); *
+ * + Helper methods, if any, like functions declared in the component's *
+ * source files but not pointed by the component's virtual table (3). *
+ * *
+ * Example: *
+ * Status_t COMPONENT_GetValue(float *f); //(1) *
+ * Status_t COMPONENT_EnableFeature(void); //(2) *
+ * Status_t COMPONENT_ComputeAverage(void); //(3) *
+ *------------------------------------------------------------------------*/
+ int32_t STA350BW_Init(void *init);
+ int32_t STA350BW_ReadID(uint8_t *id);
+ int32_t STA350BW_DeInit(void);
+ int32_t STA350BW_Play(int16_t *pData, uint16_t Size);
+ int32_t STA350BW_Stop(void);
+ int32_t STA350BW_Pause(void);
+ int32_t STA350BW_Resume(void);
+ int32_t STA350BW_SetVolume(uint8_t channel, uint8_t value);
+ int32_t STA350BW_SetFrequency(uint32_t audio_freq);
+ int32_t STA350BW_PowerOn(void);
+ int32_t STA350BW_PowerOff(void);
+ int32_t STA350BW_Reset(void);
+ int32_t STA350BW_SetEq(uint8_t ram_block, uint8_t filter_number, uint32_t * filter_values);
+ int32_t STA350BW_SetTone(uint8_t tone_gain);
+ int32_t STA350BW_SetMute(uint8_t channel, uint8_t state);
+ int32_t STA350BW_SetDSPOption(uint8_t option, uint8_t state);
+ int32_t STA350BW_WriteRAMSet(uint8_t RAM_block, uint8_t RAM_address, uint8_t * pIn);
+
+ /**
+ * @brief I2S callback.
+ * @param narg Narg flag.
+ * @retval None.
+ */
+ void I2SCallback(int narg)
+ {
+ if (!(narg & (I2S_EVENT_TX_COMPLETE | I2S_EVENT_TX_HALF_COMPLETE)))
+ error("Unexpected transmission event.\r\n");
+ else if ((narg & I2S_EVENT_TX_COMPLETE) && !_loop)
+ Stop();
+
+#ifdef X_NUCLEO_CCA01M1_DEBUG
+ _i2s_signal = !_i2s_signal;
+#endif
+ }
+
+
+ /*** Component's I/O Methods ***/
+
+ /**
+ * @brief Utility function to read data from STA350BW.
+ * @param[out] pBuffer pointer to the buffer to read data into.
+ * @param[in] RegisterAddr specifies the internal address register to read from.
+ * @param[in] NumBytesToRead number of bytes to read.
+ * @retval COMPONENT_OK in case of success, COMPONENT_ERROR otherwise.
+ */
+ Status_t Read(uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumBytesToRead)
+ {
+ if (_dev_i2c.i2c_read(pBuffer, _address, RegisterAddr, NumBytesToRead) != 0)
+ return COMPONENT_ERROR;
+ return COMPONENT_OK;
+ }
+
+ /**
+ * @brief Utility function to write data to STA350BW.
+ * @param[in] pBuffer pointer to the buffer of data to send.
+ * @param[in] RegisterAddr specifies the internal address register to write to.
+ * @param[in] NumBytesToWrite number of bytes to write.
+ * @retval COMPONENT_OK in case of success, COMPONENT_ERROR otherwise.
+ */
+ Status_t Write(uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumBytesToWrite)
+ {
+ if (_dev_i2c.i2c_write(pBuffer, _address, RegisterAddr, NumBytesToWrite) != 0)
+ return COMPONENT_ERROR;
+ return COMPONENT_OK;
+ }
+
+ /* ACTION 8 --------------------------------------------------------------*
+ * Implement here other I/O methods beyond those already implemented *
+ * above, which are declared extern within the component's header file. *
+ *------------------------------------------------------------------------*/
+ uint8_t STA350BW_IO_Init(void)
+ {
+ /* TO BE IMPLEMENTED BY USING TARGET PLATFORM'S APIs. */
+ return (uint8_t) 0;
+ }
+
+ uint8_t STA350BW_IO_Read(uint8_t reg, uint8_t *value)
+ {
+ /* TO BE IMPLEMENTED BY USING TARGET PLATFORM'S APIs. */
+ return (uint8_t) Read(value, reg, 1);
+ }
+
+ uint8_t STA350BW_IO_Write(uint8_t reg, uint8_t value)
+ {
+ /* TO BE IMPLEMENTED BY USING TARGET PLATFORM'S APIs. */
+ return (uint8_t) Write(&value, reg, 1);
+ }
+
+ uint8_t STA350BW_IO_ReadMulti(uint8_t *pBuffer, uint8_t reg, uint16_t length)
+ {
+ /* TO BE IMPLEMENTED BY USING TARGET PLATFORM'S APIs. */
+ return (uint8_t) Read(pBuffer, reg, length);
+ }
+
+ uint8_t STA350BW_IO_WriteMulti(uint8_t *pBuffer, uint8_t reg, uint16_t length)
+ {
+ /* TO BE IMPLEMENTED BY USING TARGET PLATFORM'S APIs. */
+ return (uint8_t) Write(pBuffer, reg, length);
+ }
+
+ uint8_t STA350BW_IO_Delay(uint32_t delay_ms)
+ {
+ /* TO BE IMPLEMENTED BY USING TARGET PLATFORM'S APIs. */
+ wait_ms(delay_ms);
+ return (uint8_t) 0;
+ }
+
+
+ /*** Component's Instance Variables ***/
+
+ /* ACTION 9 --------------------------------------------------------------*
+ * Declare here interrupt related variables, if needed. *
+ * Note that interrupt handling is platform dependent, see *
+ * "Interrupt Related Methods" above. *
+ * *
+ * Example: *
+ * + mbed: *
+ * InterruptIn feature_irq; *
+ *------------------------------------------------------------------------*/
+
+ /* ACTION 10 -------------------------------------------------------------*
+ * Declare here other pin related variables, if needed. *
+ * *
+ * Example: *
+ * + mbed: *
+ * DigitalOut standby_reset; *
+ *------------------------------------------------------------------------*/
+ DigitalOut _reset;
+
+ /* ACTION 11 -------------------------------------------------------------*
+ * Declare here communication related variables, if needed. *
+ * *
+ * Example: *
+ * + mbed: *
+ * DigitalOut address; *
+ * DevI2C &dev_i2c; *
+ *------------------------------------------------------------------------*/
+ /* Configuration. */
+ uint8_t _address;
+
+ /* IO Device. */
+ DevI2C &_dev_i2c;
+
+public:
+
+ /* I2S Audio Device (exclusive). */
+ I2S dev_i2s;
+
+
+protected:
+
+ /* ACTION 12 -------------------------------------------------------------*
+ * Declare here identity related variables, if needed. *
+ * Note that there should be only a unique identifier for each component, *
+ * which should be the "who_am_i" parameter. *
+ *------------------------------------------------------------------------*/
+
+ /* ACTION 13 -------------------------------------------------------------*
+ * Declare here the component's static and non-static data, one variable *
+ * per line. *
+ * *
+ * Example: *
+ * float measure; *
+ * int instance_id; *
+ * static int number_of_instances; *
+ *------------------------------------------------------------------------*/
+ /* Buffer of data to be played. */
+ int16_t *_PCM_buffer;
+ /* The size in bytes of the buffer of data to be played. */
+ uint16_t _PCM_buffer_bytes;
+ /* Loops indefinitely if true, just once otherwise. */
+ bool _loop;
+
+#ifdef X_NUCLEO_CCA01M1_DEBUG
+ /* Signals for debugging purposes. */
+ DigitalOut _i2s_signal;
+#endif
+};
+
+#endif /* __STA350BW_CLASS_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
