OSDN Git Service

送信DMAおよび割り込みの動作を確認。送信タスクまでシグナルが正しい周期で来ている
[trx-305dsp/dsp.git] / trx305 / rx_if.c
index cdd134e..2c9fac4 100644 (file)
@@ -7,13 +7,9 @@
 #include <cdefBF533.h>
 
 
-#define PEEPINGTEST             // Define PEEPING test to see the top 4 of FIFO after enabling SPORT RX
+static void init_sport0_rx(void);
+static void init_sport0_tx(void);
 
-#ifdef PEEPINGTEST
-#define SLEEPDURATION 1000
-#else
-#define SLEEPDURATION 10
-#endif
 
 struct dma_descripter{
     struct dma_descripter * next_descripter;
@@ -23,12 +19,22 @@ struct dma_descripter{
     unsigned short x_modify;
 };
 
-static struct dma_descripter rx_dma_dsc[2];
-
-unsigned int rxif_buffer[2][RXIF_BUFSIZE];
-
-/*
- *  RX_IF受信データの処理タスク。
+static struct {
+    struct dma_descripter rx_dma_dsc[2];
+    struct dma_descripter tx_dma_dsc[2];
+
+    unsigned int rxif_buffer[2][RXIF_BUFSIZE];
+    unsigned int af_buffer[2][AF_BUFSIZE];
+} sport_ctl;
+
+/**
+ * \brief RX_IF受信データの処理タスク
+ * \param cfgファイルから値を渡すための引数。使っていない
+ * \details 受信データをDMAバッファから取り出して復調し、データキューに
+ * 書き込む。データキューは \ref af_task との共用である。
+ *
+ * また、受信DMA内のRX-IFデータにはコマンドが含まれている。これらの
+ * コマンドを内部変数に記録して復調器がりようできるようにしておく。
  */
 void rx_if_task(VP_INT exinf)
 {
@@ -40,111 +46,45 @@ void rx_if_task(VP_INT exinf)
             (IOCTL_CRLF | IOCTL_FCSND | IOCTL_FCRCV)));
 
 
-
+        // SPORT0の送受割り込みを可能にする
     syscall(ena_int(INTNO_SPORT0_RX));
+    syscall(ena_int(INTNO_SPORT0_TX));
 
-    *pSPORT0_TCR1 =
-            0 << 14 |   // TCKFE,   0:sample at down edge, 1:sample at up edge
-            0 << 13 |   // LATFS,   0:early frame sync, 1:late frame sync
-            0 << 12 |   // LTFS,    0:Active high TFS, 1:Active low TFS
-            0 << 11 |   // DITFS,   0:data dependent TFS generation, 1:data independent TFS generation
-            0 << 10 |   // TFSR,    0:TFS is not required every word, 1:TFS is required every word
-            0 << 9  |   // ITFS,    0:external TFS, 1:internal TFS
-            0 << 4  |   // TLSBIT,  0:MSB first transmission, 1:LSB first transmission
-            0 << 2  |   // TDTYPE   0:normal, 1:reserved, 2:u-law, 3:a-law
-            0 << 1  |   // ITCLK,   0:external clock generation, 1:internal clock generation
-            0 << 0  ;   // TSPEN    0:Tx disable, 1:Tx enable
-
-    *pSPORT0_TCR2 =
-            0 << 10 |   // TRFST,   0:left streo ch first, 1:right stereo ch first
-            0 << 9  |   // TSFESE,  0:normal frame sync, 1:LR frame clock
-            0 << 8  |   // TXSE,    0:secondary ch disable, 1:secondary ch enable
-            0 << 0  ;   // SLEN     0-1:not allowed,2-31:Serial word length - 1
-
+        // SPORT0の送受信を初期化する。
+    init_sport0_tx();       // 送信DMA開始。割り込みはまだ生成しない
+    init_sport0_rx();       // 受信DMA開始。割り込みイネーブル。
 
