]> rtime.felk.cvut.cz Git - arc.git/blobdiff - include/Com_Types.h
Added an example of CAN communication for the TMS570LS31x HDK
[arc.git] / include / Com_Types.h
index dfec87413d8d1a77329bbc150a388dfa21ebf972..f606032db3d8a7c1949355dd96e3834fac0cc034 100644 (file)
@@ -1,31 +1,31 @@
-/* -------------------------------- Arctic Core ------------------------------
- * Arctic Core - the open source AUTOSAR platform http://arccore.com
- *
- * Copyright (C) 2009  ArcCore AB <contact@arccore.com>
- *
- * This source code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by the
- * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
- *
- * 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.
- * -------------------------------- Arctic Core ------------------------------*/
-
-
-
-/** @addtogroup Com COM module
- *  @{ */
-
-/** @file Com_Types.h
- * Definitions of configuration types and parameters for the COM module.
- */
-
-
-
+/* -------------------------------- Arctic Core ------------------------------\r
+ * Arctic Core - the open source AUTOSAR platform http://arccore.com\r
+ *\r
+ * Copyright (C) 2009  ArcCore AB <contact@arccore.com>\r
+ *\r
+ * This source code is free software; you can redistribute it and/or modify it\r
+ * under the terms of the GNU General Public License version 2 as published by the\r
+ * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.\r
+ *\r
+ * This program is distributed in the hope that it will be useful, but\r
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\r
+ * for more details.\r
+ * -------------------------------- Arctic Core ------------------------------*/\r
+\r
+\r
+\r
+/** @addtogroup Com COM module\r
+ *  @{ */\r
+\r
+/** @file Com_Types.h\r
+ * Definitions of configuration types and parameters for the COM module.\r
+ */\r
+\r
+\r
+\r
 #ifndef COM_TYPES_H_\r
-#define COM_TYPES_H_
+#define COM_TYPES_H_\r
 \r
 \r
 #include "ComStack_Types.h"\r
 typedef uint8 Com_PduGroupIdType;\r
 typedef uint16 Com_SignalIdType;\r
 typedef uint8 Com_SignalGroupIdType;\r
-\r
+typedef uint16 Com_BitPositionType;\r
 typedef enum {\r
        IMMEDIATE,\r
-       DEFERRED,\r
+       DEFERRED\r
 } Com_IPduSignalProcessingMode;\r
 \r
 typedef enum {\r
@@ -50,24 +50,25 @@ typedef enum {
        UINT16,\r
        UINT32,\r
        UINT8_N,\r
+       UINT8_DYN,\r
        SINT8,\r
        SINT16,\r
        SINT32\r
-} Com_SignalType;
-
-#define COM_SIGNALTYPE_UNSIGNED  FALSE
+} Com_SignalType;\r
+\r
+#define COM_SIGNALTYPE_UNSIGNED  FALSE\r
 #define COM_SIGNALTYPE_SIGNED    TRUE\r
 \r
 typedef enum {\r
        PENDING,\r
-       TRIGGERED,\r
+       TRIGGERED\r
 } ComTransferProperty_type;\r
 \r
 typedef enum {\r
        DIRECT,\r
        MIXED,\r
        NONE,\r
-       PERIODIC,\r
+       PERIODIC\r
 } ComTxModeMode_type;\r
 \r
 \r
