MAX32680 Peripheral Driver API
Peripheral Driver API for the MAX32680
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Modules
hart_uart.h
1
6/******************************************************************************
7 *
8 * Copyright (C) 2022-2023 Maxim Integrated Products, Inc. (now owned by
9 * Analog Devices, Inc.),
10 * Copyright (C) 2023-2024 Analog Devices, Inc.
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *
24 ******************************************************************************/
25
26#ifndef LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32680_HART_UART_H_
27#define LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32680_HART_UART_H_
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33/***** Includes *******/
34#include "stdint.h"
35#include "afe.h"
36#include "afe_adc_zero_regs.h"
37#include "afe_adc_one_regs.h"
38#include "afe_dac_regs.h"
39#include "afe_hart_regs.h"
40#include "mxc_sys.h"
41#include "mxc_assert.h"
42
43/***** Definitions *****/
44#define NORMAL_HART_TRANSCEIVE_MODE 0
45#define HART_TEST_MODE_TX_1200 1
46#define HART_TEST_MODE_TX_2200 2
47#define HART_TEST_MODE_EXTERNAL 3
48
51#define TPDLL_COMM_ERROR_INDICATOR 0x80
52#define TPDLL_VERTICAL_PARITY_ERROR 0x40
53#define TPDLL_OVERRUN_ERROR 0x20
54#define TPDLL_FRAMING_ERROR 0x10
55#define TPDLL_BUFFER_OVERFLOW_ERROR 0x02
56
58#define HART_STATE_IDLE 0
59#define HART_STATE_TRANSMIT 1
60#define HART_STATE_RECEIVE_ACTIVE 2
61
62// Note: no flag in UARTn_INT_FL register map for buffer overflow since
63// since its a SW error
64#define UART_FLAG_BUFFER_OVERFLOW_ERROR 0x80
65
67typedef void (*reset_confirm_callback_t)(void);
68
70typedef void (*enable_confirm_callback_t)(uint32_t);
71
73typedef void (*enable_indicate_callback_t)(uint32_t);
74
76typedef void (*data_confirm_callback_t)(uint8_t);
77
79typedef void (*data_indicate_callback_t)(uint8_t);
80
82typedef void (*error_indicate_callback_t)(uint8_t, uint8_t);
83
85typedef struct {
86 reset_confirm_callback_t reset_confirm_cb;
87 enable_confirm_callback_t enable_confirm_cb;
88 enable_indicate_callback_t enable_indicate_cb;
89 data_confirm_callback_t data_confirm_cb;
90 data_indicate_callback_t data_indicate_cb;
91 error_indicate_callback_t
94
95/***** Function Prototypes *****/
105int hart_uart_setup(uint32_t test_mode);
106
112void hart_uart_setup_saps(hart_uart_callbacks_t callbacks);
113
119int hart_uart_enable(void);
120
126int hart_uart_disable(void);
127
131void hart_uart_test_transmit_1200(void);
132
136void hart_uart_test_transmit_2200(void);
137
147int hart_uart_send(uint8_t *data, uint32_t length);
148
156int hart_uart_check_transmit_complete(void);
157
167int hart_uart_get_received_packet(uint8_t *buffer, uint32_t *packet_length, uint32_t *comm_errors);
168
176void hart_uart_handler(void);
177
182void hart_rts_receive_mode(void);
183
188void hart_rts_transmit_mode(void);
189
194int hart_clock_enable(void);
195
200void hart_clock_disable(void);
201
206void hart_sap_reset_request(void);
207
214int hart_sap_data_request(uint8_t data);
215
221void hart_sap_enable_request(uint32_t state);
222
225#ifdef __cplusplus
226}
227#endif
228
229#endif // LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32680_HART_UART_H_
Registers, Bit Masks and Bit Positions for the AFE_ADC_ONE Peripheral Module.
Registers, Bit Masks and Bit Positions for the AFE_ADC_ZERO Peripheral Module.
Registers, Bit Masks and Bit Positions for the AFE_DAC Peripheral Module.
Registers, Bit Masks and Bit Positions for the AFE_HART Peripheral Module.
Definition: hart_uart.h:85
error_indicate_callback_t error_indicate_cb
Definition: hart_uart.h:92
data_indicate_callback_t data_indicate_cb
Definition: hart_uart.h:90
data_confirm_callback_t data_confirm_cb
Definition: hart_uart.h:89
enable_indicate_callback_t enable_indicate_cb
Definition: hart_uart.h:88
enable_confirm_callback_t enable_confirm_cb
Definition: hart_uart.h:87
reset_confirm_callback_t reset_confirm_cb
Definition: hart_uart.h:86