Library to handle the X-NUCLEO-PLC01A1 Programmable Logic Controller Expansion Board based on the VNI8200XP (solid state relay) and CLT01-38SQ7 (octal digital termination array) components.

Dependents:   HelloWorld_PLC01A1

Programmable Logic Controller Library

Library to handle the X-NUCLEO-PLC01A1 Programmable Logic Controller Expansion Board based on the VNI8200XP (solid state relay) and CLT01-38SQ7 (octal digital termination array) components.

Information

For further details on VNI8200XP (Octal high side smart power solid state relay with serial/parallel selectable interface on chip) please refer to ST's web site.

For further details on CLT01-38SQ7 (High speed digital input current limiter) please refer to ST's web site.

SPI configuration

Pin D3 and D13 providing the SPI serial clock are short-circuited in the X-NUCLEO-PLC01A1 Expansion Board.

Please be aware that you may not drive the base board LED if it is connected to pin D13 (as it happens on STM32 Nucleo boards) or D3, otherwise you will get a conflict.

Platform compatibility

  • STM32 NUCLEO boards have been tested with the default configuration provided by the HelloWorld_PLC01A1 example.

return DSPI_HAL_ReadData(spi_address[obj->instance]);

X-NUCLEO-PLC01A1 board powering and startup

The following steps must be followed to run the X-NUCLEO-PLC01A1:

  1. Plug the X-NUCLEO-PLC01A1 onto a base board
  2. Connect the base board to a PC via a standard Type A / mini (or micro) B USB cable
  3. Download the firmware on the MCU hosted on the base board
  4. Supply 24 V to the X-NUCLEO-PLC01A1 board through the J8 connector
  5. The HelloWorld_PLC01A1 demonstration firmware is ready to run: connect any of the 8 inputs on the J8 connector to see the corresponding output on the J10 connector capable of driving a load (i.e. short-circuit input “x” with the 24 V and connect the corresponding output “x” to a load).
