MT7687 API Reference  LinkIt SDK v4
hal_uart.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 __HAL_UART_H__
36 #define __HAL_UART_H__
37 
38 #include "hal_platform.h"
39 
40 #ifdef HAL_UART_MODULE_ENABLED
41 
291 #ifdef __cplusplus
292 extern "C" {
293 #endif
294 
295 
302 typedef enum {
318 
319 
321 typedef enum {
327 
328 
330 typedef enum {
334 
335 
337 typedef enum {
342 
343 
345 typedef enum {
352 
353 
355 typedef enum {
360 
361 
373 typedef struct {
374  hal_uart_baudrate_t baudrate;
379 
380 
382 typedef struct {
383  uint8_t *send_vfifo_buffer;
391 
392 
410 typedef void (*hal_uart_callback_t)(hal_uart_callback_event_t event, void *user_data);
411 
412 
428 
429 
441 
442 
450 void hal_uart_put_char(hal_uart_port_t uart_port, char byte);
451 
452 
461 char hal_uart_get_char(hal_uart_port_t uart_port);
462 
463 
464 
477 uint32_t hal_uart_send_polling(hal_uart_port_t uart_port, const uint8_t *data, uint32_t size);
478 
479 
496 uint32_t hal_uart_send_dma(hal_uart_port_t uart_port, const uint8_t *data, uint32_t size);
497 
498 
510 uint32_t hal_uart_receive_polling(hal_uart_port_t uart_port, uint8_t *buffer, uint32_t size);
511 
512 
527 uint32_t hal_uart_receive_dma(hal_uart_port_t uart_port, uint8_t *buffer, uint32_t size);
528 
529 
539 
540 
550 
551 
567  hal_uart_callback_t user_callback,
568  void *user_data);
569 
570 
583 
584 
610  uint8_t xon,
611  uint8_t xoff,
612  uint8_t escape_character);
613 
614 
627 
628 
642 hal_uart_status_t hal_uart_set_baudrate(hal_uart_port_t uart_port, hal_uart_baudrate_t baudrate);
643 
644 
666 
667 
683 
684 
685 #ifdef HAL_UART_FEATURE_VFIFO_DMA_TIMEOUT
686 
699 hal_uart_status_t hal_uart_set_dma_timeout(hal_uart_port_t uart_port, uint32_t timeout);
700 #endif
701 
702 
703 #ifdef __cplusplus
704 }
705 #endif
706 
707 
713 #endif /* HAL_UART_MODULE_ENABLED */
714 #endif /* __HAL_UART_H__ */
715 
Defines UART baudrate as 9600 bps.
Definition: hal_uart.h:308
Defines UART baudrate as 921600 bps.
Definition: hal_uart.h:315
hal_uart_baudrate_t baudrate
This field represents the baudrate of UART frame.
Definition: hal_uart.h:374
uint32_t send_vfifo_threshold_size
This field represents the threshold of the transmitting VFIFO buffer.
Definition: hal_uart.h:385
hal_uart_status_t hal_uart_init(hal_uart_port_t uart_port, hal_uart_config_t *uart_config)
This function initializes the UART hardware with basic functionality.
Defines UART word length as 8 bit per frame.
Definition: hal_uart.h:325
Defines UART baudrate as 57600 bps.
Definition: hal_uart.h:311
Indicates user's parameter is invalid.
Definition: hal_uart.h:346
uint32_t hal_uart_receive_dma(hal_uart_port_t uart_port, uint8_t *buffer, uint32_t size)
This function receives user data in a VFIFO DMA mode.
Indicates if there is enough free space available in the TX buffer for the user to write into it...
Definition: hal_uart.h:358
Defines UART baudrate as 4800 bps.
Definition: hal_uart.h:307
uint32_t hal_uart_get_available_receive_bytes(hal_uart_port_t uart_port)
This function queries available data in the VFIFO RX buffer.
Defines UART stop bit as 1 bit per frame.
Definition: hal_uart.h:331
hal_uart_status_t
This enum defines return status of UART HAL public API.
Definition: hal_uart.h:345
hal_uart_word_length_t word_length
This field represents the word length of UART frame.
Definition: hal_uart.h:375
Defines UART parity as none.
Definition: hal_uart.h:338
Indicates UART port has not been initialized.
Definition: hal_uart.h:348
Indicates UART driver detected a common error.
Definition: hal_uart.h:349
char hal_uart_get_char(hal_uart_port_t uart_port)
This function gets one character from UART port in a poll mode.
Defines UART word length as 6 bit per frame.
Definition: hal_uart.h:323
Indicates UART port is currently used by other user.
Definition: hal_uart.h:347
uint32_t send_vfifo_buffer_size
This field represents the size of the transmitting VFIFO buffer.
Definition: hal_uart.h:384
hal_uart_status_t hal_uart_set_software_flowcontrol(hal_uart_port_t uart_port, uint8_t xon, uint8_t xoff, uint8_t escape_character)
This function sets and enables software flow control of the UART.
uint32_t receive_vfifo_buffer_size
This field represents size of the receiving VFIFO buffer.
Definition: hal_uart.h:387
Indicates if there is a transaction error when receiving data.
Definition: hal_uart.h:356
hal_uart_baudrate_t
This enum defines baud rate of the UART frame.
Definition: hal_uart.h:302
hal_uart_status_t hal_uart_deinit(hal_uart_port_t uart_port)
This function deinitializes the UART hardware to its default status.
uint32_t hal_uart_send_polling(hal_uart_port_t uart_port, const uint8_t *data, uint32_t size)
This function sends user data byte by byte in a poll mode.
hal_uart_status_t hal_uart_disable_flowcontrol(hal_uart_port_t uart_port)
This function disables flow control of the UART.
Defines UART word length as 7 bit per frame.
Definition: hal_uart.h:324
Defines UART baudrate as 115200 bps.
Definition: hal_uart.h:312
hal_uart_status_t hal_uart_register_callback(hal_uart_port_t uart_port, hal_uart_callback_t user_callback, void *user_data)
This function registers user's callback in the UART driver.
hal_uart_callback_event_t
This enum defines UART event when an interrupt occurs.
Definition: hal_uart.h:355
hal_uart_parity_t parity
This field represents the parity of UART frame.
Definition: hal_uart.h:377
uint8_t * send_vfifo_buffer
This field represents the transmitting VFIFO buffer allocated by user.
Definition: hal_uart.h:383
Defines UART baudrate as 300 bps.
Definition: hal_uart.h:304
hal_uart_status_t hal_uart_set_dma_timeout(hal_uart_port_t uart_port, uint32_t timeout)
This function sets timeout value for the UART VFIFO DMA.
Defines UART baudrate as 38400 bps.
Definition: hal_uart.h:310
void hal_uart_put_char(hal_uart_port_t uart_port, char byte)
This function places one character at a time to the UART port in a poll mode.
Indicates if there is enough data available in the RX buffer for the user to read from it...
Definition: hal_uart.h:357
hal_uart_status_t hal_uart_set_format(hal_uart_port_t uart_port, const hal_uart_config_t *config)
This function sets the UART's frame parameter.
Defines UART baudrate as 110 bps.
Definition: hal_uart.h:303
hal_uart_status_t hal_uart_set_hardware_flowcontrol(hal_uart_port_t uart_port)
This function sets and enables hardware flow control of the UART.
uint32_t hal_uart_send_dma(hal_uart_port_t uart_port, const uint8_t *data, uint32_t size)
This function sends user data in a VFIFO DMA mode.
Defines UART baudrate as 19200 bps.
Definition: hal_uart.h:309
hal_uart_status_t hal_uart_set_baudrate(hal_uart_port_t uart_port, hal_uart_baudrate_t baudrate)
This function sets a baud rate for the UART frame.
This struct defines config parameters and TX/RX buffers for the VFIFO DMA associated with a specific ...
Definition: hal_uart.h:382
Defines UART baudrate as 1200 bps.
Definition: hal_uart.h:305
hal_uart_word_length_t
This enum defines word length of UART frame.
Definition: hal_uart.h:321
hal_uart_status_t hal_uart_set_dma(hal_uart_port_t uart_port, const hal_uart_dma_config_t *dma_config)
This function sets the VFIFO DMA hardware relative to the UART.
Defines UART baudrate as 2400 bps.
Definition: hal_uart.h:306
void(* hal_uart_callback_t)(hal_uart_callback_event_t event, void *user_data)
This typedef defines user's callback function prototype.
Definition: hal_uart.h:410
Defines UART parity as even.
Definition: hal_uart.h:340
uint32_t hal_uart_get_available_send_space(hal_uart_port_t uart_port)
This function queries available space in the VFIFO TX buffer.
hal_uart_parity_t
This enum defines parity of UART frame.
Definition: hal_uart.h:337
hal_uart_stop_bit_t stop_bit
This field represents the stop bit of UART frame.
Definition: hal_uart.h:376
Defines maximum enum value of UART baudrate.
Definition: hal_uart.h:316
Defines UART baudrate as 460800 bps.
Definition: hal_uart.h:314
Defines UART baudrate as 230400 bps.
Definition: hal_uart.h:313
Defines UART word length as 5 bit per frame.
Definition: hal_uart.h:322
Defines UART stop bit as 2 bit per frame.
Definition: hal_uart.h:332
Indicates UART function executed successfully.
Definition: hal_uart.h:350
Defines UART parity as odd.
Definition: hal_uart.h:339
hal_uart_port_t
UART port index We have total 2 UART ports.
Definition: hal_platform.h:101
uint32_t receive_vfifo_alert_size
This field represents the threshold size of free space left in the VFIFO buffer that actives the UART...
Definition: hal_uart.h:389
uint8_t * receive_vfifo_buffer
This field represents the receiving VFIFO buffer allocated by the user.
Definition: hal_uart.h:386
uint32_t receive_vfifo_threshold_size
This field represents the threshold of the receiving VFIFO buffer.
Definition: hal_uart.h:388
hal_uart_stop_bit_t
This enum defines stop bit of UART frame.
Definition: hal_uart.h:330
This struct defines UART configure parameters.
Definition: hal_uart.h:373
uint32_t hal_uart_receive_polling(hal_uart_port_t uart_port, uint8_t *buffer, uint32_t size)
This function receives data byte by byte in a poll mode.