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
i2s: Add an nrfx-based implementation for Nordic ICs #19436
Conversation
@adamkondraciuk thanks for the PR. Could you perhaps take the .pdf and convert it to a combination of |
All checks are passing now. Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
3a542cd
to
f6319be
Compare
On second thought, we don't really have anywhere to place this kind of documentation today, and it would probably be very difficult to keep it updated, so let's not include it in the Pull Request |
f6319be
to
1c4c8f8
Compare
5d6ef85
to
f78b470
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of initial comments. More to come.
f78b470
to
ccd909f
Compare
@@ -176,6 +176,8 @@ | |||
/drivers/i2c/i2c_rv32m1_lpi2c* @henrikbrixandersen | |||
/drivers/i2c/*sam0* @Sizurka | |||
/drivers/i2c/i2c_dw* @gnuless | |||
/drivers/i2s/Kconfig.nrfx @adamkondraciuk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some example code you can add as well? Having a sample that e.g. sends incremental numbers over I2S would greatly assist developers in getting started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some example code you can add as well? Having a sample that e.g. sends incremental numbers over I2S would greatly assist developers in getting started.
I'll push it as another PR after driver review
ccd909f
to
b5f54d3
Compare
b5f54d3
to
ea0b580
Compare
7dbb34b
to
a435051
Compare
a435051
to
93b388d
Compare
{ \ | ||
IRQ_CONNECT(DT_NORDIC_NRF_I2S_I2S_##idx##_IRQ_0, \ | ||
DT_NORDIC_NRF_I2S_I2S_##idx##_IRQ_0_PRIORITY, \ | ||
isr, DEVICE_GET(i2s_##idx), 0); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use:
isr, DEVICE_GET(i2s_##idx), 0); \ | |
nrfx_isr, nrfx_i2s_irq_handler, 0); \ |
and remove the isr
function.
* next to be transferred (content of 'TXD.PTR' register). | ||
* Status parameter informs about handler execution reason: | ||
* - if 1 - next buffer is needed | ||
* - if 0 - transfer is finishing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not guaranteed. nrfx_i2s API does not specify it so.
struct channel_str *ch_rx = &i2s->channel_rx; | ||
int ret; | ||
|
||
if (p_released->p_rx_buffer != NULL && next_buffers_needed(status)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p_released
itself may also be NULL
, see nrfx_i2s.h.
* - allocates new rx buffer for next transfer purpose | ||
* Status parameter informs about handler execution reason: | ||
* - if 1 - next buffer is needed | ||
* - if 0 - transfer is finishing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not guaranteed. nrfx_i2s API does not specify it so.
} | ||
return; | ||
} | ||
if (p_released->p_tx_buffer != NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p_released
itself may also be NULL
, see nrfx_i2s.h.
if (p_released->p_rx_buffer != NULL && next_buffers_needed(status)) { | ||
/* Content of received buffer is valuable. | ||
* If 'EVENT_STOPPED' generated 'then next_buffers_needed()' | ||
* returns false - function 'channel_rx_store_data()' won't |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to use some different logic here. next_buffers_needed()
returns false
when the event handler was called without the driver's request of next buffers, what does not necessarily mean that the STOPPED
event has been generated. nrfx_i2s API does not specify it this way, so you cannot rely on it.
next_buffers_needed(status)) { | ||
/* when interface needs to be restarted and | ||
* last event was 'EVENT_STOPPED' then we don't | ||
* free this buffer - it will be used after |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As in channel_rx_callback
, you cannot use next_buffers_needed
to check if the transfer was stopped.
} else { | ||
if (p_released->p_rx_buffer) { | ||
ret = channel_rx_store_data(i2s, | ||
(u32_t **)&p_released->p_rx_buffer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part of code needs to be described. For instance, why is this data stored only when next buffers were not requested by the nrfx_i2s driver?
break; | ||
default: | ||
channel_change_state(ch_tx, I2S_STATE_ERROR); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part of code needs to be described as well, and perhaps reworked. Currently, it is too hard to understand what is actually going on here. For instance, what happens with mem_block
here (when the error is signaled)? When will it get freed?
} | ||
|
||
static void channel_tx_mem_clear(struct i2s_nrfx_data *i2s, | ||
void const *first_block) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is called only from two places, and only once it is called with first_block
not being NULL
. Why not free this first block right there, get rid of this parameter, and thus seriously simplify whole this function?
Changed board definitions to use I2S driver Signed-off-by: Adam Kondraciuk <adam.kondraciuk@nordicsemi.no>
93b388d
to
197e63e
Compare
Translation layer to make I2S drivers work with Zephyr API. This shim is provided only for master-stereo transmission Signed-off-by: Adam Kondraciuk <adam.kondraciuk@nordicsemi.no>
197e63e
to
bc88dbc
Compare
Since i2s interface and API are quite complex this driver should be tested with |
The driver has a function called |
This PR has been superseded by #34251. |
I2S Machine State.pdf