-    *pSPORT0_RCR1 =
-            0 << 14 |   // RCKFE,   0:sample at down edge, 1:sample at up edge
-            0 << 13 |   // LARFS,   0:early frame sync, 1:late frame sync
-            0 << 12 |   // LRFS,    0:Active high RFS, 1:Active low RFS
-            1 << 10 |   // RFSR,    0:RFS is not required every word, 1:RFS is required every word
-            0 << 9  |   // IRFS,    0:external RFS, 1:internal RFS
-            0 << 4  |   // RLSBIT,  0:MSB first transmission, 1:LSB first transmission
-            0 << 2  |   // RDTYPE   0:zero fill, 1:sign extend, 2:u-law, 3:a-law
-            0 << 1  |   // IRCLK,   0:external clock generation, 1:internal clock generation
-            0 << 0  ;   // RSPEN    0:Rx disable, 1:Rx enable
-
-    *pSPORT0_RCR2 =
-            0 << 10 |   // RRFST,   0:left streo ch first, 1:right stereo ch first
-            0 << 9  |   // RSFESE,  0:normal frame sync, 1:LR frame clock
-            1 << 8  |   // RXSE,    0:secondary ch disable, 1:secondary ch enable
-           29 << 0  ;   // SLEN     0-1:not allowed,2-31:Serial word length - 1
+        // AF送信を開始する。ただし、送信DMA割り込みはまだ発生しない。
+    *pDMA2_CONFIG |= DMAEN;     // TX SPORT DMA Enable
+    *pSPORT0_TCR1 |= RSPEN;     // TX SPORT Enable
     ssync();
 
+    tslp_tsk(1);      // DMAがFIFOを充填するのに十分な時間待つ。
+    syscall(act_tsk(TASK_AF));  // AFデータ送信タスクをアクティブにする
 
-
-        // 受信DMAデスクリプタを作る
-    rx_dma_dsc[0].next_descripter = &rx_dma_dsc[1];
-    rx_dma_dsc[0].start_address = rxif_buffer[0];
-    rx_dma_dsc[0].x_count = RXIF_BUFSIZE;
-    rx_dma_dsc[0].x_modify = sizeof(rxif_buffer[0][0]);
-    rx_dma_dsc[0].config =
-            FLOW_LARGE      |   // FLOW,    0:Stop, 1:Auto buffer, 4:Desc array, 6:Desc List small, 7:Desc, List, Large
-            NDSIZE_7        |   // NDSIZE,  the # of element of the next descripter to fetch
-            1 << DI_EN_P    |   // DI_EN,   0:No interrupt at the end, 1:Interrupt at the end
-            0 << DI_SEL_P   |   // DI_SEL,  0:Interrupt at the end of outer loop, 1:Interrupt at the end of inter loop
-            0 << RESTART_P  |   // RESTART, 0:Keep DMA FIFO before start, 1:Purge DMA FIFO before start
-            0 << DMA2D_P    |   // DMA2D,   0:Linear DMA, 1:2D DMA
-            WDSIZE_32       |   // WDSIZE,  0:8bit, 1:16bit, 2:32bit,3:reserved
-            1 << WNR_P      |   // WNR,     0:Read from memory, 1:Write to Memory
-            1 << 0          ;   // DMA_EN,  0:Disable DMA, 1:Enable DMA
-
-    rx_dma_dsc[1].next_descripter = &rx_dma_dsc[0];
-    rx_dma_dsc[1].start_address = rxif_buffer[1];
-    rx_dma_dsc[1].x_count = RXIF_BUFSIZE;
-    rx_dma_dsc[1].x_modify = sizeof(rxif_buffer[1][0]);
-    rx_dma_dsc[1].config =
-            FLOW_LARGE      |   // FLOW,    0:Stop, 1:Auto buffer, 4:Desc array, 6:Desc List small, 7:Desc, List, Large
-            NDSIZE_7        |   // NDSIZE,  the # of element of the next descripter to fetch
-            1 << DI_EN_P    |   // DI_EN,   0:No interrupt at the end, 1:Interrupt at the end
-            0 << DI_SEL_P   |   // DI_SEL,  0:Interrupt at the end of outer loop, 1:Interrupt at the end of inter loop
-            0 << RESTART_P  |   // RESTART, 0:Keep DMA FIFO before start, 1:Purge DMA FIFO before start
-            0 << DMA2D_P    |   // DMA2D,   0:Linear DMA, 1:2D DMA
-            WDSIZE_32       |   // WDSIZE,  0:8bit, 1:16bit, 2:32bit,3:reserved
-            1 << WNR_P      |   // WNR,     0:Read from memory, 1:Write to Memory
-            1 << 0          ;   // DMA_EN,  0:Disable DMA, 1:Enable DMA
-
-        // DMAコントローラの初期状態設定
-        // ここではDMAをイネーブルにしない。また、バッファクリアする
-    *pDMA1_CONFIG =
-            FLOW_LARGE      |   // FLOW,    0:Stop, 1:Auto buffer, 4:Desc array, 6:Desc List small, 7:Desc, List, Large
-            NDSIZE_7        |   // NDSIZE,  the # of element of the next descripter to fetch
-            1 << DI_EN_P    |   // DI_EN,   0:No interrupt at the end, 1:Interrupt at the end
-            0 << DI_SEL_P   |   // DI_SEL,  0:Interrupt at the end of outer loop, 1:Interrupt at the end of inter loop
-            1 << RESTART_P  |   // RESTART, 0:Keep DMA FIFO before start, 1:Purge DMA FIFO before start
-            0 << DMA2D_P    |   // DMA2D,   0:Linear DMA, 1:2D DMA
-            WDSIZE_32       |   // WDSIZE,  0:8bit, 1:16bit, 2:32bit,3:reserved
-            1 << WNR_P      |   // WNR,     0:Read from memory, 1:Write to Memory
-            0 << 0          ;   // DMA_EN,  0:Disable DMA, 1:Enable DMA
-    *pDMA1_NEXT_DESC_PTR = &rx_dma_dsc[0];
-
-
-#ifndef PEEPINGTEST
-    int count = 0, event = 0;
-#endif
-
+        // 頃合いなので送信DMA割り込みを開始する。
+        // CPUロックするのは割り込みにより、タイミングがずれるのを嫌って。
+    loc_cpu();
+    sport_ctl.tx_dma_dsc[0].config |= 1 << DI_EN_P;
+    sport_ctl.tx_dma_dsc[1].config |= 1 << DI_EN_P;
+    unl_cpu();
 
         // RX受信を開始する
