MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / srd_inst_initial_pins_set_all

Function srd_inst_initial_pins_set_all

libsigrokdecode4DSL/instance.c:655–694  ·  view source on GitHub ↗

* Set the list of initial (assumed) pin values. * * @param di Decoder instance to use. Must not be NULL. * @param initial_pins A GArray of uint8_t values. Must not be NULL. * * @since 0.5.0 */

Source from the content-addressed store, hash-verified

653 * @since 0.5.0
654 */
655SRD_API int srd_inst_initial_pins_set_all(struct srd_decoder_inst *di, GArray *initial_pins)
656{
657 int i;
658 GString *s;
659
660 if (!di) {
661 srd_err("Invalid decoder instance.");
662 return SRD_ERR_ARG;
663 }
664
665 if (!initial_pins)
666 return SRD_ERR_ARG;
667
668 if (initial_pins->len != (guint)di->dec_num_channels) {
669 srd_err("Incorrect number of channels (need %d, got %d).",
670 di->dec_num_channels, initial_pins->len);
671 return SRD_ERR_ARG;
672 }
673
674 /* Sanity-check initial pin state values. */
675 for (i = 0; i < di->dec_num_channels; i++) {
676 if (initial_pins->data[i] <= 2)
677 continue;
678 srd_err("Invalid initial channel %d pin state: %d.",
679 i, initial_pins->data[i]);
680 return SRD_ERR_ARG;
681 }
682
683 s = g_string_sized_new(100);
684 oldpins_array_seed(di);
685 for (i = 0; i < di->dec_num_channels; i++) {
686 di->old_pins_array->data[i] = initial_pins->data[i];
687 g_string_append_printf(s, "%d, ", di->old_pins_array->data[i]);
688 }
689 s = g_string_truncate(s, s->len - 2);
690 srd_dbg("Initial pins: %s.", s->str);
691 g_string_free(s, TRUE);
692
693 return SRD_OK;
694}
695
696/** @private */
697SRD_PRIV int srd_inst_start(struct srd_decoder_inst *di, char **error)

Callers

nothing calls this directly

Calls 1

oldpins_array_seedFunction · 0.85

Tested by

no test coverage detected