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

Function sample_matches

libsigrokdecode4DSL/instance.c:761–802  ·  view source on GitHub ↗

* Check whether the specified sample matches the specified term. * * In the case of SRD_TERM_SKIP, this function can modify * term->num_samples_already_skipped. * * @param old_sample The value of the previous sample (0/1). * @param sample The value of the current sample (0/1). * @param term The term that should be checked for a match. Must not be NULL. * * @retval TRUE The current sample

Source from the content-addressed store, hash-verified

759 * @private
760 */
761__attribute__((always_inline))
762static inline gboolean sample_matches(uint8_t old_sample, uint8_t sample, struct srd_term *term)
763{
764 /* Caller ensures term != NULL. */
765
766 switch (term->type) {
767 case SRD_TERM_HIGH:
768 if (sample == 1)
769 return TRUE;
770 break;
771 case SRD_TERM_LOW:
772 if (sample == 0)
773 return TRUE;
774 break;
775 case SRD_TERM_RISING_EDGE:
776 if (old_sample == 0 && sample == 1)
777 return TRUE;
778 break;
779 case SRD_TERM_FALLING_EDGE:
780 if (old_sample == 1 && sample == 0)
781 return TRUE;
782 break;
783 case SRD_TERM_EITHER_EDGE:
784 if ((old_sample == 1 && sample == 0) || (old_sample == 0 && sample == 1))
785 return TRUE;
786 break;
787 case SRD_TERM_NO_EDGE:
788 if ((old_sample == 0 && sample == 0) || (old_sample == 1 && sample == 1))
789 return TRUE;
790 break;
791 case SRD_TERM_SKIP:
792 if (term->num_samples_already_skipped == term->num_samples_to_skip)
793 return TRUE;
794 term->num_samples_already_skipped++;
795 break;
796 default:
797 srd_err("Unknown term type %d.", term->type);
798 break;
799 }
800
801 return FALSE;
802}
803
804/** @private */
805SRD_PRIV void condition_list_free(struct srd_decoder_inst *di)

Callers 1

term_matchesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected