Add portapack_io_update().
Some checks failed
Build / host (3.10.0, map[os:ubuntu shell:bash]) (push) Failing after 9s
Build / host (3.16.0, map[os:ubuntu shell:bash]) (push) Failing after 9s
Build / host (3.21.0, map[os:ubuntu shell:bash]) (push) Failing after 7s
Build / host (4.0.0, map[os:ubuntu shell:bash]) (push) Failing after 6s
Build / host (latest, map[os:ubuntu shell:bash]) (push) Failing after 6s
Build / firmware (HACKRF_ONE, 3.12.0, ubuntu) (push) Failing after 7s
Build / firmware (HACKRF_ONE, latest, ubuntu) (push) Failing after 7s
Build / firmware (JAWBREAKER, latest, ubuntu) (push) Failing after 4s
Build / firmware (JAWBREAKER, 3.12.0, ubuntu) (push) Failing after 6s
Build / firmware (PRALINE, 3.12.0, ubuntu) (push) Failing after 7s
Build / firmware (PRALINE, latest, ubuntu) (push) Failing after 6s
Build / firmware (RAD1O, 3.12.0, ubuntu) (push) Failing after 5s
Build / firmware (RAD1O, latest, ubuntu) (push) Failing after 7s
Build / firmware (UNIVERSAL, latest, ubuntu) (push) Failing after 5s
Build / firmware (UNIVERSAL, 3.12.0, ubuntu) (push) Failing after 7s
Check code style / clang-format (push) Failing after 4s
Check code style / clang-format-1 (push) Failing after 3s
Check code style / clang-format-2 (push) Failing after 5s
Check code style / clang-format-3 (push) Failing after 3s
Check includes / includes-check (HACKRF_ONE, 3.12.0) (push) Failing after 3s
Check includes / includes-check (HACKRF_ONE, latest) (push) Failing after 2s
Check includes / includes-check (JAWBREAKER, 3.12.0) (push) Failing after 2s
Check includes / includes-check (JAWBREAKER, latest) (push) Failing after 4s
Check includes / includes-check (PRALINE, 3.12.0) (push) Failing after 3s
Check includes / includes-check (PRALINE, latest) (push) Failing after 3s
Check includes / includes-check (RAD1O, 3.12.0) (push) Failing after 3s
Check includes / includes-check (RAD1O, latest) (push) Failing after 2s
Check includes / includes-check (UNIVERSAL, 3.12.0) (push) Failing after 3s
Check includes / includes-check (UNIVERSAL, latest) (push) Failing after 2s
Build / host (3.10.0, map[os:macos shell:bash]) (push) Has been cancelled
Build / host (3.16.0, map[os:macos shell:bash]) (push) Has been cancelled
Build / host (3.21.0, -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake --install-prefix=$env:GITHUB_WORKSPACE/install, map[os:windows shell:pwsh]) (push) Has been cancelled
Build / host (3.21.0, map[os:macos shell:bash]) (push) Has been cancelled
Build / host (4.0.0, -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake --install-prefix=$env:GITHUB_WORKSPACE/install, map[os:windows shell:pwsh]) (push) Has been cancelled
Build / host (latest, -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake --install-prefix=$env:GITHUB_WORKSPACE/install, map[os:windows shell:pwsh]) (push) Has been cancelled
Build / host (latest, map[os:macos shell:bash]) (push) Has been cancelled
Build / firmware (HACKRF_ONE, latest, windows) (push) Has been cancelled
Build / firmware (JAWBREAKER, latest, windows) (push) Has been cancelled
Build / firmware (PRALINE, 3.12.0, macos) (push) Has been cancelled
Build / firmware (PRALINE, latest, macos) (push) Has been cancelled
Build / firmware (PRALINE, latest, windows) (push) Has been cancelled
Build / firmware (RAD1O, latest, windows) (push) Has been cancelled
Build / firmware (UNIVERSAL, 3.12.0, macos) (push) Has been cancelled
Build / firmware (UNIVERSAL, latest, macos) (push) Has been cancelled
Build / firmware (UNIVERSAL, latest, windows) (push) Has been cancelled
Build / host (4.0.0, map[os:macos shell:bash]) (push) Has been cancelled
Build / host (latest, --install-prefix=/usr/local, map[os:windows shell:msys2]) (push) Has been cancelled

This commit is contained in:
Martin Ling 2026-06-11 16:21:39 +01:00
parent 202a97b6a8
commit b1dbb4731f
2 changed files with 45 additions and 0 deletions

View file

@ -67,6 +67,11 @@ void portapack_data_write_high(const uint32_t value)
portapack_if.gpio_port_data->mpin = value;
}
uint8_t portapack_data_read(void)
{
return portapack_if.gpio_port_data->mpin >> GPIO_DATA_SHIFT;
}
void portapack_dir_read(void)
{
portapack_if.gpio_port_data->dir &= ~gpio_data_mask;
@ -168,6 +173,44 @@ void portapack_io_write(const bool address, const uint_fast16_t value)
portapack_io_stb_deassert();
}
uint16_t portapack_io_update(const uint8_t value)
{
/* Very touchy code to save context of PortaPack data bus while the
* resistive touch pin drive is changed. Order of operations is
* important to prevent latching spurious data into the LCD or IO
* registers.
*/
uint8_t save_data = portapack_data_read();
bool addr = gpio_read(portapack_if.gpio_addr);
bool dir = gpio_read(portapack_if.gpio_dir);
portapack_io_stb_assert();
/* Switch to read */
portapack_dir_read();
portapack_addr(0);
__asm__("nop");
__asm__("nop");
__asm__("nop");
uint8_t new_data = portapack_data_read();
/* Switch to write */
portapack_data_write_low(value);
portapack_dir_write();
__asm__("nop");
__asm__("nop");
__asm__("nop");
portapack_io_stb_deassert();
portapack_data_write_low(save_data);
if (dir) { /* 0 (write) -> 1 (read) */
portapack_dir_read();
}
gpio_write(portapack_if.gpio_addr, addr);
return new_data;
}
void portapack_if_init(void)
{
const platform_gpio_t* gpio = platform_gpio();

View file

@ -89,6 +89,8 @@ void portapack_data_write_low(const uint32_t value);
void portapack_io_write(const bool address, const uint_fast16_t value);
uint16_t portapack_io_update(const uint8_t value);
void portapack_lcd_command(const uint32_t value);
void portapack_lcd_write_data(const uint32_t value);