PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
uartrx.h
Go to the documentation of this file.
1 
26 #pragma once
27 
30 #include <PropWare/gpio/pin.h>
31 
32 namespace PropWare {
33 
34 #ifdef __PROPELLER_COG__
35 #define virtual
36 #endif
37 
41 class UARTRX : public UART
42 #ifndef __PROPELLER_COG__
43  , public ScanCapable
44 #endif
45 {
46  public:
50  UARTRX () {
51  // Can't rely on parent constructor because the setters are virtual
52  this->set_data_width(UART::DEFAULT_DATA_WIDTH);
53  this->set_parity(UART::DEFAULT_PARITY);
54  this->set_stop_bit_width(UART::DEFAULT_STOP_BIT_WIDTH);
55  this->set_baud_rate(_cfg_baudrate);
56  this->set_rx_mask((Port::Mask) (1 << _cfg_rxpin));
57  }
58 
64  UARTRX (const Port::Mask rx) {
65  // Can't rely on parent constructor because the setters are virtual
66  this->set_data_width(UART::DEFAULT_DATA_WIDTH);
67  this->set_parity(UART::DEFAULT_PARITY);
68  this->set_stop_bit_width(UART::DEFAULT_STOP_BIT_WIDTH);
69  this->set_baud_rate(_cfg_baudrate);
70  this->set_rx_mask(rx);
71  }
72 
73  void set_rx_mask (const Port::Mask rx) {
74  this->m_pin.set_mask(rx);
75  this->m_pin.set_dir_in();
76  this->m_pin.set();
77  }
78 
79  Port::Mask get_rx_mask () const {
80  return this->m_pin.get_mask();
81  }
82 
83  virtual ErrorCode set_data_width (const uint8_t dataWidth) {
84  ErrorCode err;
85  check_errors(UART::set_data_width(dataWidth));
86 
87  this->set_msb_mask();
88  this->set_receivable_bits();
89 
90  return NO_ERROR;
91  }
92 
93  virtual void set_parity (const UART::Parity parity) {
94  UART::set_parity(parity);
95  this->set_msb_mask();
96  this->set_receivable_bits();
97  }
98 
104  uint32_t receive () const {
105  uint32_t rxVal = this->shift_in_data(this->m_receivableBits, this->m_bitCycles, this->m_pin.get_mask(),
106  this->m_msbMask);
107 
108  if (static_cast<bool>(this->m_parity) && this->check_parity(rxVal))
109  return static_cast<uint32_t>(-1);
110  else
111  return rxVal & this->m_dataMask;
112  }
113 
121  PropWare::ErrorCode receive (uint32_t &data) const {
122  const uint32_t rxVal = this->shift_in_data(this->m_receivableBits, this->m_bitCycles,
123  this->m_pin.get_mask(), this->m_msbMask);
124 
125  if (static_cast<bool>(this->m_parity) && this->check_parity(rxVal))
126  return PARITY_ERROR;
127  else {
128  data = rxVal & this->m_dataMask;
129  return NO_ERROR;
130  }
131  }
132 
146  PropWare::ErrorCode receive (uint32_t &data, const uint32_t timeout) const {
147  const uint32_t rxVal = this->shift_in_data(this->m_receivableBits, this->m_bitCycles,
148  this->m_pin.get_mask(), this->m_msbMask, timeout);
149  if (static_cast<uint32_t>(-1) == rxVal)
150  return TIMEOUT_ERROR;
151  else if (static_cast<bool>(this->m_parity) && this->check_parity(rxVal))
152  return PARITY_ERROR;
153  else {
154  data = rxVal & this->m_dataMask;
155  return NO_ERROR;
156  }
157  }
158 
175  PropWare::ErrorCode get_line (char *buffer, int32_t *length, const char delimiter = '\n') const {
176  if (NULL == length)
177  return NULL_POINTER;
178  else if (0 == *length)
179  *length = INT32_MAX;
180  int32_t wordCnt = 0;
181 
182  // Check if the total receivable bits can fit within a byte
183  if (8 >= this->m_receivableBits) {
184  // Set RX as input
185  __asm__ volatile ("andn dira, %0" : : "r" (this->m_pin.get_mask()));
186 
187  *length = this->shift_in_byte_array((uint32_t) buffer, *length, delimiter);
188 
189  if (Parity::NO_PARITY != this->m_parity)
190  for (int32_t i = 0; i < *length; --i)
191  if (this->check_parity(static_cast<uint32_t>(buffer[i])))
192  return UART::PARITY_ERROR;
193  }
194  // If total receivable bits does not fit within a byte, shift in one word at a time (this offers no speed
195  // improvement - it is only here for user convenience)
196  else {
197  uint32_t rxVal;
198 
199  do {
200  rxVal = this->receive();
201  if (static_cast<uint32_t>(-1) == rxVal)
202  return UART::PARITY_ERROR;
203  else {
204  *buffer = (char) rxVal;
205  ++buffer;
206  ++wordCnt;
207  }
208  } while (rxVal != delimiter && wordCnt < *length);
209 
210  *length = wordCnt;
211  }
212 
213  return NO_ERROR;
214  }
215 
225  PropWare::ErrorCode receive_array (uint8_t *buffer, uint32_t length) const {
226  PropWare::ErrorCode err;
227 
228  // Check if the total receivable bits can fit within a byte
229  if (8 >= this->m_receivableBits) {
230  // Set RX as input
231  __asm__ volatile ("andn dira, %0" : : "r" (this->m_pin.get_mask()));
232 
233  this->shift_in_byte_array(buffer, length);
234 
235  if (Parity::NO_PARITY != this->m_parity)
236  for (uint32_t i = 0; i < length; --i)
237  check_errors(this->check_parity(buffer[i]));
238  }
239  // If total receivable bits does not fit within a byte, shift in one word at a time (this offers no speed
240  // improvement - it is only here for user convenience)
241  else {
242  uint32_t temp;
243  for (uint32_t i = 0; i < length; ++i) {
244  if (static_cast<uint32_t>(-1) == (temp = this->receive()))
245  return UART::PARITY_ERROR;
246  else
247  buffer[i] = (char) temp;
248  }
249  }
250 
251  return NO_ERROR;
252  }
253 
264  PropWare::ErrorCode receive_array (uint8_t *buffer, uint32_t length, const uint32_t timeout) const {
265  PropWare::ErrorCode err;
266 
267  // Check if the total receivable bits can fit within a byte
268  if (8 >= this->m_receivableBits) {
269  // Set RX as input
270  __asm__ volatile ("andn dira, %0" : : "r" (this->m_pin.get_mask()));
271 
272  if (!this->shift_in_byte_array(buffer, length, timeout))
273  return TIMEOUT_ERROR;
274  else if (Parity::NO_PARITY != this->m_parity)
275  for (uint32_t i = 0; i < length; --i)
276  check_errors(this->check_parity(buffer[i]));
277  }
278  // If total receivable bits does not fit within a byte, shift in one word at a time (this offers no speed
279  // improvement - it is only here for user convenience)
280  else {
281  uint32_t rxVal;
282  for (uint32_t i = 0; i < length; ++i) {
283  check_errors(this->receive(rxVal, timeout));
284  buffer[i] = static_cast<uint8_t>(rxVal);
285  }
286  }
287 
288  return NO_ERROR;
289  }
290 
302  PropWare::ErrorCode fgets (char string[], int32_t *bufferSize) const {
303  const int32_t originalBufferSize = *bufferSize;
304 
305  PropWare::ErrorCode err;
306  check_errors(this->get_line(string, bufferSize));
307 
308  // Replace delimiter with null-terminator IFF we found one
309  if (*bufferSize != originalBufferSize || '\n' == string[originalBufferSize])
310  string[*bufferSize - 1] = '\0';
311  return NO_ERROR;
312  }
313 
314  virtual char get_char () {
315  return (char) this->receive();
316  }
317 
318  protected:
323  void set_msb_mask () {
324  if (static_cast<bool>(this->m_parity))
325  this->m_msbMask = (Port::Mask) (1 << this->m_dataWidth);
326  else
327  this->m_msbMask = (Port::Mask) (1 << (this->m_dataWidth - 1));
328  }
329 
334  void set_receivable_bits () {
335  if (static_cast<bool>(this->m_parity))
336  this->m_receivableBits = (uint8_t) (this->m_dataWidth + 1);
337  else
338  this->m_receivableBits = this->m_dataWidth;
339  }
340 
344  uint32_t shift_in_data (uint_fast8_t bits, const uint32_t bitCycles, const register uint32_t rxMask,
345  const uint32_t msbMask) const {
346  volatile uint32_t data = 0;
347  volatile uint32_t waitCycles = bitCycles;
348 
349 #ifndef DOXYGEN_IGNORE
350  __asm__ volatile (
351  FC_START("ShiftInDataStart%=", "ShiftInDataEnd%=")
352  " shr %[_waitCycles], #1 \n\t"
353  " add %[_waitCycles], %[_bitCycles] \n\t"
354  " waitpne %[_rxMask], %[_rxMask] \n\t"
355  " add %[_waitCycles], CNT \n\t"
356 
357  // Receive a word
358  "loop%=: \n\t"
359  " waitcnt %[_waitCycles], %[_bitCycles] \n\t"
360  " shr %[_data],# 1 \n\t"
361  " test %[_rxMask],ina wz \n\t"
362  " muxnz %[_data], %[_msbMask] \n\t"
363  " djnz %[_bits], #" FC_ADDR("loop%=", "ShiftInDataStart%=") " \n\t"
364 
365  // Wait for a stop bit
366  " waitpeq %[_rxMask], %[_rxMask] \n\t"
367  FC_END("ShiftInDataEnd%=")
368  :// Outputs
369  [_data] "+r"(data),
370  [_waitCycles] "+r"(waitCycles),
371  [_bits] "+r"(bits)
372  :// Inputs
373  [_rxMask] "r"(rxMask),
374  [_msbMask] "r"(msbMask),
375  [_bitCycles] "r"(bitCycles));
376 #endif
377 
378  return data;
379  }
380 
384  uint32_t shift_in_data (uint_fast8_t bits, const uint32_t bitCycles, const uint32_t rxMask,
385  const uint32_t msbMask, uint32_t timeoutCycles) const {
386  volatile uint32_t data = -1;
387  volatile uint32_t waitCycles = bitCycles;
388 
389  timeoutCycles /= 8; //the instruction that decrements the timeoutCounter needs 4 clock cycles
390 
391 #ifndef DOXYGEN_IGNORE
392  __asm__ volatile (
393  FC_START("ShiftInDataStart%=", "ShiftInDataEnd%=")
394  " shr %[_waitCycles], #1 \n\t"
395  " add %[_waitCycles], %[_bitCycles] \n\t"
396 
397  "awaitStart%=: "
398  " test %[_rxMask], ina wz \n\t"
399  " if_nz djnz %[_timeout], #" FC_ADDR("awaitStart%=", "ShiftInDataStart%=") " \n\t"
400  " add %[_waitCycles], CNT \n\t"
401  " if_nz jmp #" FC_ADDR("end%=", "ShiftInDataStart%=") " \n\t" //timed out
402 
403  // Receive a word
404  "loop%=: \n\t"
405  " waitcnt %[_waitCycles], %[_bitCycles] \n\t"
406  " shr %[_data],# 1 \n\t"
407  " test %[_rxMask],ina wz \n\t"
408  " muxnz %[_data], %[_msbMask] \n\t"
409  " djnz %[_bits], #" FC_ADDR("loop%=", "ShiftInDataStart%=") " \n\t"
410 
411  // Wait for a stop bit
412  " waitpeq %[_rxMask], %[_rxMask] \n\t"
413  "end%=: "
414  FC_END("ShiftInDataEnd%=")
415  :// Outputs
416  [_data] "+r"(data),
417  [_waitCycles] "+r"(waitCycles),
418  [_bits] "+r"(bits),
419  [_timeout] "+r"(timeoutCycles)
420  :// Inputs
421  [_rxMask] "r"(rxMask),
422  [_msbMask] "r"(msbMask),
423  [_bitCycles] "r"(bitCycles));
424 #endif
425 
426  return data;
427  }
428 
436  int shift_in_byte_array (uint32_t bufferAddr, const int maxLength, const char delimiter) const {
437  volatile uint32_t data = 0;
438  volatile int wordCnt = 0;
439  volatile uint32_t bitIdx = 0;
440  volatile uint32_t waitCycles = 0;
441  volatile uint32_t initWaitCycles = (this->m_bitCycles >> 1) + this->m_bitCycles;
442 
443 #ifndef DOXYGEN_IGNORE
444  // Initialize variables
445  __asm__ volatile (
446  FC_START("ShiftInStringStart%=", "ShiftInStringEnd%=")
447  "outerLoop%=: \n\t"
448  // Initialize the index variable
449  " mov %[_bitIdx], %[_bits] \n\t"
450  // Re-initialize the timer
451  " mov %[_waitCycles], %[_initWaitCycles] \n\t"
452  // Wait for the start bit
453  " waitpne %[_rxMask], %[_rxMask] \n\t"
454  // Begin the timer
455  " add %[_waitCycles], CNT \n\t"
456 
457  "innerLoop%=: \n\t"
458  // Wait for the next bit
459  " waitcnt %[_waitCycles], %[_bitCycles] \n\t"
460  " shr %[_data], #1 \n\t"
461  " test %[_rxMask], ina wz \n\t"
462  " muxnz %[_data], %[_msbMask] \n\t"
463  " djnz %[_bitIdx], #" FC_ADDR("innerLoop%=", "ShiftInStringStart%=") " \n\t"
464 
465  // Write the word back to the buffer in HUB memory
466  " wrbyte %[_data], %[_bufAdr] \n\t"
467 
468  // Check if we hit the delimiter (store result in Z)
469  " and %[_data], #0xff \n\t"
470  " cmp %[_data], %[_delim] wz \n\t"
471 
472  // Clear the data register
473  " mov %[_data], #0 \n\t"
474  // Increment the buffer address and total word count
475  " add %[_wordCnt], #1 \n\t"
476  " add %[_bufAdr], #1 \n\t"
477 
478  // Check if we hit the end of the buffer (store result in C)
479  " cmp %[_wordCnt], %[_maxLength] wc \n\t"
480 
481  // Wait for the stop bits
482  " waitpeq %[_rxMask], %[_rxMask] \n\t"
483 
484  // Finally, loop to the beginning if the delimiter is not equal to our most recent word and
485  // the buffer is not about to overflow
486  "if_nz_and_c jmp #" FC_ADDR("outerLoop%=", "ShiftInStringStart%=") " \n\t"
487  FC_END("ShiftInStringEnd%=")
488  :// Outputs
489  [_bitIdx] "+r"(bitIdx),
490  [_waitCycles] "+r"(waitCycles),
491  [_data] "+r"(data),
492  [_bufAdr] "+r"(bufferAddr),
493  [_wordCnt] "+r"(wordCnt)
494  :// Inputs
495  [_rxMask] "r"(this->m_pin.get_mask()),
496  [_bits] "r"(this->m_receivableBits),
497  [_bitCycles] "r"(this->m_bitCycles),
498  [_initWaitCycles] "r"(initWaitCycles),
499  [_msbMask] "r"(this->m_msbMask),
500  [_delim] "r"(delimiter),
501  [_maxLength] "r"(maxLength));
502 #endif
503 
504  return wordCnt;
505  }
506 
513  void shift_in_byte_array (uint8_t *buffer, unsigned int length) const {
514  uint32_t initWaitCycles = (this->m_bitCycles >> 1) + this->m_bitCycles;
515 
516 #ifndef DOXYGEN_IGNORE
517  // Initialize variables
518  __asm__ volatile (
519 #define ASMVAR(name) FC_ADDR(#name "%=", "ShiftInArrayDataStart%=")
520  FC_START("ShiftInArrayDataStart%=", "ShiftInArrayDataEnd%=")
521  " jmp #" FC_ADDR("outerLoop%=", "ShiftInArrayDataStart%=") " \n\t"
522 
523  // Temporary variables
524  "bitIdx%=: \n\t"
525  " nop \n\t"
526  "waitCycles%=: \n\t"
527  " nop \n\t"
528  "data%=: \n\t"
529  " nop \n\t"
530  " mov " ASMVAR(data) ", #0 \n\t"
531 
532  "outerLoop%=: \n\t"
533  // Initialize the index variable
534  " mov " ASMVAR(bitIdx) ", %[_bits] \n\t"
535  // Re-initialize the timer
536  " mov " ASMVAR(waitCycles) ", %[_initWaitCycles] \n\t"
537  // Wait for the start bit
538  " waitpne %[_rxMask], %[_rxMask] \n\t"
539  // Begin the timer
540  " add " ASMVAR(waitCycles) ", CNT \n\t"
541 
542  "innerLoop%=: \n\t"
543  // Wait for the next bit
544  " waitcnt " ASMVAR(waitCycles) ", %[_bitCycles] \n\t"
545  " shr " ASMVAR(data) ", #1 \n\t"
546  " test %[_rxMask], ina wz \n\t"
547  " muxnz " ASMVAR(data) ", %[_msbMask] \n\t"
548  " djnz " ASMVAR(bitIdx) ", #" FC_ADDR("innerLoop%=", "ShiftInArrayDataStart%=") " \n\t"
549 
550  // Write the word back to the buffer in HUB memory
551  " wrbyte " ASMVAR(data) ", %[_bufAdr] \n\t"
552 
553  // Clear the data register
554  " mov " ASMVAR(data) ", #0 \n\t"
555  // Increment the buffer address
556  " add %[_bufAdr], #1 \n\t"
557 
558  // Wait for the stop bits and the loop back
559  " waitpeq %[_rxMask], %[_rxMask] \n\t"
560  " djnz %[_length], #" FC_ADDR("outerLoop%=", "ShiftInArrayDataStart%=") " \n\t"
561  FC_END("ShiftInArrayDataEnd%=")
562 #undef ASMVAR
563  :// Outputs
564  [_bufAdr] "+r"(buffer),
565  [_length] "+r"(length)
566  :// Inputs
567  [_rxMask] "r"(this->m_pin.get_mask()),
568  [_bits] "r"(this->m_receivableBits),
569  [_bitCycles] "r"(this->m_bitCycles),
570  [_initWaitCycles] "r"(initWaitCycles),
571  [_msbMask] "r"(this->m_msbMask));
572 #endif
573  }
574 
575 
586  bool shift_in_byte_array (uint8_t *buffer, unsigned int length, uint32_t timeout) const {
587  uint32_t initWaitCycles = (this->m_bitCycles >> 1) + this->m_bitCycles;
588  volatile uint32_t timeLeft = 0;
589 
590  timeout /= 8; //the instruction that decrements the timeoutCounter needs 4 clock cycles
591 
592 #ifndef DOXYGEN_IGNORE
593  // Initialize variables
594  __asm__ volatile (
595 #define ASMVAR(name) FC_ADDR(#name "%=", "ShiftInArrayDataStart%=")
596  FC_START("ShiftInArrayDataStart%=", "ShiftInArrayDataEnd%=")
597  " jmp #" FC_ADDR("outerLoop%=", "ShiftInArrayDataStart%=") " \n\t"
598 
599  // Temporary variables
600  "bitIdx%=: \n\t"
601  " nop \n\t"
602  "waitCycles%=: \n\t"
603  " nop \n\t"
604  "data%=: \n\t"
605  " nop \n\t"
606  " mov " ASMVAR(data) ", #0 \n\t"
607 
608  "outerLoop%=: \n\t"
609  // Initialize the index variable
610  " mov " ASMVAR(bitIdx) ", %[_bits] \n\t"
611  // Re-initialize the timer
612  " mov " ASMVAR(waitCycles) ", %[_initWaitCycles] \n\t"
613 
614  //reset timeout and wait for startBit
615  " mov %[_timeLeft], %[_timeout] \n\t"
616  "awaitStart%=: "
617  " test %[_rxMask], ina wz \n\t"
618  " if_nz djnz %[_timeLeft], #" FC_ADDR("awaitStart%=", "ShiftInArrayDataStart%=") " \n\t"
619  // Begin the timer (even if we just timed out - for performance reasons)
620  " add " ASMVAR(waitCycles) ", CNT \n\t"
621  //timed out, jump to the end (timeLeft is 0 now)
622  " if_nz jmp #" FC_ADDR("end%=", "ShiftInArrayDataStart%=") " \n\t"
623 
624  "innerLoop%=: \n\t"
625  // Wait for the next bit
626  " waitcnt " ASMVAR(waitCycles) ", %[_bitCycles] \n\t"
627  " shr " ASMVAR(data) ", #1 \n\t"
628  " test %[_rxMask], ina wz \n\t"
629  " muxnz " ASMVAR(data) ", %[_msbMask] \n\t"
630  " djnz " ASMVAR(bitIdx) ", #" FC_ADDR("innerLoop%=", "ShiftInArrayDataStart%=") " \n\t"
631 
632  // Write the word back to the buffer in HUB memory
633  " wrbyte " ASMVAR(data) ", %[_bufAdr] \n\t"
634 
635  // Clear the data register
636  " mov " ASMVAR(data) ", #0 \n\t"
637  // Increment the buffer address
638  " add %[_bufAdr], #1 \n\t"
639 
640  // Wait for the stop bits and the loop back
641  " waitpeq %[_rxMask], %[_rxMask] \n\t"
642  " djnz %[_length], #" FC_ADDR("outerLoop%=", "ShiftInArrayDataStart%=") " \n\t"
643 
644  "end%=: "
645  FC_END("ShiftInArrayDataEnd%=")
646 #undef ASMVAR
647  :// Outputs
648  [_bufAdr] "+r"(buffer),
649  [_length] "+r"(length),
650  [_timeLeft] "+r"(timeLeft)
651  :// Inputs
652  [_rxMask] "r"(this->m_pin.get_mask()),
653  [_bits] "r"(this->m_receivableBits),
654  [_bitCycles] "r"(this->m_bitCycles),
655  [_initWaitCycles] "r"(initWaitCycles),
656  [_msbMask] "r"(this->m_msbMask),
657  [_timeout] "r"(timeout));
658 #endif
659 
660  return 0 != timeLeft;
661  }
662 
663 
672  PropWare::ErrorCode check_parity (uint32_t rxVal) const {
673  uint32_t evenParityResult;
674 
675  evenParityResult = 0;
676  __asm__ volatile("test %[_data], %[_dataMask] wc \n\t"
677  "muxc %[_parityResult], %[_parityMask]"
678  : [_parityResult] "+r"(evenParityResult)
679  : [_data] "r"(rxVal),
680  [_dataMask] "r"(this->m_dataMask),
681  [_parityMask] "r"(this->m_parityMask));
682 
683  if (Parity::ODD_PARITY == this->m_parity) {
684  //if using odd parity, the result should be different from evenParity
685  if (evenParityResult == (rxVal & this->m_parityMask))
686  return UART::PARITY_ERROR;
687  } else if (evenParityResult != (rxVal & this->m_parityMask))
688  //if using even parity, the result should be that of evenParity
689  return UART::PARITY_ERROR;
690 
691  return UART::NO_ERROR;
692  }
693 
694  protected:
695  Pin m_pin;
696  Port::Mask m_msbMask;
697  uint8_t m_receivableBits;
698 };
699 
700 #ifdef __PROPELLER_COG__
701 #undef virtual
702 #endif
703 
704 }
PropWare::UART::Parity::ODD_PARITY
@ ODD_PARITY
uart.h
PropWare::Pin::set_mask
void set_mask(const Pin::Mask mask)
Definition: pin.h:80
PropWare::UARTRX::UARTRX
UARTRX()
Definition: uartrx.h:50
PropWare::UART::Parity::NO_PARITY
@ NO_PARITY
PropWare::UART
Abstract base class for all unbuffered UART devices.
Definition: uart.h:86
PropWare::UART::TIMEOUT_ERROR
@ TIMEOUT_ERROR
Definition: uart.h:110
PropWare::Port::Mask
Mask
Definition: port.h:43
PropWare::UART::NULL_POINTER
@ NULL_POINTER
Definition: uart.h:109
PropWare::ScanCapable
Interface for all classes capable of printing.
Definition: scancapable.h:38
PropWare::UARTRX::receive
PropWare::ErrorCode receive(uint32_t &data, const uint32_t timeout) const
Receive one byte from the uart. This blocks until either the byte was received or the timeout trigger...
Definition: uartrx.h:146
PropWare::UARTRX::get_char
virtual char get_char()
Read and return a single character. Whether the method is blocking or not depends entirely on the imp...
Definition: uartrx.h:314
timeout
int timeout(int time)
Compares the time against the time elapsed since mark (deprecated).
Definition: timeout.c:19
PropWare::UARTRX::receive
PropWare::ErrorCode receive(uint32_t &data) const
Receive one byte from the uart. This blocks until the byte is received.
Definition: uartrx.h:121
PropWare::UARTRX
Receive routines for basic UART communication.
Definition: uartrx.h:41
PropWare::UART::PARITY_ERROR
@ PARITY_ERROR
Definition: uart.h:106
PropWare::Port::set_dir_in
void set_dir_in() const
Set the port for input.
Definition: port.h:217
PropWare::UARTRX::receive_array
PropWare::ErrorCode receive_array(uint8_t *buffer, uint32_t length, const uint32_t timeout) const
Reads multiple bytes into the given buffer. This blocks until either the.
Definition: uartrx.h:264
PropWare::UARTRX::receive
uint32_t receive() const
Retrieve a single word from the bus.
Definition: uartrx.h:104
PropWare::Port::set
void set() const
Set selected output port high (set all pins to 1)
Definition: port.h:226
PropWare::UARTRX::UARTRX
UARTRX(const Port::Mask rx)
Initialize a UART receiver.
Definition: uartrx.h:64
PropWare::UARTRX::get_line
PropWare::ErrorCode get_line(char *buffer, int32_t *length, const char delimiter='\n') const
Read bytes until the provided delimiter is read or max length is reached.
Definition: uartrx.h:175
char
PropWare::UARTRX::receive_array
PropWare::ErrorCode receive_array(uint8_t *buffer, uint32_t length) const
Reads multiple bytes into the given buffer. This blocks until requested number of words have been rec...
Definition: uartrx.h:225
pin.h
PropWare
Generic definitions and functions for the Parallax Propeller.
Definition: runnable.h:33
PropWare::UART::NO_ERROR
@ NO_ERROR
Definition: uart.h:103
PropWare::UARTRX::fgets
PropWare::ErrorCode fgets(char string[], int32_t *bufferSize) const
Read words from the bus until a newline character (\\n) is received or the buffer is filled.
Definition: uartrx.h:302
PropWare::UART::Parity
Parity
Definition: uart.h:88
scancapable.h