MT2523 API Reference  LinkIt SDK v4
serial_port.h
1 /* Copyright Statement:
2  *
3  * (C) 2005-2016 MediaTek Inc. All rights reserved.
4  *
5  * This software/firmware and related documentation ("MediaTek Software") are
6  * protected under relevant copyright laws. The information contained herein
7  * is confidential and proprietary to MediaTek Inc. ("MediaTek") and/or its licensors.
8  * Without the prior written permission of MediaTek and/or its licensors,
9  * any reproduction, modification, use or disclosure of MediaTek Software,
10  * and information contained herein, in whole or in part, shall be strictly prohibited.
11  * You may only use, reproduce, modify, or distribute (as applicable) MediaTek Software
12  * if you have agreed to and been bound by the applicable license agreement with
13  * MediaTek ("License Agreement") and been granted explicit permission to do so within
14  * the License Agreement ("Permitted User"). If you are not a Permitted User,
15  * please cease any access or use of MediaTek Software immediately.
16  * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
17  * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES
18  * ARE PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
19  * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
21  * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
22  * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
23  * SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
24  * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
25  * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
26  * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
27  * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
28  * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
29  * CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
30  * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE MEDIATEK SOFTWARE AT ISSUE,
31  * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
32  * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
33  */
34 
35 #ifndef __SERIAL_PORT_H__
36 #define __SERIAL_PORT_H__
37 
38 #ifdef MTK_PORT_SERVICE_ENABLE
39 
136 #include <stdint.h>
137 #include "serial_port_config.h"
138 #include "hal_uart.h"
139 
140 #ifdef __cplusplus
141 extern "C" {
142 #endif
143 
151 typedef enum {
167 
171 typedef enum {
177 
181 typedef enum {
190 
194 typedef enum {
200 
204 typedef enum {
225 typedef void (*serial_port_register_callback_t)(serial_port_dev_t device, serial_port_callback_event_t event, void *parameter);
226 
230 typedef uint32_t serial_port_handle_t;
231 
245 typedef struct {
246  uint8_t *data;
247  uint32_t size;
248  uint32_t ret_size;
250 
255 typedef struct {
256  uint8_t *buffer;
257  uint32_t size;
258  uint32_t ret_size;
260 
265 typedef struct {
266  uint32_t ret_size;
268 
273 typedef struct {
274  uint32_t ret_size;
276 
281 typedef struct {
284 
288 typedef struct {
289  char name[SERIAL_PORT_USER_NAME_SIZE];
292 
296 typedef struct {
299 
303 typedef union {
306 
311 typedef union {
352  serial_port_handle_t *handle);
353 
372 serial_port_status_t serial_port_control(serial_port_handle_t handle,
373  serial_port_ctrl_cmd_t command,
375 
389 serial_port_status_t serial_port_close(serial_port_handle_t handle);
390 
402 serial_port_type_t serial_port_get_device_type(serial_port_dev_t device);
403 
424 
442 
461 
479 
500 
505 #endif
506 
507 #ifdef __cplusplus
508 }
509 #endif
510 
511 #endif
512 
This structure defines the data structure for using SERIAL_PORT_CMD_READ_DATA to read data from the s...
Definition: serial_port.h:255
UART or USB special command to get the current available space to store the transmit data...
Definition: serial_port.h:186
The first port type in the port service.
Definition: serial_port.h:172
The Serial Port Service device is invalid.
Definition: serial_port.h:209
serial_port_status_t serial_port_config_read_dev_setting(serial_port_dev_t device, serial_port_dev_setting_t *dev_setting)
This function reads current parameters for a specific device.
The Serial Port Service device is uninitialized.
Definition: serial_port.h:207
The Serial Port Service device is busy.
Definition: serial_port.h:206
UART port type in the port service.
Definition: serial_port.h:173
serial_port_status_t serial_port_open(serial_port_dev_t device, serial_port_open_para_t *para, serial_port_handle_t *handle)
This function initializes the specific device such as UART or USB.
Read data command in blocking mode.
Definition: serial_port.h:185
serial_port_status_t serial_port_config_write_dev_number(const char *user_name, serial_port_dev_t device)
This function writes new assigned device for a specific user.
The maximum number of ports in the port service of a device.
Definition: serial_port.h:164
serial_port_status_t serial_port_control(serial_port_handle_t handle, serial_port_ctrl_cmd_t command, serial_port_ctrl_para_t *para)
This function controls a specific device to read or write data or perform other operations supported ...
UART1 port in the port service of a device.
Definition: serial_port.h:154
The last valid USB port in the port service of a device.
Definition: serial_port.h:162
USB port type in the port service.
Definition: serial_port.h:174
uint32_t ret_size
The current available space to put the transmit data in.
Definition: serial_port.h:266
The invalid port number in the port service of a device.
Definition: serial_port.h:165
This structure indicates current available data received when using #SERIAL_PORT_CMD_UART_GET_READ_AV...
Definition: serial_port.h:273
serial_port_type_t serial_port_get_device_type(serial_port_dev_t device)
This function gets the device type of the serial port device.
This structure is for configuring baud rate for UART device.
Definition: serial_port.h:296
serial_port_status_t serial_port_config_dump_dev_number(uint32_t *user_count, serial_port_assign_t *port_assign)
This function dumps device assign list in NVDM, for example, device UART port0 is assigned to user AT...
The first valid UART port in the port service of a device.
Definition: serial_port.h:152
serial_port_type_t
This enum defines the port_service device types.
Definition: serial_port.h:171
USB connection event.
Definition: serial_port.h:197
uint32_t serial_port_handle_t
This defines the serial port handle for the Serial Port Service.
Definition: serial_port.h:230
serial_port_dev_t
This enum defines the port_service device.
Definition: serial_port.h:151
serial_port_get_write_avail_t serial_port_get_write_avail
Parameters for UART/USB special write command.
Definition: serial_port.h:316
UART or USB special command to get the current available size for the received data.
Definition: serial_port.h:187
This structure defines the data structure for using SERIAL_PORT_CMD_WRITE_DATA to write data to the s...
Definition: serial_port.h:245
uint8_t * data
The data to write to the serial port.
Definition: serial_port.h:246
serial_port_write_data_t serial_port_write_data_blocking
Write data parameters for blocking mode.
Definition: serial_port.h:314
The maximum number of commands.
Definition: serial_port.h:188
Write data command in blocking mode.
Definition: serial_port.h:184
Read data command.
Definition: serial_port.h:183
This defines the data structure that calls serial_port_open() to open a Serial Port Service device...
Definition: serial_port.h:281
uint32_t size
Size of the data to write to the serial port.
Definition: serial_port.h:247
serial_port_write_data_t serial_port_write_data
Write data parameters.
Definition: serial_port.h:312
hal_uart_baudrate_t
This enum defines baud rate of the UART frame.
Definition: hal_uart.h:302
This structure is for configuring a device in the Serial Port Service.
Definition: serial_port.h:303
uint32_t ret_size
The actual size of data written to the serial port.
Definition: serial_port.h:248
The Serial Port Service parameters are invalid.
Definition: serial_port.h:210
serial_port_get_read_avail_t serial_port_get_read_avail
Parameters for UART/USB special read command.
Definition: serial_port.h:317
The Serial Port Service function executed successfully.
Definition: serial_port.h:212
serial_port_register_callback_t callback
The callback function.
Definition: serial_port.h:282
serial_port_callback_event_t
This enum defines the events that trigger the user&#39;s callback.
Definition: serial_port.h:194
uint32_t size
Size of the data to read.
Definition: serial_port.h:257
Ready to write event.
Definition: serial_port.h:196
USB2 port in the port service of a device.
Definition: serial_port.h:161
The Serial Port Service function has failed.
Definition: serial_port.h:211
serial_port_dev_t device
Serial Port Service device.
Definition: serial_port.h:290
uint32_t ret_size
The size of the received data.
Definition: serial_port.h:274
void(* serial_port_register_callback_t)(serial_port_dev_t device, serial_port_callback_event_t event, void *parameter)
This defines the callback function prototype for the Serial Port Service.
Definition: serial_port.h:225
USB1 port in the port service of a device.
Definition: serial_port.h:160
serial_port_status_t serial_port_close(serial_port_handle_t handle)
This function de-initializes a specific device after using the device to release the resources for ot...
UART2 port in the port service of a device.
Definition: serial_port.h:155
UART0 port in the port service of a device.
Definition: serial_port.h:153
serial_port_read_data_t serial_port_read_data
Read data parameters.
Definition: serial_port.h:313
uint32_t ret_size
The actual size of data read from the serial port.
Definition: serial_port.h:258
The maximum number of port types in the port service.
Definition: serial_port.h:175
UART3 port in the port service of a device.
Definition: serial_port.h:156
The Serial Port Service function is not supported.
Definition: serial_port.h:208
This structure indicates current available space to put the transmit data in when using #SERIAL_PORT_...
Definition: serial_port.h:265
Write data command.
Definition: serial_port.h:182
serial_port_setting_uart_t port_setting_uart
UART device.
Definition: serial_port.h:304
serial_port_status_t serial_port_config_write_dev_setting(serial_port_dev_t device, serial_port_dev_setting_t *dev_setting)
This function writes new parameters for a specific device.
serial_port_read_data_t serial_port_read_data_blocking
Read data parameters for blocking mode.
Definition: serial_port.h:315
The first valid USB port in the port service of a device.
Definition: serial_port.h:159
USB disconnection event.
Definition: serial_port.h:198
This defines the data structure for communications between the serial port device and its user...
Definition: serial_port.h:288
uint8_t * buffer
The buffer to store the received data.
Definition: serial_port.h:256
serial_port_status_t
This enum defines the Serial Port Service status.
Definition: serial_port.h:204
This structure defines the data structure for each command in serial_port_ctrl_cmd_t.
Definition: serial_port.h:311
serial_port_ctrl_cmd_t
This enum defines the commands for each parameter in serial_port_ctrl_para_t.
Definition: serial_port.h:181
The last valid UART port in the port service of a device.
Definition: serial_port.h:157
serial_port_status_t serial_port_config_read_dev_number(const char *user_name, serial_port_dev_t *device)
This function reads assigned device for a specific user.
Ready to read event.
Definition: serial_port.h:195
hal_uart_baudrate_t baudrate
UART baud rate.
Definition: serial_port.h:297
The Serial Port Service device is not ready.
Definition: serial_port.h:205