3 #include <t_services.h>
16 UW task_loop; /* タスク内でのループ回数 */
17 UW tex_loop; /* 例外処理ルーチン内でのループ回数 */
22 void task(VP_INT exinf)
25 INT tskno = (INT) exinf;
27 syslog(LOG_NOTICE, "task%d is running (%03d). %s",
33 * 並行して実行されるタスク用のタスク例外処理ルーチン
35 void tex_routine(TEXPTN texptn, VP_INT exinf)
37 INT tskno = (INT) exinf;
39 syslog(LOG_NOTICE, "task%d receives exception 0x%04x. ",
50 cpuexc_handler(VP p_excinf)
53 syslog(LOG_NOTICE, "CPU exception handler (p_excinf = %08p).",
63 * HIGH_PRIORITY,MID_PRIORITY,LOW_PRIORITY の各優先度のレディキュー
66 void cyclic_handler(VP_INT exinf)
74 void main_task(VP_INT exinf)
78 vmsk_log(LOG_UPTO(LOG_INFO), LOG_UPTO(LOG_EMERG));
79 syslog(LOG_NOTICE, "Sample program starts (exinf = %d).", (INT) exinf);
81 syscall(serial_ctl_por(TASK_PORTID,
82 (IOCTL_CRLF | IOCTL_FCSND | IOCTL_FCRCV)));
92 0 << 14 | // TCKFE, 0:sample at down edge, 1:sample at up edge
93 0 << 13 | // LATFS, 0:early frame sync, 1:late frame sync
94 0 << 12 | // LTFS, 0:Active high TFS, 1:Active low TFS
95 0 << 11 | // DITFS, 0:data dependent TFS generation, 1:data independent TFS generation
96 0 << 10 | // TFSR, 0:TFS is not required every word, 1:TFS is required every word
97 0 << 9 | // ITFS, 0:external TFS, 1:internal TFS
98 0 << 4 | // TLSBIT, 0:MSB first transmission, 1:LSB first transmission
99 0 << 2 | // TDTYPE 0:normal, 1:reserved, 2:u-law, 3:a-law
100 0 << 1 | // ITCLK, 0:external clock generation, 1:internal clock generation
101 0 << 0 ; // TSPEN 0:Tx disable, 1:Tx enable
104 0 << 10 | // TRFST, 0:left streo ch first, 1:right stereo ch first
105 0 << 9 | // TSFESE, 0:normal frame sync, 1:LR frame clock
106 0 << 8 | // TXSE, 0:secondary ch disable, 1:secondary ch enable
107 0 << 0 ; // SLEN 0-1:not allowed,2-31:Serial word length - 1
111 0 << 14 | // RCKFE, 0:sample at down edge, 1:sample at up edge
112 0 << 13 | // LARFS, 0:early frame sync, 1:late frame sync
113 0 << 12 | // LRFS, 0:Active high RFS, 1:Active low RFS
114 1 << 10 | // RFSR, 0:RFS is not required every word, 1:RFS is required every word
115 0 << 9 | // IRFS, 0:external RFS, 1:internal RFS
116 0 << 4 | // RLSBIT, 0:MSB first transmission, 1:LSB first transmission
117 0 << 2 | // RDTYPE 0:zero fill, 1:sign extend, 2:u-law, 3:a-law
118 0 << 1 | // IRCLK, 0:external clock generation, 1:internal clock generation
119 0 << 0 ; // RSPEN 0:Rx disable, 1:Rx enable
122 0 << 10 | // RRFST, 0:left streo ch first, 1:right stereo ch first
123 0 << 9 | // RSFESE, 0:normal frame sync, 1:LR frame clock
124 1 << 8 | // RXSE, 0:secondary ch disable, 1:secondary ch enable
125 29 << 0 ; // SLEN 0-1:not allowed,2-31:Serial word length - 1
129 syslog( LOG_NOTICE, "SPORT0_Disable " );
130 syslog( LOG_NOTICE, "SPORT0_RCR1 : %08x", *pSPORT0_RCR1 );
131 syslog( LOG_NOTICE, "SPORT0_RCR2 : %08x", *pSPORT0_RCR2 );
133 syslog( LOG_NOTICE, "SPORT0_STAT : %08x", *pSPORT0_STAT );
136 int count = 0, event = 0;
139 // RX FIFOが空になるまで読み捨てる
140 while( *pSPORT0_STAT & RXNE)
141 dummy = *pSPORT0_RX32;
143 *pSPORT0_RCR1 &= ~RSPEN; // RX SPORT disable
144 syslog( LOG_NOTICE, "FIFO Cleared. FIFO must be empty");
145 syslog( LOG_NOTICE, "SPORT0_STAT : %08x", *pSPORT0_STAT );
154 *pSPORT0_RCR1 |= RSPEN; // RX SPORT Enable
157 syslog( LOG_NOTICE, "SPORT0_Enabled" );
158 syslog( LOG_NOTICE, "SPORT0_RCR1 : %08x", *pSPORT0_RCR1 );
159 syslog( LOG_NOTICE, "SPORT0_RCR2 : %08x", *pSPORT0_RCR2 );
164 // FIFOにデータがたまったはずである。
166 syslog( LOG_NOTICE, "SPORT0_Disabled. FIFO must be full " );
167 syslog( LOG_NOTICE, "SPORT0_RCR1 : %08x", *pSPORT0_RCR1 );
168 syslog( LOG_NOTICE, "SPORT0_RCR2 : %08x", *pSPORT0_RCR2 );
170 syslog( LOG_NOTICE, "SPORT0_STAT : %08x", *pSPORT0_STAT );
172 // FIFOデータを読みだして下位2bitのみ表示する
173 rx[0] = *pSPORT0_RX32 & 0x3; // 下位2bitのみ抽出
174 rx[1] = *pSPORT0_RX32 & 0x3; // 下位2bitのみ抽出
175 rx[2] = *pSPORT0_RX32 & 0x3; // 下位2bitのみ抽出
176 rx[3] = *pSPORT0_RX32 & 0x3; // 下位2bitのみ抽出
177 *pSPORT0_RCR1 &= ~RSPEN; // RX SPORT disable
178 // syslog( LOG_NOTICE, "FIFO Read. FIFO must be empty");
182 syslog( LOG_NOTICE, "RX word : %d,%d,%d,%d", rx[0], rx[1], rx[2], rx[3] );
185 if (!( count % 1000 ))
186 syslog( LOG_NOTICE, "trial : %d, event : %d", count, event);
187 // syslog( LOG_NOTICE, "SPORT0_RCR1 : %08x", *pSPORT0_RCR1 );
188 // syslog( LOG_NOTICE, "SPORT0_RCR2 : %08x", *pSPORT0_RCR2 );
189 // syslog( LOG_NOTICE, "SPORT0_STAT : %08x", *pSPORT0_STAT );
191 // RX受信を終了する。FIFOにはデータがたまっているはずである。
192 *pSPORT0_RCR1 &= ~RSPEN; // RX SPORT disable
195 syslog( LOG_NOTICE, "SPORT0 dsiabled");
196 syslog( LOG_NOTICE, "SPORT0_RCR1 : %08x", *pSPORT0_RCR1 );
197 syslog( LOG_NOTICE, "SPORT0_RCR2 : %08x", *pSPORT0_RCR2 );
198 syslog( LOG_NOTICE, "SPORT0_STAT : %08x", *pSPORT0_STAT );
203 // RX FIFOが空になるまで読み捨てる
204 while( *pSPORT0_STAT & RXNE)
205 dummy = *pSPORT0_RX32;
210 syslog(LOG_NOTICE, "Sample program ends.");