-    *pDMA1_CONFIG |= DMAEN;
-
+    *pDMA1_CONFIG |= DMAEN;     // RX SPORT DMA Enable
     *pSPORT0_RCR1 |= RSPEN;     // RX SPORT Enable
     ssync();
 
+
+
+
     int count = 0;
 
+
     /*
      *  メインループ
      */
     do {
+
         long int rx[4];
 
             // SPORT0受信DMAがバッファを埋めるのを待つ。
@@ -156,10 +96,10 @@ void rx_if_task(VP_INT exinf)
             count = 0;
                 // FIFOにデータがたまったはずである。
                 // FIFOデータを読みだして下位2bitのみ表示する
-            rx[0] = rxif_buffer[0][0];    // 下位2bitのみ抽出
-            rx[1] = rxif_buffer[0][1];    // 下位2bitのみ抽出
-            rx[2] = rxif_buffer[0][2];    // 下位2bitのみ抽出
-            rx[3] = rxif_buffer[0][3];    // 下位2bitのみ抽出
+            rx[0] = sport_ctl.rxif_buffer[1][0];    // 下位2bitのみ抽出
+            rx[1] = sport_ctl.rxif_buffer[1][1];    // 下位2bitのみ抽出
+            rx[2] = sport_ctl.rxif_buffer[1][2];    // 下位2bitのみ抽出
+            rx[3] = sport_ctl.rxif_buffer[1][3];    // 下位2bitのみ抽出
 
             syslog( LOG_NOTICE, "RX word : %08x,%08x,%08x,%08x", rx[0], rx[1], rx[2], rx[3] );
 
@@ -176,36 +116,262 @@ void rx_if_task(VP_INT exinf)
 }
 
 
