]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blobdiff - rpp/include/rpp/sci.h
Make the RPP layer thread safe
[pes-rpp/rpp-lib.git] / rpp / include / rpp / sci.h
index 2e7b9bf349b6e5286bc28e341c3790be15112bfb..e3481ff244daecfb34831f87c16fea8e0357d1a0 100644 (file)
@@ -3,7 +3,7 @@
  *
  * @file sci.h
  *
- * @copyright Copyright (C) 2013-2014 Czech Technical University in Prague
+ * @copyright Copyright (C) 2013-2015 Czech Technical University in Prague
  *
  * @author Carlos Jenkins <carlos@jenkins.co.cr>
  */
@@ -22,6 +22,8 @@
  * initialized to 115200. It can be changed later by calling
  * rpp_sci_setup().
  *
+ * This function is not thread safe. Do not call it from multiple threads.
+ *
  * @return SUCCESS if initialization successful.\n
  *         FAILURE if module already initialized.
  */
@@ -31,6 +33,8 @@ int8_t rpp_sci_init();
 /**
  * SCI module setup.
  *
+ * The function is thread safe.
+ *
  * Configure the SCI module.
  *
  * @param[in] baud      Baud rate for the SCI. Tested values are 9600 and 115200
@@ -46,6 +50,8 @@ boolean_t rpp_sci_setup(uint32_t baud);
 /**
  * Number of bytes available on input buffer.
  *
+ * The function is thread safe.
+ *
  * Get the number of bytes (characters) available for reading from the serial
  * port. This is data that's already arrived and stored in the SCI input buffer.
  *
@@ -57,6 +63,8 @@ uint16_t rpp_sci_available();
 /**
  * Read n number of bytes from input buffer.
  *
+ * The function is thread safe.
+ *
  * Transfer given amount of bytes from SCI input buffer into given buffer.
  * Buffer should be at least as large as the amount of data requested.
  *
@@ -75,6 +83,8 @@ int8_t rpp_sci_read(uint32_t amount, uint8_t *buffer);
 /**
  * Read n number of bytes from input buffer if possible.
  *
+ * The function is thread safe.
+ *
  * Transfer given amount of bytes from SCI input buffer into given buffer.
  * Buffer should be at least as large as the amount of data requested.
  *
@@ -95,6 +105,8 @@ int8_t rpp_sci_read_nb(uint32_t amount, uint8_t *buffer);
 /**
  * Write n number of bytes to the output buffer.
  *
+ * The function is thread safe.
+ *
  * Transfer given amount of bytes from given buffer to the SCI output buffer.
  * Data buffer should be at least as large as the amount of data requested to be
  * sent.
@@ -115,6 +127,8 @@ int8_t rpp_sci_write(uint32_t amount, uint8_t *data);
 /**
  * Write n number of bytes to the output buffer if possible.
  *
+ * The function is thread safe.
+ *
  * Transfer given amount of bytes from given buffer to the SCI output buffer.
  * Data buffer should be at least as large as the amount of data requested to be
  * sent.
@@ -140,6 +154,8 @@ int8_t rpp_sci_write_nb(uint32_t amount, uint8_t *data);
 /**
  * Flush incomming or outgoing buffers.
  *
+ * The function is thread safe.
+ *
  * This is a blocking call.
  *
  * This will block if another process is writing to or reading data from the
@@ -158,6 +174,8 @@ int8_t rpp_sci_flush(boolean_t buff);
 /**
  * C style printk using RPP SCI module.
  *
+ * The function is not thread safe.
+ *
  * This call is intended to be used from interrupt only.
  * Function blocks until whole string was sent to the SCI output, therefore
  * it should be used with care. Frequent usage is for debugging.
@@ -187,6 +205,8 @@ int32_t rpp_sci_printk(const char *format, ...);
 /**
  * C style printk using RPP SCI module.
  *
+ * The function is not thread safe.
+ *
  * This call is intended to be used from interrupt only.
  * Function tries to append string to the output buffer.
  *
@@ -215,6 +235,8 @@ int32_t rpp_sci_printkb(const char *format, ...);
 /**
  * C style printf using RPP SCI module.
  *
+ * The function is thread safe.
+ *
  * This is a blocking call.
  *
  * This function will wait until all the bytes are sent to the SCI output
@@ -246,6 +268,8 @@ int32_t rpp_sci_printf(const char *format, ...);
 /**
  * C style vprintf using RPP SCI module.
  *
+ * The function is thread safe.
+ *
  * This is a blocking call.
  *
  * This function will wait until all the bytes are sent to the SCI output
@@ -277,6 +301,8 @@ int32_t rpp_sci_vprintf(const char *format, va_list args);
 /**
  * C style putc (put character) using RPP SCI module.
  *
+ * The function is not thread safe.
+ *
  * This is a blocking call.
  *
  * This function will wait until the given byte is put into SCI output buffer if
@@ -292,6 +318,8 @@ int8_t rpp_sci_putc(uint8_t byte);
 /**
  * C style getc (get character) using RPP SCI module.
  *
+ * The function is not thread safe.
+ *
  * This is a blocking call.
  *
  * This function will wait until a byte is available in the SCI input buffer if