init
This commit is contained in:
commit
75fbf8809d
489 files changed
+398278
No files matched your search
@@ -0,0 +1,27 @@
|
||||
Copyright 2023 STMicroelectronics.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder 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.
|
||||
@@ -0,0 +1,6 @@
|
||||
This software component is provided to you as part of a software package and
|
||||
applicable license terms are in the Package_license file. If you received this
|
||||
software component outside of a package or without applicable license terms,
|
||||
the terms of the BSD-3-Clause license shall apply.
|
||||
You may obtain a copy of the BSD-3-Clause at:
|
||||
https://opensource.org/licenses/BSD-3-Clause
|
||||
@@ -0,0 +1,98 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="generator" content="pandoc" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
||||
<title>Release Notes for WM8904 Audio Codec Component Driver</title>
|
||||
<style>
|
||||
code{white-space: pre-wrap;}
|
||||
span.smallcaps{font-variant: small-caps;}
|
||||
div.columns{display: flex; gap: min(4vw, 1.5em);}
|
||||
div.column{flex: auto; overflow-x: auto;}
|
||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
||||
/* The extra [class] is a hack that increases specificity enough to
|
||||
override a similar rule in reveal.js */
|
||||
ul.task-list[class]{list-style: none;}
|
||||
ul.task-list li input[type="checkbox"] {
|
||||
font-size: inherit;
|
||||
width: 0.8em;
|
||||
margin: 0 0.8em 0.2em -1.6em;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
||||
</style>
|
||||
<link rel="stylesheet" href="_htmresc/mini-st_2020.css" />
|
||||
<link rel="icon" type="image/x-icon" href="_htmresc/favicon.png" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-lg-4">
|
||||
<center>
|
||||
<h1 id="release-notes-for-wm8904-component-driver">Release Notes for
|
||||
<mark>WM8904</mark> Component Driver</h1>
|
||||
<p>Copyright © 2024 STMicroelectronics<br />
|
||||
</p>
|
||||
<a href="https://www.st.com" class="logo"><img
|
||||
src="_htmresc/st_logo_2020.png" alt="ST logo" /></a>
|
||||
</center>
|
||||
<h1 id="purpose">Purpose</h1>
|
||||
<p>This driver provides a set of audio functions offered by WM8904 Codec
|
||||
component</p>
|
||||
</div>
|
||||
<section id="update-history" class="col-sm-12 col-lg-8">
|
||||
<h1>Update History</h1>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section3" checked aria-hidden="true">
|
||||
<label for="collapse-section3" aria-hidden="true"><strong>V1.1.1 /
|
||||
15-September-2025</strong></label>
|
||||
<h2 id="main-changes">Main Changes</h2>
|
||||
<ul>
|
||||
<li>Maintenance release of <strong>WM8904</strong> Audio Codec
|
||||
driver</li>
|
||||
<li>Changes compared with V1.1.0 release
|
||||
<ul>
|
||||
<li>Reduce excessive initialization delay by checking stabilization
|
||||
ready flag instead of waiting a fixed time</li>
|
||||
<li>Update initialization to use output device passed as parameter
|
||||
instead of current device which is not yet initialized</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section2" aria-hidden="true">
|
||||
<label for="collapse-section2" aria-hidden="true"><strong>V1.1.0 /
|
||||
20-September-2024</strong></label>
|
||||
<h2 id="main-changes-1">Main Changes</h2>
|
||||
<ul>
|
||||
<li>First maintenance release of <strong>WM8904</strong> Audio Codec
|
||||
driver</li>
|
||||
<li>Changes compared with V1.0.0 release
|
||||
<ul>
|
||||
<li>Update input devices to be defined as bitfields</li>
|
||||
<li>Implement LINE_IN2 and digital microphone path</li>
|
||||
<li>Add 24KHz audio frequency support</li>
|
||||
<li>Update IsInitialized variable at the end of init function
|
||||
WM8904_Init()</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section1" aria-hidden="true">
|
||||
<label for="collapse-section1" aria-hidden="true"><strong>V1.0.0 /
|
||||
28-February-2024</strong></label>
|
||||
<h2 id="main-changes-2">Main Changes</h2>
|
||||
<ul>
|
||||
<li>First official release of <strong>WM8904</strong> Audio Codec
|
||||
driver</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<footer class="sticky">
|
||||
For complete documentation on <mark>STM32 Microcontrollers</mark> ,
|
||||
visit: <span style="font-color: blue;"><a
|
||||
href="http://www.st.com/STM32">www.st.com</a></span>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
pagetitle: Release Notes for WM8904 Audio Codec Component Driver
|
||||
lang: en
|
||||
header-includes: <link rel="icon" type="image/x-icon" href="_htmresc/favicon.png" />
|
||||
---
|
||||
::: {.row}
|
||||
::: {.col-sm-12 .col-lg-4}
|
||||
|
||||
<center>
|
||||
# Release Notes for <mark>WM8904</mark> Component Driver
|
||||
Copyright © 2024 STMicroelectronics\
|
||||
|
||||
[](https://www.st.com){.logo}
|
||||
</center>
|
||||
|
||||
# Purpose
|
||||
|
||||
This driver provides a set of audio functions offered by WM8904 Codec component
|
||||
|
||||
:::
|
||||
|
||||
::: {.col-sm-12 .col-lg-8}
|
||||
# Update History
|
||||
|
||||
::: {.collapse}
|
||||
<input type="checkbox" id="collapse-section3" checked aria-hidden="true">
|
||||
<label for="collapse-section3" aria-hidden="true">__V1.1.1 / 15-September-2025__</label>
|
||||
<div>
|
||||
|
||||
## Main Changes
|
||||
|
||||
- Maintenance release of **WM8904** Audio Codec driver
|
||||
- Changes compared with V1.1.0 release
|
||||
- Reduce excessive initialization delay by checking stabilization ready flag instead of waiting a fixed time
|
||||
- Update initialization to use output device passed as parameter instead of current device which is not yet initialized
|
||||
|
||||
</div>
|
||||
:::
|
||||
|
||||
::: {.collapse}
|
||||
<input type="checkbox" id="collapse-section2" aria-hidden="true">
|
||||
<label for="collapse-section2" aria-hidden="true">__V1.1.0 / 20-September-2024__</label>
|
||||
<div>
|
||||
|
||||
## Main Changes
|
||||
|
||||
- First maintenance release of **WM8904** Audio Codec driver
|
||||
- Changes compared with V1.0.0 release
|
||||
- Update input devices to be defined as bitfields
|
||||
- Implement LINE_IN2 and digital microphone path
|
||||
- Add 24KHz audio frequency support
|
||||
- Update IsInitialized variable at the end of init function WM8904_Init()
|
||||
|
||||
</div>
|
||||
:::
|
||||
|
||||
::: {.collapse}
|
||||
<input type="checkbox" id="collapse-section1" aria-hidden="true">
|
||||
<label for="collapse-section1" aria-hidden="true">__V1.0.0 / 28-February-2024__</label>
|
||||
<div>
|
||||
|
||||
## Main Changes
|
||||
|
||||
- First official release of **WM8904** Audio Codec driver
|
||||
|
||||
</div>
|
||||
:::
|
||||
|
||||
:::
|
||||
:::
|
||||
|
||||
<footer class="sticky">
|
||||
For complete documentation on <mark>STM32 Microcontrollers</mark> ,
|
||||
visit: [[www.st.com](http://www.st.com/STM32)]{style="font-color: blue;"}
|
||||
</footer>
|
||||
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><g fill="#13254a"><path d="M100 .212C44.868.212 0 44.889 0 99.788c0 55.132 44.868 100 100 100s100-44.868 100-100C200 44.889 155.132.212 100 .212zm0 181.164c-44.974 0-81.587-36.614-81.587-81.587 0-44.762 36.614-81.164 81.587-81.164 44.995 0 81.587 36.402 81.587 81.164 0 44.973-36.592 81.587-81.587 81.587z" style="fill: #e6007e;"/><path d="M141.1 88.127h-29.439V58.688c0-6.392-5.185-11.598-11.598-11.598-6.413 0-11.619 5.206-11.619 11.598v29.439H58.476c-6.392 0-11.598 5.185-11.598 11.598 0 6.413 5.206 11.619 11.598 11.619h29.968v29.968c0 6.392 5.206 11.598 11.619 11.598 6.413 0 11.598-5.206 11.598-11.598v-29.968H141.1c6.392 0 11.598-5.206 11.598-11.619 0-6.413-5.206-11.598-11.598-11.598z" style="fill: #e6007e;"/></g></svg>
|
||||
|
After Width: | Height: | Size: 832 B |
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><g fill="#03234b"><path d="M170.934 64.569l-.04-.055-29.049 40.038-.057.079h14.867a59.366 59.366 0 0 1-1.488 15.615c-1.158 5.318-3.807 13.448-9.848 21.977-2.766 4.118-6.375 7.726-9.208 10.408-3.426 2.857-7.461 6.095-12 8.376-8.121 4.568-17.881 7.138-28.225 7.432-10.907.248-20.201-2.61-26.072-5.052-8.283-3.479-14.111-7.807-16.85-10.078-1.254-.956-2.25-1.907-3.057-2.676a28.662 28.662 0 0 0-1.157-1.069 158.874 158.874 0 0 0-1.479-1.362l-4.435-3.956 3.569 4.81.183.243c.2.263.548.722 1.048 1.389.276.334.579.747.93 1.226l.008.01c.689.939 1.546 2.107 2.664 3.322 3 3.536 8.178 8.801 15.808 13.801 5.969 3.866 15.672 8.901 28.001 10.935a79.05 79.05 0 0 0 12.485.998c7.97 0 15.651-1.228 22.828-3.649 6.366-1.877 12.192-4.981 17.053-7.771 6.16-3.936 10.817-7.586 14.654-11.488 8.084-7.899 14.884-17.913 19.15-28.199 3.259-7.594 5.456-15.727 6.529-24.175l.055-.425.083-.641H200l-29.066-40.063zM58.159 99.232l-12.655.563c-.097-.881-.159-1.986-.227-3.474a59.184 59.184 0 0 1 1.446-16.56c1.157-5.316 3.804-13.444 9.848-21.977 2.168-3.228 5.009-6.44 9.208-10.415 3.41-2.849 7.432-6.08 12.005-8.375 8.114-4.568 17.87-7.138 28.213-7.432 10.9-.25 20.196 2.607 26.072 5.045 8.258 3.473 14.105 7.812 16.857 10.091 1.257.951 2.253 1.904 3.057 2.673l.017.016c.43.411.801.766 1.136 1.051.475.438.841.777 1.091 1.01l.138.128.248.229 4.04 3.613-3.165-4.456c-.058-.083-.312-.417-.73-.971l-.507-.67a28.922 28.922 0 0 1-.901-1.192l-.02-.027c-.69-.945-1.548-2.121-2.677-3.346-3.002-3.537-8.182-8.803-15.813-13.801-5.964-3.865-15.662-8.9-27.997-10.935-8.484-1.363-21.496-2.009-35.313 2.651-6.355 1.88-12.186 4.983-17.054 7.772-6.163 3.944-10.82 7.595-14.654 11.488-8.079 7.894-14.882 17.909-19.155 28.2-3.268 7.624-5.463 15.757-6.523 24.173-.436 3.281-.642 5.421-.664 6.926L0 101.831l30.683 38.727.042.053 27.38-41.298.054-.081z" style="fill: #e6007e;"/></g></svg>
|
||||
|
After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
File diff suppressed because it is too large.
Load diff
Binary file not shown.
|
After Width: | Height: | Size: 7.3 KiB |
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,224 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file wm8904.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains all the functions prototypes for the
|
||||
* wm8904.c driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef WM8904_H
|
||||
#define WM8904_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "wm8904_reg.h"
|
||||
#include <stddef.h>
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup Component
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup WM8904
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup WM8904_Exported_Types Exported Types
|
||||
* @{
|
||||
*/
|
||||
typedef int32_t (*WM8904_Init_Func) (void);
|
||||
typedef int32_t (*WM8904_DeInit_Func) (void);
|
||||
typedef int32_t (*WM8904_GetTick_Func) (void);
|
||||
typedef int32_t (*WM8904_WriteReg_Func)(uint16_t, uint16_t, uint8_t*, uint16_t);
|
||||
typedef int32_t (*WM8904_ReadReg_Func) (uint16_t, uint16_t, uint8_t*, uint16_t);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WM8904_Init_Func Init;
|
||||
WM8904_DeInit_Func DeInit;
|
||||
uint16_t Address;
|
||||
WM8904_WriteReg_Func WriteReg;
|
||||
WM8904_ReadReg_Func ReadReg;
|
||||
WM8904_GetTick_Func GetTick;
|
||||
} WM8904_IO_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WM8904_IO_t IO;
|
||||
wm8904_ctx_t Ctx;
|
||||
uint8_t IsInitialized;
|
||||
} WM8904_Object_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t InputDevice;
|
||||
uint32_t OutputDevice;
|
||||
uint32_t Frequency;
|
||||
uint32_t Resolution;
|
||||
uint32_t Volume;
|
||||
} WM8904_Init_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t ( *Init ) ( WM8904_Object_t *, WM8904_Init_t* );
|
||||
int32_t ( *DeInit ) ( WM8904_Object_t * );
|
||||
int32_t ( *ReadID ) ( WM8904_Object_t *, uint32_t * );
|
||||
int32_t ( *Play ) ( WM8904_Object_t * );
|
||||
int32_t ( *Pause ) ( WM8904_Object_t * );
|
||||
int32_t ( *Resume ) ( WM8904_Object_t * );
|
||||
int32_t ( *Stop ) ( WM8904_Object_t *, uint32_t );
|
||||
int32_t ( *SetFrequency ) ( WM8904_Object_t *, uint32_t );
|
||||
int32_t ( *GetFrequency ) ( WM8904_Object_t *, uint32_t*);
|
||||
int32_t ( *SetVolume ) ( WM8904_Object_t *, uint32_t, uint8_t );
|
||||
int32_t ( *GetVolume ) ( WM8904_Object_t *, uint32_t, uint8_t*);
|
||||
int32_t ( *SetMute ) ( WM8904_Object_t *, uint32_t );
|
||||
int32_t ( *SetOutputMode ) ( WM8904_Object_t *, uint32_t );
|
||||
int32_t ( *SetResolution ) ( WM8904_Object_t *, uint32_t );
|
||||
int32_t ( *GetResolution ) ( WM8904_Object_t *, uint32_t*);
|
||||
int32_t ( *SetProtocol ) ( WM8904_Object_t *, uint32_t );
|
||||
int32_t ( *GetProtocol ) ( WM8904_Object_t *, uint32_t*);
|
||||
int32_t ( *Reset ) ( WM8904_Object_t * );
|
||||
} WM8904_Drv_t;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup WM8904_Exported_Constants Exported Constants
|
||||
* @{
|
||||
*/
|
||||
#define WM8904_OK (0)
|
||||
#define WM8904_ERROR (-1)
|
||||
|
||||
/******************************************************************************/
|
||||
/*************************** Codec User defines ******************************/
|
||||
/******************************************************************************/
|
||||
/* Audio Input Device */
|
||||
#define WM8904_IN_NONE 0x0000U
|
||||
#define WM8904_IN_MIC1 0x0100U
|
||||
#define WM8904_IN_MIC2 0x0200U
|
||||
#define WM8904_IN_MIC1_MIC2 0x0300U
|
||||
#define WM8904_IN_LINE1 0x0400U
|
||||
#define WM8904_IN_LINE2 0x0800U
|
||||
#define WM8904_IN_DIGITAL_MIC1 0x1000U
|
||||
#define WM8904_IN_DIGITAL_MIC2 0x2000U
|
||||
|
||||
/* Audio Output Device */
|
||||
#define WM8904_OUT_NONE 0x0000U
|
||||
#define WM8904_OUT_HEADPHONE 0x0001U
|
||||
#define WM8904_OUT_LINE 0x0002U
|
||||
#define WM8904_OUT_BOTH 0x0003U
|
||||
|
||||
/* AUDIO FREQUENCY */
|
||||
#define WM8904_FREQUENCY_192K 192000U
|
||||
#define WM8904_FREQUENCY_176K 176400U
|
||||
#define WM8904_FREQUENCY_96K 96000U
|
||||
#define WM8904_FREQUENCY_88K 88200U
|
||||
#define WM8904_FREQUENCY_48K 48000U
|
||||
#define WM8904_FREQUENCY_44K 44100U
|
||||
#define WM8904_FREQUENCY_32K 32000U
|
||||
#define WM8904_FREQUENCY_24K 24000U
|
||||
#define WM8904_FREQUENCY_22K 22050U
|
||||
#define WM8904_FREQUENCY_16K 16000U
|
||||
#define WM8904_FREQUENCY_11K 11025U
|
||||
#define WM8904_FREQUENCY_8K 8000U
|
||||
|
||||
/* AUDIO RESOLUTION */
|
||||
#define WM8904_RESOLUTION_16B 0x00U
|
||||
#define WM8904_RESOLUTION_20B 0x01U
|
||||
#define WM8904_RESOLUTION_24B 0x02U
|
||||
#define WM8904_RESOLUTION_32B 0x03U
|
||||
|
||||
/* Codec stop options */
|
||||
#define WM8904_PDWN_HW 0x00U
|
||||
#define WM8904_PDWN_SW 0x01U
|
||||
|
||||
/* Volume Input Output selection */
|
||||
#define VOLUME_INPUT 0U
|
||||
#define VOLUME_OUTPUT 1U
|
||||
|
||||
/* MUTE commands */
|
||||
#define WM8904_MUTE_ON 1U
|
||||
#define WM8904_MUTE_OFF 0U
|
||||
|
||||
/* AUDIO PROTOCOL */
|
||||
#define WM8904_PROTOCOL_R_JUSTIFIED 0x0000U
|
||||
#define WM8904_PROTOCOL_L_JUSTIFIED 0x0001U
|
||||
#define WM8904_PROTOCOL_I2S 0x0002U
|
||||
#define WM8904_PROTOCOL_DSP 0x0003U
|
||||
|
||||
/**
|
||||
* @brief WM8904 ID
|
||||
*/
|
||||
#define WM8904_ID 0x8904U
|
||||
#define WM8904_ID_MASK 0xFFFFU
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup WM8904_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
/* Audio driver structure */
|
||||
extern WM8904_Drv_t WM8904_Driver;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup WM8904_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
/*------------------------------------------------------------------------------
|
||||
Audio Codec functions
|
||||
------------------------------------------------------------------------------*/
|
||||
/* High Layer codec functions */
|
||||
int32_t WM8904_RegisterBusIO (WM8904_Object_t *pObj, const WM8904_IO_t *pIO);
|
||||
int32_t WM8904_Init(WM8904_Object_t *pObj, WM8904_Init_t *pInit);
|
||||
int32_t WM8904_DeInit(WM8904_Object_t *pObj);
|
||||
int32_t WM8904_ReadID(WM8904_Object_t *pObj, uint32_t *Id);
|
||||
int32_t WM8904_Play(WM8904_Object_t *pObj);
|
||||
int32_t WM8904_Pause(WM8904_Object_t *pObj);
|
||||
int32_t WM8904_Resume(WM8904_Object_t *pObj);
|
||||
int32_t WM8904_Stop(WM8904_Object_t *pObj, uint32_t CodecPdwnMode);
|
||||
int32_t WM8904_SetVolume(WM8904_Object_t *pObj, uint32_t InputOutput, uint8_t Volume);
|
||||
int32_t WM8904_GetVolume(WM8904_Object_t *pObj, uint32_t InputOutput, uint8_t *Volume);
|
||||
int32_t WM8904_SetMute(WM8904_Object_t *pObj, uint32_t Cmd);
|
||||
int32_t WM8904_SetOutputMode(WM8904_Object_t *pObj, uint32_t Output);
|
||||
int32_t WM8904_SetResolution(WM8904_Object_t *pObj, uint32_t Resolution);
|
||||
int32_t WM8904_GetResolution(WM8904_Object_t *pObj, uint32_t *Resolution);
|
||||
int32_t WM8904_SetProtocol(WM8904_Object_t *pObj, uint32_t Protocol);
|
||||
int32_t WM8904_GetProtocol(WM8904_Object_t *pObj, uint32_t *Protocol);
|
||||
int32_t WM8904_SetFrequency(WM8904_Object_t *pObj, uint32_t AudioFreq);
|
||||
int32_t WM8904_GetFrequency(WM8904_Object_t *pObj, uint32_t *AudioFreq);
|
||||
int32_t WM8904_Reset(WM8904_Object_t *pObj);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* WM8904_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file wm8904_reg.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides unitary register function to control the WM8904
|
||||
* Audio Codec driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "wm8904_reg.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup Components
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup wm8904
|
||||
* @brief This file provides a set of functions needed to drive the
|
||||
* WM8904 audio codec.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/************** Generic Function *******************/
|
||||
/*******************************************************************************
|
||||
* Function Name : wm8904_read_reg
|
||||
* Description : Generic Reading function. It must be full-filled with either
|
||||
* I2C or SPI reading functions
|
||||
* Input : Register Address, length of buffer
|
||||
* Output : data Read
|
||||
*******************************************************************************/
|
||||
int32_t wm8904_read_reg(const wm8904_ctx_t *ctx, uint16_t reg, uint16_t* data, uint16_t length)
|
||||
{
|
||||
int32_t ret;
|
||||
uint16_t tmp;
|
||||
|
||||
ret = ctx->ReadReg(ctx->handle, reg, (uint8_t *)data, length);
|
||||
|
||||
if(ret >= 0)
|
||||
{
|
||||
tmp = ((uint16_t)(*data >> 8) & 0x00FFU);
|
||||
tmp |= ((uint16_t)(*data << 8) & 0xFF00U);
|
||||
*data = tmp;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : wm8904_write_reg
|
||||
* Description : Generic Writing function. It must be full-filled with either
|
||||
* I2C or SPI writing function
|
||||
* Input : Register Address, data to be written, length of buffer
|
||||
* Output : None
|
||||
*******************************************************************************/
|
||||
int32_t wm8904_write_reg(const wm8904_ctx_t *ctx, uint16_t reg, const uint16_t *data, uint16_t length)
|
||||
{
|
||||
uint16_t tmp;
|
||||
tmp = ((uint16_t)(*data >> 8) & 0x00FFU);
|
||||
tmp |= ((uint16_t)(*data << 8) & 0xFF00U);
|
||||
|
||||
return ctx->WriteReg(ctx->handle, reg, (uint8_t *)&tmp, length);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,228 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file wm8904_reg.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header of wm8904_reg.c
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef WM8904_REG_H
|
||||
#define WM8904_REG_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup Component
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup WM8904
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @addtogroup WM8904_Exported_Constants
|
||||
* @{
|
||||
*/
|
||||
/******************************************************************************/
|
||||
/****************************** REGISTER MAPPING ******************************/
|
||||
/******************************************************************************/
|
||||
/* SW Reset */
|
||||
#define WM8904_SW_RESET 0x0000U
|
||||
|
||||
/* Bias Control */
|
||||
#define WM8904_BIAS_CONTROL0 0x0004U
|
||||
#define WM8904_VMID_CONTROL0 0x0005U
|
||||
#define WM8904_MIC_BIAS_CONTROL0 0x0006U
|
||||
#define WM8904_MIC_BIAS_CONTROL1 0x0007U
|
||||
|
||||
#define WM8904_ANALOG_ADC0 0x000AU
|
||||
|
||||
/* Power Management */
|
||||
#define WM8904_PWR_MANAGEMENT0 0x000CU
|
||||
#define WM8904_PWR_MANAGEMENT2 0x000EU
|
||||
#define WM8904_PWR_MANAGEMENT3 0x000FU
|
||||
#define WM8904_PWR_MANAGEMENT6 0x0012U
|
||||
|
||||
/* Clock Rates */
|
||||
#define WM8904_CLOCK_RATES0 0x0014U
|
||||
#define WM8904_CLOCK_RATES1 0x0015U
|
||||
#define WM8904_CLOCK_RATES2 0x0016U
|
||||
|
||||
/* Audio Interface */
|
||||
#define WM8904_AUDIO_INTERFACE0 0x0018U
|
||||
#define WM8904_AUDIO_INTERFACE1 0x0019U
|
||||
#define WM8904_AUDIO_INTERFACE2 0x001AU
|
||||
#define WM8904_AUDIO_INTERFACE3 0x001BU
|
||||
|
||||
/* DAC */
|
||||
#define WM8904_DAC_DIGITAL_VOL_LEFT 0x001EU
|
||||
#define WM8904_DAC_DIGITAL_VOL_RIGHT 0x001FU
|
||||
#define WM8904_DAC_DIGITAL0 0x0020U
|
||||
#define WM8904_DAC_DIGITAL1 0x0021U
|
||||
|
||||
/* ADC */
|
||||
#define WM8904_ADC_DIGITAL_VOL_LEFT 0x0024U
|
||||
#define WM8904_ADC_DIGITAL_VOL_RIGHT 0x0025U
|
||||
#define WM8904_ADC_DIGITAL0 0x0026U
|
||||
|
||||
#define WM8904_DIGITAL_MICROPHONE0 0x0027U
|
||||
|
||||
/* DRC */
|
||||
#define WM8904_DRC0 0x0028U
|
||||
#define WM8904_DRC1 0x0029U
|
||||
#define WM8904_DRC2 0x002AU
|
||||
#define WM8904_DRC3 0x002BU
|
||||
|
||||
/* Analog */
|
||||
#define WM8904_ANALOG_LEFT_INPUT0 0x002CU
|
||||
#define WM8904_ANALOG_RIGHT_INPUT0 0x002DU
|
||||
#define WM8904_ANALOG_LEFT_INPUT1 0x002EU
|
||||
#define WM8904_ANALOG_RIGHT_INPUT1 0x002FU
|
||||
#define WM8904_ANALOG_OUTPUT1_LEFT 0x0039U
|
||||
#define WM8904_ANALOG_OUTPUT1_RIGHT 0x003AU
|
||||
#define WM8904_ANALOG_OUTPUT2_LEFT 0x003BU
|
||||
#define WM8904_ANALOG_OUTPUT2_RIGHT 0x003CU
|
||||
#define WM8904_ANALOG_OUTPUT12_ZC 0x003DU
|
||||
|
||||
/* DC Servo */
|
||||
#define WM8904_DC_SERVO0 0x0043U
|
||||
#define WM8904_DC_SERVO1 0x0044U
|
||||
#define WM8904_DC_SERVO2 0x0045U
|
||||
#define WM8904_DC_SERVO4 0x0047U
|
||||
#define WM8904_DC_SERVO5 0x0048U
|
||||
#define WM8904_DC_SERVO6 0x0049U
|
||||
#define WM8904_DC_SERVO7 0x004AU
|
||||
#define WM8904_DC_SERVO8 0x004BU
|
||||
#define WM8904_DC_SERVO9 0x004CU
|
||||
#define WM8904_DC_SERVO_READBACK0 0x004DU
|
||||
|
||||
/* Analog */
|
||||
#define WM8904_ANALOG_HP0 0x005AU
|
||||
#define WM8904_ANALOG_LINEOUT0 0x005EU
|
||||
|
||||
/* Charge pump */
|
||||
#define WM8904_CHARGE_PUMP0 0x0062U
|
||||
|
||||
/* Class W/G */
|
||||
#define WM8904_CLASS_W0 0x0068U
|
||||
|
||||
/* Write Sequencer */
|
||||
#define WM8904_WRITE_SEQUENCER0 0x006CU
|
||||
#define WM8904_WRITE_SEQUENCER1 0x006DU
|
||||
#define WM8904_WRITE_SEQUENCER2 0x006EU
|
||||
#define WM8904_WRITE_SEQUENCER3 0x006FU
|
||||
#define WM8904_WRITE_SEQUENCER4 0x0070U
|
||||
|
||||
/* FLL Control */
|
||||
#define WM8904_FLL_CONTROL1 0x0074U
|
||||
#define WM8904_FLL_CONTROL2 0x0075U
|
||||
#define WM8904_FLL_CONTROL3 0x0076U
|
||||
#define WM8904_FLL_CONTROL4 0x0077U
|
||||
#define WM8904_FLL_CONTROL5 0x0078U
|
||||
|
||||
/* GPIO Control */
|
||||
#define WM8904_GPIO_CONTROL1 0x0079U
|
||||
#define WM8904_GPIO_CONTROL2 0x007AU
|
||||
#define WM8904_GPIO_CONTROL3 0x007BU
|
||||
#define WM8904_GPIO_CONTROL4 0x007CU
|
||||
|
||||
#define WM8904_DIGITAL_PULLS 0x007EU
|
||||
|
||||
/* Interrupt */
|
||||
#define WM8904_INTERRUPT_STATUS 0x007FU
|
||||
#define WM8904_INTERRUPT_STATUS_MASK 0x0080U
|
||||
#define WM8904_INTERRUPT_POLARITY 0x0081U
|
||||
#define WM8904_INTERRUPT_DEBOUNCE 0x0082U
|
||||
|
||||
/* EQ */
|
||||
#define WM8904_EQ1 0x0086U
|
||||
#define WM8904_EQ2 0x0087U
|
||||
#define WM8904_EQ3 0x0088U
|
||||
#define WM8904_EQ4 0x0089U
|
||||
#define WM8904_EQ5 0x008AU
|
||||
#define WM8904_EQ6 0x008BU
|
||||
#define WM8904_EQ7 0x008CU
|
||||
#define WM8904_EQ8 0x008DU
|
||||
#define WM8904_EQ9 0x008EU
|
||||
#define WM8904_EQ10 0x008FU
|
||||
#define WM8904_EQ11 0x0090U
|
||||
#define WM8904_EQ12 0x0091U
|
||||
#define WM8904_EQ13 0x0092U
|
||||
#define WM8904_EQ14 0x0093U
|
||||
#define WM8904_EQ15 0x0094U
|
||||
#define WM8904_EQ16 0x0095U
|
||||
#define WM8904_EQ17 0x0096U
|
||||
#define WM8904_EQ18 0x0097U
|
||||
#define WM8904_EQ19 0x0098U
|
||||
#define WM8904_EQ20 0x0099U
|
||||
#define WM8904_EQ21 0x009AU
|
||||
#define WM8904_EQ22 0x009BU
|
||||
#define WM8904_EQ23 0x009CU
|
||||
#define WM8904_EQ24 0x009DU
|
||||
|
||||
#define WM8904_ADC_TEST0 0x00C6U
|
||||
|
||||
#define WM8904_FLL_TEST0 0x00F7U
|
||||
#define WM8904_FLL_TEST1 0x00F8U
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************** Generic Function *******************/
|
||||
|
||||
typedef int32_t (*WM8904_Write_Func)(void *, uint16_t, uint8_t*, uint16_t);
|
||||
typedef int32_t (*WM8904_Read_Func) (void *, uint16_t, uint8_t*, uint16_t);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WM8904_Write_Func WriteReg;
|
||||
WM8904_Read_Func ReadReg;
|
||||
void *handle;
|
||||
} wm8904_ctx_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* Register : Generic - All
|
||||
* Address : Generic - All
|
||||
* Bit Group Name: None
|
||||
* Permission : W
|
||||
*******************************************************************************/
|
||||
int32_t wm8904_write_reg(const wm8904_ctx_t *ctx, uint16_t reg, const uint16_t *data, uint16_t length);
|
||||
int32_t wm8904_read_reg(const wm8904_ctx_t *ctx, uint16_t reg, uint16_t* data, uint16_t length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WM8904_REG_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
Reference in new issue
Block a user