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).

Components/Common/plc.h

Committer:
apalmieri
Date:
2021-07-12
Revision:
7:5d4336d0e372
Parent:
6:de3fc5f5f065

File content as of revision 7:5d4336d0e372:

/**
 ******************************************************************************
 * @file    plc.h
 * @author  System Lab Noida
 * @version V1.0.0
 * @date    08-July-2015
 * @brief   This header file contains the functions prototypes for the
 *          plc driver.
 ******************************************************************************
 * @attention
 *
 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *   1. Redistributions of source code must retain the above copyright notice,
 *      this list of conditions and the following disclaimer.
 *   2. Redistributions in binary form must reproduce the above copyright notice,
 *      this list of conditions and the following disclaimer in the documentation
 *      and/or other materials provided with the distribution.
 *   3. Neither the name of STMicroelectronics nor the names of its contributors
 *      may be used to endorse or promote products derived from this software
 *      without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 ******************************************************************************
 */


/* Define to prevent recursive inclusion -------------------------------------*/

#ifndef __PLC_H
#define __PLC_H

#ifdef __cplusplus
extern "C" {
#endif


/* Includes ------------------------------------------------------------------*/

#include <stdint.h>
#include "component_def.h"


/* Definitions ---------------------------------------------------------------*/

/** @addtogroup BSP
  * @{
  */

/** @addtogroup Components
  * @{
  */

/** @addtogroup PLC
  * @{
  */

/** @defgroup PLC_Exported_Constants
  * @{
  */
#define MAX_NUMBER_OF_PLC_INPUT_COMPONENTS 1
#define MAX_NUMBER_OF_PLC_OUTPUT_COMPONENTS 1

#define NB_BYTES 2
#define BUFFERSIZE 1


/* Types ---------------------------------------------------------------------*/

/** @defgroup PLC_Exported_Types
  * @{
  */

/** @defgroup PLC_Exported_variables     plc Exported variables
  * @{
  * @brief Exported variables 
  */

/**
 * @brief  SSRELAY driver structure definition
 */
typedef struct
{
  void (*SetChannels) (uint8_t Out_array);
  uint8_t (*ManageFault)(void);
  uint8_t (*CheckDCDCStatus)(void);
  uint8_t (*TemperatureWarning)(void);
  uint8_t (*CheckParity)(void);
  uint8_t (*CheckPowerGood)(void);
  uint8_t (*CheckCommError)(void);
  void (*Ssrelay_SetOutput)(uint8_t *TxBuff, uint8_t *RxBuff);
} SSRELAY_DrvTypeDef;


/**
 * @brief  DIGITALINPUTARRAY driver structure definition
 */
typedef struct
{
  uint8_t (*GetReadStatus)(void);
  void (*SetReadStatus)(uint8_t status);
  uint8_t (*GetInputData)(void);
  uint8_t (*OverTempAlarm)(void);
  uint8_t (*CheckParity)(void);
  uint8_t (*UnderVoltAlarm)(void);
  void (*DigInpArray_GetInput)(uint8_t *TxBuff, uint8_t *RxBuff);       
} 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;
}

/**
 * @}
 */

/**
 * @}
 */

/**
 * @}
 */

/**
 * @}
 */

#ifdef   __cplusplus
}
#endif

#endif /* __PLC_H */
/**
  * @} // end   plc Exported Function
  */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/