]> sigrok.org Git - libserialport.git/blobdiff - libserialport.h
Add some more narrative docs on the configuration API.
[libserialport.git] / libserialport.h
index 235263f5c0784732ae292a75ec3fff08dedad28f..09af4ff0672f226958b013a954d329466d520354 100644 (file)
@@ -67,6 +67,7 @@
  *
  * - @ref list_ports.c - Getting a list of ports present on the system.
  * - @ref port_info.c - Getting information on a particular serial port.
+ * - @ref port_config.c - Accessing configuration settings of a port.
  *
  * These examples are linked with the API documentation. Each function
  * in the API reference includes links to where it is used in an example
@@ -274,6 +275,25 @@ extern "C" {
 
 #include <stddef.h>
 
+/** @cond */
+#ifdef _MSC_VER
+/* Microsoft Visual C/C++ compiler in use */
+#ifdef LIBSERIALPORT_MSBUILD
+/* Building the library - need to export DLL symbols */
+#define SP_API __declspec(dllexport)
+#else
+/* Using the library - need to import DLL symbols */
+#define SP_API __declspec(dllimport)
+#endif
+#else
+/* Some other compiler in use */
+#ifndef LIBSERIALPORT_ATBUILD
+/* Not building the library itself - don't need any special prefixes. */
+#define SP_API
+#endif
+#endif
+/** @endcond */
+
 /** Return values. */
 enum sp_return {
        /** Operation completed successfully. */
@@ -482,7 +502,7 @@ struct sp_event_set {
  *
  * @since 0.1.0
  */
-enum sp_return sp_get_port_by_name(const char *portname, struct sp_port **port_ptr);
+SP_API enum sp_return sp_get_port_by_name(const char *portname, struct sp_port **port_ptr);
 
 /**
  * Free a port structure obtained from sp_get_port_by_name() or sp_copy_port().
@@ -491,7 +511,7 @@ enum sp_return sp_get_port_by_name(const char *portname, struct sp_port **port_p
  *
  * @since 0.1.0
  */
-void sp_free_port(struct sp_port *port);
+SP_API void sp_free_port(struct sp_port *port);
 
 /**
  * List the serial ports available on the system.
@@ -512,7 +532,7 @@ void sp_free_port(struct sp_port *port);
  *
  * @since 0.1.0
  */
-enum sp_return sp_list_ports(struct sp_port ***list_ptr);
+SP_API enum sp_return sp_list_ports(struct sp_port ***list_ptr);
 
 /**
  * Make a new copy of an sp_port structure.
@@ -531,7 +551,7 @@ enum sp_return sp_list_ports(struct sp_port ***list_ptr);
  *
  * @since 0.1.0
  */
-enum sp_return sp_copy_port(const struct sp_port *port, struct sp_port **copy_ptr);
+SP_API enum sp_return sp_copy_port(const struct sp_port *port, struct sp_port **copy_ptr);
 
 /**
  * Free a port list obtained from sp_list_ports().
@@ -543,7 +563,7 @@ enum sp_return sp_copy_port(const struct sp_port *port, struct sp_port **copy_pt
  *
  * @since 0.1.0
  */
-void sp_free_port_list(struct sp_port **ports);
+SP_API void sp_free_port_list(struct sp_port **ports);
 
 /**
  * @}
@@ -566,7 +586,7 @@ void sp_free_port_list(struct sp_port **ports);
  *
  * @since 0.1.0
  */
-enum sp_return sp_open(struct sp_port *port, enum sp_mode flags);
+SP_API enum sp_return sp_open(struct sp_port *port, enum sp_mode flags);
 
 /**
  * Close the specified serial port.
@@ -577,7 +597,7 @@ enum sp_return sp_open(struct sp_port *port, enum sp_mode flags);
  *
  * @since 0.1.0
  */
-enum sp_return sp_close(struct sp_port *port);
+SP_API enum sp_return sp_close(struct sp_port *port);
 
 /**
  * Get the name of a port.
@@ -594,7 +614,7 @@ enum sp_return sp_close(struct sp_port *port);
  *
  * @since 0.1.0
  */
-char *sp_get_port_name(const struct sp_port *port);
+SP_API char *sp_get_port_name(const struct sp_port *port);
 
 /**
  * Get a description for a port, to present to end user.
@@ -607,7 +627,7 @@ char *sp_get_port_name(const struct sp_port *port);
  *
  * @since 0.1.1
  */
-char *sp_get_port_description(const struct sp_port *port);
+SP_API char *sp_get_port_description(const struct sp_port *port);
 
 /**
  * Get the transport type used by a port.
@@ -618,7 +638,7 @@ char *sp_get_port_description(const struct sp_port *port);
  *
  * @since 0.1.1
  */
-enum sp_transport sp_get_port_transport(const struct sp_port *port);
+SP_API enum sp_transport sp_get_port_transport(const struct sp_port *port);
 
 /**
  * Get the USB bus number and address on bus of a USB serial adapter port.
@@ -633,7 +653,7 @@ enum sp_transport sp_get_port_transport(const struct sp_port *port);
  *
  * @since 0.1.1
  */
-enum sp_return sp_get_port_usb_bus_address(const struct sp_port *port,
+SP_API enum sp_return sp_get_port_usb_bus_address(const struct sp_port *port,
                                            int *usb_bus, int *usb_address);
 
 /**
@@ -649,7 +669,7 @@ enum sp_return sp_get_port_usb_bus_address(const struct sp_port *port,
  *
  * @since 0.1.1
  */
-enum sp_return sp_get_port_usb_vid_pid(const struct sp_port *port, int *usb_vid, int *usb_pid);
+SP_API enum sp_return sp_get_port_usb_vid_pid(const struct sp_port *port, int *usb_vid, int *usb_pid);
 
 /**
  * Get the USB manufacturer string of a USB serial adapter port.
@@ -662,7 +682,7 @@ enum sp_return sp_get_port_usb_vid_pid(const struct sp_port *port, int *usb_vid,
  *
  * @since 0.1.1
  */
-char *sp_get_port_usb_manufacturer(const struct sp_port *port);
+SP_API char *sp_get_port_usb_manufacturer(const struct sp_port *port);
 
 /**
  * Get the USB product string of a USB serial adapter port.
@@ -675,7 +695,7 @@ char *sp_get_port_usb_manufacturer(const struct sp_port *port);
  *
  * @since 0.1.1
  */
-char *sp_get_port_usb_product(const struct sp_port *port);
+SP_API char *sp_get_port_usb_product(const struct sp_port *port);
 
 /**
  * Get the USB serial number string of a USB serial adapter port.
@@ -688,7 +708,7 @@ char *sp_get_port_usb_product(const struct sp_port *port);
  *
  * @since 0.1.1
  */
-char *sp_get_port_usb_serial(const struct sp_port *port);
+SP_API char *sp_get_port_usb_serial(const struct sp_port *port);
 
 /**
  * Get the MAC address of a Bluetooth serial adapter port.
@@ -701,7 +721,7 @@ char *sp_get_port_usb_serial(const struct sp_port *port);
  *
  * @since 0.1.1
  */
-char *sp_get_port_bluetooth_address(const struct sp_port *port);
+SP_API char *sp_get_port_bluetooth_address(const struct sp_port *port);
 
 /**
  * Get the operating system handle for a port.
@@ -733,7 +753,7 @@ char *sp_get_port_bluetooth_address(const struct sp_port *port);
  *
  * @since 0.1.0
  */
-enum sp_return sp_get_port_handle(const struct sp_port *port, void *result_ptr);
+SP_API enum sp_return sp_get_port_handle(const struct sp_port *port, void *result_ptr);
 
 /**
  * @}
@@ -741,6 +761,63 @@ enum sp_return sp_get_port_handle(const struct sp_port *port, void *result_ptr);
  * @defgroup Configuration Configuration
  *
  * Setting and querying serial port parameters.
+ *
+ * See @ref port_config.c for a working example of port configuration.
+ *
+ * You should always configure all settings before using a port.
+ * There are no default settings applied by libserialport.
+ * When you open a port it may have default settings from the OS or
+ * driver, or the settings left over by the last program to use it.
+ *
+ * You should always set baud rate, data bits, parity and stop bits.
+ *
+ * You should normally also set one of the preset @ref sp_flowcontrol
+ * flow control modes, which will set up the RTS, CTS, DTR and DSR pin
+ * behaviours and enable or disable XON/XOFF. If you need an unusual
+ * configuration not covered by the preset flow control modes, you
+ * will need to configure these settings individually, and avoid
+ * calling sp_set_flowcontrol() or sp_set_config_flowcontrol() which
+ * will overwrite these settings.
+ *
+ * A port must be opened before you can change its settings.
+ *
+ * There are two ways of accessing port settings:
+ *
+ * Configuration structures
+ * ------------------------
+ *
+ * You can read and write a whole configuration (all settings at once)
+ * using sp_get_config() and sp_set_config(). This is handy if you want
+ * to change between some preset combinations, or save and restore an
+ * existing configuration. It also ensures the changes are made
+ * together, via an efficient set of calls into the OS - in some cases
+ * a single system call can be used.
+ *
+ * Use accessor functions like sp_get_config_baudrate() and
+ * sp_set_config_baudrate() to get and set individual settings
+ * from a configuration.
+ *
+ * For each setting in a port configuration, a special value of -1 can
+ * be used, which will cause that setting to be left alone when the
+ * configuration is applied by sp_set_config().
+ *
+ * This value is also be used by sp_get_config() for any settings
+ * which are unconfigured at the OS level, or in a state that is
+ * not representable within the libserialport API.
+ *
+ * Configurations are allocated using sp_new_config() and freed
+ * with sp_free_config(). You need to manage them yourself. When
+ * a new configuration is allocated by sp_new_config(), all of
+ * its settings are initially set to the special -1 value.
+ *
+ * Direct functions for changing port settings
+ * -------------------------------------------
+ *
+ * As a shortcut, you can set individual settings on a port directly
+ * by calling functions like sp_set_baudrate() and sp_set_parity().
+ * This saves you the work of allocating a temporary config, setting it
+ * up, applying it to a port and then freeing it.
+ *
  * @{
  */
 
@@ -766,7 +843,7 @@ enum sp_return sp_get_port_handle(const struct sp_port *port, void *result_ptr);
  *
  * @since 0.1.0
  */
-enum sp_return sp_new_config(struct sp_port_config **config_ptr);
+SP_API enum sp_return sp_new_config(struct sp_port_config **config_ptr);
 
 /**
  * Free a port configuration structure.
@@ -775,7 +852,7 @@ enum sp_return sp_new_config(struct sp_port_config **config_ptr);
  *
  * @since 0.1.0
  */
-void sp_free_config(struct sp_port_config *config);
+SP_API void sp_free_config(struct sp_port_config *config);
 
 /**
  * Get the current configuration of the specified serial port.
@@ -797,7 +874,7 @@ void sp_free_config(struct sp_port_config *config);
  *
  * @since 0.1.0
  */
-enum sp_return sp_get_config(struct sp_port *port, struct sp_port_config *config);
+SP_API enum sp_return sp_get_config(struct sp_port *port, struct sp_port_config *config);
 
 /**
  * Set the configuration for the specified serial port.
@@ -816,7 +893,7 @@ enum sp_return sp_get_config(struct sp_port *port, struct sp_port_config *config
  *
  * @since 0.1.0
  */
-enum sp_return sp_set_config(struct sp_port *port, const struct sp_port_config *config);
+SP_API enum sp_return sp_set_config(struct sp_port *port, const struct sp_port_config *config);
 
 /**
  * Set the baud rate for the specified serial port.
@@ -828,7 +905,7 @@ enum sp_return sp_set_config(struct sp_port *port, const struct sp_port_config *
  *
  * @since 0.1.0
  */
-enum sp_return sp_set_baudrate(struct sp_port *port, int baudrate);
+SP_API enum sp_return sp_set_baudrate(struct sp_port *port, int baudrate);
 
 /**
  * Get the baud rate from a port configuration.
@@ -843,7 +920,7 @@ enum sp_return sp_set_baudrate(struct sp_port *port, int baudrate);
  *
  * @since 0.1.0
  */
-enum sp_return sp_get_config_baudrate(const struct sp_port_config *config, int *baudrate_ptr);
+SP_API enum sp_return sp_get_config_baudrate(const struct sp_port_config *config, int *baudrate_ptr);
 
 /**
  * Set the baud rate in a port configuration.
@@ -855,7 +932,7 @@ enum sp_return sp_get_config_baudrate(const struct sp_port_config *config, int *
  *
  * @since 0.1.0
  */
-enum sp_return sp_set_config_baudrate(struct sp_port_config *config, int baudrate);
+SP_API enum sp_return sp_set_config_baudrate(struct sp_port_config *config, int baudrate);
 
 /**
  * Set the data bits for the specified serial port.
@@ -867,7 +944,7 @@ enum sp_return sp_set_config_baudrate(struct sp_port_config *config, int baudrat
  *
  * @since 0.1.0
  */
-enum sp_return sp_set_bits(struct sp_port *port, int bits);
+SP_API enum sp_return sp_set_bits(struct sp_port *port, int bits);
 
 /**
  * Get the data bits from a port configuration.
@@ -882,7 +959,7 @@ enum sp_return sp_set_bits(struct sp_port *port, int bits);
  *
  * @since 0.1.0
  */
-enum sp_return sp_get_config_bits(const struct sp_port_config *config, int *bits_ptr);
+SP_API enum sp_return sp_get_config_bits(const struct sp_port_config *config, int *bits_ptr);
 
 /**
  * Set the data bits in a port configuration.
@@ -894,7 +971,7 @@ enum sp_return sp_get_config_bits(const struct sp_port_config *config, int *bits
  *
  * @since 0.1.0
  */
-enum sp_return sp_set_config_bits(struct sp_port_config *config, int bits);
+SP_API enum sp_return sp_set_config_bits(struct sp_port_config *config, int bits);
 
 /**
  * Set the parity setting for the specified serial port.
@@ -906,7 +983,7 @@ enum sp_return sp_set_config_bits(struct sp_port_config *config, int bits);
  *
  * @since 0.1.0
  */
-enum sp_return sp_set_parity(struct sp_port *port, enum sp_parity parity);
+SP_API enum sp_return sp_set_parity(struct sp_port *port, enum sp_parity parity);
 
 /**
  * Get the parity setting from a port configuration.
@@ -921,7 +998,7 @@ enum sp_return sp_set_parity(struct sp_port *port, enum sp_parity parity);
  *
  * @since 0.1.0
  */
-enum sp_return sp_get_config_parity(const struct sp_port_config *config, enum sp_parity *parity_ptr);
+SP_API enum sp_return sp_get_config_parity(const struct sp_port_config *config, enum sp_parity *parity_ptr);
 
 /**
  * Set the parity setting in a port configuration.
@@ -933,7 +1010,7 @@ enum sp_return sp_get_config_parity(const struct sp_port_config *config, enum sp
  *
  * @since 0.1.0
  */
-enum sp_return sp_set_config_parity(struct sp_port_config *config, enum sp_parity parity);
+SP_API enum sp_return sp_set_config_parity(struct sp_port_config *config, enum sp_parity parity);
 
 /**
  * Set the stop bits for the specified serial port.
@@ -945,7 +1022,7 @@ enum sp_return sp_set_config_parity(struct sp_port_config *config, enum sp_parit
  *
  * @since 0.1.0
  */
-enum sp_return sp_set_stopbits(struct sp_port *port, int stopbits);
+SP_API enum sp_return sp_set_stopbits(struct sp_port *port, int stopbits);
 
 /**
  * Get the stop bits from a port configuration.
@@ -960,7 +1037,7 @@ enum sp_return sp_set_stopbits(struct sp_port *port, int stopbits);
  *
  * @since 0.1.0
  */
-enum sp_return sp_get_config_stopbits(const struct sp_port_config *config, int *stopbits_ptr);
+SP_API enum sp_return sp_get_config_stopbits(const struct sp_port_config *config, int *stopbits_ptr);
 
 /**
  * Set the stop bits in a port configuration.
@@ -972,7 +1049,7 @@ enum sp_return sp_get_config_stopbits(const struct sp_port_config *config, int *
  *
  * @since 0.1.0
  */
-enum sp_return sp_set_config_stopbits(struct sp_port_config *config, int stopbits);
+SP_API enum sp_return sp_set_config_stopbits(struct sp_port_config *config, int stopbits);
 
 /**
  * Set the RTS pin behaviour for the specified serial port.
@@ -984,7 +1061,7 @@ enum sp_return sp_set_config_stopbits(struct sp_port_config *config, int stopbit
  *
  * @since 0.1.0
  */
-enum sp_return sp_set_rts(struct sp_port *port, enum sp_rts rts);
+SP_API enum sp_return sp_set_rts(struct sp_port *port, enum sp_rts rts);
 
 /**
  * Get the RTS pin behaviour from a port configuration.
@@ -999,7 +1076,7 @@ enum sp_return sp_set_rts(struct sp_port *port, enum sp_rts rts);
  *
  * @since 0.1.0
  */
-enum sp_return sp_get_config_rts(const struct sp_port_config *config, enum sp_rts *rts_ptr);
+SP_API enum sp_return sp_get_config_rts(const struct sp_port_config *config, enum sp_rts *rts_ptr);
 
 /**
  * Set the RTS pin behaviour in a port configuration.
@@ -1011,7 +1088,7 @@ enum sp_return sp_get_config_rts(const struct sp_port_config *config, enum sp_rt
  *
  * @since 0.1.0
  */
-enum sp_return sp_set_config_rts(struct sp_port_config *config, enum sp_rts rts);
+SP_API enum sp_return sp_set_config_rts(struct sp_port_config *config, enum sp_rts rts);
 
 /**
  * Set the CTS pin behaviour for the specified serial port.
@@ -1023,7 +1100,7 @@ enum sp_return sp_set_config_rts(struct sp_port_config *config, enum sp_rts rts)
  *
  * @since 0.1.0
  */
-enum sp_return sp_set_cts(struct sp_port *port, enum sp_cts cts);
+SP_API enum sp_return sp_set_cts(struct sp_port *port, enum sp_cts cts);
 
 /**
  * Get the CTS pin behaviour from a port configuration.
@@ -1038,7 +1115,7 @@ enum sp_return sp_set_cts(struct sp_port *port, enum sp_cts cts);
  *
  * @since 0.1.0
  */
-enum sp_return sp_get_config_cts(const struct sp_port_config *config, enum sp_cts *cts_ptr);
+SP_API enum sp_return sp_get_config_cts(const struct sp_port_config *config, enum sp_cts *cts_ptr);
 
 /**
  * Set the CTS pin behaviour in a port configuration.
@@ -1050,7 +1127,7 @@ enum sp_return sp_get_config_cts(const struct sp_port_config *config, enum sp_ct
  *
  * @since 0.1.0
  */
-enum sp_return sp_set_config_cts(struct sp_port_config *config, enum sp_cts cts);
+SP_API enum sp_return sp_set_config_cts(struct sp_port_config *config, enum sp_cts cts);
 
 /**
  * Set the DTR pin behaviour for the specified serial port.
@@ -1062,7 +1139,7 @@ enum sp_return sp_set_config_cts(struct sp_port_config *config, enum sp_cts cts)
  *
  * @since 0.1.0
  */
-enum sp_return sp_set_dtr(struct sp_port *port, enum sp_dtr dtr);
+SP_API enum sp_return sp_set_dtr(struct sp_port *port, enum sp_dtr dtr);
 
 /**
  * Get the DTR pin behaviour from a port configuration.
@@ -1077,7 +1154,7 @@ enum sp_return sp_set_dtr(struct sp_port *port, enum sp_dtr dtr);
  *
  * @since 0.1.0
  */
-enum sp_return sp_get_config_dtr(const struct sp_port_config *config, enum sp_dtr *dtr_ptr);
+SP_API enum sp_return sp_get_config_dtr(const struct sp_port_config *config, enum sp_dtr *dtr_ptr);
 
 /**
  * Set the DTR pin behaviour in a port configuration.
@@ -1089,7 +1166,7 @@ enum sp_return sp_get_config_dtr(const struct sp_port_config *config, enum sp_dt
  *
  * @since 0.1.0
  */
-enum sp_return sp_set_config_dtr(struct sp_port_config *config, enum sp_dtr dtr);
+SP_API enum sp_return sp_set_config_dtr(struct sp_port_config *config, enum sp_dtr dtr);
 
 /**
  * Set the DSR pin behaviour for the specified serial port.
@@ -1101,7 +1178,7 @@ enum sp_return sp_set_config_dtr(struct sp_port_config *config, enum sp_dtr dtr)
  *
  * @since 0.1.0
  */
-enum sp_return sp_set_dsr(struct sp_port *port, enum sp_dsr dsr);
+SP_API enum sp_return sp_set_dsr(struct sp_port *port, enum sp_dsr dsr);
 
 /**
  * Get the DSR pin behaviour from a port configuration.
@@ -1116,7 +1193,7 @@ enum sp_return sp_set_dsr(struct sp_port *port, enum sp_dsr dsr);
  *
  * @since 0.1.0
  */
-enum sp_return sp_get_config_dsr(const struct sp_port_config *config, enum sp_dsr *dsr_ptr);
+SP_API enum sp_return sp_get_config_dsr(const struct sp_port_config *config, enum sp_dsr *dsr_ptr);
 
 /**
  * Set the DSR pin behaviour in a port configuration.
@@ -1128,7 +1205,7 @@ enum sp_return sp_get_config_dsr(const struct sp_port_config *config, enum sp_ds
  *
  * @since 0.1.0
  */
-enum sp_return sp_set_config_dsr(struct sp_port_config *config, enum sp_dsr dsr);
+SP_API enum sp_return sp_set_config_dsr(struct sp_port_config *config, enum sp_dsr dsr);
 
 /**
  * Set the XON/XOFF configuration for the specified serial port.
@@ -1140,7 +1217,7 @@ enum sp_return sp_set_config_dsr(struct sp_port_config *config, enum sp_dsr dsr)
  *
  * @since 0.1.0
  */
-enum sp_return sp_set_xon_xoff(struct sp_port *port, enum sp_xonxoff xon_xoff);
+SP_API enum sp_return sp_set_xon_xoff(struct sp_port *port, enum sp_xonxoff xon_xoff);
 
 /**
  * Get the XON/XOFF configuration from a port configuration.
@@ -1155,7 +1232,7 @@ enum sp_return sp_set_xon_xoff(struct sp_port *port, enum sp_xonxoff xon_xoff);
  *
  * @since 0.1.0
  */
-enum sp_return sp_get_config_xon_xoff(const struct sp_port_config *config, enum sp_xonxoff *xon_xoff_ptr);
+SP_API enum sp_return sp_get_config_xon_xoff(const struct sp_port_config *config, enum sp_xonxoff *xon_xoff_ptr);
 
 /**
  * Set the XON/XOFF configuration in a port configuration.
@@ -1167,7 +1244,7 @@ enum sp_return sp_get_config_xon_xoff(const struct sp_port_config *config, enum
  *
  * @since 0.1.0
  */
-enum sp_return sp_set_config_xon_xoff(struct sp_port_config *config, enum sp_xonxoff xon_xoff);
+SP_API enum sp_return sp_set_config_xon_xoff(struct sp_port_config *config, enum sp_xonxoff xon_xoff);
 
 /**
  * Set the flow control type in a port configuration.
@@ -1184,7 +1261,7 @@ enum sp_return sp_set_config_xon_xoff(struct sp_port_config *config, enum sp_xon
  *
  * @since 0.1.0
  */
-enum sp_return sp_set_config_flowcontrol(struct sp_port_config *config, enum sp_flowcontrol flowcontrol);
+SP_API enum sp_return sp_set_config_flowcontrol(struct sp_port_config *config, enum sp_flowcontrol flowcontrol);
 
 /**
  * Set the flow control type for the specified serial port.
@@ -1201,7 +1278,7 @@ enum sp_return sp_set_config_flowcontrol(struct sp_port_config *config, enum sp_
  *
  * @since 0.1.0
  */
-enum sp_return sp_set_flowcontrol(struct sp_port *port, enum sp_flowcontrol flowcontrol);
+SP_API enum sp_return sp_set_flowcontrol(struct sp_port *port, enum sp_flowcontrol flowcontrol);
 
 /**
  * @}
@@ -1239,7 +1316,7 @@ enum sp_return sp_set_flowcontrol(struct sp_port *port, enum sp_flowcontrol flow
  *
  * @since 0.1.0
  */
-enum sp_return sp_blocking_read(struct sp_port *port, void *buf, size_t count, unsigned int timeout_ms);
+SP_API enum sp_return sp_blocking_read(struct sp_port *port, void *buf, size_t count, unsigned int timeout_ms);
 
 /**
  * Read bytes from the specified serial port, returning as soon as any data is
@@ -1267,7 +1344,7 @@ enum sp_return sp_blocking_read(struct sp_port *port, void *buf, size_t count, u
  *
  * @since 0.1.1
  */
-enum sp_return sp_blocking_read_next(struct sp_port *port, void *buf, size_t count, unsigned int timeout_ms);
+SP_API enum sp_return sp_blocking_read_next(struct sp_port *port, void *buf, size_t count, unsigned int timeout_ms);
 
 /**
  * Read bytes from the specified serial port, without blocking.
@@ -1282,7 +1359,7 @@ enum sp_return sp_blocking_read_next(struct sp_port *port, void *buf, size_t cou
  *
  * @since 0.1.0
  */
-enum sp_return sp_nonblocking_read(struct sp_port *port, void *buf, size_t count);
+SP_API enum sp_return sp_nonblocking_read(struct sp_port *port, void *buf, size_t count);
 
 /**
  * Write bytes to the specified serial port, blocking until complete.
@@ -1318,7 +1395,7 @@ enum sp_return sp_nonblocking_read(struct sp_port *port, void *buf, size_t count
  *
  * @since 0.1.0
  */
-enum sp_return sp_blocking_write(struct sp_port *port, const void *buf, size_t count, unsigned int timeout_ms);
+SP_API enum sp_return sp_blocking_write(struct sp_port *port, const void *buf, size_t count, unsigned int timeout_ms);
 
 /**
  * Write bytes to the specified serial port, without blocking.
@@ -1339,7 +1416,7 @@ enum sp_return sp_blocking_write(struct sp_port *port, const void *buf, size_t c
  *
  * @since 0.1.0
  */
-enum sp_return sp_nonblocking_write(struct sp_port *port, const void *buf, size_t count);
+SP_API enum sp_return sp_nonblocking_write(struct sp_port *port, const void *buf, size_t count);
 
 /**
  * Gets the number of bytes waiting in the input buffer.
@@ -1350,7 +1427,7 @@ enum sp_return sp_nonblocking_write(struct sp_port *port, const void *buf, size_
  *
  * @since 0.1.0
  */
-enum sp_return sp_input_waiting(struct sp_port *port);
+SP_API enum sp_return sp_input_waiting(struct sp_port *port);
 
 /**
  * Gets the number of bytes waiting in the output buffer.
@@ -1361,7 +1438,7 @@ enum sp_return sp_input_waiting(struct sp_port *port);
  *
  * @since 0.1.0
  */
-enum sp_return sp_output_waiting(struct sp_port *port);
+SP_API enum sp_return sp_output_waiting(struct sp_port *port);
 
 /**
  * Flush serial port buffers. Data in the selected buffer(s) is discarded.
@@ -1373,7 +1450,7 @@ enum sp_return sp_output_waiting(struct sp_port *port);
  *
  * @since 0.1.0
  */
-enum sp_return sp_flush(struct sp_port *port, enum sp_buffer buffers);
+SP_API enum sp_return sp_flush(struct sp_port *port, enum sp_buffer buffers);
 
 /**
  * Wait for buffered data to be transmitted.
@@ -1391,7 +1468,7 @@ enum sp_return sp_flush(struct sp_port *port, enum sp_buffer buffers);
  *
  * @since 0.1.0
  */
-enum sp_return sp_drain(struct sp_port *port);
+SP_API enum sp_return sp_drain(struct sp_port *port);
 
 /**
  * @}
@@ -1419,7 +1496,7 @@ enum sp_return sp_drain(struct sp_port *port);
  *
  * @since 0.1.0
  */
-enum sp_return sp_new_event_set(struct sp_event_set **result_ptr);
+SP_API enum sp_return sp_new_event_set(struct sp_event_set **result_ptr);
 
 /**
  * Add events to a struct sp_event_set for a given port.
@@ -1438,7 +1515,7 @@ enum sp_return sp_new_event_set(struct sp_event_set **result_ptr);
  *
  * @since 0.1.0
  */
-enum sp_return sp_add_port_events(struct sp_event_set *event_set,
+SP_API enum sp_return sp_add_port_events(struct sp_event_set *event_set,
        const struct sp_port *port, enum sp_event mask);
 
 /**
@@ -1451,7 +1528,7 @@ enum sp_return sp_add_port_events(struct sp_event_set *event_set,
  *
  * @since 0.1.0
  */
-enum sp_return sp_wait(struct sp_event_set *event_set, unsigned int timeout_ms);
+SP_API enum sp_return sp_wait(struct sp_event_set *event_set, unsigned int timeout_ms);
 
 /**
  * Free a structure allocated by sp_new_event_set().
@@ -1460,7 +1537,7 @@ enum sp_return sp_wait(struct sp_event_set *event_set, unsigned int timeout_ms);
  *
  * @since 0.1.0
  */
-void sp_free_event_set(struct sp_event_set *event_set);
+SP_API void sp_free_event_set(struct sp_event_set *event_set);
 
 /**
  * @}
@@ -1488,7 +1565,7 @@ void sp_free_event_set(struct sp_event_set *event_set);
  *
  * @since 0.1.0
  */
-enum sp_return sp_get_signals(struct sp_port *port, enum sp_signal *signal_mask);
+SP_API enum sp_return sp_get_signals(struct sp_port *port, enum sp_signal *signal_mask);
 
 /**
  * Put the port transmit line into the break state.
@@ -1499,7 +1576,7 @@ enum sp_return sp_get_signals(struct sp_port *port, enum sp_signal *signal_mask)
  *
  * @since 0.1.0
  */
-enum sp_return sp_start_break(struct sp_port *port);
+SP_API enum sp_return sp_start_break(struct sp_port *port);
 
 /**
  * Take the port transmit line out of the break state.
@@ -1510,7 +1587,7 @@ enum sp_return sp_start_break(struct sp_port *port);
  *
  * @since 0.1.0
  */
-enum sp_return sp_end_break(struct sp_port *port);
+SP_API enum sp_return sp_end_break(struct sp_port *port);
 
 /**
  * @}
@@ -1535,7 +1612,7 @@ enum sp_return sp_end_break(struct sp_port *port);
  *
  * @since 0.1.0
  */
-int sp_last_error_code(void);
+SP_API int sp_last_error_code(void);
 
 /**
  * Get the error message for a failed operation.
@@ -1551,7 +1628,7 @@ int sp_last_error_code(void);
  *
  * @since 0.1.0
  */
-char *sp_last_error_message(void);
+SP_API char *sp_last_error_message(void);
 
 /**
  * Free an error message returned by sp_last_error_message().
@@ -1560,7 +1637,7 @@ char *sp_last_error_message(void);
  *
  * @since 0.1.0
  */
-void sp_free_error_message(char *message);
+SP_API void sp_free_error_message(char *message);
 
 /**
  * Set the handler function for library debugging messages.
@@ -1579,7 +1656,7 @@ void sp_free_error_message(char *message);
  *
  * @since 0.1.0
  */
-void sp_set_debug_handler(void (*handler)(const char *format, ...));
+SP_API void sp_set_debug_handler(void (*handler)(const char *format, ...));
 
 /**
  * Default handler function for library debugging messages.
@@ -1593,7 +1670,7 @@ void sp_set_debug_handler(void (*handler)(const char *format, ...));
  *
  * @since 0.1.0
  */
-void sp_default_debug_handler(const char *format, ...);
+SP_API void sp_default_debug_handler(const char *format, ...);
 
 /** @} */
 
@@ -1656,7 +1733,7 @@ void sp_default_debug_handler(const char *format, ...);
  *
  * @since 0.1.0
  */
-int sp_get_major_package_version(void);
+SP_API int sp_get_major_package_version(void);
 
 /**
  * Get the minor libserialport package version number.
@@ -1665,7 +1742,7 @@ int sp_get_major_package_version(void);
  *
  * @since 0.1.0
  */
-int sp_get_minor_package_version(void);
+SP_API int sp_get_minor_package_version(void);
 
 /**
  * Get the micro libserialport package version number.
@@ -1674,7 +1751,7 @@ int sp_get_minor_package_version(void);
  *
  * @since 0.1.0
  */
-int sp_get_micro_package_version(void);
+SP_API int sp_get_micro_package_version(void);
 
 /**
  * Get the libserialport package version number as a string.
@@ -1684,7 +1761,7 @@ int sp_get_micro_package_version(void);
  *
  * @since 0.1.0
  */
-const char *sp_get_package_version_string(void);
+SP_API const char *sp_get_package_version_string(void);
 
 /**
  * Get the "current" part of the libserialport library version number.
@@ -1693,7 +1770,7 @@ const char *sp_get_package_version_string(void);
  *
  * @since 0.1.0
  */
-int sp_get_current_lib_version(void);
+SP_API int sp_get_current_lib_version(void);
 
 /**
  * Get the "revision" part of the libserialport library version number.
@@ -1702,7 +1779,7 @@ int sp_get_current_lib_version(void);
  *
  * @since 0.1.0
  */
-int sp_get_revision_lib_version(void);
+SP_API int sp_get_revision_lib_version(void);
 
 /**
  * Get the "age" part of the libserialport library version number.
@@ -1711,7 +1788,7 @@ int sp_get_revision_lib_version(void);
  *
  * @since 0.1.0
  */
-int sp_get_age_lib_version(void);
+SP_API int sp_get_age_lib_version(void);
 
 /**
  * Get the libserialport library version number as a string.
@@ -1721,13 +1798,14 @@ int sp_get_age_lib_version(void);
  *
  * @since 0.1.0
  */
-const char *sp_get_lib_version_string(void);
+SP_API const char *sp_get_lib_version_string(void);
 
 /** @} */
 
 /**
  * @example list_ports.c Getting a list of ports present on the system.
  * @example port_info.c Getting information on a particular serial port.
+ * @example port_config.c Accessing configuration settings of a port.
 */
 
 #ifdef __cplusplus