*/
#include "uzume.h"
+#include <string.h>
+#include <cdefBF592-A.h>
+
+/*
+ * See 'Blackfin GCC Built-in Functions'
+ */
+
+static void effect_through(
+ UZUME *p,
+ const int32_t *src, int32_t *des, int32_t count)
+{
+ memcpy(des, src, sizeof(int32_t) * count);
+}
+
+static void system_default(UZUME *p)
+{
+}
int main(void)
{
- uzume_execute();
+ UZUME u;
+ uzume_init(&u);
+ uzume_set_effect(&u, effect_through);
+ uzume_set_system(&u, system_default);
+ uzume_execute(&u);
return 0;
}
/**
- * @file main.c
+ * @file uzume.c
* @brief BlueTank ACB-BF592 Application Sample Codes.
* @author Copyright(C) 2012 Shinichiro Nakamura
*/
#include "led.h"
#include "pff.h"
#include "ssm2603.h"
+#include "uzume.h"
#define SCLOCK_HZ (100000000) /**< システムクロック(100MHz) */
#define DMA_SAMPLE_SIZE (256) /**< 1回のサンプルサイズ */
static void setup_pll(uint8_t mul_val, uint8_t div_val);
static void __attribute__((interrupt_handler)) sport_rx_isr();
-static void audio_effect(const int32_t* src, int32_t* des, int32_t count);
/**
* SPORT受信バッファ(ダブルバッファ)
bufidx_dma_target = (bufidx_dma_target ^ 1) & 1;
}
-/**
- * @brief オーディオ処理を実行する。
- *
- * @param src 処理元バッファ。
- * @param des 処理後バッファ。
- */
-static void audio_effect(const int32_t *src, int32_t *des, int32_t count)
-{
- memcpy(des, src, sizeof(int32_t) * count);
-}
-
static void vdsp_register_handler(interrupt_kind kind, ex_handler_fn_gcc fn)
{
uint32_t mask;
sti(mask);
}
-void uzume_execute(void)
+void uzume_init(UZUME *p)
{
- int32_t bufidx_dma_done;
FATFS fatfs;
#if 0
DIR dir;
FILINFO finfo;
#endif
+ p->effect = NULL;
+ p->system = NULL;
+
/*
* PLLを設定する。
*/
* ミュートを解除する。
*/
ssm2603_mute(false);
+}
+
+void uzume_set_effect(UZUME *p, UZUME_EFFECT_FUNC effect)
+{
+ p->effect = effect;
+}
+
+void uzume_set_system(UZUME *p, UZUME_SYSTEM_FUNC system)
+{
+ p->system = system;
+}
+
+void uzume_execute(UZUME *p)
+{
+ int32_t bufidx_dma_done;
while (1) {
asm("idle;");
* DMAが完了したバッファを使用してオーディオ処理を行なう。
*/
bufidx_dma_done = bufidx_dma_target ^ 1;
- audio_effect(sport_buffer_rx[bufidx_dma_done], sport_buffer_tx[bufidx_dma_done], DMA_SAMPLE_SIZE);
+ if (p->effect != NULL) {
+ p->effect(
+ p,
+ sport_buffer_rx[bufidx_dma_done],
+ sport_buffer_tx[bufidx_dma_done],
+ DMA_SAMPLE_SIZE);
+ }
/*
*
*/
led_write(LedTargetR, 1);
}
+ if (p->system != NULL) {
+ p->system(p);
+ }
}
}
+
#ifndef UZUME_H
#define UZUME_H
-void uzume_execute(void);
+#include <stdint.h>
+
+typedef struct UZUME UZUME;
+typedef void (*UZUME_EFFECT_FUNC)(UZUME *p,
+ const int32_t *src, int32_t *des, int32_t count);
+typedef void (*UZUME_SYSTEM_FUNC)(UZUME *p);
+
+struct UZUME {
+ UZUME_EFFECT_FUNC effect;
+ UZUME_SYSTEM_FUNC system;
+};
+
+void uzume_init(UZUME *p);
+void uzume_set_effect(UZUME *p, UZUME_EFFECT_FUNC effect);
+void uzume_set_system(UZUME *p, UZUME_SYSTEM_FUNC system);
+void uzume_execute(UZUME *p);
#endif