Skip to content

Commit

Permalink
ports/psoc6: Fixes based on review comments.
Browse files Browse the repository at this point in the history
Signed-off-by: NikhitaR-IFX <[email protected]>
  • Loading branch information
NikhitaR-IFX committed Sep 12, 2024
1 parent 60d5a35 commit 00db6cb
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ports_psoc6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ jobs:
- name: Run psoc6 tests
timeout-minutes: 12
run: |
./tests/ports/psoc6/run_psoc6_tests.sh --test-suite ci-tests --board ${{ matrix.board }} --hil ${{ runner.name }}
./tests/ports/psoc6/run_psoc6_tests.sh --test-suite pdm_pcm --board ${{ matrix.board }} --hil ${{ runner.name }}
#./tests/ports/psoc6/run_psoc6_tests.sh --test-suite ci-tests --board ${{ matrix.board }} --hil ${{ runner.name }}
- name: Container teardown
if: failure() || success()
run: |
Expand Down
8 changes: 2 additions & 6 deletions docs/psoc6/quickref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,8 @@ PDM objects can be created and initialized using::
from machine import PDM_PCM
from machine import Pin

clk_pin = Pin('P10_4')
data_pin = Pin('P10_5')
clk_pin = "P10_4"
data_pin = "P10_5"

pdm_pcm = PDM_PCM(
0,
Expand Down Expand Up @@ -647,10 +647,6 @@ Methods

.. method:: PDM_PCM.gain(gain_left, gain_right)

.. method:: PDM_PCM.start()

.. method:: PDM_PCM.stop()

Constants
---------

Expand Down
20 changes: 6 additions & 14 deletions ports/psoc6/machine_pdm_pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
* Copyright (c) 2022-2024 Infineon Technologies AG
* Copyright (c) 2024 Infineon Technologies AG
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -32,6 +32,8 @@
#include "modmachine.h"
#include "mplogger.h"

#if MICROPY_PY_MACHINE_PDM_PCM

#define pdm_pcm_assert_raise_val(msg, ret) if (ret != CY_RSLT_SUCCESS) { \
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT(msg), ret); \
}
Expand Down Expand Up @@ -64,11 +66,6 @@ typedef enum {
BITS_24 = 24
} pdm_pcm_word_length_t;

typedef enum {
RX,
TX
} pdm_pcm_op_mode_t;

// To be compatible with extmod
typedef enum {
MONO_LEFT = CYHAL_PDM_PCM_MODE_LEFT,
Expand All @@ -88,7 +85,6 @@ typedef struct _machine_pdm_pcm_obj_t {
cyhal_pdm_pcm_t pdm_pcm_obj;
uint32_t clk;
uint32_t data;
uint16_t pdm_pcm_op_mode; // always RX
io_mode_t io_mode;
format_t format;
uint8_t bits;
Expand Down Expand Up @@ -177,7 +173,7 @@ static mp_obj_t machine_pdm_pcm_make_new(const mp_obj_type_t *type, size_t n_pos

// =======================================================================================
// Private functions
// Init clock

void pdm_pcm_audio_clock_init(uint32_t audio_clock_freq_hz) {
cyhal_clock_t pll_clock;
cy_rslt_t result;
Expand Down Expand Up @@ -260,12 +256,8 @@ static machine_pdm_pcm_obj_t *mp_machine_pdm_pcm_make_new_instance(mp_int_t pdm_
return self;
}

// Init helper
static void mp_machine_pdm_pcm_init_helper(machine_pdm_pcm_obj_t *self, mp_arg_val_t *args) {

// Only RX mode supported in psoc6
self->pdm_pcm_op_mode = RX;

// Assign pins
self->clk = pin_addr_by_name(args[ARG_clk].u_obj);
self->data = pin_addr_by_name(args[ARG_data].u_obj);
Expand Down Expand Up @@ -317,8 +309,6 @@ static void mp_machine_pdm_pcm_deinit(machine_pdm_pcm_obj_t *self) {
MP_STATE_PORT(machine_pdm_pcm_obj[self->pdm_pcm_id]) = NULL;
}



static const mp_rom_map_elem_t machine_pdm_pcm_locals_dict_table[] = {
// Methods
{ MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&machine_pdm_pcm_init_obj) },
Expand Down Expand Up @@ -353,3 +343,5 @@ MP_DEFINE_CONST_OBJ_TYPE(
print, machine_pdm_pcm_print,
locals_dict, &machine_pdm_pcm_locals_dict
);

#endif // MICROPY_PY_MACHINE_PDM_PCM
1 change: 1 addition & 0 deletions ports/psoc6/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
#define MICROPY_PY_MACHINE_PSOC6_I2S (1)
#define MICROPY_PY_MACHINE_I2S_INCLUDEFILE "ports/psoc6/machine_i2s.c"

#define MICROPY_PY_MACHINE_PDM_PCM (1)
// VFS
#define MICROPY_VFS (1)
#define MICROPY_READER_VFS (1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
if "CY8CPROTO-062-4343W" in board:
clk_pin = "P10_4"
data_pin = "P10_5"

elif "CY8CPROTO-063-BLE" in board:
print("SKIP")
raise SystemExit

elif "CY8CKIT-062S2-AI" in board:
clk_pin = "P10_4"
data_pin = "P10_5"
Expand Down
5 changes: 4 additions & 1 deletion tests/ports/psoc6/run_psoc6_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ i2s_tests() {
}

pdm_pcm_tests() {
run_tests "pdm_pcm" ${dev_test} "${tests_psoc6_dir}/board_only_hw/single/pdm_pcm.py"
run_tests "pdm_pcm" ${dev_test} "${tests_psoc6_dir}/board_ext_hw/multi/pdm_pcm.py"
}

wdt_tests() {
Expand Down Expand Up @@ -298,6 +298,9 @@ run_ci_tests() {
dev_test=${devs_a[0]}
pwm_tests

dev_test=${devs_a[0]}
pdm_pcm_tests

if [ "${board}" == "CY8CPROTO-062-4343W" ] || [ "${board}" == "CY8CPROTO-063-BLE" ]; then
dev_test=${devs_a[0]}
else
Expand Down

0 comments on commit 00db6cb

Please sign in to comment.