Committer:
Davidroid
Date:
Tue Feb 23 10:40:17 2016 +0000
Revision:
2:1ec0dea195f8
Parent:
0:b66a560b6618
Re-design to keep coherence with other expansion boards.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
apalmieri 0:b66a560b6618 1 /**
apalmieri 0:b66a560b6618 2 ******************************************************************************
apalmieri 0:b66a560b6618 3 * @file plc.h
apalmieri 0:b66a560b6618 4 * @author System Lab Noida
apalmieri 0:b66a560b6618 5 * @version V1.0.0
apalmieri 0:b66a560b6618 6 * @date 08-July-2015
apalmieri 0:b66a560b6618 7 * @brief This header file contains the functions prototypes for the
apalmieri 0:b66a560b6618 8 * plc driver.
apalmieri 0:b66a560b6618 9 ******************************************************************************
apalmieri 0:b66a560b6618 10 * @attention
apalmieri 0:b66a560b6618 11 *
apalmieri 0:b66a560b6618 12 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
apalmieri 0:b66a560b6618 13 *
apalmieri 0:b66a560b6618 14 * Redistribution and use in source and binary forms, with or without modification,
apalmieri 0:b66a560b6618 15 * are permitted provided that the following conditions are met:
apalmieri 0:b66a560b6618 16 * 1. Redistributions of source code must retain the above copyright notice,
apalmieri 0:b66a560b6618 17 * this list of conditions and the following disclaimer.
apalmieri 0:b66a560b6618 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
apalmieri 0:b66a560b6618 19 * this list of conditions and the following disclaimer in the documentation
apalmieri 0:b66a560b6618 20 * and/or other materials provided with the distribution.
apalmieri 0:b66a560b6618 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
apalmieri 0:b66a560b6618 22 * may be used to endorse or promote products derived from this software
apalmieri 0:b66a560b6618 23 * without specific prior written permission.
apalmieri 0:b66a560b6618 24 *
apalmieri 0:b66a560b6618 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
apalmieri 0:b66a560b6618 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
apalmieri 0:b66a560b6618 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
apalmieri 0:b66a560b6618 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
apalmieri 0:b66a560b6618 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
apalmieri 0:b66a560b6618 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
apalmieri 0:b66a560b6618 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
apalmieri 0:b66a560b6618 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
apalmieri 0:b66a560b6618 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
apalmieri 0:b66a560b6618 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
apalmieri 0:b66a560b6618 35 *
apalmieri 0:b66a560b6618 36 ******************************************************************************
apalmieri 0:b66a560b6618 37 */
apalmieri 0:b66a560b6618 38
apalmieri 0:b66a560b6618 39
apalmieri 0:b66a560b6618 40 /* Define to prevent recursive inclusion -------------------------------------*/
Davidroid 2:1ec0dea195f8 41
apalmieri 0:b66a560b6618 42 #ifndef __PLC_H
apalmieri 0:b66a560b6618 43 #define __PLC_H
apalmieri 0:b66a560b6618 44
apalmieri 0:b66a560b6618 45 #ifdef __cplusplus
apalmieri 0:b66a560b6618 46 extern "C" {
apalmieri 0:b66a560b6618 47 #endif
apalmieri 0:b66a560b6618 48
Davidroid 2:1ec0dea195f8 49
apalmieri 0:b66a560b6618 50 /* Includes ------------------------------------------------------------------*/
Davidroid 2:1ec0dea195f8 51
apalmieri 0:b66a560b6618 52 #include <stdint.h>
Davidroid 2:1ec0dea195f8 53 #include "component.h"
Davidroid 2:1ec0dea195f8 54
Davidroid 2:1ec0dea195f8 55
Davidroid 2:1ec0dea195f8 56 /* Definitions ---------------------------------------------------------------*/
apalmieri 0:b66a560b6618 57
apalmieri 0:b66a560b6618 58 /** @addtogroup BSP
apalmieri 0:b66a560b6618 59 * @{
apalmieri 0:b66a560b6618 60 */
apalmieri 0:b66a560b6618 61
apalmieri 0:b66a560b6618 62 /** @addtogroup Components
apalmieri 0:b66a560b6618 63 * @{
apalmieri 0:b66a560b6618 64 */
apalmieri 0:b66a560b6618 65
apalmieri 0:b66a560b6618 66 /** @addtogroup PLC
apalmieri 0:b66a560b6618 67 * @{
apalmieri 0:b66a560b6618 68 */
apalmieri 0:b66a560b6618 69
apalmieri 0:b66a560b6618 70 /** @defgroup PLC_Exported_Constants
apalmieri 0:b66a560b6618 71 * @{
apalmieri 0:b66a560b6618 72 */
apalmieri 0:b66a560b6618 73 #define MAX_NUMBER_OF_PLC_INPUT_COMPONENTS 1
apalmieri 0:b66a560b6618 74 #define MAX_NUMBER_OF_PLC_OUTPUT_COMPONENTS 1
apalmieri 0:b66a560b6618 75
apalmieri 0:b66a560b6618 76 #define NB_BYTES 2
apalmieri 0:b66a560b6618 77 #define BUFFERSIZE 1
apalmieri 0:b66a560b6618 78
Davidroid 2:1ec0dea195f8 79
Davidroid 2:1ec0dea195f8 80 /* Types ---------------------------------------------------------------------*/
Davidroid 2:1ec0dea195f8 81
apalmieri 0:b66a560b6618 82 /** @defgroup PLC_Exported_Types
apalmieri 0:b66a560b6618 83 * @{
apalmieri 0:b66a560b6618 84 */
apalmieri 0:b66a560b6618 85
apalmieri 0:b66a560b6618 86 /** @defgroup PLC_Exported_variables plc Exported variables
apalmieri 0:b66a560b6618 87 * @{
apalmieri 0:b66a560b6618 88 * @brief Exported variables
apalmieri 0:b66a560b6618 89 */
apalmieri 0:b66a560b6618 90
apalmieri 0:b66a560b6618 91 /**
apalmieri 0:b66a560b6618 92 * @brief SSRELAY driver structure definition
apalmieri 0:b66a560b6618 93 */
apalmieri 0:b66a560b6618 94 typedef struct
apalmieri 0:b66a560b6618 95 {
apalmieri 0:b66a560b6618 96 void (*SetChannels) (uint8_t Out_array);
apalmieri 0:b66a560b6618 97 uint8_t (*ManageFault)(void);
apalmieri 0:b66a560b6618 98 uint8_t (*CheckDCDCStatus)(void);
apalmieri 0:b66a560b6618 99 uint8_t (*TemperatureWarning)(void);
apalmieri 0:b66a560b6618 100 uint8_t (*CheckParity)(void);
apalmieri 0:b66a560b6618 101 uint8_t (*CheckPowerGood)(void);
apalmieri 0:b66a560b6618 102 uint8_t (*CheckCommError)(void);
apalmieri 0:b66a560b6618 103 void (*Ssrelay_SetOutput)(uint8_t *TxBuff, uint8_t *RxBuff);
apalmieri 0:b66a560b6618 104 } SSRELAY_DrvTypeDef;
apalmieri 0:b66a560b6618 105
apalmieri 0:b66a560b6618 106
apalmieri 0:b66a560b6618 107 /**
apalmieri 0:b66a560b6618 108 * @brief DIGITALINPUTARRAY driver structure definition
apalmieri 0:b66a560b6618 109 */
apalmieri 0:b66a560b6618 110 typedef struct
apalmieri 0:b66a560b6618 111 {
apalmieri 0:b66a560b6618 112 uint8_t (*GetReadStatus)(void);
apalmieri 0:b66a560b6618 113 void (*SetReadStatus)(uint8_t status);
apalmieri 0:b66a560b6618 114 uint8_t (*GetInputData)(void);
apalmieri 0:b66a560b6618 115 uint8_t (*OverTempAlarm)(void);
apalmieri 0:b66a560b6618 116 uint8_t (*CheckParity)(void);
apalmieri 0:b66a560b6618 117 uint8_t (*UnderVoltAlarm)(void);
apalmieri 0:b66a560b6618 118 void (*DigInpArray_GetInput)(uint8_t *TxBuff, uint8_t *RxBuff);
apalmieri 0:b66a560b6618 119 } DIGITALINPUTARRAY_DrvTypeDef;
apalmieri 0:b66a560b6618 120
apalmieri 0:b66a560b6618 121
Davidroid 2:1ec0dea195f8 122 /* Functions -----------------------------------------------------------------*/
Davidroid 2:1ec0dea195f8 123
Davidroid 2:1ec0dea195f8 124 /**
Davidroid 2:1ec0dea195f8 125 * @brief Converts two uint8_t words into one of uint16_t
Davidroid 2:1ec0dea195f8 126 * @param[in] ptr pointer to the buffer of data to be converted.
Davidroid 2:1ec0dea195f8 127 * @retval 16-bit data.
Davidroid 2:1ec0dea195f8 128 */
Davidroid 2:1ec0dea195f8 129 inline uint16_t convertFrom8To16(uint8_t *ptr)
Davidroid 2:1ec0dea195f8 130 {
Davidroid 2:1ec0dea195f8 131 uint16_t data16 = 0x0000;
Davidroid 2:1ec0dea195f8 132
Davidroid 2:1ec0dea195f8 133 data16 = *ptr;
Davidroid 2:1ec0dea195f8 134 data16 |= *(++ptr) << 8;
Davidroid 2:1ec0dea195f8 135
Davidroid 2:1ec0dea195f8 136 return data16;
Davidroid 2:1ec0dea195f8 137 }
Davidroid 2:1ec0dea195f8 138
Davidroid 2:1ec0dea195f8 139 /**
Davidroid 2:1ec0dea195f8 140 * @brief Converts one uint16_t word into two uint8_t
Davidroid 2:1ec0dea195f8 141 * @param[in] ptr pointer to the buffer of uint8_t words.
Davidroid 2:1ec0dea195f8 142 * @param[in] 16-bit data.
Davidroid 2:1ec0dea195f8 143 * @retval none.
Davidroid 2:1ec0dea195f8 144 */
Davidroid 2:1ec0dea195f8 145 inline void convertFrom16To8(uint16_t data16, uint8_t *ptr)
Davidroid 2:1ec0dea195f8 146 {
Davidroid 2:1ec0dea195f8 147 *(ptr) = data16 & 0x00FF;
Davidroid 2:1ec0dea195f8 148 *(++ptr) = (data16 >> 8) & 0x00FF;
Davidroid 2:1ec0dea195f8 149 }
Davidroid 2:1ec0dea195f8 150
apalmieri 0:b66a560b6618 151 /**
apalmieri 0:b66a560b6618 152 * @}
apalmieri 0:b66a560b6618 153 */
apalmieri 0:b66a560b6618 154
apalmieri 0:b66a560b6618 155 /**
apalmieri 0:b66a560b6618 156 * @}
apalmieri 0:b66a560b6618 157 */
apalmieri 0:b66a560b6618 158
apalmieri 0:b66a560b6618 159 /**
apalmieri 0:b66a560b6618 160 * @}
apalmieri 0:b66a560b6618 161 */
apalmieri 0:b66a560b6618 162
apalmieri 0:b66a560b6618 163 /**
apalmieri 0:b66a560b6618 164 * @}
apalmieri 0:b66a560b6618 165 */
apalmieri 0:b66a560b6618 166
apalmieri 0:b66a560b6618 167 #ifdef __cplusplus
apalmieri 0:b66a560b6618 168 }
apalmieri 0:b66a560b6618 169 #endif
apalmieri 0:b66a560b6618 170
apalmieri 0:b66a560b6618 171 #endif /* __PLC_H */
apalmieri 0:b66a560b6618 172 /**
apalmieri 0:b66a560b6618 173 * @} // end plc Exported Function
apalmieri 0:b66a560b6618 174 */
apalmieri 0:b66a560b6618 175 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/