summaryrefslogtreecommitdiffstats
path: root/ucs2-lib/inc/ucs_message_pb.h
blob: 53ec7fe109f9f964ddc444518bfdf4d3c522e714 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*------------------------------------------------------------------------------------------------*/
/* 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 Declaration of public message types
 */

#ifndef UCS_MESSAGE_PB_H
#define UCS_MESSAGE_PB_H

#ifdef __cplusplus
extern "C"
{
#endif

/*!
 * \addtogroup G_UCS_TRACE_TYPES
 * @{
 */
/*------------------------------------------------------------------------------------------------*/
/* Defines                                                                                        */
/*------------------------------------------------------------------------------------------------*/
#define UCS_ADDR_INTERNAL                0x0000U  /* < \brief   Internal transmission destination address
                                                   *   \details Can be used for internal message transmission
                                                   *            to avoid possible race conditions during 
                                                   *            recalculation of the own node address.
                                                   */
#define UCS_ADDR_LOCAL_INIC              0x0001U  /* < \brief Destination address of the local INIC */
#define UCS_ADDR_BROADCAST_BLOCKING      0x03C8U  /*!< \brief Blocking broadcast destination address */
#define UCS_ADDR_BROADCAST_UNBLOCKING    0x03FFU  /*!< \brief Unblocking broadcast destination address */
#define UCS_ADDR_DEBUG                   0x0FF0U  /* < \brief Optional debug destination address */

/*------------------------------------------------------------------------------------------------*/
/* Types                                                                                          */
/*------------------------------------------------------------------------------------------------*/
/*! \brief   Message transmission status for internal/debug use
 */
typedef enum Ucs_MsgTxStatus_
{
    UCS_MSG_STAT_OK                     = 0x00U, /*!< \brief Transmission succeeded */
    UCS_MSG_STAT_ERROR_CFG_NO_RCVR      = 0x01U, /*!< \brief No internal receiver exists */
    UCS_MSG_STAT_ERROR_BF               = 0x08U, /*!< \brief Buffer full */ 
    UCS_MSG_STAT_ERROR_CRC              = 0x09U, /*!< \brief CRC */ 
    UCS_MSG_STAT_ERROR_ID               = 0x0AU, /*!< \brief Corrupted identifiers */ 
    UCS_MSG_STAT_ERROR_ACK              = 0x0BU, /*!< \brief Corrupted PACK or CACK */ 
    UCS_MSG_STAT_ERROR_TIMEOUT          = 0x0CU, /*!< \brief TX timeout */
    UCS_MSG_STAT_ERROR_FATAL_WT         = 0x10U, /*!< \brief Wrong target */ 
    UCS_MSG_STAT_ERROR_FATAL_OA         = 0x11U, /*!< \brief Own node address */
    UCS_MSG_STAT_ERROR_NA_TRANS         = 0x18U, /*!< \brief Control channel was switched off and 
                                                  *          a pending transmission was canceled */ 
    UCS_MSG_STAT_ERROR_NA_OFF           = 0x19U, /*!< \brief Control channel not available */
    UCS_MSG_STAT_ERROR_UNKNOWN          = 0xFEU, /*!< \brief Unknown error status */
    UCS_MSG_STAT_ERROR_SYNC             = 0xFFU  /*!< \brief Internal error which is notified if 
                                                  *          communication link with INIC is lost
                                                  */
} Ucs_MsgTxStatus_t;

/*! \brief   Operation Types 
 */
typedef enum Ucs_OpType_
{
    UCS_OP_SET              = 0x0,  /*!< \brief Operation Set (Property) */
    UCS_OP_GET              = 0x1,  /*!< \brief Operation Get (Property) */
    UCS_OP_SETGET           = 0x2,  /*!< \brief Operation SetGet (Property) */
    UCS_OP_INC              = 0x3,  /*!< \brief Operation Increment (Property) */
    UCS_OP_DEC              = 0x4,  /*!< \brief Operation Decrement (Property) */
    UCS_OP_STATUS           = 0xC,  /*!< \brief Operation Status (Property) */

    UCS_OP_START            = 0x0,  /*!< \brief Operation Start (Method) */
    UCS_OP_ABORT            = 0x1,  /*!< \brief Operation Abort (Method) */
    UCS_OP_STARTRESULT      = 0x2,  /*!< \brief Operation StartResult (Method) */
    UCS_OP_PROCESSING       = 0xB,  /*!< \brief Operation Processing (Method) */
    UCS_OP_RESULT           = 0xC,  /*!< \brief Operation Result (Method) */

    UCS_OP_STARTACK         = 0x8,  /*!< \brief Operation StartAck (Method) */
    UCS_OP_ABORTACK         = 0x7,  /*!< \brief Operation AbortAck (Method) */
    UCS_OP_STARTRESULTACK   = 0x6,  /*!< \brief Operation StartResultAck (Method) */
    UCS_OP_PROCESSINGACK    = 0xA,  /*!< \brief Operation ProcessingAck (Method) */
    UCS_OP_RESULTACK        = 0xD,  /*!< \brief Operation ResultAck (Method) */

    UCS_OP_GETINTERFACE     = 0x5,  /*!< \brief Operation GetInterface (Property/Method) */
    UCS_OP_INTERFACE        = 0xE,  /*!< \brief Operation Interface (Property/Method) */
    UCS_OP_ERROR            = 0xF,  /*!< \brief Operation Error (Property/Method) */
    UCS_OP_ERRORACK         = 0x9   /*!< \brief Operation ErrorAck (Property/Method) */

} Ucs_OpType_t;

/*! \brief  MOST message id "FBlockID.InstID.FktID.OPType" */
typedef struct Msg_MsgId_
{
    uint8_t         fblock_id;      /*!< \brief FBlockID */
    uint8_t         instance_id;    /*!< \brief InstID */
    uint16_t        function_id;    /*!< \brief FktID */
    Ucs_OpType_t    op_type;        /*!< \brief Operation type */

} Msg_MsgId_t;

/*! \brief  Retry options */
typedef struct Msg_TxOptions_
{
    uint8_t     llrbc;          /*!< \brief   Low-level retry block count performed by the INIC. 
                                 *   \details The LLRBC are applicable for MCMs. ICMs don't care.
                                 *            Values exceeding the maximum value are be corrected 
                                 *            by the INIC silently to the maximum value.
                                 *            Valid range: 0..100
                                 */
    uint8_t     cancel_id;      /*!< \brief   Either "0" or label for a group of dependent telegrams. 
                                 *   \details The value determines the required action if the transmission
                                 *            has failed.
                                 *            Valid range:
                                 *            - 0: Only the failed telegram will is removed from the FIFO.
                                 *            - 1..255: All telegrams with the same cancel_id as a failed telegram 
                                 *              will be removed from the FIFO queue.
                                 */

} Msg_TxOptions_t;

/*! \brief  Most telegram data */
typedef struct Msg_TelData_
{
    uint8_t     tel_id;         /*!< \brief Telegram id which indicates the telegram as part of
                                 *          segmented message or as single transfer. */
    uint8_t     tel_len;        /*!< \brief The telegram length. 
                                 *          I.e. the number of telegram bytes starting at address
                                 *          which is referred in \c tel_data_ptr. The INIC will add
                                 *          \em one in case of \"tel_id = 1..3\". 
                                 */
    uint8_t     tel_cnt;        /*!< \brief The message count indexing the telegram within a segmented
                                 *          message.
                                 *          The respective tel_cnt is moved by the INIC to \"DATA[0]\"
                                 *          in case of \"tel_id = 1..3\". Otherwise it is ignored.
                                 */
    uint8_t    *tel_data_ptr;   /*!< \brief Points to telegram data. */

} Msg_TelData_t;

/*! \brief  Common MOST message */
typedef struct Msg_MostTel_
{
    uint16_t destination_addr;      /*!< \brief MOST destination address */
    uint16_t source_addr;           /*!< \brief MOST source address */

    Msg_MsgId_t         id;         /*!< \brief MOST message id "FBlockID.InstID.FktID.OPType" */
    Msg_TxOptions_t     opts;       /*!< \brief Message transmission options */
    Msg_TelData_t       tel;        /*!< \brief MOST telegram data */
    void               *info_ptr;   /*!< \brief Possible reference to additional data */

} Msg_MostTel_t;

/*! @} */

#ifdef __cplusplus
}                                   /* extern "C" */
#endif

#endif /* #ifndef UCS_MESSAGE_PB_H */


/*------------------------------------------------------------------------------------------------*/
/* End of file                                                                                    */
/*------------------------------------------------------------------------------------------------*/