Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-esp32
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-esp32
Commits
5ca45beb
Unverified
Commit
5ca45beb
authored
Nov 29, 2023
by
Me No Dev
Committed by
GitHub
Nov 29, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for I2S Slot Mask (#8936)
Needed for some setups, where only the right channel is being used.
parent
c1417e9b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
15 deletions
+13
-15
libraries/ESP_I2S/src/ESP_I2S.cpp
libraries/ESP_I2S/src/ESP_I2S.cpp
+10
-8
libraries/ESP_I2S/src/ESP_I2S.h
libraries/ESP_I2S/src/ESP_I2S.h
+3
-7
No files found.
libraries/ESP_I2S/src/ESP_I2S.cpp
View file @
5ca45beb
...
...
@@ -281,7 +281,7 @@ void I2SClass::setInvertedPdm(bool clk){
}
#endif
bool
I2SClass
::
initSTD
(
uint32_t
rate
,
i2s_data_bit_width_t
bits_cfg
,
i2s_slot_mode_t
ch
){
bool
I2SClass
::
initSTD
(
uint32_t
rate
,
i2s_data_bit_width_t
bits_cfg
,
i2s_slot_mode_t
ch
,
int8_t
slot_mask
){
// Peripheral manager deinit previous peripheral if pin was used
if
(
_mclk
>=
0
)
if
(
!
perimanClearPinBus
(
_mclk
)){
return
false
;
}
if
(
_bclk
>=
0
)
if
(
!
perimanClearPinBus
(
_bclk
)){
return
false
;
}
...
...
@@ -307,6 +307,9 @@ bool I2SClass::initSTD(uint32_t rate, i2s_data_bit_width_t bits_cfg, i2s_slot_mo
}
i2s_std_config_t
i2s_config
=
I2S_STD_CHAN_CFG
(
rate
,
bits_cfg
,
ch
);
if
(
slot_mask
>=
0
&&
(
i2s_std_slot_mask_t
)
slot_mask
<=
I2S_STD_SLOT_BOTH
){
i2s_config
.
slot_cfg
.
slot_mask
=
(
i2s_std_slot_mask_t
)
slot_mask
;
}
if
(
tx_chan
!=
NULL
)
{
tx_sample_rate
=
rate
;
tx_data_bit_width
=
bits_cfg
;
...
...
@@ -475,11 +478,7 @@ err:
}
#endif
bool
I2SClass
::
begin
(
i2s_mode_t
mode
,
uint32_t
rate
,
i2s_data_bit_width_t
bits_cfg
,
i2s_slot_mode_t
ch
#if SOC_I2S_SUPPORTS_TDM
,
int8_t
slot_mask
#endif
){
bool
I2SClass
::
begin
(
i2s_mode_t
mode
,
uint32_t
rate
,
i2s_data_bit_width_t
bits_cfg
,
i2s_slot_mode_t
ch
,
int8_t
slot_mask
){
/* Setup I2S peripheral */
if
(
mode
>=
I2S_MODE_MAX
){
log_e
(
"Invalid I2S mode selected."
);
...
...
@@ -490,7 +489,7 @@ bool I2SClass::begin(i2s_mode_t mode, uint32_t rate, i2s_data_bit_width_t bits_c
bool
init
=
false
;
switch
(
_mode
){
case
I2S_MODE_STD
:
init
=
initSTD
(
rate
,
bits_cfg
,
ch
);
init
=
initSTD
(
rate
,
bits_cfg
,
ch
,
slot_mask
);
break
;
#if SOC_I2S_SUPPORTS_TDM
case
I2S_MODE_TDM
:
...
...
@@ -569,13 +568,16 @@ bool I2SClass::end(){
return
true
;
}
bool
I2SClass
::
configureTX
(
uint32_t
rate
,
i2s_data_bit_width_t
bits_cfg
,
i2s_slot_mode_t
ch
){
bool
I2SClass
::
configureTX
(
uint32_t
rate
,
i2s_data_bit_width_t
bits_cfg
,
i2s_slot_mode_t
ch
,
int8_t
slot_mask
){
/* Setup I2S channels */
if
(
tx_chan
!=
NULL
)
{
if
(
tx_sample_rate
==
rate
&&
tx_data_bit_width
==
bits_cfg
&&
tx_slot_mode
==
ch
){
return
true
;
}
i2s_std_config_t
i2s_config
=
I2S_STD_CHAN_CFG
(
rate
,
bits_cfg
,
ch
);
if
(
slot_mask
>=
0
&&
(
i2s_std_slot_mask_t
)
slot_mask
<=
I2S_STD_SLOT_BOTH
){
i2s_config
.
slot_cfg
.
slot_mask
=
(
i2s_std_slot_mask_t
)
slot_mask
;
}
I2S_ERROR_CHECK_RETURN_FALSE
(
i2s_channel_disable
(
tx_chan
));
I2S_ERROR_CHECK_RETURN_FALSE
(
i2s_channel_reconfig_std_clock
(
tx_chan
,
&
i2s_config
.
clk_cfg
));
tx_sample_rate
=
rate
;
...
...
libraries/ESP_I2S/src/ESP_I2S.h
View file @
5ca45beb
...
...
@@ -56,12 +56,8 @@ class I2SClass: public Stream {
void
setInvertedPdm
(
bool
clk
);
#endif
bool
begin
(
i2s_mode_t
mode
,
uint32_t
rate
,
i2s_data_bit_width_t
bits_cfg
,
i2s_slot_mode_t
ch
#if SOC_I2S_SUPPORTS_TDM
,
int8_t
slot_mask
=-
1
#endif
);
bool
configureTX
(
uint32_t
rate
,
i2s_data_bit_width_t
bits_cfg
,
i2s_slot_mode_t
ch
);
bool
begin
(
i2s_mode_t
mode
,
uint32_t
rate
,
i2s_data_bit_width_t
bits_cfg
,
i2s_slot_mode_t
ch
,
int8_t
slot_mask
=-
1
);
bool
configureTX
(
uint32_t
rate
,
i2s_data_bit_width_t
bits_cfg
,
i2s_slot_mode_t
ch
,
int8_t
slot_mask
=-
1
);
bool
configureRX
(
uint32_t
rate
,
i2s_data_bit_width_t
bits_cfg
,
i2s_slot_mode_t
ch
,
i2s_rx_transform_t
transform
=
I2S_RX_TRANSFORM_NONE
);
bool
end
();
...
...
@@ -130,7 +126,7 @@ class I2SClass: public Stream {
bool
transformRX
(
i2s_rx_transform_t
transform
);
static
bool
i2sDetachBus
(
void
*
bus_pointer
);
bool
initSTD
(
uint32_t
rate
,
i2s_data_bit_width_t
bits_cfg
,
i2s_slot_mode_t
ch
);
bool
initSTD
(
uint32_t
rate
,
i2s_data_bit_width_t
bits_cfg
,
i2s_slot_mode_t
ch
,
int8_t
slot_mask
);
#if SOC_I2S_SUPPORTS_TDM
bool
initTDM
(
uint32_t
rate
,
i2s_data_bit_width_t
bits_cfg
,
i2s_slot_mode_t
ch
,
int8_t
slot_mask
);
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment