File tree Expand file tree Collapse file tree 7 files changed +1086
-0
lines changed Expand file tree Collapse file tree 7 files changed +1086
-0
lines changed Original file line number Diff line number Diff line change 1+ /* *
2+ * A simple sketch to test the rx channel of the i2s interface.
3+ * A callback function is used to fill up a buffer whenever data is received
4+ *
5+ * To test this sketch you will need a second Arduino/Genuino 101 board with the I2S_TxCallback sketch uploaded
6+ *
7+ * Connection:
8+ * I2S_RSCK(pin 8) -> I2S_TSCK(pin 2)
9+ * I2S_RWS(pin 3) -> I2S_TWS(pin 4)
10+ * I2S_RXD(pin 5) -> I2S_TXD(pin 7)
11+ *
12+ **/
13+ #include < CurieI2S.h>
14+
15+ uint32_t dataBuff[256 ];
16+ volatile int count = 0 ;
17+
18+ void setup ()
19+ {
20+ // put your setup code here, to run once:
21+ Serial.begin (115200 );
22+ while (!Serial);
23+ Serial.println (" CurieI2S Rx Callback Example" );
24+ CurieI2S.begin (I2S_44K, I2S_32bit);
25+ CurieI2S.setI2SMode (PHILIPS_MODE);
26+ CurieI2S.attachRxInterrupt (rxDataReceived);
27+ CurieI2S.initRX ();
28+ CurieI2S.startRX ();
29+
30+ }
31+
32+ void loop ()
33+ {
34+ if (count>0 )
35+ {
36+ for (int i =0 ; i < count; i++)
37+ {
38+ Serial.print (" data: " );
39+ Serial.println (dataBuff[i], HEX);
40+ }
41+ count = 0 ;
42+ }
43+ delay (500 );
44+ }
45+
46+ // This function is called inside an ISR so it is important to make this as atomic/fast as possible
47+ void rxDataReceived ()
48+ {
49+ while (CurieI2S.available ())
50+ {
51+ dataBuff[count++] = CurieI2S.requestdword ();
52+ count %= 256 ; // prevent buffer overflow and just write data in front of the buffer.
53+ }
54+ }
Original file line number Diff line number Diff line change 1+ #include < CurieI2S.h>
2+
3+ // I2S_TX -> Pin 7
4+ // I2S_TSK -> Pin 4
5+ // I2S_TSCK -> pin 2
6+
7+ void setup ()
8+ {
9+ Serial.begin (115200 );
10+ while (!Serial);
11+ Serial.println (" CurieI2S Tx Callback" );
12+ CurieI2S.begin (I2S_44K, I2S_32bit);
13+ CurieI2S.setI2SMode (PHILIPS_MODE);
14+ CurieI2S.attachTxEmptyInterrupt (doneTX);
15+ CurieI2S.attachTxInterrupt (fillTxBuffer);
16+ CurieI2S.initTX ();
17+ }
18+
19+ void loop ()
20+ {
21+ Serial.println (" +++" );
22+
23+ // start filling the tx buffer
24+ CurieI2S.pushData (0xFFFFFFFF );
25+ CurieI2S.pushData (0x00000000 );
26+ CurieI2S.pushData (0xDEADFACE );
27+ CurieI2S.pushData (0x10101010 );
28+ Serial.println (" start transmitting" );
29+ // Start Transmission
30+ CurieI2S.startTX ();
31+ for (int i = 0 ; i < 40 ; i++)
32+ {
33+ // keep filling the buffer
34+ while (!CurieI2S.pushData (0xFFFFFFFF ));
35+ while (!CurieI2S.pushData (0x00000000 ));
36+ while (!CurieI2S.pushData (0xDEADFACE ));
37+ while (!CurieI2S.pushData (0x10101010 ));
38+ }
39+ // Tx is automatically stopped after the tx buffer is emptied
40+
41+ delay (500 );
42+ Serial.println (" +++" );
43+ }
44+
45+ void doneTX ()
46+ {
47+ Serial.println (" done transmitting" );
48+ }
49+
50+ void fillTxBuffer ()
51+ {
52+ // you can fill the tx buffer here if you want
53+ // CurieI2S.pushData(0xDEADDEAD);
54+ // CurieI2S.pushData(0xDEADFACE);
55+ }
56+
Original file line number Diff line number Diff line change 1+ #######################################
2+ # Syntax Coloring Map For CurieI2S
3+ #######################################
4+
5+ #######################################
6+ # Datatypes (KEYWORD1)
7+ #######################################
8+
9+ Curie_I2S KEYWORD1
10+
11+ #######################################
12+ # Methods and Functions (KEYWORD2)
13+ #######################################
14+
15+ begin KEYWORD2
16+ start KEYWORD2
17+ stop KEYWORD2
18+ begin KEYWORD2
19+ enableRX KEYWORD2
20+ enableTX KEYWORD2
21+ startRX KEYWORD2
22+ startTX KEYWORD2
23+ stopRX KEYWORD2
24+ stopTX KEYWORD2
25+ setI2SMode KEYWORD2
26+ setResolution KEYWORD2
27+ initRX KEYWORD2
28+ initTX KEYWORD2
29+ end KEYWORD2
30+ pushData KEYWORD2
31+ fastPushData KEYWORD2
32+ write KEYWORD2
33+ pullData KEYWORD2
34+ read KEYWORD2
35+ requestdword KEYWORD2
36+ available KEYWORD2
37+ availableTx KEYWORD2
38+ attachRxInterrupt KEYWORD2
39+ detachRxInterrupt KEYWORD2
40+ attachTxInterrupt KEYWORD2
41+ detachTxInterrupt KEYWORD2
42+ #######################################
43+ # Instances (KEYWORD2)
44+ #######################################
45+ CurieI2S KEYWORD2
46+ #######################################
47+ # Constants (LITERAL1)
48+ #######################################
Original file line number Diff line number Diff line change 1+ name =CurieI2S
2+ version =1.0
3+ author =Intel
4+ maintainer =Intel
5+ email =dino.tinitigan@intel.com
6+ sentence =Curie I2S 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)
You can’t perform that action at this time.
0 commit comments