Skip to content

CurieI2S library #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions libraries/CurieI2S/examples/I2S_RxCallback/I2S_RxCallback.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* A simple sketch to test the rx channel of the i2s interface.
* A callback function is used to fill up a buffer whenever data is received
*
* To test this sketch you will need a second Arduino/Genuino 101 board with the I2S_TxCallback sketch uploaded
*
* Connection:
* I2S_RSCK(pin 8) -> I2S_TSCK(pin 2)
* I2S_RWS(pin 3) -> I2S_TWS(pin 4)
* I2S_RXD(pin 5) -> I2S_TXD(pin 7)
*
**/
#include <CurieI2S.h>

uint32_t dataBuff[256];
volatile int count = 0;

void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
while(!Serial);
Serial.println("CurieI2S Rx Callback Example");
CurieI2S.begin(I2S_44K, I2S_32bit);
CurieI2S.setI2SMode(PHILIPS_MODE);
CurieI2S.attachRxInterrupt(rxDataReceived);
CurieI2S.initRX();
CurieI2S.startRX();

}

void loop()
{
if(count>0)
{
for(int i =0; i < count; i++)
{
Serial.print("data: ");
Serial.println(dataBuff[i], HEX);
}
count = 0;
}
delay(500);
}

//This function is called inside an ISR so it is important to make this as atomic/fast as possible
void rxDataReceived()
{
while(CurieI2S.available())
{
dataBuff[count++] = CurieI2S.requestdword();
count %= 256; //prevent buffer overflow and just write data in front of the buffer.
}
}
56 changes: 56 additions & 0 deletions libraries/CurieI2S/examples/I2S_TxCallback/I2S_TxCallback.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include <CurieI2S.h>

//I2S_TX -> Pin 7
//I2S_TSK -> Pin 4
//I2S_TSCK -> pin 2

void setup()
{
Serial.begin(115200);
while(!Serial);
Serial.println("CurieI2S Tx Callback");
CurieI2S.begin(I2S_44K, I2S_32bit);
CurieI2S.setI2SMode(PHILIPS_MODE);
CurieI2S.attachTxEmptyInterrupt(doneTX);
CurieI2S.attachTxInterrupt(fillTxBuffer);
CurieI2S.initTX();
}

void loop()
{
Serial.println("+++");

//start filling the tx buffer
CurieI2S.pushData(0xFFFFFFFF);
CurieI2S.pushData(0x00000000);
CurieI2S.pushData(0xDEADFACE);
CurieI2S.pushData(0x10101010);
Serial.println("start transmitting");
//Start Transmission
CurieI2S.startTX();
for(int i = 0; i < 40; i++)
{
//keep filling the buffer
while(!CurieI2S.pushData(0xFFFFFFFF));
while(!CurieI2S.pushData(0x00000000));
while(!CurieI2S.pushData(0xDEADFACE));
while(!CurieI2S.pushData(0x10101010));
}
//Tx is automatically stopped after the tx buffer is emptied

delay(500);
Serial.println("+++");
}

void doneTX()
{
Serial.println("done transmitting");
}

void fillTxBuffer()
{
//you can fill the tx buffer here if you want
//CurieI2S.pushData(0xDEADDEAD);
//CurieI2S.pushData(0xDEADFACE);
}

48 changes: 48 additions & 0 deletions libraries/CurieI2S/keywords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#######################################
# Syntax Coloring Map For CurieI2S
#######################################

#######################################
# Datatypes (KEYWORD1)
#######################################

Curie_I2S KEYWORD1

#######################################
# Methods and Functions (KEYWORD2)
#######################################

begin KEYWORD2
start KEYWORD2
stop KEYWORD2
begin KEYWORD2
enableRX KEYWORD2
enableTX KEYWORD2
startRX KEYWORD2
startTX KEYWORD2
stopRX KEYWORD2
stopTX KEYWORD2
setI2SMode KEYWORD2
setResolution KEYWORD2
initRX KEYWORD2
initTX KEYWORD2
end KEYWORD2
pushData KEYWORD2
fastPushData KEYWORD2
write KEYWORD2
pullData KEYWORD2
read KEYWORD2
requestdword KEYWORD2
available KEYWORD2
availableTx KEYWORD2
attachRxInterrupt KEYWORD2
detachRxInterrupt KEYWORD2
attachTxInterrupt KEYWORD2
detachTxInterrupt KEYWORD2
#######################################
# Instances (KEYWORD2)
#######################################
CurieI2S KEYWORD2
#######################################
# Constants (LITERAL1)
#######################################
11 changes: 11 additions & 0 deletions libraries/CurieI2S/library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name=CurieI2S
version=1.0
author=Intel
maintainer=Intel
[email protected]
sentence=Curie I2S Library for Arduino/Genuino 101
paragraph=
category=Communication
url=http://makers.intel.com
architectures=arc32
core-dependencies=arduino (>=1.6.3)
Loading