+/**
+ * \brief AF送信データの処理タスク。
+ * \param exinf cfgファイルに記述されたパラメタを受け取る引数。使っていない。
+ * \details データキューから取り出したAF信号をDMAバッファに転送する。
+ * このタスクは受信データ処理タスクより優先順位が高い。これは、DMAの送信割り込みへの
+ * 応答が遅れると、バッファを埋め終わる前に送信が始まってしまうからである。
+ *
+ * このタスクではあまり多くの時間を割くべきではなく、そのため、データキューへデータを
+ * 送り込む段階でAFデータの組み立ては終わっている。また、データの初期化などは全部
+ * RX-IF処理タスクに任せている。
+ */
+void af_task(VP_INT exinf)
+{
+    syslog( LOG_NOTICE, "TASK_AF activatred!" );
+
+    int i = 0;
+
+    do{
+        syscall(wai_sem(SEM_SPORT0_TX));
+        // ここに送信処理を書く
+
+        if ( i == 0)
+        {
+            i=8000;
+            syslog( LOG_NOTICE, "AF Interrupt" );
+        }
+        i--;
+    }while (1);
+}
+
+/**
+ * \brief SPORT0 受信割り込みハンドラ
+ * \details このルーチンはcfgファイルで宣言され、SPORT0 RX 割り込みハンドラとして登録される。
+ * SPORT0 RX DMAがバッファの受信を終えるたびに呼び出される。
+ * 割り込み専有時間を小さくするため、実際には、割り込みのクリアと受信タスクへの通知しかしていない。
+ */
 void sport0_rx_int_handler(void)
 {
         // DMA割り込みをクリアする。
     *pDMA1_IRQ_STATUS = DMA_DONE;
 
-        // ペリフェラルへの書き込みを待つ。
-    ssync();
-
         // タスクにSPORT0受信DMAのバッファが埋まったと知らせる。
-    isig_sem(SEM_SPORT0_RX);
+    syscall(isig_sem(SEM_SPORT0_RX));
 
+        // ペリフェラルへの書き込みを待つ。
+    ssync();
 
 }
 
+/**
+ * \brief SPORT0 送信割り込みハンドラ
+ * \details このルーチンはcfgファイルで宣言され、SPORT0 TX 割り込みハンドラとして登録される。
+ * SPORT0 TX DMAがバッファの送信を終えるたびに呼び出される。
+ * 割り込み専有時間を小さくするため、実際には、割り込みのクリアと送信タスクへの通知しかしていない。
+ */
 void sport0_tx_int_handler(void)
 {
+        // DMA割り込みをクリアする。
     *pDMA2_IRQ_STATUS = DMA_DONE;
-    ssync();
 
+        // タスクにSPORT0送信DMAのバッファが空いたと知らせる。
+     syscall(isig_sem(SEM_SPORT0_TX));
+
+         // ペリフェラルへの書き込みを待つ。
+     ssync();
 
 }
 
