/** * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. * * SPDX-License-Identifier: BSD-3-Clause */ #include #include #include #include #include "pio_sbw.h" void printbuf(const uint8_t* buf, size_t size) { for (size_t i = 0; i < size; ++i) printf("%02x%c", buf[i], i % 16 == 15 ? '\n' : ' '); } int main() { gpio_init(PINOUT_SBW_TCK); gpio_set_function(PINOUT_SBW_TCK, GPIO_FUNC_SIO); gpio_set_dir(PINOUT_SBW_TCK, true); gpio_put(PINOUT_SBW_TCK, true); stdio_init_all(); bool s = sbw_init(); printf("%s\n", s ? "inited" : "failure"); uint8_t tdi = 0x0f, tdo = 0; sbw_sequence(8, true, &tdi, &tdo); printf("seq done, tdo=%02x\n", tdo); uint8_t tms = 0xf0; sbw_tms_sequence(8, true, &tms); printf("tmsseq done\n"); printf("%s tclk:\n", "set"); sbw_set_tclk(); printf("%s tclk:\n", "clr"); sbw_clr_tclk(); printf("%s tclk:\n", "set"); sbw_set_tclk(); printf("%s tclk:\n", "clr"); sbw_clr_tclk(); printf("doing a tclk burst now!\n"); sbw_tclk_burst(16); printf("done.\n"); return 0; }