Skip to content

Commit e1810cd

Browse files
committed
Support 384kHz and make buffer length configurable via CMake
1 parent b78ccc2 commit e1810cd

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
cmake_minimum_required(VERSION 3.12)
22
project(pico-i2s-pio)
33

4+
if (NOT DEFINED I2S_MAX_FREQ_KHZ)
5+
set(I2S_MAX_FREQ_KHZ 384)
6+
endif()
7+
8+
if (NOT DEFINED I2S_QUEUE_LEN)
9+
set(I2S_QUEUE_LEN 10)
10+
endif()
11+
412
add_library(pico-i2s-pio STATIC i2s.c)
513
pico_generate_pio_header(pico-i2s-pio ${CMAKE_CURRENT_LIST_DIR}/i2s.pio)
614
target_link_libraries(pico-i2s-pio
@@ -12,4 +20,9 @@ target_link_libraries(pico-i2s-pio
1220
hardware_sync
1321
)
1422

23+
target_compile_definitions(pico-i2s-pio PUBLIC
24+
I2S_MAX_FREQ_KHZ=${I2S_MAX_FREQ_KHZ}
25+
I2S_QUEUE_LEN=${I2S_QUEUE_LEN}
26+
)
27+
1528
target_include_directories(pico-i2s-pio PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Raspberry Pi Picoのpioを使ってMCLK対応のi2sを出力するライブラリです。RP2040/RP2350のシステムクロックをMCLKの整数倍に設定し、pioのフラクショナル分周を使わないlowジッタモードを搭載しています。また、PCM5102AやPT8211のような差動出力非対応のDACをデュアルモノで動作させる機能を搭載しています。i2sのslaveモードにも対応しました。
33

44
## 対応フォーマット
5-
16,24,32bit 44.1kHz~96kHz
6-
キューを使わない場合は384kHzまで対応
5+
16,24,32bit 44.1kHz~384kHz
6+
バッファの長さは3840サンプル(384kHz 10ms)です。
77

88
### i2s
99
BCLK: 64fs

i2s.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@
2727
#define I2S_H
2828
#include "hardware/pio.h"
2929

30-
#define I2S_MAX_FREQ_KHZ 96
30+
#ifndef I2S_MAX_FREQ_KHZ
31+
#define I2S_MAX_FREQ_KHZ 384
32+
#endif
33+
#ifndef I2S_QUEUE_LEN
3134
#define I2S_QUEUE_LEN 10
35+
#endif
3236
#define I2S_QUEUE_MAX (I2S_MAX_FREQ_KHZ * I2S_QUEUE_LEN)
3337
#define I2S_DEQUEUE_LEN 48
3438

0 commit comments

Comments
 (0)