ST / X_NUCLEO_PLC01A1

Dependents:   HelloWorld_PLC01A1

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers plc.h Source File

plc.h

Go to the documentation of this file.
00001 /**
00002  ******************************************************************************
00003  * @file    plc.h
00004  * @author  System Lab Noida
00005  * @version V1.0.0
00006  * @date    08-July-2015
00007  * @brief   This header file contains the functions prototypes for the
00008  *          plc driver.
00009  ******************************************************************************
00010  * @attention
00011  *
00012  * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
00013  *
00014  * Redistribution and use in source and binary forms, with or without modification,
00015  * are permitted provided that the following conditions are met:
00016  *   1. Redistributions of source code must retain the above copyright notice,
00017  *      this list of conditions and the following disclaimer.
00018  *   2. Redistributions in binary form must reproduce the above copyright notice,
00019  *      this list of conditions and the following disclaimer in the documentation
00020  *      and/or other materials provided with the distribution.
00021  *   3. Neither the name of STMicroelectronics nor the names of its contributors
00022  *      may be used to endorse or promote products derived from this software
00023  *      without specific prior written permission.
00024  *
00025  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00026  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00028  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00029  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00030  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00031  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00032  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00033  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00034  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00035  *
00036  ******************************************************************************
00037  */
00038 
00039 
00040 /* Define to prevent recursive inclusion -------------------------------------*/
00041 
00042 #ifndef __PLC_H
00043 #define __PLC_H
00044 
00045 #ifdef __cplusplus
00046 extern "C" {
00047 #endif
00048 
00049 
00050 /* Includes ------------------------------------------------------------------*/
00051 
00052 #include <stdint.h>
00053 #include "component_def.h"
00054 
00055 
00056 /* Definitions ---------------------------------------------------------------*/
00057 
00058 /** @addtogroup BSP
00059   * @{
00060   */
00061 
00062 /** @addtogroup Components
00063   * @{
00064   */
00065 
00066 /** @addtogroup PLC
00067   * @{
00068   */
00069 
00070 /** @defgroup PLC_Exported_Constants
00071   * @{
00072   */
00073 #define MAX_NUMBER_OF_PLC_INPUT_COMPONENTS 1
00074 #define MAX_NUMBER_OF_PLC_OUTPUT_COMPONENTS 1
00075 
00076 #define NB_BYTES 2
00077 #define BUFFERSIZE 1
00078 
00079 
00080 /* Types ---------------------------------------------------------------------*/
00081 
00082 /** @defgroup PLC_Exported_Types
00083   * @{
00084   */
00085 
00086 /** @defgroup PLC_Exported_variables     plc Exported variables
00087   * @{
00088   * @brief Exported variables 
00089   */
00090 
00091 /**
00092  * @brief  SSRELAY driver structure definition
00093  */
00094 typedef struct
00095 {
00096   void (*SetChannels) (uint8_t Out_array);
00097   uint8_t (*ManageFault)(void);
00098   uint8_t (*CheckDCDCStatus)(void);
00099   uint8_t (*TemperatureWarning)(void);
00100   uint8_t (*CheckParity)(void);
00101   uint8_t (*CheckPowerGood)(void);
00102   uint8_t (*CheckCommError)(void);
00103   void (*Ssrelay_SetOutput)(uint8_t *TxBuff, uint8_t *RxBuff);
00104 } SSRELAY_DrvTypeDef;
00105 
00106 
00107 /**
00108  * @brief  DIGITALINPUTARRAY driver structure definition
00109  */
00110 typedef struct
00111 {
00112   uint8_t (*GetReadStatus)(void);
00113   void (*SetReadStatus)(uint8_t status);
00114   uint8_t (*GetInputData)(void);
00115   uint8_t (*OverTempAlarm)(void);
00116   uint8_t (*CheckParity)(void);
00117   uint8_t (*UnderVoltAlarm)(void);
00118   void (*DigInpArray_GetInput)(uint8_t *TxBuff, uint8_t *RxBuff);       
00119 } DIGITALINPUTARRAY_DrvTypeDef;
00120     
00121 
00122 /* Functions -----------------------------------------------------------------*/
00123 
00124 /**
00125  * @brief      Converts two uint8_t words into one of uint16_t
00126  * @param[in]  ptr pointer to the buffer of data to be converted.
00127  * @retval     16-bit data.
00128  */
00129 inline uint16_t convertFrom8To16(uint8_t *ptr)
00130 {
00131     uint16_t data16 = 0x0000;
00132     
00133     data16 = *ptr;
00134     data16 |= *(++ptr) << 8;
00135     
00136     return data16;
00137 }
00138 
00139 /**
00140  * @brief      Converts one uint16_t word into two uint8_t
00141  * @param[in]  ptr pointer to the buffer of uint8_t words.
00142  * @param[in]  16-bit data.
00143  * @retval     none.
00144  */
00145 inline void convertFrom16To8(uint16_t data16, uint8_t *ptr)
00146 {
00147     *(ptr) = data16 & 0x00FF;
00148     *(++ptr) = (data16 >> 8) & 0x00FF;
00149 }
00150 
00151 /**
00152  * @}
00153  */
00154 
00155 /**
00156  * @}
00157  */
00158 
00159 /**
00160  * @}
00161  */
00162 
00163 /**
00164  * @}
00165  */
00166 
00167 #ifdef   __cplusplus
00168 }
00169 #endif
00170 
00171 #endif /* __PLC_H */
00172 /**
00173   * @} // end   plc Exported Function
00174   */
00175 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/