Skip to content

Commit 3858319

Browse files
committed
Jira566 I2S DMA improvement: add two extra buffer on TX and RX side
1 parent 3168ede commit 3858319

File tree

15 files changed

+3688
-427
lines changed

15 files changed

+3688
-427
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
* Copyright (c) 2016 Intel Corporation. All rights reserved.
3+
* See the bottom of this file for the license terms.
4+
*/
5+
6+
/**
7+
* A simple sketch to test the rx channel of the i2s interface.
8+
* A callback function is used to fill up a buffer whenever data is received
9+
*
10+
* To test this sketch you will need a second Arduino/Genuino 101 board with the I2SDMA_TxCallback sketch uploaded
11+
*
12+
* Connection:
13+
* GND -> GND
14+
* I2S_RSCK(pin 8) -> I2S_TSCK(pin 2)
15+
* I2S_RWS(pin 3) -> I2S_TWS(pin 4)
16+
* I2S_RXD(pin 5) -> I2S_TXD(pin 7)
17+
*
18+
**/
19+
#include <CurieI2SDMA.h>
20+
21+
#define BUFF_SIZE 128
22+
uint32_t dataBuff[BUFF_SIZE+2]; // extra 2 buffer is for the padding zero
23+
24+
uint32_t OFFSET = 0;
25+
uint8_t start_flag = 0;
26+
uint8_t done_flag = 0;
27+
uint32_t loop_count = 0;
28+
29+
void setup()
30+
{
31+
Serial.begin(115200);
32+
while(!Serial);
33+
Serial.println("CurieI2SDMA Rx Callback");
34+
35+
CurieI2SDMA.iniRX();
36+
/*
37+
* CurieI2SDMA.beginTX(sample_rate, resolution, master,mode)
38+
* mode 1 : PHILIPS_MODE
39+
* 2 : RIGHT_JST_MODE
40+
* 3 : LEFT_JST_MODE
41+
* 4 : DSP_MODE
42+
*/
43+
CurieI2SDMA.beginRX(44100, 32,0,1);
44+
45+
}
46+
47+
void loop()
48+
{
49+
int status = CurieI2SDMA.transRX(dataBuff,sizeof(dataBuff));
50+
if(status)
51+
return;
52+
53+
if(start_flag)
54+
{
55+
if( (dataBuff[OFFSET]>>16) != loop_count+1)
56+
Serial.println("+++ loop_count jump +++");
57+
}
58+
else
59+
{
60+
start_flag = 1;
61+
OFFSET = (dataBuff[0] == 0) ? 2 : 0;
62+
}
63+
loop_count = (dataBuff[OFFSET] >> 16);
64+
65+
done_flag = 1;
66+
for(uint32_t i = 0 ;i < BUFF_SIZE;++i)
67+
{
68+
//Serial.println(dataBuff[i+OFFSET],HEX);
69+
if ((dataBuff[i+OFFSET] & 0XFFFF0000) == (loop_count <<16)
70+
&& (dataBuff[i+OFFSET] & 0XFFFF) == (i+1))
71+
;
72+
else
73+
{
74+
done_flag = 0;
75+
Serial.println(dataBuff[i+OFFSET],HEX);
76+
Serial.println("ERROR");
77+
break;
78+
}
79+
}
80+
81+
if(done_flag)
82+
Serial.println("RX done");
83+
delay(100);
84+
}
85+
86+
/*
87+
Copyright (c) 2016 Intel Corporation. All rights reserved.
88+
This library is free software; you can redistribute it and/or
89+
modify it under the terms of the GNU Lesser General Public
90+
License as published by the Free Software Foundation; either
91+
version 2.1 of the License, or (at your option) any later version.
92+
This library is distributed in the hope that it will be useful,
93+
but WITHOUT ANY WARRANTY; without even the implied warranty of
94+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
95+
Lesser General Public License for more details.
96+
You should have received a copy of the GNU Lesser General Public
97+
License along with this library; if not, write to the Free Software
98+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-
99+
1301 USA
100+
*/
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright (c) 2016 Intel Corporation. All rights reserved.
3+
* See the bottom of this file for the license terms.
4+
*/
5+
6+
//I2S_TX -> Pin 7
7+
//I2S_TSK -> Pin 4
8+
//I2S_TSCK -> pin 2
9+
10+
#include <CurieI2SDMA.h>
11+
12+
#define BUFF_SIZE 128
13+
boolean blinkState = true; // state of the LED
14+
uint32_t dataBuff[BUFF_SIZE];
15+
uint32_t loop_count = 0;
16+
void setup()
17+
{
18+
Serial.begin(115200);
19+
while(!Serial);
20+
Serial.println("CurieI2SDMA Tx Callback");
21+
22+
CurieI2SDMA.iniTX();
23+
/*
24+
* CurieI2SDMA.beginTX(sample_rate, resolution, master,mode)
25+
* mode 1 : PHILIPS_MODE
26+
* 2 : RIGHT_JST_MODE
27+
* 3 : LEFT_JST_MODE
28+
* 4 : DSP_MODE
29+
*/
30+
CurieI2SDMA.beginTX(44100, 32,1, 1);
31+
digitalWrite(13, blinkState);
32+
}
33+
34+
void loop()
35+
{
36+
for(uint32_t i = 0; i <BUFF_SIZE; ++i)
37+
{
38+
dataBuff[i] = i + 1 + (loop_count<<16);
39+
}
40+
loop_count++;
41+
int status = CurieI2SDMA.transTX(dataBuff,sizeof(dataBuff));
42+
if(status)
43+
return;
44+
45+
blinkState = !blinkState;
46+
digitalWrite(13, blinkState);
47+
48+
//when the TX set to be slave, the two lines below will introduce delay.
49+
//Please remove them.
50+
Serial.println("done transmitting");
51+
delay(1000);
52+
53+
}
54+
55+
/*
56+
Copyright (c) 2016 Intel Corporation. All rights reserved.
57+
This library is free software; you can redistribute it and/or
58+
modify it under the terms of the GNU Lesser General Public
59+
License as published by the Free Software Foundation; either
60+
version 2.1 of the License, or (at your option) any later version.
61+
This library is distributed in the hope that it will be useful,
62+
but WITHOUT ANY WARRANTY; without even the implied warranty of
63+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
64+
Lesser General Public License for more details.
65+
You should have received a copy of the GNU Lesser General Public
66+
License along with this library; if not, write to the Free Software
67+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-
68+
1301 USA
69+
*/

libraries/CurieI2SDMA/keywords.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#######################################
2+
# Syntax Coloring Map For CurieI2S
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
9+
Curie_I2SDMA KEYWORD1
10+
11+
#######################################
12+
# Methods and Functions (KEYWORD2)
13+
#######################################
14+
15+
beginTX KEYWORD2
16+
beginRX KEYWORD2
17+
iniTX KEYWORD2
18+
iniRX KEYWORD2
19+
transTX KEYWORD2
20+
transRX KEYWORD2
21+
stopTX KEYWORD2
22+
stopRX KEYWORD2
23+
mergeData KEYWORD2
24+
separateData KEYWORD2
25+
26+
#######################################
27+
# Instances (KEYWORD2)
28+
#######################################
29+
CurieI2SDMA KEYWORD2
30+
#######################################
31+
# Constants (LITERAL1)
32+
#######################################
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name=CurieI2SDMA
2+
version=1.0
3+
author=Intel
4+
maintainer=Intel
5+
6+
sentence=Curie I2S DMA Library for Arduino/Genuino 101
7+
paragraph=
8+
category=Communication
9+
url=http://makers.intel.com
10+
architectures=arc32
11+
core-dependencies=arduino (>=1.6.3)

0 commit comments

Comments
 (0)