@@ -79,13 +80,13 @@ typedef enum {
        NEVER,\r
        NEW_IS_OUTSIDE,\r
        NEW_IS_WITHIN,\r
-       ONE_EVERY_N,\r
+       ONE_EVERY_N\r
 } ComFilterAlgorithm_type;\r
 \r
 typedef enum {\r
-       BIG_ENDIAN,\r
-       LITTLE_ENDIAN,\r
-       OPAQUE,\r
+       COM_BIG_ENDIAN,\r
+       COM_LITTLE_ENDIAN,\r
+       COM_OPAQUE\r
 } ComSignalEndianess_type;\r
 \r
 typedef enum {\r
@@ -117,24 +118,24 @@ typedef enum {
        type == SINT8   ? sizeof(sint8) : \\r
        type == SINT16  ? sizeof(sint16) : \\r
        type == SINT32  ? sizeof(sint32) : sizeof(boolean)) \\r
-
-#define SignalTypeSignedness(type) \
-               ((type == SINT8 || type == SINT16 || type == SINT32) ? \
-                               COM_SIGNALTYPE_SIGNED : COM_SIGNALTYPE_UNSIGNED)
-\r
-/** Filter configuration type.
- * NOT SUPPORTED
- */
-typedef struct {
-       /** The algorithm that this filter uses. */
-       ComFilterAlgorithm_type ComFilterAlgorithm;
-       /** Filter mask. */
-       uint32 ComFilterMask;
-       /** Max value for filter. */
-       uint32 ComFilterMax;
-       /** Min value for filter. */
-       uint32 ComFilterMin;
-       /** Offset for filter. */
+\r
+#define SignalTypeSignedness(type) \\r
+               (( (type == SINT8) || (type == SINT16) || (type == SINT32) ) ? \\r
+                               COM_SIGNALTYPE_SIGNED : COM_SIGNALTYPE_UNSIGNED)\r
+\r
+/** Filter configuration type.\r
+ * NOT SUPPORTED\r
+ */\r
+typedef struct {\r
+       /** The algorithm that this filter uses. */\r
+       ComFilterAlgorithm_type ComFilterAlgorithm;\r
+       /** Filter mask. */\r
+       uint32 ComFilterMask;\r
+       /** Max value for filter. */\r
+       uint32 ComFilterMax;\r
+       /** Min value for filter. */\r
+       uint32 ComFilterMin;\r
+       /** Offset for filter. */\r
        uint32 ComFilterOffset;\r
        uint32 ComFilterPeriodFactor;\r
        uint32 ComFilterX;\r
@@ -144,230 +145,234 @@ typedef struct {
 \r
 } ComFilter_type;\r
 \r
-/** Configuration structure for group signals */
+/** Configuration structure for group signals */\r
 typedef struct {\r
-       /** Starting position (bit) of the signal within the IPDU.
-        * Range 0 to 63.
+       /** Starting position (bit) of the signal within the IPDU.\r
+        * Range 0 to 63.\r
         */\r
-       const uint8 ComBitPosition;\r
+       const Com_BitPositionType ComBitPosition;\r
 \r
-       /** The size of the signal in bits.
-        * Range 0 to 64.
+       /** The size of the signal in bits.\r
+        * Range 0 to 64.\r
         */\r
        const uint8 ComBitSize;\r
 \r
-       /** Identifier for the signal.
-        * Should be the same value as the index in the COM signal array.
+       /** Identifier for the signal.\r
+        * Should be the same value as the index in the COM signal array.\r
         */\r
        const uint8 ComHandleId;\r
 \r
-       /** Defines the endianess of the signal's network representation. */
+       /** Defines the endianess of the signal's network representation. */\r
        const ComSignalEndianess_type ComSignalEndianess;\r
 \r
-       /** Value used to initialize this signal. */
+       /** Value used to initialize this signal. */\r
        const void *ComSignalInitValue;\r
 \r
-       /** Defines the type of the signal. */
+       /** Defines the type of the signal. */\r
        const Com_SignalType ComSignalType;\r
 \r
 \r
-       /** Filter for this signal.
-        * NOT SUPPORTED
+       /** Filter for this signal.\r
+        * NOT SUPPORTED\r
         */\r
-       const ComFilter_type ComFilter;\r
+       //const ComFilter_type ComFilter;\r
 \r
        /* Pointer to the shadow buffer of the signal group that this group signal is contained in.\r
         *\r
-        * This is initialized by Com_Init() and should not be configured.
+        * This is initialized by Com_Init() and should not be configured.\r
         */\r
        //void *Com_Arc_ShadowBuffer;\r
-
-       /* Callback function used when an invalid signal is received. */
-       // ComInvalidNotification;
-       //uint8 ComSignalDataInvalidValue;
+\r
+       /* Callback function used when an invalid signal is received. */\r
+       // ComInvalidNotification;\r
+       //uint8 ComSignalDataInvalidValue;\r
 \r
        /* IPDU id of the IPDU that this signal belongs to.\r
         *\r
-        * This is initialized by Com_Init() and should not be configured.
+        * This is initialized by Com_Init() and should not be configured.\r
         */\r
 \r
        //const uint8 ComIPduHandleId;\r
        //const uint8 ComSignalUpdated;\r
-
-       /** Marks the end of list for the configuration array. */
+\r
+       /** Marks the end of list for the configuration array. */\r
        const uint8 Com_Arc_EOL;\r
 } ComGroupSignal_type;\r
-
-
-/** Configuration structure for signals and signal groups. */
+\r
+\r
+/** Configuration structure for signals and signal groups. */\r
 typedef struct {\r
 \r
-       /** Starting position (bit) of the signal within the IPDU.
-        * Range 0 to 63.
+       /** Starting position (bit) of the signal within the IPDU.\r
+        * Range 0 to 2031.\r
         */\r
-       const uint8 ComBitPosition;\r
+       const Com_BitPositionType ComBitPosition;\r
 \r
-       /** The size of the signal in bits.
-        * Range 0 to 63.
+       /** The size of the signal in bits.\r
+        * Range 0 to 63.\r
         */\r
        const uint8 ComBitSize;\r
 \r
-       /** Notification function for error notification. */
+       /** Notification function for error notification. */\r
        void (*ComErrorNotification) (void);\r
 \r
-       /** First timeout period for deadline monitoring. */
+       /** First timeout period for deadline monitoring. */\r
        const uint32 ComFirstTimeoutFactor;\r
 \r
-       /** Identifier for the signal.
-        * Should be the same value as the index in the COM signal array.
+       /** Identifier for the signal.\r
+        * Should be the same value as the index in the COM signal array.\r
         */\r
        const uint16 ComHandleId;\r
 \r
-       /** Tx and Rx notification function. */
+       /** Tx and Rx notification function. */\r
        void (*ComNotification) (void);\r
 \r
-       /** Action to be performed when a reception timeout occurs. */
+       /** Action to be performed when a reception timeout occurs. */\r
        const ComRxDataTimeoutAction_type ComRxDataTimeoutAction;\r
 \r
-       /** Defines the endianess of the signal's network representation. */
+       /** Defines the endianess of the signal's network representation. */\r
        const ComSignalEndianess_type ComSignalEndianess;\r
 \r
-       /** Value used to initialized this signal. */
+       /** Value used to initialized this signal. */\r
        const void *ComSignalInitValue;\r
 \r
-       /** The number of bytes if the signal has type UINT8_N;
-        * Range 1 to 8.
+       /** The number of bytes if the signal has type UINT8_N;\r
+        * Range 1 to 8.\r
         */\r
-       const uint8 ComSignalLength;\r
+       //const uint8 ComSignalLength;\r
 \r
-       /** Defines the type of the signal. */
+       /** Defines the type of the signal. */\r
        const Com_SignalType ComSignalType;\r
 \r
-       /** Timeout period for deadline monitoring. */
+       /** Timeout period for deadline monitoring. */\r
        const uint32 ComTimeoutFactor;\r
 \r
-       /** Timeout notification function. */
+       /** Timeout notification function. */\r
        void (*ComTimeoutNotification) (void);\r
 \r
+       /** Defines if a write access to this signal can trigger the transmission of the corresponding I-PDU. */\r
        const ComTransferProperty_type ComTransferProperty;\r
 \r
-       /** The bit position in the PDU for this signal's update bit.
-        * Range 0 to 63.
-        * Only applicable if an update bit is used. NULL otherwise.
+       /** The bit position in the PDU for this signal's update bit.\r
+        * Range 0 to 2031.\r
+        * Only applicable if an update bit is used. NULL otherwise.\r
+        */\r
+       const Com_BitPositionType ComUpdateBitPosition;\r
+\r
+       /** Marks if this signal uses an update bit.\r
+        * Should be set to one if an update bit is used.\r
         */\r
-       const uint8 ComUpdateBitPosition;
-
-       /** Marks if this signal uses an update bit.
-        * Should be set to one if an update bit is used.
-        */
        const uint8 ComSignalArcUseUpdateBit;\r
 \r
-       /** Filter for this signal.
-        * NOT SUPPORTED.
+       /** Filter for this signal.\r
+        * NOT SUPPORTED.\r
         */\r
-       const ComFilter_type ComFilter;\r
-\r
-       /** Marks if this signal is a signal group.
-        * Should be set to 1 if the signal is a signal group.
-        */
-       const uint8 Com_Arc_IsSignalGroup;
-
-       /** Array of group signals.
-        * Only applicable if this signal is a signal group.
-        */
-       const ComGroupSignal_type **ComGroupSignal;\r
-
-
-       //void *Com_Arc_ShadowBuffer;\r
+       //const ComFilter_type ComFilter;\r
+\r
+       /** Marks if this signal is a signal group.\r
+        * Should be set to 1 if the signal is a signal group.\r
+        */\r
+       const uint8 Com_Arc_IsSignalGroup;\r
+\r
+       /** Array of group signals.\r
+        * Only applicable if this signal is a signal group.\r
+        */\r
+       const ComGroupSignal_type * const *ComGroupSignal;\r
+\r
+\r
+       const void *Com_Arc_ShadowBuffer;\r
        //void *Com_Arc_IPduDataPtr;\r
 \r
        /* Pointer to the data storage of this signals IPDU.\r
-        * This is initialized by Com_Init() and should not be configured.
+        * This is initialized by Com_Init() and should not be configured.\r
         */\r
        //const void *ComIPduDataPtr;\r
 \r
        /* IPDU id of the IPDU that this signal belongs to.\r
-        * This is initialized by Com_Init() and should not be configured.
+        * This is initialized by Com_Init() and should not be configured.\r
         */\r
-\r
-       //const uint8 ComIPduHandleId;\r
+       /** The numerical value used as the ID of this I-PDU.\r
+        * TheComIPduHandleId is required by the API calls to receive I-PDUs from the PduR (ComIP-duDirection: Receive).\r
+        * For Tx-I-PDUs (ComIPduDirection: Send) this handle Id is used by the PduR to confirm the transmission of the ComIPdu\r
+        */\r
+       const uint16 ComIPduHandleId;\r
        //const uint8 ComSignalUpdated;\r
-
-       /* Callback function used when an invalid signal is received.
-        */
-       // ComInvalidNotification;
-
-       //uint8 ComSignalDataInvalidValue;
-
-       /* Action to be taken if an invalid signal is received.
-        */
-       // ComDataInvalidAction;
-
-       /** Marks the end of list for the signal configuration array. */
+\r
+       /* Callback function used when an invalid signal is received.\r
+        */\r
+       // ComInvalidNotification;\r
+\r
+       //uint8 ComSignalDataInvalidValue;\r
+\r
+       /* Action to be taken if an invalid signal is received.\r
+        */\r
+       // ComDataInvalidAction;\r
+\r
+       /** Marks the end of list for the signal configuration array. */\r
        const uint8 Com_Arc_EOL;\r
 } ComSignal_type;\r
-
-
 \r
-/** Configuration structure for Tx-mode for I-PDUs. */
-typedef struct {
 \r
-       /** Transmission mode for this IPdu. */
+\r
+/** Configuration structure for Tx-mode for I-PDUs. */\r
+typedef struct {\r
+\r
+       /** Transmission mode for this IPdu. */\r
        const ComTxModeMode_type ComTxModeMode;\r
 \r
-       /** Defines the number of times this IPdu will be sent in each IPdu cycle.
-        * Should be set to 0 for DIRECT transmission mode and >0 for DIRECT/N-times mode.
+       /** Defines the number of times this IPdu will be sent in each IPdu cycle.\r
+        * Should be set to 0 for DIRECT transmission mode and >0 for DIRECT/N-times mode.\r
         */\r
        const uint8 ComTxModeNumberOfRepetitions;\r
 \r
-       /** Defines the period of the transmissions in DIRECT/N-times and MIXED transmission modes. */
+       /** Defines the period of the transmissions in DIRECT/N-times and MIXED transmission modes. */\r
        const uint32 ComTxModeRepetitionPeriodFactor;\r
 \r
-       /** Time before first transmission of this IPDU. (i.e. between the ipdu group start and this IPDU is sent for the first time. */
+       /** Time before first transmission of this IPDU. (i.e. between the ipdu group start and this IPDU is sent for the first time. */\r
        const uint32 ComTxModeTimeOffsetFactor;\r
 \r
-       /** Period of cyclic transmission. */
+       /** Period of cyclic transmission. */\r
        const uint32 ComTxModeTimePeriodFactor;\r
 } ComTxMode_type;\r
 \r
-/** Extra configuration structure for Tx I-PDUs. */
+/** Extra configuration structure for Tx I-PDUs. */\r
 typedef struct {\r
 \r
-       /** Minimum delay between successive transmissions of the IPdu. */
+       /** Minimum delay between successive transmissions of the IPdu. */\r
        const uint32 ComTxIPduMinimumDelayFactor;\r
 \r
-       /** COM will fill unused areas within an IPdu with this bit patter.
+       /** COM will fill unused areas within an IPdu with this bit patter.\r
         */\r
        const uint8 ComTxIPduUnusedAreasDefault;\r
 \r
-       /** Transmission modes for the IPdu.
-        * TMS is not implemented so only one static transmission mode is supported.
+       /** Transmission modes for the IPdu.\r
+        * TMS is not implemented so only one static transmission mode is supported.\r
         */\r
        const ComTxMode_type ComTxModeTrue;\r
-
+\r
        //ComTxMode_type ComTxModeFalse;\r
-} ComTxIPdu_type;
-
+} ComTxIPdu_type;\r
+\r
 \r
-/** Configuration structure for I-PDU groups */
+/** Configuration structure for I-PDU groups */\r
 typedef struct ComIPduGroup_type {\r
-       /** ID of this group.
-        * Range 0 to 31.
-        */
+       /** ID of this group.\r
+        * Range 0 to 31.\r
+        */\r
        const uint8 ComIPduGroupHandleId;\r
 \r
        // reference to the group that this group possibly belongs to.\r
        //struct ComIPduGroup_type *ComIPduGroupRef;\r
-
-       /** Marks the end of list for the I-PDU group configuration array. */
+\r
+       /** Marks the end of list for the I-PDU group configuration array. */\r
        const uint8 Com_Arc_EOL;\r
 } ComIPduGroup_type;\r
 \r
-
-/** Configuration structure for an I-PDU. */
+\r
+/** Configuration structure for an I-PDU. */\r
 typedef struct {\r
 \r
-       /** Callout function of this IPDU.
+       /** Callout function of this IPDU.\r
         * The callout function is an optional function used both on sender and receiver side.\r
         * If configured, it determines whether an IPdu is considered for further processing. If\r
         * the callout return false the IPdu will not be received/sent.\r
@@ -375,55 +380,58 @@ typedef struct {
        boolean (*ComIPduCallout)(PduIdType PduId, const uint8 *IPduData);\r
 \r
 \r
-       /** The ID of this IPDU. */
-       const uint8 ComIPduRxHandleId;
-
-       /** The outgoing PDU id. For polite PDU id handling. */
+       /** The outgoing PDU id. For polite PDU id handling. */\r
        const uint8 ArcIPduOutgoingId;\r
 \r
-       /** Signal processing mode for this IPDU. */
+       /** Signal processing mode for this IPDU. */\r
        const Com_IPduSignalProcessingMode ComIPduSignalProcessing;\r
 \r
-       /** Size of the IPDU in bytes.
-        * Range 0-8 for CAN and LIN and 0-256 for FlexRay.
+       /** Size of the IPDU in bytes.\r
+        * Range 0-8 for CAN and LIN and 0-256 for FlexRay.\r
         */\r
        const uint8 ComIPduSize;\r
 \r
-       /** The direction of the IPDU. Receive or Send. */
+       /** The direction of the IPDU. Receive or Send. */\r
        const Com_IPduDirection ComIPduDirection;\r
 \r
-       /** Reference to the IPDU group that this IPDU belongs to. */
+       /** Reference to the IPDU group that this IPDU belongs to. */\r
        const uint8 ComIPduGroupRef;\r
 \r
-       /** Container of transmission related parameters. */
+       /** Container of transmission related parameters. */\r
        const ComTxIPdu_type ComTxIPdu;\r
 \r
-       /** References to all signals and signal groups contained in this IPDU.
-        * It probably makes little sense not to define at least one signal or signal group for each IPDU.
+       /** Reference to the actual pdu data storage */\r
+       void *const ComIPduDataPtr;\r
+       void *const ComIPduDeferredDataPtr;\r
+\r
+       /** References to all signals and signal groups contained in this IPDU.\r
+        * It probably makes little sense not to define at least one signal or signal group for each IPDU.\r
         */\r
-       const ComSignal_type **ComIPduSignalRef;\r
+       const ComSignal_type * const *ComIPduSignalRef;\r
+\r
+       const ComSignal_type * const ComIPduDynSignalRef;\r
 \r
        /*\r
         * The following two variables are used to control the per I-PDU based Rx/Tx-deadline monitoring.\r
         */\r
        //const uint32 Com_Arc_DeadlineCounter;\r
-       //const uint32 Com_Arc_TimeoutFactor;
-
-       /* Transmission related timers and parameters.
-        * These are internal variables and should not be configured.
-        */
+       //const uint32 Com_Arc_TimeoutFactor;\r
+\r
+       /* Transmission related timers and parameters.\r
+        * These are internal variables and should not be configured.\r
+        */\r
        //ComTxIPduTimer_type Com_Arc_TxIPduTimers;\r
-
-       /** Marks the end of list for this configuration array. */
+\r
+       /** Marks the end of list for this configuration array. */\r
        const uint8 Com_Arc_EOL;\r
 \r
 } ComIPdu_type;\r
 \r
 \r
-/** Top-level configuration container for COM. Exists once per configuration. */
+/** Top-level configuration container for COM. Exists once per configuration. */\r
 typedef struct {\r
 \r
-       /** The ID of this configuration. This is returned by Com_GetConfigurationId(); */
+       /** The ID of this configuration. This is returned by Com_GetConfigurationId(); */\r
        const uint8 ComConfigurationId;\r
 \r
        /*\r
@@ -432,24 +440,24 @@ typedef struct {
        ComGwMapping_type ComGwMapping[];\r
         */\r
 \r
-       /** IPDU definitions */
+       /** IPDU definitions */\r
        const ComIPdu_type *ComIPdu;\r
 \r
        //uint16 Com_Arc_NIPdu;\r
 \r
-       /** IPDU group definitions */
+       /** IPDU group definitions */\r
        const ComIPduGroup_type *ComIPduGroup;\r
 \r
-       /** Signal definitions */
+       /** Signal definitions */\r
        const ComSignal_type *ComSignal;\r
 \r
        // Signal group definitions\r
        //ComSignalGroup_type *ComSignalGroup;\r
 \r
-       /** Group signal definitions */
+       /** Group signal definitions */\r
        const ComGroupSignal_type *ComGroupSignal;\r
 \r
 } Com_ConfigType;\r
 \r
-#endif /*COM_TYPES_H_*/
-/** @} */
+#endif /*COM_TYPES_H_*/\r
+/** @} */\r