Skip to content

Commit c829aab

Browse files
mariopajaaescolar
authored andcommitted
drivers: i2s: stm32 sai add sai fifo threashold config
This change adds sai fifo configuration option Signed-off-by: Mario Paja <mariopaja@hotmail.com>
1 parent 408e280 commit c829aab

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

drivers/i2s/i2s_stm32_sai.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ static const uint32_t dma_m_size[] = {
6767
};
6868
#endif
6969

70+
static const uint32_t sai_fifo_threshold[] = {
71+
SAI_FIFOTHRESHOLD_EMPTY,
72+
SAI_FIFOTHRESHOLD_1QF,
73+
SAI_FIFOTHRESHOLD_HF,
74+
SAI_FIFOTHRESHOLD_3QF,
75+
SAI_FIFOTHRESHOLD_FULL,
76+
};
77+
7078
struct queue_item {
7179
void *buffer;
7280
size_t size;
@@ -951,6 +959,9 @@ static DEVICE_API(i2s, i2s_stm32_driver_api) = {
951959
.queue_drop = queue_drop, \
952960
}
953961

962+
#define SAI_FIFO_THRESHOLD(index) \
963+
sai_fifo_threshold[DT_INST_ENUM_IDX_OR(index, fifo_threshold, 0)]
964+
954965
#define I2S_STM32_SAI_INIT(index) \
955966
\
956967
PINCTRL_DT_INST_DEFINE(index); \
@@ -961,7 +972,7 @@ static DEVICE_API(i2s, i2s_stm32_driver_api) = {
961972
.hsai = { \
962973
.Instance = (SAI_Block_TypeDef *)DT_INST_REG_ADDR(index), \
963974
.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE, \
964-
.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_FULL, \
975+
.Init.FIFOThreshold = SAI_FIFO_THRESHOLD(index), \
965976
.Init.SynchroExt = SAI_SYNCEXT_DISABLE, \
966977
.Init.CompandingMode = SAI_NOCOMPANDING, \
967978
.Init.TriState = SAI_OUTPUT_NOTRELEASED, \

dts/bindings/i2s/st,stm32-sai.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,16 @@ properties:
5454
description: |
5555
Synchronous mode.
5656
When present, the SAI controller is configured to work in synchronous mode.
57+
58+
fifo-threshold:
59+
type: string
60+
default: "full"
61+
description: |
62+
SAI Block Fifo Threshold defines the fill level at which the peripheral
63+
triggers a DMA request or interrupt to transfer data
64+
enum:
65+
- "empty"
66+
- "1/4"
67+
- "1/2"
68+
- "3/4"
69+
- "full"

0 commit comments

Comments
 (0)