11/* **********************************************************************************************************************
22* *
3- * libscopehal v0.1 *
3+ * libscopehal *
44* *
5- * Copyright (c) 2012-2021 Andrew D. Zonenberg and contributors *
5+ * Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
66* All rights reserved. *
77* *
88* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
3131 @file
3232 @author Andrew D. Zonenberg
3333 @brief Declaration of UartTrigger
34+ @ingroup triggers
3435 */
3536#ifndef UartTrigger_h
3637#define UartTrigger_h
4950
5051/* *
5152 @brief Trigger when a UART sees a certain data pattern
53+ @ingroup triggers
5254 */
5355class UartTrigger : public SerialTrigger
5456{
5557public:
5658 UartTrigger (Oscilloscope* scope);
5759 virtual ~UartTrigger ();
5860
61+ // /@brief Type of parity to use
5962 enum ParityType
6063 {
64+ // /@brief No parity
6165 PARITY_NONE,
66+
67+ // /@brief Odd parity
6268 PARITY_ODD,
69+
70+ // /@brief Even parity
6371 PARITY_EVEN,
64- PARITY_MARK,
65- PARITY_SPACE
72+
73+ // /@brief Mark parity
74+ PARITY_MARK,
75+
76+ // /@brief Space parity
77+ PARITY_SPACE
6678 };
6779
80+ /* *
81+ @brief Set the parity for the trigger
82+
83+ @param type Selected parity mode
84+ */
6885 void SetParityType (ParityType type)
6986 { m_parameters[m_ptypename].SetIntVal (type); }
7087
88+ // /@brief Get the currently selected parity mode
7189 ParityType GetParityType ()
7290 { return (ParityType) m_parameters[m_ptypename].GetIntVal (); }
7391
92+ // /@brief What kind of pattern to match
7493 enum MatchType
7594 {
95+ // /@brief Match on a data byte
7696 TYPE_DATA,
97+
98+ // /@brief Match on a parity error
7799 TYPE_PARITY_ERR,
78- TYPE_START,
79- TYPE_STOP
100+
101+ // /@brief Match on a start bit
102+ TYPE_START,
103+
104+ // /@brief Match on a stop bit
105+ TYPE_STOP
80106 };
81107
108+ /* *
109+ @brief Sets the match mode for the trigger
110+
111+ @param type Type of pattern to look for
112+ */
82113 void SetMatchType (MatchType type)
83114 { m_parameters[m_typename].SetIntVal (type); }
84115
116+ // /@brief Returns the currently selected match mode
85117 MatchType GetMatchType ()
86118 { return (MatchType) m_parameters[m_typename].GetIntVal (); }
87119
120+ // /@brief Polarity of the port
88121 enum Polarity
89122 {
123+ // /@brief Idle high, pull low to send a bit
90124 IDLE_HIGH,
125+
126+ // /@brief Idle low, pull high to send a bit
91127 IDLE_LOW
92128 };
93129
130+ /* *
131+ @brief Sets the UART polarity
132+
133+ @param type Desired polarity
134+ */
94135 void SetPolarity (Polarity type)
95136 { m_parameters[m_polarname].SetIntVal (type); }
96137
138+ // /@brief Get the current trigger polarity
97139 Polarity GetPolarity ()
98140 { return (Polarity) m_parameters[m_polarname].GetIntVal (); }
99141
142+ // /@brief Get the current baud rate
100143 int64_t GetBitRate ()
101144 { return m_parameters[m_baudname].GetIntVal (); }
102145
146+ /* *
147+ @brief Sets the baud rate
148+
149+ @param t Desired baud rate
150+ */
103151 void SetBitRate (int64_t t)
104152 { m_parameters[m_baudname].SetIntVal (t); }
105153
154+ // /@brief Get the length of the stop bit, in UI
106155 float GetStopBits ()
107156 { return m_parameters[m_stopname].GetFloatVal (); }
108157
158+ /* *
159+ @brief Set the length of the stop bit
160+
161+ @param n Length of the stop bit, in UI
162+ */
109163 void SetStopBits (float n)
110164 { m_parameters[m_stopname].SetFloatVal (n); }
111165
@@ -115,10 +169,20 @@ class UartTrigger : public SerialTrigger
115169 TRIGGER_INITPROC (UartTrigger);
116170
117171protected:
172+
173+ // /@brief Name of the "baud rate" parameter
118174 std::string m_baudname;
175+
176+ // /@brief Name of the "parity type" parameter
119177 std::string m_ptypename;
178+
179+ // /@brief Name of the "match type" parameter
120180 std::string m_typename;
181+
182+ // /@brief Name of the "stop bits" parameter
121183 std::string m_stopname;
184+
185+ // /@brief Name of the "polarity" parameter
122186 std::string m_polarname;
123187};
124188
0 commit comments