MAX32672 Peripheral Driver API
Peripheral Driver API for the MAX32672
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
qdec.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/* Define to prevent redundant inclusion */
27#ifndef LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32672_QDEC_H_
28#define LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32672_QDEC_H_
29
30/* **** Includes **** */
31#include <stdint.h>
32#include "qdec_regs.h"
33#include "mcr_regs.h"
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
45/***************************************************************************************************************
46 DATA STRUCTURES FOR QDEC INITIALIZATION
47***************************************************************************************************************/
48
52typedef enum {
57
61typedef enum {
65
69typedef enum {
79
83typedef enum {
87
91typedef enum {
101
105typedef enum {
106 MXC_QDEC_RST_ON_MAXCNT = 0,
107 MXC_QDEC_RST_ON_INDEX,
109
113typedef enum {
114 MXC_QDEC_NONE = 0,
115 MXC_QDEC_CAPTURE,
116 MXC_QDEC_COMPARE,
118
120typedef void (*mxc_qdec_cb_t)(void *req, int error);
121
122typedef struct {
124 mxc_qdec_swap_t swap;
125 mxc_qdec_filter_t sample;
126 mxc_qdec_clkdiv_t clkdiv;
127 mxc_qdec_sticky_t sticky;
130 uint32_t maxcnt;
131 uint32_t initial;
132 uint32_t compare;
133 mxc_qdec_cb_t callback;
134} mxc_qdec_req_t;
135
141int MXC_QDEC_Init(mxc_qdec_req_t *req);
142
149
155void MXC_QDEC_EnableInt(uint32_t flags);
156
162void MXC_QDEC_DisableInt(uint32_t flags);
163
170
176void MXC_QDEC_ClearFlags(uint32_t flags);
177
183void MXC_QDEC_SetMaxCount(uint32_t maxCount);
184
191
197void MXC_QDEC_SetInitial(uint32_t initial);
198
205
211void MXC_QDEC_SetCompare(uint32_t compare);
212
219
226
233
241
248
255
258#ifdef __cplusplus
259}
260#endif
261
262#endif // LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32672_QDEC_H_
#define MXC_S_QDEC_CTRL_FILTER_2_SAMPLES
Definition: qdec_regs.h:136
#define MXC_S_QDEC_CTRL_FILTER_4_SAMPLES
Definition: qdec_regs.h:140
#define MXC_S_QDEC_CTRL_FILTER_1_SAMPLE
Definition: qdec_regs.h:134
#define MXC_S_QDEC_CTRL_FILTER_3_SAMPLES
Definition: qdec_regs.h:138
mxc_qdec_clkdiv_t
Enumeration type for QDEC clock divider.
Definition: qdec.h:91
void MXC_QDEC_SetMaxCount(uint32_t maxCount)
Sets the Maximum Poisiton Count for the QDEC.
int MXC_QDEC_Shutdown(void)
Shuts down the QDEC.
int MXC_QDEC_Handler(void)
Call this function from the QDEC ISR when using Async API functions.
int MXC_QDEC_GetIndex(void)
Retrieves Index value.
void MXC_QDEC_EnableInt(uint32_t flags)
Enable specific QDEC interrupts.
void MXC_QDEC_DisableInt(uint32_t flags)
Disable specific QDEC interrupts.
mxc_qdec_swap_t
Enumeration type for QDEC Phase Swap.
Definition: qdec.h:61
void MXC_QDEC_ClearFlags(uint32_t flags)
Clear interrupt flags.
int MXC_QDEC_GetCapture(void)
Retrieves capture value.
int MXC_QDEC_GetDirection(void)
Gets the direction (Clockwise/Counter-Clockwise) of the QDEC.
int MXC_QDEC_GetFlags(void)
Retrieves current interrupt flag status.
mxc_qdec_counter_mode_t
Enumeration type for the QDEC Counter Modes.
Definition: qdec.h:52
int MXC_QDEC_Init(mxc_qdec_req_t *req)
Performs the QDEC startup procedure.
mxc_qdec_filter_t
Enumeration type for QDEC Filtering.
Definition: qdec.h:69
mxc_qdec_rst_on_t
Enumeration type for QDEC Reset on select.
Definition: qdec.h:105
mxc_qdec_sticky_t
Enumeration type for QDEC Sticky Condition.
Definition: qdec.h:83
int MXC_QDEC_GetPosition(void)
Gets the current position of the QDEC.
int MXC_QDEC_GetInitial(void)
Retrieves Initial position value.
void MXC_QDEC_SetCompare(uint32_t compare)
Sets the Compare value for the QDEC.
int MXC_QDEC_GetCompare(void)
Retrieves Compare value.
int MXC_QDEC_GetMaxCount(void)
Retrieves Maximum position value.
mxc_qdec_function_t
Enumeration type for QDEC function states.
Definition: qdec.h:113
void MXC_QDEC_SetInitial(uint32_t initial)
Sets the Initial (Minimum) Poisiton Count for the QDEC.
@ MXC_QDEC_CLKDIV_8
QDEC Scale by 1/8.
Definition: qdec.h:95
@ MXC_QDEC_CLKDIV_4
QDEC Scale by 1/4.
Definition: qdec.h:94
@ MXC_QDEC_CLKDIV_64
QDEC Scale by 1/64.
Definition: qdec.h:98
@ MXC_QDEC_CLKDIV_2
QDEC Scale by 1/2.
Definition: qdec.h:93
@ MXC_QDEC_CLKDIV_1
QDEC Scale by 1.
Definition: qdec.h:92
@ MXC_QDEC_CLKDIV_128
QDEC Scale by 1/128.
Definition: qdec.h:99
@ MXC_QDEC_CLKDIV_16
QDEC Scale by 1/16.
Definition: qdec.h:96
@ MXC_QDEC_CLKDIV_32
QDEC Scale by 1/32.
Definition: qdec.h:97
@ MXC_QDEC_SWAP_CW_B_LEADS_A
QDEC Clockwise QEB leads QEA.
Definition: qdec.h:63
@ MXC_QDEC_SWAP_CW_A_LEADS_B
QDEC Clockwise QEA leads QEB.
Definition: qdec.h:62
@ MXC_QDEC_X2_MODE
Select Channel 1.
Definition: qdec.h:54
@ MXC_QDEC_x4_MODE
Select Channel 2.
Definition: qdec.h:55
@ MXC_QDEC_X1_MODE
Select Channel 0.
Definition: qdec.h:53
@ MXC_QDEC_FILTER_2_SAMPLES
QDEC Pulse active for one clock cycle.
Definition: qdec.h:72
@ MXC_QDEC_FILTER_3_SAMPLES
QDEC Pulse active for one clock cycle.
Definition: qdec.h:74
@ MXC_QDEC_FILTER_4_SAMPLES
QDEC Pulse active for one clock cycle.
Definition: qdec.h:76
@ MXC_QDEC_FILTER_1_SAMPLE
QDEC Pulse active for one clock cycle.
Definition: qdec.h:70
@ MXC_QDEC_STICKY_PULSE
QDEC Pulse active for one clock cycle.
Definition: qdec.h:84
@ MXC_QDEC_STICKY_MIRROR
QDEC Mirror state.
Definition: qdec.h:85
Registers, Bit Masks and Bit Positions for the MCR Peripheral Module.
Registers, Bit Masks and Bit Positions for the QDEC Peripheral Module.