9ceb218f80
Co-authored-by: Cursor <cursoragent@cursor.com>
69 lines
2.7 KiB
C
69 lines
2.7 KiB
C
/*!
|
|
\file usart.h
|
|
\brief the header file of USART
|
|
|
|
\version 2025-01-24, V1.4.0, firmware for GD32H7xx
|
|
*/
|
|
|
|
/*
|
|
Copyright (c) 2025, GigaDevice Semiconductor Inc.
|
|
|
|
Redistribution and use in source and binary forms, with or without modification,
|
|
are permitted provided that the following conditions are met:
|
|
|
|
1. Redistributions of source code must retain the above copyright notice, this
|
|
list of conditions and the following disclaimer.
|
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
this list of conditions and the following disclaimer in the documentation
|
|
and/or other materials provided with the distribution.
|
|
3. Neither the name of the copyright holder nor the names of its contributors
|
|
may be used to endorse or promote products derived from this software without
|
|
specific prior written permission.
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
|
OF SUCH DAMAGE.
|
|
*/
|
|
|
|
#ifndef USART_H
|
|
#define USART_H
|
|
|
|
#include <stdint.h>
|
|
#include "main.h"
|
|
#include "publicdata/public_define.h"
|
|
|
|
typedef enum{
|
|
E_USART_0 = 0,
|
|
E_USART_2 = 2,
|
|
E_USART_3 = 3,
|
|
E_USART_4 = 4,
|
|
E_USART_5 = 5,
|
|
E_USART_6 = 6,
|
|
E_USART_7 = 7
|
|
}E_USART_ID;
|
|
|
|
/* 批量初始化所有串口 */
|
|
int v_usart_init_all(void);
|
|
|
|
/* 兼容层原子接口(meter_coll_task 等模块直接调用) */
|
|
int v_usart_send_data(uint8_t usart_num, uint8_t *data, uint16_t len);
|
|
int v_usart_read_rx_buffer(uint8_t usart_num, uint8_t *data, uint16_t len);
|
|
|
|
/* 对外二进制收发统一接口 */
|
|
uint16_t u16_usart_recv(E_USART_ID usart_id ,uint8_t* u8_recvBuf ,uint16_t u16_len);
|
|
uint16_t u16_usart_send(E_USART_ID usart_id ,uint8_t* u8_sendBuf ,uint16_t u16_len);
|
|
void printf_hex(const char *mag , U8_T *data , U16_T len);
|
|
|
|
/* Shell: usart_printf <slot 0~6> <0|1> 对应物理口 USART0,USART2,3,4,5,6,7;与 CCU601E_D 行为一致,按 slot 下标。 */
|
|
#define USART_NUM_PRINT_CNT (7U)
|
|
extern U8_T u8_uasrt_print[USART_NUM_PRINT_CNT];
|
|
|
|
#endif /* USART_H */
|