Modified a little for 32k byte buffer.
Dependents: Peach_AudioChannelDividerAndCompensator
Revision 61:ff0388dee94f, committed 2015-10-18
- Comitter:
- dokunewon
- Date:
- Sun Oct 18 08:16:03 2015 +0000
- Parent:
- 60:68924f211e71
- Commit message:
- Change a little.
Changed in this revision
--- a/Doku_USBAudio/USBAudio.cpp Sun Oct 11 07:37:39 2015 +0000
+++ b/Doku_USBAudio/USBAudio.cpp Sun Oct 18 08:16:03 2015 +0000
@@ -55,7 +55,7 @@
volume = 0;
// connect the device
- USBDevice::connect();
+ //USBDevice::connect(); //doku
}
bool USBAudio::read(uint8_t * buf) {
@@ -116,58 +116,17 @@
return (mute) ? 0.0 : volume;
}
-extern DigitalOut LedR;
-extern DigitalOut LedG;
-extern DigitalOut LedB;
-
-// receive 32k sample of sudio stereo data
-// if input stalls then zero is paded
-// so, it every time returns 32k sample of data
-int USBAudio::read32kSZ(uint32_t *Buf)
+// receive 32k sample of stereo data
+int USBAudio::read32k(uint32_t *Buf)
{
//受信データが準備できてなければ、
if(! m_prbuf)
{
-printf("Data stall in bank:");
- //バッファの前半を受信中ならば、
- if(m_widx < 32768)
- {
-printf("0\n");
- //データをユーザのバッファへコピーして、
- memcpy((uint8_t *)Buf,(uint8_t *)&m_rbuf[32768*0],32768 * 4);
- //ユーザバッファをゼロで埋めて
- memset((uint8_t *)Buf,0,32768*4);
- //受信バッファをクリアする
- memset((uint8_t*)m_rbuf,0,65536*4);
- //次は、バッファの前半から受信する
- //m_widx = 0;
- //受信データに「準備中」を設定する
- //m_prbuf = NULL;
- //1(受信完了)を返す
- return 1;
- }
- //バッファの後半を受信中ならば、
- else
- {
-printf("1\n");
- //データをユーザのバッファへコピーして、
- memcpy((uint8_t *)Buf,(uint8_t *)&m_rbuf[32768*1],32768 * 4);
- //ユーザバッファをゼロで埋めて
- memset((uint8_t *)Buf,0,32768*4);
- //受信バッファをクリアする
- memset((uint8_t*)m_rbuf,0,65536*4);
- //次は、バッファの前半から受信する
- //m_widx = 0;
- //受信データに「準備中」を設定する
- //m_prbuf = NULL;
- //1(受信完了)を返す
- return 1;
- }
+ return 0;
}
//受信データが準備できていれば、
else
{
-printf("Data ready\n");
//データをユーザのバッファへコピーして、
memcpy((uint8_t *)Buf,(uint8_t *)m_prbuf,32768 * 4);
//受信データに「準備中」を設定する
@@ -177,26 +136,11 @@
}
}
-// receive 32k sample of sudio stereo data
-//int USBAudio::read32k(uint8_t *buf)
-//{
-// //受信データが準備できてなければ、
-// if(! m_prbuf)
-// {
-// //0(受信準備中)を返す。
-// return 0;
-// }
-// //受信データが準備できていれば、
-// else
-// {
-// //データをユーザのバッファへコピーして、
-// memcpy((uint8_t *)buf,(uint8_t *)m_prbuf,32768 * 4);
-// //受信データに「準備中」を設定する
-// m_prbuf = NULL;
-// //1(受信完了)を返す
-// return 1;
-// }
-//}
+int USBAudio::clear32k()
+{
+ //clear entier buffer
+ memset((uint8_t *)m_rbuf,0,32768 * 4 * 2);
+}
bool USBAudio::EPISO_OUT_callback() {
int ridx;
--- a/Doku_USBAudio/USBAudio.h Sun Oct 11 07:37:39 2015 +0000
+++ b/Doku_USBAudio/USBAudio.h Sun Oct 18 08:16:03 2015 +0000
@@ -102,8 +102,9 @@
volatile uint32_t m_rbuf[32768 * 2];
uint32_t tmpbuf[48];
int m_widx;
- int USBAudio::read32kSZ(uint32_t *buf);
-
+ int USBAudio::read32k(uint32_t *buf);
+ int USBAudio::clear32k();
+
/**
* Try to read an audio packet. During a frame, only a single reading (you can't write and read an audio packet during the same frame)can be done using this method. Warning: Non Blocking
*
--- a/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb1/src/userdef/usb1_function_userdef.c Sun Oct 11 07:37:39 2015 +0000
+++ b/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb1/src/userdef/usb1_function_userdef.c Sun Oct 18 08:16:03 2015 +0000
@@ -115,11 +115,13 @@
* Arguments : none
* Return Value : none
*******************************************************************************/
+int USB_Audio_Attached = 0;//doku
void Userdef_USB_usb1_function_attach (void)
{
- printf("\n");
- printf("channel 1 attach device\n");
- printf("\n");
+ USB_Audio_Attached = 1; //doku
+// printf("\n"); //doku
+// printf("channel 1 attach device\n"); //doku
+// printf("\n"); //doku
}
/*******************************************************************************
@@ -131,9 +133,10 @@
*******************************************************************************/
void Userdef_USB_usb1_function_detach (void)
{
- printf("\n");
- printf("channel 1 detach device\n");
- printf("\n");
+ USB_Audio_Attached = 0; //doku
+// printf("\n"); //doku
+// printf("channel 1 detach device\n"); //doku
+// printf("\n"); //doku
}
/*******************************************************************************