+/**
+ * \brief ペリフェラルの初期化
+ * \param p イニシャライザにコンフィギュレータから与えられる数値。使っていない。
+ * \details この関数はATT_INIによってコンフィギュレータによりイニシャライザとして
+ * 登録される。システムが起動すると、マルチタスク処理が始まる前にこの関数が一度だけ呼ばれる。
+ */
 
 void init_peripherals(VP_INT p)
 {
+        // ペリフェラルをディセーブルにする
     *pSPORT0_TCR1 = 0;
     *pSPORT0_RCR1 = 0;
     *pDMA1_CONFIG = 0;
     *pDMA2_CONFIG = 0;
     ssync();
+}
+
+/**
+ * \brief SPORT0 RX 関連の初期化
+ * \details この関数は、\ref rx_if_task から一度だけ呼び出される。呼び出されると、
+ * DMAバッファをクリアし、SPORT0 RX関係のレジスタを然るべき値で初期化する。
+ */
+
+static void init_sport0_rx(void)
+{
+    int i;
+
+        // DMAバッファを明示的にクリアする
+    for ( i = 0; i < RXIF_BUFSIZE; i++)
+    {
+        sport_ctl.rxif_buffer[0][i] = 0;
+        sport_ctl.rxif_buffer[0][i] = 0;
+    }
+
+        // 受信SPORTの設定。WORD長は30bitで、アーリー同期信号。外部クロック入力。
+    *pSPORT0_RCR1 =
+            0 << 14 |   // RCKFE,   0:sample at down edge, 1:sample at up edge
+            0 << 13 |   // LARFS,   0:early frame sync, 1:late frame sync
+            0 << 12 |   // LRFS,    0:Active high RFS, 1:Active low RFS
+            1 << 10 |   // RFSR,    0:RFS is not required every word, 1:RFS is required every word
+            0 << 9  |   // IRFS,    0:external RFS, 1:internal RFS
+            0 << 4  |   // RLSBIT,  0:MSB first transmission, 1:LSB first transmission
+            0 << 2  |   // RDTYPE   0:zero fill, 1:sign extend, 2:u-law, 3:a-law
+            0 << 1  |   // IRCLK,   0:external clock generation, 1:internal clock generation
+            0 << 0  ;   // RSPEN    0:Rx disable, 1:Rx enable
+
+    *pSPORT0_RCR2 =
+            0 << 10 |   // RRFST,   0:left streo ch first, 1:right stereo ch first
+            0 << 9  |   // RSFESE,  0:normal frame sync, 1:LR frame clock
+            1 << 8  |   // RXSE,    0:secondary ch disable, 1:secondary ch enable
+           29 << 0  ;   // SLEN     0-1:not allowed,2-31:Serial word length - 1
+    ssync();
+
+
+        // 受信DMAデスクリプタを作る
+    sport_ctl.rx_dma_dsc[0].next_descripter = &sport_ctl.rx_dma_dsc[1];
+    sport_ctl.rx_dma_dsc[0].start_address = sport_ctl.rxif_buffer[0];
+    sport_ctl.rx_dma_dsc[0].x_count = RXIF_BUFSIZE;
+    sport_ctl.rx_dma_dsc[0].x_modify = sizeof(sport_ctl.rxif_buffer[0][0]);
+    sport_ctl.rx_dma_dsc[0].config =
+            FLOW_LARGE      |   // FLOW,    0:Stop, 1:Auto buffer, 4:Desc array, 6:Desc List small, 7:Desc, List, Large
+            NDSIZE_7        |   // NDSIZE,  the # of element of the next descripter to fetch
+            1 << DI_EN_P    |   // DI_EN,   0:No interrupt at the end, 1:Interrupt at the end
+            0 << DI_SEL_P   |   // DI_SEL,  0:Interrupt at the end of outer loop, 1:Interrupt at the end of inter loop
+            0 << RESTART_P  |   // RESTART, 0:Keep DMA FIFO before start, 1:Purge DMA FIFO before start
+            0 << DMA2D_P    |   // DMA2D,   0:Linear DMA, 1:2D DMA
+            WDSIZE_32       |   // WDSIZE,  0:8bit, 1:16bit, 2:32bit,3:reserved
+            1 << WNR_P      |   // WNR,     0:Read from memory, 1:Write to Memory
+            1 << 0          ;   // DMA_EN,  0:Disable DMA, 1:Enable DMA
+
+    sport_ctl.rx_dma_dsc[1].next_descripter = &sport_ctl.rx_dma_dsc[0];
+    sport_ctl.rx_dma_dsc[1].start_address = sport_ctl.rxif_buffer[1];
+    sport_ctl.rx_dma_dsc[1].x_count = RXIF_BUFSIZE;
+    sport_ctl.rx_dma_dsc[1].x_modify = sizeof(sport_ctl.rxif_buffer[1][0]);
+    sport_ctl.rx_dma_dsc[1].config =
+            FLOW_LARGE      |   // FLOW,    0:Stop, 1:Auto buffer, 4:Desc array, 6:Desc List small, 7:Desc, List, Large
+            NDSIZE_7        |   // NDSIZE,  the # of element of the next descripter to fetch
+            1 << DI_EN_P    |   // DI_EN,   0:No interrupt at the end, 1:Interrupt at the end
+            0 << DI_SEL_P   |   // DI_SEL,  0:Interrupt at the end of outer loop, 1:Interrupt at the end of inter loop
+            0 << RESTART_P  |   // RESTART, 0:Keep DMA FIFO before start, 1:Purge DMA FIFO before start
+            0 << DMA2D_P    |   // DMA2D,   0:Linear DMA, 1:2D DMA
+            WDSIZE_32       |   // WDSIZE,  0:8bit, 1:16bit, 2:32bit,3:reserved
+            1 << WNR_P      |   // WNR,     0:Read from memory, 1:Write to Memory
+            1 << 0          ;   // DMA_EN,  0:Disable DMA, 1:Enable DMA
+
+        // SPORT0 受信DMAコントローラの初期状態設定
+        // ここではDMAをイネーブルにしない。また、バッファクリアする
+    *pDMA1_CONFIG =
+            FLOW_LARGE      |   // FLOW,    0:Stop, 1:Auto buffer, 4:Desc array, 6:Desc List small, 7:Desc, List, Large
+            NDSIZE_7        |   // NDSIZE,  the # of element of the next descripter to fetch
+            1 << DI_EN_P    |   // DI_EN,   0:No interrupt at the end, 1:Interrupt at the end
+            0 << DI_SEL_P   |   // DI_SEL,  0:Interrupt at the end of outer loop, 1:Interrupt at the end of inter loop
+            1 << RESTART_P  |   // RESTART, 0:Keep DMA FIFO before start, 1:Purge DMA FIFO before start
+            0 << DMA2D_P    |   // DMA2D,   0:Linear DMA, 1:2D DMA
+            WDSIZE_32       |   // WDSIZE,  0:8bit, 1:16bit, 2:32bit,3:reserved
+            1 << WNR_P      |   // WNR,     0:Read from memory, 1:Write to Memory
+            0 << 0          ;   // DMA_EN,  0:Disable DMA, 1:Enable DMA
+    *pDMA1_NEXT_DESC_PTR = &sport_ctl.rx_dma_dsc[0];
+
+
+}
+
+/**
+ * \brief SPORT0 TX 関連の初期化
+ * \details この関数は、\ref rx_if_task から一度だけ呼び出される。呼び出されると、
+ * DMAバッファをクリアし、SPORT0 RX関係のレジスタを然るべき値で初期化する。
+ */
+
+static void init_sport0_tx(void)
+{
+    int i;
+
+        // DMAバッファを明示的にクリアする
+    for ( i = 0; i < AF_BUFSIZE; i++)
+    {
+        sport_ctl.af_buffer[0][i] = 0;
+        sport_ctl.af_buffer[0][i] = 0;
+    }
+
+
+        // 送信SPORTの設定。WORD長は31bitで、アーリー同期信号。外部クロック入力。
+    *pSPORT0_TCR1 =
+            0 << 14 |   // TCKFE,   0:sample at down edge, 1:sample at up edge
+            0 << 13 |   // LATFS,   0:early frame sync, 1:late frame sync
+            0 << 12 |   // LTFS,    0:Active high TFS, 1:Active low TFS
+            0 << 11 |   // DITFS,   0:data dependent TFS generation, 1:data independent TFS generation
+            1 << 10 |   // TFSR,    0:TFS is not required every word, 1:TFS is required every word
+            0 << 9  |   // ITFS,    0:external TFS, 1:internal TFS
+            0 << 4  |   // TLSBIT,  0:MSB first transmission, 1:LSB first transmission
+            0 << 2  |   // TDTYPE   0:normal, 1:reserved, 2:u-law, 3:a-law
+            0 << 1  |   // ITCLK,   0:external clock generation, 1:internal clock generation
+            0 << 0  ;   // TSPEN    0:Tx disable, 1:Tx enable
+
+    *pSPORT0_TCR2 =
+            0 << 10 |   // TRFST,   0:left streo ch first, 1:right stereo ch first
+            0 << 9  |   // TSFESE,  0:normal frame sync, 1:LR frame clock
+            0 << 8  |   // TXSE,    0:secondary ch disable, 1:secondary ch enable
+           30 << 0  ;   // SLEN     0-1:not allowed,2-31:Serial word length - 1
+
+
+        // 送信DMAデスクリプタを作る
+        // 注意:制御の都合上、最初はDMA割り込みをオフにしておく。これは
+        // DMA及びSPORT FIFOへの書き込みによるスタート後のラッシュで割り込みが
+        // 起きないようにするためである。ラッシュで送信されるのはダミーデータのみ
+        // である。rx_if_taskの初期化部でSPORT受信部を起動する際に、送信部の割り込みも
+        // 有効にする。
+    sport_ctl.tx_dma_dsc[0].next_descripter = &sport_ctl.tx_dma_dsc[1];
+    sport_ctl.tx_dma_dsc[0].start_address = sport_ctl.af_buffer[0];
+    sport_ctl.tx_dma_dsc[0].x_count = RXIF_BUFSIZE;
+    sport_ctl.tx_dma_dsc[0].x_modify = sizeof(sport_ctl.af_buffer[0][0]);
+    sport_ctl.tx_dma_dsc[0].config =
+            FLOW_LARGE      |   // FLOW,    0:Stop, 1:Auto buffer, 4:Desc array, 6:Desc List small, 7:Desc, List, Large
+            NDSIZE_7        |   // NDSIZE,  the # of element of the next descripter to fetch
+            0 << DI_EN_P    |   // DI_EN,   0:No interrupt at the end, 1:Interrupt at the end
+            0 << DI_SEL_P   |   // DI_SEL,  0:Interrupt at the end of outer loop, 1:Interrupt at the end of inter loop
+            0 << RESTART_P  |   // RESTART, 0:Keep DMA FIFO before start, 1:Purge DMA FIFO before start
+            0 << DMA2D_P    |   // DMA2D,   0:Linear DMA, 1:2D DMA
+            WDSIZE_32       |   // WDSIZE,  0:8bit, 1:16bit, 2:32bit,3:reserved
+            0 << WNR_P      |   // WNR,     0:Read from memory, 1:Write to Memory
+            1 << 0          ;   // DMA_EN,  0:Disable DMA, 1:Enable DMA
+
+    sport_ctl.tx_dma_dsc[1].next_descripter = &sport_ctl.tx_dma_dsc[0];
+    sport_ctl.tx_dma_dsc[1].start_address = sport_ctl.af_buffer[1];
+    sport_ctl.tx_dma_dsc[1].x_count = RXIF_BUFSIZE;
+    sport_ctl.tx_dma_dsc[1].x_modify = sizeof(sport_ctl.af_buffer[1][0]);
+    sport_ctl.tx_dma_dsc[1].config =
+            FLOW_LARGE      |   // FLOW,    0:Stop, 1:Auto buffer, 4:Desc array, 6:Desc List small, 7:Desc, List, Large
+            NDSIZE_7        |   // NDSIZE,  the # of element of the next descripter to fetch
+            0 << DI_EN_P    |   // DI_EN,   0:No interrupt at the end, 1:Interrupt at the end
+            0 << DI_SEL_P   |   // DI_SEL,  0:Interrupt at the end of outer loop, 1:Interrupt at the end of inter loop
+            0 << RESTART_P  |   // RESTART, 0:Keep DMA FIFO before start, 1:Purge DMA FIFO before start
+            0 << DMA2D_P    |   // DMA2D,   0:Linear DMA, 1:2D DMA
+            WDSIZE_32       |   // WDSIZE,  0:8bit, 1:16bit, 2:32bit,3:reserved
+            0 << WNR_P      |   // WNR,     0:Read from memory, 1:Write to Memory
+            1 << 0          ;   // DMA_EN,  0:Disable DMA, 1:Enable DMA
+
+        // SPORT0 送信DMAコントローラの初期状態設定
+        // ここではDMAをイネーブルにしない。また、バッファクリアする
+    *pDMA2_CONFIG =
+            FLOW_LARGE      |   // FLOW,    0:Stop, 1:Auto buffer, 4:Desc array, 6:Desc List small, 7:Desc, List, Large
+            NDSIZE_7        |   // NDSIZE,  the # of element of the next descripter to fetch
+            0 << DI_EN_P    |   // DI_EN,   0:No interrupt at the end, 1:Interrupt at the end
+            0 << DI_SEL_P   |   // DI_SEL,  0:Interrupt at the end of outer loop, 1:Interrupt at the end of inter loop
+            1 << RESTART_P  |   // RESTART, 0:Keep DMA FIFO before start, 1:Purge DMA FIFO before start
+            0 << DMA2D_P    |   // DMA2D,   0:Linear DMA, 1:2D DMA
+            WDSIZE_32       |   // WDSIZE,  0:8bit, 1:16bit, 2:32bit,3:reserved
+            0 << WNR_P      |   // WNR,     0:Read from memory, 1:Write to Memory
+            0 << 0          ;   // DMA_EN,  0:Disable DMA, 1:Enable DMA
+    *pDMA2_NEXT_DESC_PTR = &sport_ctl.tx_dma_dsc[0];
 
-    return;
 }