/Unicens Schema for the description of a UNICENS configuration /Unicens/Node Node is a connection point that can receive, create, store or send data along distributed network routes. /Unicens/Node/USBPort Configuration Structure of a USB Port /Unicens/Node/USBPort/@PhysicalLayer Interface of the USB Ports Physical Layer This attribute corresponds with the parameter PhysicalLayer of the INIC function INIC.USBPortCreate. /Unicens/Node/USBPort/@DeviceInterfaces USB Devices interfaces mask. This attribute corresponds with the parameter DeviceInterfaces of the INIC function INIC.USBPortCreate. /Unicens/Node/USBPort/@StreamingIfEpInCount IN Endpoints inside the streaming interfaces. This attribute corresponds with the parameter StreamingIfEpInCount of the INIC function INIC.USBPortCreate. /Unicens/Node/USBPort/@StreamingIfEpOutCount OUT Endpoints inside the streaming interfaces. This attribute corresponds with the parameter StreamingIfEpInCount of the INIC function INIC.USBPortCreate. /Unicens/Node/MediaLBPort Configuration Structure of a MediaLB Port The MediaLB Port is the interface to the Media Local Bus. It supports the handling of all MOST network data types and is available in two pin-out options: MediaLB 3-Pin (single-ended) and MediaLB 6-Pin (differential). /Unicens/Node/MediaLBPort/@ClockConfig Clock speed configuration. This attribute corresponds with the parameter ClockConfig of the INIC function INIC.MediaLBPortCreate. /Unicens/Node/StreamPort Configuration Structure of a Stream Port /Unicens/Node/StreamPort/@ClockConfig Clock speed configuration. This attribute corresponds with the parameter ClockConfig of the INIC function INIC.StreamPortCreate. /Unicens/Node/StreamPort/@DataAlignment Alignment of the data bytes . This attribute corresponds with the parameter DataAlignment of the INIC function INIC.StreamPortCreate /Unicens/Node/SyncConnection Configuration Structure of a SyncConnection It sets the connection in Sync mode. /Unicens/Node/SyncConnection/@MuteMode Mode of operation of mute. This attribute corresponds with the parameter MuteMode of the INIC function INIC.SyncCreate /Unicens/Node/AVPConnection Configuration Structure of an AVP Connection. It sets the connection in AVP mode. /Unicens/Node/AVPConnection/@IsocPacketSize Size of data packets. This attribute corresponds with the parameter IsocPacketSize of the INIC function INIC.AVPacketizedCreate /Unicens/Node/@Address Address of the Unicens node /Unicens/Node/@Script Script to which the node is linked. /Unicens/Script A script is a structure data composed of : The command based on INIC FBlock-Syntax to be transmitted The expected result also based on INIC FBlock-Syntax. The amount time [in milliseconds] to pause before sending the Tx command. /Unicens/Script/GPIOPortCreate Creates the GPIO port with its associated port instance identifier. /Unicens/Script/GPIOPortCreate/@DebounceTime The timeout for the GPIO debounce timer (in ms). /Unicens/Script/GPIOPortPinMode This function is used for GPIO pin configuration. To change a pin into a GPIO pin, it has to be configured via GPIOPortPinMode /Unicens/Script/GPIOPortPinMode/@PinConfiguration Defines the GPIO pin configuration and clears the trigger conditions on level-sensitive inputs and sticky inputs thereby allowing reporting of further trigger events. Note that trigger conditions are automatically cleared for all edge-sensitive input/output GPIO classes when the INIC.GPIOPortTriggerEvent.Status message is sent. /Unicens/Script/GPIOPinStateTO DO - [State of GPIO Pin : High/Low] /Unicens/Script/GPIOPinState/@Mask TO DO - [Changing certain data elements within a data store so that the structure remains similar while the information itself is changed to protect sensitive information] /Unicens/Script/GPIOPinState/@Data TO DO - [Data to be given to GPIO Pin State] /Unicens/Script/I2CPortCreate This function is used to define the I2C Port working as I2C-bus master. The function creates the I2C Port with its associated port instance identifier. /Unicens/Script/I2CPortCreate/@Speed The speed grade of I2C port. /Unicens/Script/I2CPortWrite This function writes a block of bytes to an I2C device at a specified I2C address. The function supports also a burst write mechanism for optimized transactions. /Unicens/Script/I2CPortWrite/@Mode The write transfer mode. /Unicens/Script/I2CPortWrite/@BlockCount The number of blocks to be written to the I2C address. If parameter mode is not set to Burst Mode, the value of block_count has to be set to 0. Otherwise the valid range of this parameter goes from 1 to 30. /Unicens/Script/I2CPortWrite/@Address Address of the target device. Use the UCS_ADDR_LOCAL_DEV macro to target the local device. The following address ranges are supported: •[0x10 ... 0x2FF] •[0x500 ... 0xFEF] •UCS_ADDR_LOCAL_DEV /Unicens/Script/I2CPortWrite/@Length The total number of bytes to be written to the addressed I2C peripheral. Even if parameter mode is set to Burst Mode, the data_len shall correspond to the whole size of the burst transfer. That is, the data_len shall equal the size of a block times the block_count value. /Unicens/Script/I2CPortWrite/@PayLoad Payload bytes to be written on I2C /Unicens/Script/I2CPortWrite/@Timeout The timeout for the I2C Port write. /Unicens/Script/I2CPortRead This function reads a block of bytes from an I2C device at a specified I2C address. The function can only be used, if the I2C Port has been configured as Master. If the I2C Port was configured as I2C-bus slave via the configuration string, an error message will be returned. /Unicens/Script/I2CPortRead/@Address Address of the target device. Use the UCS_ADDR_LOCAL_DEV macro to target the local device. The following address ranges are supported: •[0x10 ... 0x2FF] •[0x500 ... 0xFEF] •UCS_ADDR_LOCAL_DEV /Unicens/Script/I2CPortRead/@Length Number of bytes to be read from the address. /Unicens/Script/I2CPortRead/@Timeout The timeout for the I2C Port read. /Unicens/Script/MsgSend TO DO /Unicens/Script/MsgSend/@FBlockId FBlockId of the config msg. /Unicens/Script/MsgSend/@FunctionId TO DO /Unicens/Script/MsgSend/@OpTypeRequest TO DO /Unicens/Script/MsgSend/@OpTypeResponse TO DO /Unicens/Script/MsgSend/@PayloadRequest TO DO /Unicens/Script/MsgSend/@PayloadResponse TO DO /Unicens/Script/Pause Specifies the pause which shall be set before sending the configuration message. /Unicens/Script/Pause/@Wait
/*------------------------------------------------------------------------------------------------*/
/* UNICENS V2.1.0-3491                                                                            */
/* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG.                              */
/*                                                                                                */
/* This program is free software: you can redistribute it and/or modify                           */
/* it under the terms of the GNU General Public License as published by                           */
/* the Free Software Foundation, either version 2 of the License, or                              */
/* (at your option) any later version.                                                            */
/*                                                                                                */
/* This program is distributed in the hope that it will be useful,                                */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of                                 */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                  */
/* GNU General Public License for more details.                                                   */
/*                                                                                                */
/* You should have received a copy of the GNU General Public License                              */
/* along with this program.  If not, see <http://www.gnu.org/licenses/>.                          */
/*                                                                                                */
/* You may also obtain this software under a propriety license from Microchip.                    */
/* Please contact Microchip for further information.                                              */
/*------------------------------------------------------------------------------------------------*/

/*!
 * \file
 * \brief Implementation of class CPmFifos
 *
 * \cond UCS_INTERNAL_DOC
 * \addtogroup  G_PMFIFOS
 * @{
 */

/*------------------------------------------------------------------------------------------------*/
/* Includes                                                                                       */
/*------------------------------------------------------------------------------------------------*/
#include "ucs_pmfifos.h"
#include "ucs_misc.h"
#include "ucs_trace.h"

/*------------------------------------------------------------------------------------------------*/
/* Internal Constants                                                                             */
/*------------------------------------------------------------------------------------------------*/
/*! \brief The initialization value of sync_count. It is incremented for each sync or un-sync attempt. */
static const uint8_t     FIFOS_SYNC_CNT_INITIAL = 0xFFU;

/*------------------------------------------------------------------------------------------------*/
/* Internal typedefs                                                                              */
/*------------------------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------------------------------*/
/* Internal prototypes                                                                            */
/*---------------------------------------------------------------------------