Skip to content

Commit

Permalink
Fix build failed
Browse files Browse the repository at this point in the history
  • Loading branch information
sepfy committed Nov 18, 2024
1 parent 9b32da3 commit da7cfcb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
2 changes: 2 additions & 0 deletions examples/pico/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ target_link_libraries(peer
cjson
)

pico_generate_pio_header(pico_peer ${CMAKE_CURRENT_LIST_DIR}/rp2040_i2s_example/i2s.pio)

# Build pico_peer
add_executable(pico_peer
main.c
Expand Down
27 changes: 12 additions & 15 deletions examples/pico/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#include "hardware/dma.h"

#include "pcm-g711/pcm-g711/g711.h"
#include "rp2040_i2s_example/i2s.h"
#include "peer.h"
#include "rp2040_i2s_example/i2s.h"

static __attribute__((aligned(8))) pio_i2s i2s;

Expand Down Expand Up @@ -52,7 +52,6 @@ uint32_t get_epoch_time() {
}
#endif
static void dma_i2s_in_handler(void) {

int8_t alaw[AUDIO_BUFFER_FRAMES];
int16_t pcm[AUDIO_BUFFER_FRAMES];
int32_t* input_buffer;
Expand All @@ -62,20 +61,20 @@ static void dma_i2s_in_handler(void) {
input_buffer = i2s.input_buffer + STEREO_BUFFER_SIZE;
}
for (int i = 0; i < AUDIO_BUFFER_FRAMES; i++) {
pcm[i] = (int16_t)(input_buffer[2*i+1] >> 16);
pcm[i] = (int16_t)(input_buffer[2 * i + 1] >> 16);
alaw[i] = ALaw_Encode(pcm[i]);
}

#if 1
static uint32_t total_bytes = 0;
static uint32_t last_time = 0;
total_bytes += AUDIO_BUFFER_FRAMES;
uint32_t current_time = get_epoch_time();
if (current_time - last_time > 1000) {
printf("AUDIO_BUFFER_FRAMES: %d, bps: %d\n", AUDIO_BUFFER_FRAMES, 1000*total_bytes * 8 / (current_time - last_time));
total_bytes = 0;
last_time = current_time;
}
static uint32_t total_bytes = 0;
static uint32_t last_time = 0;
total_bytes += AUDIO_BUFFER_FRAMES;
uint32_t current_time = get_epoch_time();
if (current_time - last_time > 1000) {
printf("AUDIO_BUFFER_FRAMES: %d, bps: %d\n", AUDIO_BUFFER_FRAMES, 1000 * total_bytes * 8 / (current_time - last_time));
total_bytes = 0;
last_time = current_time;
}
#endif

if (eState == PEER_CONNECTION_COMPLETED) {
Expand All @@ -94,7 +93,6 @@ void peer_connection_task() {
}

void main_task(__unused void* params) {

if (cyw43_arch_init()) {
printf("failed to initialise\n");
vTaskDelete(NULL);
Expand Down Expand Up @@ -152,9 +150,8 @@ void vLaunch(void) {
}

int main(void) {

stdio_init_all();
//set_sys_clock_khz(132000, true);
// set_sys_clock_khz(132000, true);
vLaunch();
return 0;
}

0 comments on commit da7cfcb

Please sign in to comment.