summaryrefslogtreecommitdiffstats
path: root/deck_hal/hal_api/deck_hal.h
blob: 74aa19af458c44b53765d4f364d4b16415df78ed (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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
/*
 * @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*!-----------------------------------------------------------------------------
 * @file    deck_hal.h
 * @~english
 * @brief   deck_hal API head
 *
 */

#ifndef HAL_API_DECK_HAL_H_
#define HAL_API_DECK_HAL_H_

#include <native_service/frameworkunified_types.h>

/**
 * @file deck_hal.h
 */

/** @addtogroup interface_unified
 *  @{
 */
/** @addtogroup deck_hal
 *  @ingroup interface_unified
 *  @{
 */
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/

/*! @~english Maximum length of command data division */
#define DECK_CMD_SIZE_CMDDATA_MAX  252
/*! @~english Maximum length of notification destination */
#define NOTIFY_NAME_MAX_SIZE 15

// CID_DECK_SYS_DELIVERY is for deck_hal to report correspinding message to vehicle,
// the value 0x40 can be changed in the future
/**
 * \~english @brief  DECK SYS Command-Delivery Notification
 * \~english @brief  If you want to receive this DECK SYS command-delivery notification, use the NSFW IF as follows: 
 * \~english @code
 * l_eStatus = FrameworkunifiedAttachCallbackToDispatcher(hApp, DECKHAL_THREAD, CID_DECK_SYS_DELIVERY, LineSensDrvRcvDeckHal);
 *            @endcode
 */
#define CID_DECK_SYS_DELIVERY 0x40

/*!
 * @~english
 * @brief Disc eject mode
*/
typedef enum {
  /*! @~english  normal eject   */
  DECK_EJECT_NORMAL,
  /*! @~english  forced eject   */
  DECK_EJECT_FORCED
} DeckEjectMode;

/*!
 * @~english
 * @brief Disc mode
*/
typedef enum {
  /*! @~english  CD    */
  DECK_KIND_CD,
  /*! @~english  DVD    */
  DECK_KIND_DVD,
  /*! @~english  Blue-lay disc    */
  DECK_KIND_BD
} DeckKind;

/*------------------------------------------------------------------------------
 * typedefs
 *----------------------------------------------------------------------------*/
/**
 * \~english  Deck-Sys command header structure
 */
typedef struct {
  /*! @~english Source logical address  */
  uint8_t  lgadr_from;
  /*! @~english Forwarding destination logical address  */
  uint8_t  lgadr_to;
  /*! @~english OP code  */
  uint8_t  opc;
  /*! @~english Reserve  */
  uint8_t  reserve;
} DeckCmdhdr;

/**
 * \~english  Deck-Sys command body structure
 */
typedef struct DeckCmd {
  /*! @~english Deck-Sys command header  */
    DeckCmdhdr cmdhdr;
  /*! @~english Data length  */
    uint16_t data_length;
  /*! @~english Reserve  */
    uint16_t reserve;
  /*! @~english Command data  */
    uint8_t data[DECK_CMD_SIZE_CMDDATA_MAX];
} DeckCmd;

/*!
 * @~english
 * @brief Structure for message header
 */
typedef struct {
  uint16_t replyid;      //!< \~english Send Result ID
  uint16_t sndpno;       //!< \~english Send process No
  uint16_t respno;       //!< \~english Response No
  uint16_t cid;          //!< \~english Command ID
  uint16_t msgbodysize;  //!< \~english Message body size
  uint8_t rid;           //!< \~english Resource ID
  uint8_t reserve;       //!< \~english Reserve
  uint8_t filler[2];     //!< \~english filler
} DECK_HEADER_COMM;

/*!
 * @~english
 * @brief Structure for buffer message header
 */
typedef struct {
  uint32_t signo;            //!< \~english Signal No
  DECK_HEADER_COMM hdr;  //!< \~english Message Header
} DECK_MSGBUF_HEADER_COMM;

/**
 * \~english Delivery message structure
 */
typedef struct {
  /*! @~english Header part  */
  DECK_MSGBUF_HEADER_COMM hdr;
  /*! @~english Physical address  */
  uint16_t phyadr_from;
  /*! @~english Communication type  */
  uint8_t service_type;
  /*! @~english Reserve    */
  uint8_t reserve;
  /*! @~english Data section  */
  DeckCmd cmd;
} DECK_MSG_DELIVERY;

/*!
 * @~english
 * @brief Structure for send command data
 */
typedef struct {
  /*! @~english Physical address */
  uint16_t  phyadr_from;
  /*! @~english Communication type */
  uint8_t   service_type;
  /*! @~english Forwarding former logic address */
  uint8_t   lgadr_from;
  /*! @~english Forwarding site logic address */
  uint8_t   lgadr_to;
  /*! @~english Operation code */
  uint8_t   opc;
  /*! @~english Data length (size in command data */
  uint8_t   d_length;
  /*! @~english Command data */
  uint8_t   data[DECK_CMD_SIZE_CMDDATA_MAX];
  /*! @~english reserve */
  uint8_t   reserve;
} DECK_CMD_DATA;

/*!
 * @~english
 * @brief Structure for send command
 */
typedef struct {
  /*! @~english Command information */
  DECK_CMD_DATA   cmd_data;
} DECK_CMD;

/*------------------------------------------------------------------------------
 * function declaration
 *----------------------------------------------------------------------------*/
////////////////////////////////////////////////////////////////////////////////////////////
/// \ingroup StopDiscRotation
/// \~english @par Brief
///        Stop disc rotation
/// \~english @param [in] -
/// \~english @param [out] -
/// \~english @retval eFrameworkunifiedStatusOK OK
/// \~english @retval eFrameworkunifiedStatusFail Abnormal Error
/// \~english @par Prerequisite
///       - Disc was inserted
/// \~english @par Change of internal state
///       - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///       - Error occurs when call open or ioctl function.[eFrameworkunifiedStatusFail]
/// \~english @par Classification
///         Public
/// \~english @par Type
///         Sync
/// \~english @par Detail
///       - Stop disc rotation
///       - Whatever disc is rotating or stoped, return successed.
///       - The API can be used by multi-process.
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////////////////

EFrameworkunifiedStatus StopDiscRotation();

////////////////////////////////////////////////////////////////////////////////////////////
/// \ingroup EjectDisc
/// \~english @par Brief
///        Eject disc
/// \~english @param [in]  kind
///       DeckKind       - kind of deck.
/// \~english @param [in]  mode
///       DeckEjectMode       - eject mode(normal/forcedly)
/// \~english @param [out] -
/// \~english @retval eFrameworkunifiedStatusOK OK
/// \~english @retval eFrameworkunifiedStatusFail Abnormal Error
/// \~english @par Prerequisite
///       - None
/// \~english @par Change of internal state
///       - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///       - Error occurs when call open or ioctl function.[eFrameworkunifiedStatusFail]
/// \~english @par Classification
///         Public
/// \~english @par Type
///         Sync
/// \~english @par Detail
///       - Eject disc
///       - Whatever disc is Ejecting or Unejected, return successed.
///       - The API can be used by multi-process.
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////////////////
EFrameworkunifiedStatus EjectDisc(DeckKind kind, DeckEjectMode mode);

////////////////////////////////////////////////////////////////////////////////////////////
/// \ingroup DeckHalSysSend
/// \~english @par Brief
///        Send Disc Sys-Command to MICON
/// \~english @param [in] h_app
///        HANDLE   - Handle of caller (Handle to get in Dispatcher generation
///                  (FrameworkunifiedCreateDispatcherWithoutLoop etc.))
/// \~english @param [in] name
///        PCSTR    - Name to notification of send result destination thread name
/// \~english @param [in] cmd
///        DECK_CMD - Send command pointer
/// \~english @param [in] req_id
///        uint8_t - Resource ID
/// \~english @param [out] -
/// \~english @retval eFrameworkunifiedStatusOK Normal termination
/// \~english @retval eFrameworkunifiedStatusInvldParam Abnormal parameter
/// \~english @par Prerequisite
///       - None
/// \~english @par Change of internal state
///       - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///       - h_app is NULL.[eFrameworkunifiedStatusInvldParam]
///       - name is NULL or the length of name is longer than 15 bytes.
///         [eFrameworkunifiedStatusInvldParam]
///       - Send command pointer(cmd) is null.[eFrameworkunifiedStatusInvldParam]
/// \~english @par Classification
///         Public
/// \~english @par Type
///         Sync
/// \~english @par Detail
///       - Send SYS command to MICON
///       - Now only usb disc exists,MICON disc is stub now.
///       - The API can only be used by 1 process.
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////////////////
EFrameworkunifiedStatus DeckHalSysSend(HANDLE h_app, PCSTR name, const DECK_CMD* cmd, uint8_t req_id);

////////////////////////////////////////////////////////////////////////////////////////////
/// \ingroup DeckHalRegister
/// \~english @par Brief
///        Register the deck_hal command to receive from MICON
/// \~english @param [in] h_app
///        HANDLE   - Handle of caller (Handle to get in Dispatcher generation
///                  (FrameworkunifiedCreateDispatcherWithoutLoop etc.))
/// \~english @param [in] notify_name
///        PCSTR    - Name to notification destination thread name
/// \~english @param [out] -
/// \~english @retval eFrameworkunifiedStatusOK Normal termination
/// \~english @retval eFrameworkunifiedStatusInvldParam Abnormal parameter
/// \~english @par Prerequisite
///       - None
/// \~english @par Change of internal state
///       - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///       - h_app is NULL.[eFrameworkunifiedStatusInvldParam]
///       - notify_name is NULL or the length of notify_name is longer than 15 bytes.
///         [eFrameworkunifiedStatusInvldParam]
/// \~english @par Classification
///         Public
/// \~english @par Type
///         Sync
/// \~english @par Detail
///       - After call this API, the user can received dech_hal command from MICON.
///       - Now MICON is stub,so that deck_hal won't register to MICON.
///       - The API can only be used by 1 process.
/// \~english @see None
////////////////////////////////////////////////////////////////////////////////////////////
EFrameworkunifiedStatus DeckHalRegister(HANDLE h_app, PCSTR notify_name);

#ifdef __cplusplus
}
#endif /*__cplusplus  */

/** @}*/  // end of deck_hal
/** @}*/  // end of interface_unified

#endif  // HAL_API_DECK_HAL_H_