From: Shinichiro Nakamura Date: Mon, 20 Aug 2012 17:45:35 +0000 (+0900) Subject: Ticket #29299 Updated the uzume interface. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=0bc03fcbabd1fac2ad851f94c9d0c8c2fa1c1498;p=bluetank%2Fbluetank.git Ticket #29299 Updated the uzume interface. --- diff --git a/firm/bare_metal/main.c b/firm/bare_metal/main.c index 1d1eb0e..1c3afc3 100644 --- a/firm/bare_metal/main.c +++ b/firm/bare_metal/main.c @@ -5,10 +5,31 @@ */ #include "uzume.h" +#include +#include + +/* + * 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; } diff --git a/firm/bare_metal/uzume.c b/firm/bare_metal/uzume.c index 68c4112..e404e1a 100644 --- a/firm/bare_metal/uzume.c +++ b/firm/bare_metal/uzume.c @@ -1,5 +1,5 @@ /** - * @file main.c + * @file uzume.c * @brief BlueTank ACB-BF592 Application Sample Codes. * @author Copyright(C) 2012 Shinichiro Nakamura */ @@ -13,6 +13,7 @@ #include "led.h" #include "pff.h" #include "ssm2603.h" +#include "uzume.h" #define SCLOCK_HZ (100000000) /**< システムクロック(100MHz) */ #define DMA_SAMPLE_SIZE (256) /**< 1回のサンプルサイズ */ @@ -21,7 +22,6 @@ typedef __attribute__((interrupt_handler)) void (*ex_handler_fn_gcc)(void); 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受信バッファ(ダブルバッファ) @@ -59,17 +59,6 @@ static void __attribute__((interrupt_handler)) sport_rx_isr() 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; @@ -84,15 +73,17 @@ static void vdsp_register_handler(interrupt_kind kind, ex_handler_fn_gcc fn) 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を設定する。 */ @@ -213,6 +204,21 @@ void uzume_execute(void) * ミュートを解除する。 */ 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;"); @@ -226,12 +232,21 @@ void uzume_execute(void) * 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); + } } } diff --git a/firm/bare_metal/uzume.h b/firm/bare_metal/uzume.h index dd9d957..afe6b82 100644 --- a/firm/bare_metal/uzume.h +++ b/firm/bare_metal/uzume.h @@ -1,7 +1,23 @@ + #ifndef UZUME_H #define UZUME_H -void uzume_execute(void); +#include + +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