Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ enum pio_instr_bits {
#define _PIO_INVALID_MOV_SRC 0u
#define _PIO_INVALID_MOV_DEST 0u
#endif
#define _PIO_AMBIGUOUS_SRC_DEST 0x100u

/*! \brief Enumeration of values to pass for source/destination args for instruction encoding functions
* \ingroup pio_instructions
Expand All @@ -68,7 +69,7 @@ enum pio_src_dest {
pio_null = 3u | _PIO_INVALID_SET_DEST | _PIO_INVALID_MOV_DEST,
#if PICO_PIO_VERSION > 0
pio_pindirs_mov = 3u | _PIO_INVALID_IN_SRC | _PIO_INVALID_MOV_SRC,
pio_pindirs = 4u | _PIO_INVALID_IN_SRC | _PIO_INVALID_MOV_SRC,
pio_pindirs = 4u | _PIO_INVALID_IN_SRC | _PIO_INVALID_MOV_SRC | _PIO_AMBIGUOUS_SRC_DEST,
#else
pio_pindirs = 4u | _PIO_INVALID_IN_SRC | _PIO_INVALID_MOV_SRC | _PIO_INVALID_MOV_DEST,
#endif
Expand All @@ -79,7 +80,7 @@ enum pio_src_dest {
pio_isr = 6u | _PIO_INVALID_SET_DEST,
pio_osr = 7u | _PIO_INVALID_OUT_DEST | _PIO_INVALID_SET_DEST,
pio_exec_out = 7u | _PIO_INVALID_IN_SRC | _PIO_INVALID_SET_DEST | _PIO_INVALID_MOV_SRC | _PIO_INVALID_MOV_DEST,
pio_exec = 7u | _PIO_INVALID_IN_SRC | _PIO_INVALID_SET_DEST | _PIO_INVALID_MOV_SRC,
pio_exec = 7u | _PIO_INVALID_IN_SRC | _PIO_INVALID_SET_DEST | _PIO_INVALID_MOV_SRC | _PIO_AMBIGUOUS_SRC_DEST,
};

static inline uint _pio_major_instr_bits(uint instr) {
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ if (PICO_ON_DEVICE)
add_subdirectory(pico_low_power_test)
add_subdirectory(pico_async_context_test)
add_subdirectory(pico_thread_local_test)
add_subdirectory(pio_encoding_test)
endif()

# PICO_TEST_FILE_GENERATOR: Path to the a CMake script to generate test files for ci
Expand Down
7 changes: 2 additions & 5 deletions test/pico_sync_test/pico_sync_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@

#include <stdio.h>

#include "../../src/common/pico_base_headers/include/pico/types.h"
#include "../../src/common/pico_time/include/pico/time.h"
#include "../../src/rp2_common/hardware_sync_spin_lock/include/hardware/sync/spin_lock.h"
#include "pico/lock_core.h"
#include "pico/stdlib.h"
#include "pico/sync.h"
#include "pico/test.h"
#include "pico/stdio.h"

PICOTEST_MODULE_NAME("SYNC", "sync test");

Expand Down
7 changes: 7 additions & 0 deletions test/pio_encoding_test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# TODO: Add these tests to the Bazel build.
filegroup(
name = "unsupported_tests",
srcs = [
"pio_encoding_test.c",
],
)
5 changes: 5 additions & 0 deletions test/pio_encoding_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
add_executable(pio_encoding_test ${CMAKE_CURRENT_LIST_DIR}/pio_encoding_test.c)
target_link_libraries(pio_encoding_test PRIVATE pico_stdlib pico_test hardware_pio)
pico_add_extra_outputs(pio_encoding_test)

pico_generate_pio_header(pio_encoding_test ${CMAKE_CURRENT_LIST_DIR}/encodings.pio)
12 changes: 12 additions & 0 deletions test/pio_encoding_test/encodings.pio
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.pio_version 1

.program encodings

public mov_osr_x:
mov osr, x
public mov_pindirs_x:
mov pindirs, x
public mov_exec_x:
mov exec, x
public mov_y_x:
mov y, x
40 changes: 40 additions & 0 deletions test/pio_encoding_test/pio_encoding_test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright (c) 2022 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#include <stdio.h>

#include "pico/stdlib.h"
#include "pico/test.h"
#include "hardware/pio_instructions.h"
#include "encodings.pio.h"

PICOTEST_MODULE_NAME("PIO_ENCODING", "pio encoding test");


int main() {
stdio_init_all();

PICOTEST_START();

PICOTEST_START_SECTION("check pio_encodings");

PICOTEST_CHECK(0xa0e1 == encodings_program_instructions[encodings_offset_mov_osr_x], "mov osr, x");
PICOTEST_CHECK(0xa0e1 == pio_encode_mov(pio_osr, pio_x), "pio_encode_mov(pio_osr, pio_x)");
PICOTEST_CHECK(0xa061 == encodings_program_instructions[encodings_offset_mov_pindirs_x], "mov pindirs, x");
PICOTEST_CHECK(0xa061 == pio_encode_mov(pio_pindirs, pio_x), "pio_encode_mov(pio_pindirs, pio_x)");
#if PICO_PIO_VERSION > 1
PICOTEST_CHECK(0xa061 == pio_encode_mov(pio_pindirs_mov, pio_x), "pio_encode_mov(pio_pindirs_mov, pio_x)");
#endif
PICOTEST_CHECK(0xa081 == encodings_program_instructions[encodings_offset_mov_exec_x], "mov exec, x");
PICOTEST_CHECK(0xa081 == pio_encode_mov(pio_exec, pio_x), "pio_encode_mov(pio_exec, pio_x)");
PICOTEST_CHECK(0xa081 == pio_encode_mov(pio_exec_mov, pio_x), "pio_encode_mov(pio_exec_mov, pio_x)");
PICOTEST_CHECK(0xa041 == encodings_program_instructions[encodings_offset_mov_y_x], "mov y, x");
PICOTEST_CHECK(0xa041 == pio_encode_mov(pio_y, pio_x), "pio_encode_mov(pio_y, pio_x)");
PICOTEST_END_SECTION();

PICOTEST_END_TEST();
}

Loading