Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
flow3r firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dos
flow3r firmware
Commits
2162821d
Verified
Commit
2162821d
authored
2 months ago
by
dos
Browse files
Options
Downloads
Patches
Plain Diff
stereo audio output and software volume control
parent
5a1977ef
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+2
-0
2 additions, 0 deletions
.gitlab-ci.yml
components/flow3r_bsp/flow3r_bsp_audio.c
+47
-25
47 additions, 25 deletions
components/flow3r_bsp/flow3r_bsp_audio.c
with
49 additions
and
25 deletions
.gitlab-ci.yml
+
2
−
0
View file @
2162821d
...
...
@@ -10,6 +10,8 @@ default:
# built via:
# docker load < $(nix-build nix/docker-image.nix)
image
:
registry.gitlab.com/flow3r-badge/flow3r-build:kfjixcricw2358zp5vg15b784l9jnpzz
before_script
:
-
sed -i 's/clk_info->bclk_div = 8;/clk_info->bclk_div = 13;/g' $IDF_PATH/components/driver/i2s/i2s_pdm.c
build
:
stage
:
build
...
...
This diff is collapsed.
Click to expand it.
components/flow3r_bsp/flow3r_bsp_audio.c
+
47
−
25
View file @
2162821d
...
...
@@ -2,53 +2,75 @@
#include
<string.h>
#include
"driver/i2s.h"
#include
"driver/i2s
_pdm
.h"
#include
"esp_log.h"
i2s_chan_handle_t
tx_handle
;
esp_err_t
flow3r_bsp_audio_write
(
const
void
*
src
,
size_t
size
,
size_t
*
bytes_written
,
TickType_t
ticks_to_wait
)
{
return
i2s_
write
(
0
,
src
,
size
,
bytes_written
,
ticks_to_wait
);
return
i2s_
channel_write
(
tx_handle
,
src
,
size
,
bytes_written
,
ticks_to_wait
);
}
#include
"flow3r_bsp_max98091.h"
// TODO: rewrite to new driver, enable stereo
// copied from ESP-IDF 5.2
#define I2S_PDM_TX_SLOT_DAC_DEFAULT_CONFIG(bits_per_sample, mono_or_stereo) { \
.data_bit_width = bits_per_sample, \
.slot_bit_width = I2S_SLOT_BIT_WIDTH_AUTO, \
.slot_mode = mono_or_stereo, \
.sd_prescale = 0, \
.sd_scale = I2S_PDM_SIG_SCALING_MUL_1, \
.hp_scale = I2S_PDM_SIG_SCALING_MUL_1, \
.lp_scale = I2S_PDM_SIG_SCALING_MUL_1, \
.sinc_scale = I2S_PDM_SIG_SCALING_MUL_1, \
.line_mode = ((mono_or_stereo) == I2S_SLOT_MODE_MONO ? \
I2S_PDM_TX_ONE_LINE_DAC : I2S_PDM_TX_TWO_LINE_DAC), \
.hp_en = true, \
.hp_cut_off_freq_hz = 35.5, \
.sd_dither = 0, \
.sd_dither2 = 1, \
}
#define I2S_PDM_TX_CLK_DAC_DEFAULT_CONFIG(rate) { \
.sample_rate_hz = rate, \
.clk_src = I2S_CLK_SRC_DEFAULT, \
.mclk_multiple = I2S_MCLK_MULTIPLE_256, \
.up_sample_fp = 960, \
.up_sample_fs = (rate) / 100, \
}
// .bclk_div = 13,
void
flow3r_bsp_audio_init
(
void
)
{
//flow3r_bsp_max98091_init();
//vTaskDelay(100 / portTICK_PERIOD_MS); // dunno if necessary
static
const
i2s_config_t
i2s_config
=
{
.
mode
=
I2S_MODE_MASTER
|
I2S_MODE_TX
|
I2S_MODE_PDM
,
.
sample_rate
=
FLOW3R_BSP_AUDIO_SAMPLE_RATE
,
.
bits_per_sample
=
16
,
.
channel_format
=
I2S_CHANNEL_FMT_RIGHT_LEFT
,
.
communication_format
=
I2S_COMM_FORMAT_I2S
|
I2S_COMM_FORMAT_I2S_LSB
,
.
intr_alloc_flags
=
0
,
// default interrupt priority
.
dma_buf_count
=
FLOW3R_BSP_AUDIO_DMA_BUFFER_COUNT
,
.
dma_buf_len
=
FLOW3R_BSP_AUDIO_DMA_BUFFER_SIZE
,
.
use_apll
=
false
};
static
const
i2s_pin_config_t
pin_config
=
{
.
bck_io_num
=
I2S_PIN_NO_CHANGE
,
.
mck_io_num
=
I2S_PIN_NO_CHANGE
,
.
ws_io_num
=
45
,
.
data_out_num
=
46
,
.
data_in_num
=
I2S_PIN_NO_CHANGE
,
i2s_chan_config_t
chan_cfg
=
I2S_CHANNEL_DEFAULT_CONFIG
(
I2S_NUM_0
,
I2S_ROLE_MASTER
);
i2s_new_channel
(
&
chan_cfg
,
&
tx_handle
,
NULL
);
i2s_pdm_tx_config_t
pdm_tx_cfg
=
{
.
clk_cfg
=
I2S_PDM_TX_CLK_DAC_DEFAULT_CONFIG
(
FLOW3R_BSP_AUDIO_SAMPLE_RATE
),
.
slot_cfg
=
I2S_PDM_TX_SLOT_DAC_DEFAULT_CONFIG
(
I2S_DATA_BIT_WIDTH_16BIT
,
I2S_SLOT_MODE_STEREO
),
.
gpio_cfg
=
{
.
dout
=
46
,
.
dout2
=
45
},
};
ESP_ERROR_CHECK
(
i2s_driver_install
(
0
,
&
i2s_config
,
0
,
NULL
)
);
i2s_
set_pin
(
0
,
&
pin_config
);
i2s_channel_init_pdm_tx_mode
(
tx_handle
,
&
pdm_tx_cfg
);
i2s_
channel_enable
(
tx_handle
);
}
float
flow3r_bsp_audio_headphones_set_volume
(
bool
mute
,
float
dB
)
{
return
dB
;
//flow3r_bsp_max98091_headphones_set_volume(mute, dB);
return
0
;
//flow3r_bsp_max98091_headphones_set_volume(mute, dB);
}
float
flow3r_bsp_audio_speaker_set_volume
(
bool
mute
,
float
dB
)
{
return
dB
;
//flow3r_bsp_max98091_speaker_set_volume(mute, dB);
return
0
;
//flow3r_bsp_max98091_speaker_set_volume(mute, dB);
}
int8_t
flow3r_bsp_audio_headset_set_gain_dB
(
int8_t
gain_dB
)
{
return
gain_dB
;
//flow3r_bsp_max98091_headset_set_gain_dB(gain_dB);
return
0
;
//flow3r_bsp_max98091_headset_set_gain_dB(gain_dB);
}
void
flow3r_bsp_audio_read_jacksense
(
flow3r_bsp_audio_jacksense_state_t
*
st
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment