aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-06-05 21:08:03 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-06-05 21:08:22 +0200
commit8618657695b2530f463d1e7e0fca11304d2b897e (patch)
tree1f183912e438599ef7abdc0e188c48a3da30d56d
parentba105ccbf7c350e24ee527472a99e3672983e93d (diff)
downloadglutte-o-matic-8618657695b2530f463d1e7e0fca11304d2b897e.tar.gz
glutte-o-matic-8618657695b2530f463d1e7e0fca11304d2b897e.tar.bz2
glutte-o-matic-8618657695b2530f463d1e7e0fca11304d2b897e.zip
Make object for common/Audio
-rw-r--r--src/common/includes/Audio/audio.h12
-rw-r--r--src/common/sourcelist.txt2
-rw-r--r--src/common/src/Audio/audio.c18
-rw-r--r--src/glutt-o-logique/audio.c11
-rw-r--r--src/glutt-o-logique/cw.c1
-rw-r--r--src/simulator/src/Audio/audio.c36
-rw-r--r--src/simulator/src/Audio/cw.c24
7 files changed, 79 insertions, 25 deletions
diff --git a/src/common/includes/Audio/audio.h b/src/common/includes/Audio/audio.h
index 006f82e..6531879 100644
--- a/src/common/includes/Audio/audio.h
+++ b/src/common/includes/Audio/audio.h
@@ -6,6 +6,18 @@
typedef void AudioCallbackFunction(void *context,int buffer);
+// Variables used by both glutt-o-logique and simulator
+extern AudioCallbackFunction *callback_function;
+extern void *callback_context;
+extern int16_t *next_buffer_samples;
+extern int next_buffer_length;
+extern int buffer_number;
+extern bool dma_running;
+
+void audio_initialize_platform(int plln, int pllr, int i2sdiv, int i2sodd, int rate);
+void audio_start_dma_and_request_buffers();
+void audio_stop_dma();
+
#define Audio8000HzSettings 256,5,12,1,8000
#define Audio16000HzSettings 213,2,13,0,16000
#define Audio32000HzSettings 213,2,6,1,32000
diff --git a/src/common/sourcelist.txt b/src/common/sourcelist.txt
index 97cb298..4c85b65 100644
--- a/src/common/sourcelist.txt
+++ b/src/common/sourcelist.txt
@@ -1,3 +1,5 @@
src/GPIO/usart.c
src/GPS/gps.c
src/Core/common.c
+src/Audio/cw.c
+src/Audio/audio.c
diff --git a/src/common/src/Audio/audio.c b/src/common/src/Audio/audio.c
index 40f0e76..f68f867 100644
--- a/src/common/src/Audio/audio.c
+++ b/src/common/src/Audio/audio.c
@@ -26,18 +26,12 @@
#include <stdlib.h>
-static void audio_write_register(uint8_t address, uint8_t value);
-static void audio_start_dma_and_request_buffers();
-static void audio_stop_dma();
-
-static AudioCallbackFunction *callback_function;
-static void *callback_context;
-static int16_t * volatile next_buffer_samples;
-static volatile int next_buffer_length;
-static volatile int buffer_number;
-static volatile bool dma_running;
-
-void audio_initialize_platform(int plln, int pllr, int i2sdiv, int i2sodd, int rate);
+AudioCallbackFunction *callback_function;
+void *callback_context;
+int16_t * next_buffer_samples;
+int next_buffer_length;
+int buffer_number;
+bool dma_running;
void audio_initialize(int plln, int pllr, int i2sdiv, int i2sodd, int rate) {
diff --git a/src/glutt-o-logique/audio.c b/src/glutt-o-logique/audio.c
index 87bd896..bf41169 100644
--- a/src/glutt-o-logique/audio.c
+++ b/src/glutt-o-logique/audio.c
@@ -23,10 +23,11 @@
*/
#include "GPIO/i2c.h"
+#include "Audio/audio.h"
#include "stm32f4xx_conf.h"
#include "stm32f4xx.h"
-#include "../common/src/Audio/audio.c"
+static void audio_write_register(uint8_t address, uint8_t value);
void audio_initialize_platform(int plln, int pllr, int i2sdiv, int i2sodd, int rate) {
@@ -164,7 +165,7 @@ void audio_stop() {
audio_stop_dma();
SPI3 ->CR2 &= ~SPI_CR2_TXDMAEN; // Disable I2S TX DMA request.
NVIC_DisableIRQ(DMA1_Stream7_IRQn);
- callback_function = NULL;
+ callback_function = (AudioCallbackFunction*)0;
}
void audio_provide_buffer(void *samples, int numsamples) {
@@ -189,7 +190,7 @@ bool audio_provide_buffer_without_blocking(void *samples, int numsamples) {
return true;
}
-static void audio_start_dma_and_request_buffers() {
+void audio_start_dma_and_request_buffers() {
// Configure DMA stream.
DMA1_Stream7 ->CR = (0 * DMA_SxCR_CHSEL_0 ) | // Channel 0
(1 * DMA_SxCR_PL_0 ) | // Priority 1
@@ -205,7 +206,7 @@ static void audio_start_dma_and_request_buffers() {
DMA1_Stream7 ->CR |= DMA_SxCR_EN;
// Update state.
- next_buffer_samples = NULL;
+ next_buffer_samples = (void*)0;
buffer_number ^= 1;
dma_running = true;
@@ -214,7 +215,7 @@ static void audio_start_dma_and_request_buffers() {
callback_function(callback_context, buffer_number);
}
-static void audio_stop_dma() {
+void audio_stop_dma() {
DMA1_Stream7 ->CR &= ~DMA_SxCR_EN; // Disable DMA stream.
while (DMA1_Stream7 ->CR & DMA_SxCR_EN )
; // Wait for DMA stream to stop.
diff --git a/src/glutt-o-logique/cw.c b/src/glutt-o-logique/cw.c
index a54ca83..c362f6a 100644
--- a/src/glutt-o-logique/cw.c
+++ b/src/glutt-o-logique/cw.c
@@ -22,7 +22,6 @@
* SOFTWARE.
*/
-#include "../common/src/Audio/cw.c"
#include "GPIO/usart.h"
// Function to display message in GUI, unused on STM32 firmware
diff --git a/src/simulator/src/Audio/audio.c b/src/simulator/src/Audio/audio.c
index e4a0129..51a7f3d 100644
--- a/src/simulator/src/Audio/audio.c
+++ b/src/simulator/src/Audio/audio.c
@@ -1,15 +1,39 @@
-#include "../../../common/src/Audio/audio.c"
-
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Matthias P. Braendli, Maximilien Cuony
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+*/
+
+#include <stdio.h>
#include <pulse/simple.h>
+#include "Audio/audio.h"
#include "FreeRTOS.h"
#include "task.h"
-
pa_simple *s = NULL;
int current_buffer_length = 0;
int16_t * current_buffer_samples;
+static void audio_buffer_sent();
static void audio_buffer_sender(void *args);
extern char gui_audio_on;
@@ -60,7 +84,7 @@ static void audio_buffer_sender(void *args) {
}
-void audio_buffer_sent() {
+static void audio_buffer_sent() {
if (next_buffer_samples) {
audio_start_dma_and_request_buffers();
@@ -119,7 +143,7 @@ bool audio_provide_buffer_without_blocking(void *samples, int numsamples) {
return true;
}
-static void audio_start_dma_and_request_buffers() {
+void audio_start_dma_and_request_buffers() {
current_buffer_length = next_buffer_length;
current_buffer_samples = next_buffer_samples;
@@ -134,7 +158,7 @@ static void audio_start_dma_and_request_buffers() {
callback_function(callback_context, buffer_number);
}
-static void audio_stop_dma() {
+void audio_stop_dma() {
dma_running = false;
}
diff --git a/src/simulator/src/Audio/cw.c b/src/simulator/src/Audio/cw.c
index 0f37be4..e9321da 100644
--- a/src/simulator/src/Audio/cw.c
+++ b/src/simulator/src/Audio/cw.c
@@ -1,4 +1,26 @@
-#include "../../../common/src/Audio/cw.c"
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Matthias P. Braendli, Maximilien Cuony
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+*/
extern char gui_cw_text[4096];
int gui_cw_text_pointer = 0;