Álvaro de Rada / X_NUCLEO_PLC01A1
Revision:
2:1ec0dea195f8
Parent:
0:b66a560b6618
--- a/Components/Common/plc.h	Fri Feb 19 11:10:02 2016 +0000
+++ b/Components/Common/plc.h	Tue Feb 23 10:40:17 2016 +0000
@@ -38,6 +38,7 @@
 
 
 /* Define to prevent recursive inclusion -------------------------------------*/
+
 #ifndef __PLC_H
 #define __PLC_H
 
@@ -45,8 +46,14 @@
 extern "C" {
 #endif
 
+
 /* Includes ------------------------------------------------------------------*/
+
 #include <stdint.h>
+#include "component.h"
+
+
+/* Definitions ---------------------------------------------------------------*/
 
 /** @addtogroup BSP
   * @{
@@ -69,6 +76,9 @@
 #define NB_BYTES 2
 #define BUFFERSIZE 1
 
+
+/* Types ---------------------------------------------------------------------*/
+
 /** @defgroup PLC_Exported_Types
   * @{
   */
@@ -79,17 +89,6 @@
   */
 
 /**
- * @brief  Component's Status enumerator definition.
- */
-typedef enum
-{
-    COMPONENT_OK = 0,
-    COMPONENT_ERROR,
-    COMPONENT_TIMEOUT,
-    COMPONENT_NOT_IMPLEMENTED
-} DrvStatusTypeDef;
-
-/**
  * @brief  SSRELAY driver structure definition
  */
 typedef struct
@@ -120,6 +119,35 @@
 } DIGITALINPUTARRAY_DrvTypeDef;
     
 
+/* Functions -----------------------------------------------------------------*/
+
+/**
+ * @brief      Converts two uint8_t words into one of uint16_t
+ * @param[in]  ptr pointer to the buffer of data to be converted.
+ * @retval     16-bit data.
+ */
+inline uint16_t convertFrom8To16(uint8_t *ptr)
+{
+    uint16_t data16 = 0x0000;
+    
+    data16 = *ptr;
+    data16 |= *(++ptr) << 8;
+    
+    return data16;
+}
+
+/**
+ * @brief      Converts one uint16_t word into two uint8_t
+ * @param[in]  ptr pointer to the buffer of uint8_t words.
+ * @param[in]  16-bit data.
+ * @retval     none.
+ */
+inline void convertFrom16To8(uint16_t data16, uint8_t *ptr)
+{
+    *(ptr) = data16 & 0x00FF;
+    *(++ptr) = (data16 >> 8) & 0x00FF;
+}
+
 /**
  * @}
  */