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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
/*
* MOST NetServices "Light" V3.2.7.0.1796 MultiInstance Patch
*
* Copyright (C) 2015 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 3 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.
*
*/
/* parasoft suppress item * reason "not part of MOST NetServices delivery" */
/*!
* \file
* \brief Header file of MOST NetServices Light
*/
#ifndef MNSL_H
#define MNSL_H
#ifdef __cplusplus
extern "C"
{
#endif
/*------------------------------------------------------------------------------------------------*/
/* Includes */
/*------------------------------------------------------------------------------------------------*/
#include "mns_transceiver.h"
#include "mns_ams.h"
#include "mns_pmfifos.h"
/*------------------------------------------------------------------------------------------------*/
/* Definitions */
/*------------------------------------------------------------------------------------------------*/
/*! \brief MNS Major Version Number */
#define MNSL_VERSION_MAJOR 3
/*! \brief MNS Minor Version Number */
#define MNSL_VERSION_MINOR 2
/*! \brief MNS Release Version Number */
#define MNSL_VERSION_RELEASE 7
/*! \brief MNS Service Release Number */
#define MNSL_VERSION_SR 0
/*! \brief MNS Build Number */
#define MNSL_VERSION_BUILD 1796
/*------------------------------------------------------------------------------------------------*/
/* Types */
/*------------------------------------------------------------------------------------------------*/
/*! \brief Defines which FIFOs shall be built on the Port Message Channel */
typedef enum Mnsl_ActiveFifos_
{
MNSL_FIFOS_MCM = 0x01U, /*!< \brief Initialize PM channel with MCM FIFO only */
MNSL_FIFOS_ICM = 0x02U, /*!< \brief Initialize PM channel with ICM FIFO only */
MNSL_FIFOS_MCM_ICM = 0x03U, /*!< \brief Initialize PM channel with MCM and ICM FIFO */
MNSL_FIFOS_RCM = 0x04U, /*!< \brief Initialize PM channel with RCM FIFO only */
MNSL_FIFOS_MCM_RCM = 0x05U, /*!< \brief Initialize PM channel with MCM and RCM FIFO */
MNSL_FIFOS_ICM_RCM = 0x06U, /*!< \brief Initialize PM channel with ICM and RCM FIFO */
MNSL_FIFOS_MCM_ICM_RCM = 0x07U /*!< \brief Initialize PM channel with MCM, ICM and RCM FIFO */
} Mnsl_ActiveFifos_t;
/*! \brief Possible MNSL events */
typedef enum Mnsl_Event_
{
MNSL_EVENT_SYNC_COMPLETE = 0, /*!< \brief The initial synchronization completed successfully */
MNSL_EVENT_SYNC_FAILED = 1, /*!< \brief The initial synchronization failed */
MNSL_EVENT_SYNC_LOST = 2, /*!< \brief The synchronization to the INIC was lost irrecoverably */
MNSL_EVENT_UNSYNC_COMPLETE = 3, /*!< \brief The un-synchronization was completed successfully */
MNSL_EVENT_UNSYNC_FAILED = 4 /*!< \brief The un-synchronization failed */
} Mnsl_Event_t;
typedef uint16_t (*Mnsl_GetTickCountCb_t)(void);
typedef void (*Mnsl_EventCb_t)(Mnsl_Event_t event_code, void *inst_ptr);
typedef void (*Mnsl_ServiceRequestCb_t)(void *inst_ptr);
typedef void (*Mnsl_SetAppTimerCb_t)(uint16_t timeout, void *inst_ptr);
/*! \brief General initialization settings */
typedef struct Mnsl_General_InitData_
{
Mnsl_EventCb_t event_fptr; /*!< \brief Reports an MNSL event (mandatory callback) */
Mnsl_GetTickCountCb_t get_tickcount_fptr; /*!< \brief Requests the current tick count in milliseconds (mandatory callback) */
Mnsl_ServiceRequestCb_t request_service_fptr;/*!< \brief Reports that the application shall call Mnsl_Service() (optional callback) */
Mnsl_SetAppTimerCb_t set_app_timer_fptr; /*!< \brief Triggers the application to call Mnsl_ReportTimeout() after a specific time (mandatory callback) */
} Mnsl_General_InitData_t;
/*! \brief Port Message Service (PMS) settings */
typedef struct Mnsl_Pms_InitData_
{
Mnsl_ActiveFifos_t active_fifos; /*!< \brief Defines which FIFOs shall be initialized */
Fifo_Config_t icm_config; /*!< \brief Setup of ICM FIFO */
Fifo_Config_t mcm_config; /*!< \brief Setup of MCM FIFO */
Fifo_Config_t rcm_config; /*!< \brief Setup of RCM FIFO */
bool compressed; /*!< \brief Set to \c true in order to use OS81118 Rev.C */
} Mnsl_Pms_InitData_t;
/*! \brief Application Message Service (AMS) settings */
typedef struct Mnsl_Ams_InitData_
{
Mns_Ams_AllocMemCb_t rx_alloc_mem_fptr; /*!< \brief Required to allocate memory for an AMS Rx message */
Mns_Ams_FreeMemCb_t rx_free_mem_fptr; /*!< \brief Required to free memory for an AMS Rx message */
} Mnsl_Ams_InitData_t;
/*! \brief Initialization settings */
typedef struct Mnsl_InitData_
{
Mnsl_General_InitData_t general; /*!< \brief Basic settings to drive MNSL */
Mns_Lld_Callbacks_t lld; /*!< \brief Mandatory callback functions of the driver */
Mnsl_Pms_InitData_t pms; /*!< \brief Port Message Service settings */
Mnsl_Ams_InitData_t ams; /*!< \brief Application Message Service settings */
} Mnsl_InitData_t;
/*------------------------------------------------------------------------------------------------*/
/* Helper Macros */
/*------------------------------------------------------------------------------------------------*/
#define MNSL_UNUSED(p) ((p) = (p)) /* parasoft-suppress MISRA2004-19_7 "suppress warning" */
/*------------------------------------------------------------------------------------------------*/
/* Internal structures */
/*------------------------------------------------------------------------------------------------*/
typedef struct CMnsl_
{
uint8_t inst_id;
CBase base;
CPmChannel pm_channel;
CPmFifos fifos;
CPmFifo icm_fifo;
CPmFifo rcm_fifo;
CPmFifo mcm_fifo;
Mnsl_GetTickCountCb_t get_tick_count_fptr;
CSingleObserver get_tick_count_obs;
Mnsl_ServiceRequestCb_t srv_request_fptr;
CSingleObserver srv_request_obs;
Mnsl_SetAppTimerCb_t set_app_timer_fptr;
CSingleObserver set_app_timer_obs;
CTransceiver icm_transceiver;
CTransceiver rcm_transceiver;
CTransceiver mcm_transceiver;
CAms ams;
CAmsMsgPool ams_pool;
Ams_MemAllocator_t ams_allocator;
Mnsl_EventCb_t event_fptr;
CObserver pms_observer;
void *inst_ptr; //TKU: added
} CMnsl;
/*------------------------------------------------------------------------------------------------*/
/* Prototypes */
/*------------------------------------------------------------------------------------------------*/
extern void Mnsl_SetDefaultConfig(Mnsl_InitData_t *init_ptr, bool enable_watchdog);
extern void Mnsl_Init(CMnsl *mnsl, Mnsl_InitData_t *init_ptr, void *inst_ptr);
extern void Mnsl_Synchronize(CMnsl *mnsl);
extern void Mnsl_Unsynchronize(CMnsl *mnsl, bool initial);
extern void Mnsl_Service(CMnsl *mnsl);
extern void Mnsl_ReportTimeout(CMnsl *mnsl);
extern CTransceiver * Mnsl_GetIcmTransceiver(CMnsl *mnsl);
extern CTransceiver * Mnsl_GetRcmTransceiver(CMnsl *mnsl);
extern CTransceiver * Mnsl_GetMcmTransceiver(CMnsl *mnsl);
extern CAms * Mnsl_GetAmsTransceiver(CMnsl *mnsl);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* #ifndef MNSL_H */
/*------------------------------------------------------------------------------------------------*/
/* End of file */
/*------------------------------------------------------------------------------------------------*/
|