Skip to content
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

CurieI2S library #156

Merged
merged 5 commits into from
May 2, 2016
Merged

CurieI2S library #156

merged 5 commits into from
May 2, 2016

Conversation

bigdinotech
Copy link
Contributor

-interrupt based i2s library

- Minimal functional version
-Use interrupts to fill FIFO buffer from TX buffer
-CurieI2S using interrupts
-add basic examples using callback functions/interrupts
-add callback function to fill tx buffer
@bigdinotech
Copy link
Contributor Author

@SidLeung @kmsywula ready for code review

@PaulStoffregen
Copy link

In your I2S_RxCallback.ino example, might be a good idea to check if count is greater than 255, to prevent a possible buffer overflow.

Even if the specific timing of this example code doesn't ever overflow the buffer, as an example published for general consumption by makers in the Arduino world, you can expect it to be used together with other example code that may alter the interrupt to main program timing.

@bbaltz505
Copy link
Contributor

Good catch, Paul. I forgot to Run the PR through Klocwork. It flagged possible buffer overflow on lines 137 and 324.

@kitsunami kitsunami added this to the Bellatrix milestone Apr 1, 2016
-prevent buffer overflow in I2S_RxCallback example
-calculate delay for any sample rate
#endif

}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May need to consider a timing window here. Consider a byte came in, after fifoDataLength was set with the h/w register earlier on. The FIFO would not be emptied here. With the "Almost Full" interrupt disabled and the "Empty" interrupt enabled, there may no more interrupt from here on. Would that be a real case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think that it should be fine as long as we enter the ISR quickly enough.
The filling of the buffer is much faster than the transmission rate supported by the I2S.
The only real issue I see is if the user callback routine inside the ISR takes too long.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be you leave the "Almost Full" interrupt enabled since the flag is going to be cleared. If the FIFO got filled up because the call back was taking its merry time, the AFull interrupt would not be missed.

@SidLeung
Copy link
Contributor

@calvinatintel Went over the Almost Full interrupt with Dino. Looks good. Please merge.

@calvinatintel calvinatintel merged commit 443916f into arduino:master May 2, 2016
@calvinatintel
Copy link
Contributor

Used non fast-forward merge since there are multiple commits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants