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