Skip to content

Commit 5ae2bd1

Browse files
authored
VS1053 audio streaming project (#44)
1 parent 07265f6 commit 5ae2bd1

16 files changed

+879
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Each folder within this repository contains a README.md file that describes the
3636
| [SetTimeFromLocation](SetTimeFromLocation) | Project that shows how to use Reverse IP lookup to get location information, then obtain time for location, and set device time. |
3737
| [TranslatorCognitiveServices](TranslatorCognitiveServices) | Project that shows how to call Microsoft Translator Cognitive Services APIs from Azure Sphere |
3838
| [UdpDebugLog](UdpDebugLog) | Code that demonstrates how to override Log_Debug to broadcast on a UDP Socket, includes a Desktop Viewer application. |
39+
| [VS1053AudioStreaming](VS1053AudioStreaming) | Project that shows how to play audio through a VS1053 codec board |
3940
| [WifiConfigurationViaAppResource](WifiConfigurationViaAppResource) | Project that shows how to configure device Wi-Fi settings using an embedded JSON resource file |
4041
| [WifiConfigurationViaNfc](WifiConfigurationViaNfc) | Project that shows how to configure device Wi-Fi settings using NFC |
4142
| [WifiConfigurationViaUart](WifiConfigurationViaUart) | Project that shows how to configure device Wi-Fi settings using Uart |

VS1053AudioStreaming/LICENSE.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright (c) Microsoft Corporation.
2+
3+
MIT License
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

VS1053AudioStreaming/README.md

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Audio Streaming using VS1053 Audio Codec
2+
3+
The goal of this project is to show how to interface with a VS1053 Audio Codec connected using SPI, and streaming NPR.
4+
5+
## Contents
6+
7+
| File/folder | Description |
8+
|-------------|-------------|
9+
| `src\` | Azure Sphere Sample App source code |
10+
| `src\HardwareDefinitions` | Hardware definition files for the Seeed RDB and Avnet Starter Kit |
11+
| `src\VS1053` | Source for VS1053 hardware |
12+
| `README.md` | This README file. |
13+
| `LICENSE.txt` | The license for the project. |
14+
15+
## Prerequisites & Setup
16+
17+
- An Azure Sphere-based device with development features (see [Get started with Azure Sphere](https://azure.microsoft.com/en-us/services/azure-sphere/get-started/) for more information).
18+
- Setup a development environment for Azure Sphere (see [Quickstarts to set up your Azure Sphere device](https://docs.microsoft.com/en-us/azure-sphere/install/overview) for more information).
19+
20+
Note that the Azure Sphere High Level application is configured for the 21.04 SDK release.
21+
22+
## How to use
23+
24+
The project supports the Seeed RDB with an [Adafruit VS1053](https://www.adafruit.com/product/1381) board.
25+
26+
Here's the pinout used in the project the Seeed RDB pinout diagram is [here](https://docs.microsoft.com/en-us/azure-sphere/hardware/mt3620-user-guide))
27+
28+
| Adafruit VS1053 Pin | Seeed MT3620 RDB Pin | Hardware Definition Mapping |
29+
|-------------|-------------|-------------|
30+
| VCC | Header 3, Pin 3 | NA |
31+
| GND | Header 3, Pin 2 | NA |
32+
| DREQ | Header 2, Pin 6 | VS1053_DREQ |
33+
| MISO | Header 4, Pin 5 | VS1053_SPI ISU1 |
34+
| MOSI | Header 4, Pin 11 | VS1053_SPI ISU1 |
35+
| SCLK | Header 4, Pin 7 | VS1053_SPI ISU1 |
36+
| RST | Header 2, Pin 14 | VS1053_RST |
37+
| CS | Header 1, Pin 3 | VS1053_CS |
38+
| xDCS | Header 2, Pin 12 | VS1053_DCS |
39+
| AGND | Audio Jack GND | NA |
40+
| ROUT | Audio Jack Right | NA |
41+
| LOUT | Audio Jack Left | NA |
42+
43+
The VS1053 project code exposes four functions:
44+
45+
* **VS1053_Init** to initialize the hardware
46+
* **VS1053_Cleanup** to cleanup SPI and GPIO resources
47+
* **VS1053_SetVolume** to set the volume level (0 is off, 30 is max)
48+
* **VS1053_PlayByte** to play audio data
49+
50+
The project is configured to play an embedded resource audio file, and also supports internet radio streaming. To enable the internet radio stream uncomment the **add_compile_definitions** line in the following block in the CMakeLists.txt file.
51+
52+
```cmake
53+
# ENABLE NPR INTERNET RADIO STREAM ##########################################################################################
54+
#
55+
# add_compile_definitions(ENABLE_RADIO_STREAMING)
56+
#
57+
###################################################################################################################
58+
59+
```
60+
61+
## Project expectations
62+
63+
* The code is not official, maintained, or production-ready.
64+
65+
### Expected support for the code
66+
67+
This code is not formally maintained, but we will make a best effort to respond to/address any issues you encounter.
68+
69+
### How to report an issue
70+
71+
If you run into an issue with this code, please open a GitHub issue against this repo.
72+
73+
## Contributing
74+
75+
This project welcomes contributions and suggestions. Most contributions require you to
76+
agree to a Contributor License Agreement (CLA) declaring that you have the right to,
77+
and actually do, grant us the rights to use your contribution. For details, visit
78+
https://cla.microsoft.com.
79+
80+
When you submit a pull request, a CLA-bot will automatically determine whether you need
81+
to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the
82+
instructions provided by the bot. You will only need to do this once across all repositories using our CLA.
83+
84+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
85+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
86+
or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
87+
88+
## License
89+
90+
See [LICENSE.txt](./LICENCE.txt)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Launch for Azure Sphere High-Level Applications (gdb)",
9+
"type": "azurespheredbg",
10+
"request": "launch",
11+
"args": [],
12+
"stopAtEntry": false,
13+
"cwd": "${workspaceFolder}",
14+
"environment": [],
15+
"externalConsole": true,
16+
"targetCore": "HLCore",
17+
"partnerComponents": [],
18+
"MIMode": "gdb",
19+
"setupCommands": [
20+
{
21+
"description": "Enable pretty-printing for gdb",
22+
"text": "-enable-pretty-printing",
23+
"ignoreFailures": true
24+
}
25+
]
26+
}
27+
]
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"cmake.generator": "Ninja",
3+
"cmake.buildDirectory": "${workspaceRoot}/out/ARM-${buildType}",
4+
"cmake.buildToolArgs": [ "-v" ],
5+
"cmake.configureSettings": {
6+
"CMAKE_TOOLCHAIN_FILE": "${command:azuresphere.AzureSphereSdkDir}/CMakeFiles/AzureSphereToolchain.cmake",
7+
"AZURE_SPHERE_TARGET_API_SET": "latest-lts"
8+
},
9+
"cmake.configureOnOpen": true,
10+
"C_Cpp.default.configurationProvider": "vector-of-bool.cmake-tools"
11+
}
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
# SELECT DEVELOPER BOARD ##########################################################################################
5+
#
6+
set(SEEED_STUDIO_RDB TRUE "Seeed Studio Azure Sphere MT3620 Development Kit (aka Reference Design Board or rdb)")
7+
#
8+
###################################################################################################################
9+
10+
cmake_minimum_required(VERSION 3.10)
11+
12+
project(VS1053AudioStream_HighLevelApp C)
13+
14+
azsphere_configure_tools(TOOLS_REVISION "21.04")
15+
azsphere_configure_api(TARGET_API_SET "9")
16+
17+
# ENABLE NPR INTERNET RADIO STREAM ##########################################################################################
18+
#
19+
# add_compile_definitions(ENABLE_RADIO_STREAMING)
20+
#
21+
###################################################################################################################
22+
23+
include_directories(${CMAKE_SOURCE_DIR} VS1053)
24+
25+
add_executable(${PROJECT_NAME}
26+
main.c
27+
VS1053/vs1053.c
28+
)
29+
30+
target_link_libraries(${PROJECT_NAME} applibs gcc_s c)
31+
32+
if (SEEED_STUDIO_RDB)
33+
message(verbose " NOTE: Build is configured for Seeed and Adafruit VS1053")
34+
azsphere_target_hardware_definition(${PROJECT_NAME} TARGET_DIRECTORY "${CMAKE_SOURCE_DIR}/HardwareDefinitions/mt3620_rdb" TARGET_DEFINITION "audioplayback_hw.json")
35+
endif(SEEED_STUDIO_RDB)
36+
37+
azsphere_target_add_image_package(${PROJECT_NAME} RESOURCE_FILES speech.mp3)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"environments": [
3+
{
4+
"environment": "AzureSphere"
5+
}
6+
],
7+
"configurations": [
8+
{
9+
"name": "ARM-Debug",
10+
"generator": "Ninja",
11+
"configurationType": "Debug",
12+
"inheritEnvironments": [
13+
"AzureSphere"
14+
],
15+
"buildRoot": "${projectDir}\\out\\${name}",
16+
"installRoot": "${projectDir}\\install\\${name}",
17+
"cmakeToolchain": "${env.AzureSphereDefaultSDKDir}CMakeFiles\\AzureSphereToolchain.cmake",
18+
"buildCommandArgs": "-v",
19+
"ctestCommandArgs": "",
20+
"variables": [
21+
{
22+
"name": "AZURE_SPHERE_TARGET_API_SET",
23+
"value": "latest-lts"
24+
}
25+
]
26+
},
27+
{
28+
"name": "ARM-Release",
29+
"generator": "Ninja",
30+
"configurationType": "Release",
31+
"inheritEnvironments": [
32+
"AzureSphere"
33+
],
34+
"buildRoot": "${projectDir}\\out\\${name}",
35+
"installRoot": "${projectDir}\\install\\${name}",
36+
"cmakeToolchain": "${env.AzureSphereDefaultSDKDir}CMakeFiles\\AzureSphereToolchain.cmake",
37+
"buildCommandArgs": "-v",
38+
"ctestCommandArgs": "",
39+
"variables": [
40+
{
41+
"name": "AZURE_SPHERE_TARGET_API_SET",
42+
"value": "latest-lts"
43+
}
44+
]
45+
}
46+
]
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"Metadata": {
3+
"Type": "Azure Sphere Hardware Definition",
4+
"Version": 1
5+
},
6+
"Description":
7+
{
8+
"Name": "Sample hardware abstraction for MT3620 RDB",
9+
"MainCoreHeaderFileTopContent": [
10+
"/* Copyright (c) Microsoft Corporation. All rights reserved.",
11+
" Licensed under the MIT License. */",
12+
"",
13+
"// This file defines the mapping from the MT3620 reference development board (RDB) to the",
14+
"// 'Adafruit VS1053 board"
15+
]
16+
},
17+
"Imports" : [ {"Path": "mt3620_rdb.json"} ],
18+
"Peripherals": [
19+
{
20+
"Name": "VS1053_DREQ",
21+
"Type": "Gpio",
22+
"Mapping": "MT3620_RDB_HEADER2_PIN6_GPIO",
23+
"Comment": "DREQ"
24+
},
25+
{
26+
"Name": "VS1053_RST",
27+
"Type": "Gpio",
28+
"Mapping": "MT3620_RDB_HEADER2_PIN14_GPIO",
29+
"Comment": "RST"
30+
},
31+
{
32+
"Name": "VS1053_DCS",
33+
"Type": "Gpio",
34+
"Mapping": "MT3620_RDB_HEADER2_PIN12_GPIO",
35+
"Comment": "DCS"
36+
},
37+
{
38+
"Name": "VS1053_SPI",
39+
"Type": "SpiMaster",
40+
"Mapping": "MT3620_RDB_HEADER4_ISU1_SPI",
41+
"Comment": "VS1053 SPI"
42+
},
43+
{
44+
"Name": "VS1053_CS",
45+
"Type": "Gpio",
46+
"Mapping": "MT3620_RDB_HEADER1_PIN3_GPIO",
47+
"Comment": "VS1053 CS"
48+
}
49+
]
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* Copyright (c) Microsoft Corporation. All rights reserved.
2+
Licensed under the MIT License. */
3+
4+
// This file defines the mapping from the MT3620 reference development board (RDB) to the
5+
// Adafruit VS1053 board
6+
7+
#pragma once
8+
#include "mt3620_rdb.h"
9+
10+
#define VS1053_DREQ MT3620_RDB_HEADER2_PIN6_GPIO
11+
#define VS1053_RST MT3620_RDB_HEADER2_PIN14_GPIO
12+
#define VS1053_DCS MT3620_RDB_HEADER2_PIN12_GPIO
13+
#define VS1053_SPI MT3620_RDB_HEADER4_ISU1_SPI
14+
#define VS1053_CS MT3620_RDB_HEADER1_PIN3_GPIO
15+
#define VS1053_SPICS MT3620_SPI_CS_B
16+
17+
18+

0 commit comments

Comments
 (0)