PAN1080 Peripheral API
pan_qdec.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021 Panchip Technology Corp. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
15#ifndef __PAN_QDEC_H__
16#define __PAN_QDEC_H__
22#ifdef __cplusplus
23extern "C"
24{
25#endif
26
27
28#define QDEC_FUNC_ALL (0XFF)
29#define QDEC_FUNC_ALL_EXCEPT_WK (0XBF)
36#define QDEC_POLARITY_HIGH (1)
37#define QDEC_POLARITY_LOW (0)
43#define QDEC_CNT_IDX_X (0)
44#define QDEC_CNT_IDX_Y (1)
45#define QDEC_CNT_IDX_Z (2)
51#define QDEC_MAX_CNT_RESOLUTION (3)
52#define QDEC_CNT_RESOLUTION_1X (0)
53#define QDEC_CNT_RESOLUTION_2X (1)
54#define QDEC_CNT_RESOLUTION_4X (2)
60#define QDEC_MAX_FILTER_NUM (7)
61#define QDEC_FILTER_PERIOD_1 (0)
62#define QDEC_FILTER_PERIOD_2 (1)
63#define QDEC_FILTER_PERIOD_3 (2)
64#define QDEC_FILTER_PERIOD_4 (3)
65#define QDEC_FILTER_PERIOD_5 (4)
66#define QDEC_FILTER_PERIOD_6 (5)
67#define QDEC_FILTER_PERIOD_7 (6)
68#define QDEC_FILTER_PERIOD_8 (7)
85__STATIC_INLINE void QDEC_Enable(FunctionalState NewState,uint32_t func)
86{
87 (NewState != DISABLE)?(QDEC->QDEC_EN |= func):(QDEC->QDEC_EN &= ~func);
88}
89
101__STATIC_INLINE bool QDEC_IsIntOccured(uint32_t intMsk)
102{
103 return ((QDEC->QDEC_INT_FLAG & intMsk) == intMsk)?(true):(false);
104}
105
117__STATIC_INLINE void QDEC_ClearIntFlag(uint32_t intMsk)
118{
119 QDEC->QDEC_INT_FLAG |= intMsk;
120}
121
133__STATIC_INLINE bool QDEC_IsRawIntOccured(uint32_t intMsk)
134{
135 return ((QDEC->QDEC_INT_RAW & intMsk) == intMsk)?(true):(false);
136}
137
149__STATIC_INLINE void QDEC_ClearRawIntFlag(uint32_t intMsk)
150{
151 QDEC->QDEC_INT_RAW |= intMsk;
152}
153
167__STATIC_INLINE void QDEC_ClearIntMsk(uint32_t intMsk,FunctionalState NewState)
168{
169 (NewState)?(QDEC->QDEC_CTL |= intMsk):(QDEC->QDEC_CTL &= ~intMsk);
170}
171
172
180__STATIC_INLINE void QDEC_SetPolarity(uint8_t polarity)
181{
182 (QDEC_POLARITY_HIGH == polarity)?(QDEC->QDEC_CTL |= QDEC_INDEX_POLARITY_Msk):(QDEC->QDEC_CTL &= ~QDEC_INDEX_POLARITY_Msk);
183}
184
185
195__STATIC_INLINE uint32_t QDEC_GetEventCnt(uint8_t idx)
196{
197 return ((uint32_t*)(&QDEC->QDEC_X_CNT))[idx] & QDEC_CNT_VALUE_Msk;
198}
199
209__STATIC_INLINE uint32_t QDEC_ClearEventCnt(uint8_t idx)
210{
211 return ((uint32_t*)(&QDEC->QDEC_X_CNT))[idx] | QDEC_CNT_CLEAR_Msk;
212}
213
222void QDEC_SetCntResolution(uint8_t resolution);
223
237void QDEC_SetFilterThreshold(uint8_t threshold);
238
244void QDEC_SetEventThreshold(uint16_t threshold);
245
246
248#ifdef __cplusplus
249}
250#endif
251
252#endif
#define QDEC_POLARITY_HIGH
Definition: pan_qdec.h:36
__STATIC_INLINE bool QDEC_IsRawIntOccured(uint32_t intMsk)
This function adjust qdec raw interrupt occured or not.
Definition: pan_qdec.h:133
__STATIC_INLINE uint32_t QDEC_GetEventCnt(uint8_t idx)
This function used to get event count value.
Definition: pan_qdec.h:195
__STATIC_INLINE void QDEC_Enable(FunctionalState NewState, uint32_t func)
This function is set qdec enable bit.
Definition: pan_qdec.h:85
__STATIC_INLINE bool QDEC_IsIntOccured(uint32_t intMsk)
This function adjust qdec interrupt occured or not.
Definition: pan_qdec.h:101
__STATIC_INLINE void QDEC_ClearIntFlag(uint32_t intMsk)
This function clear qdec interrupt flag.
Definition: pan_qdec.h:117
__STATIC_INLINE void QDEC_ClearIntMsk(uint32_t intMsk, FunctionalState NewState)
This function used to set interrupt mask, if masked,qdec int flag will not be placed.
Definition: pan_qdec.h:167
void QDEC_SetEventThreshold(uint16_t threshold)
This function used to set event threshold.
__STATIC_INLINE void QDEC_SetPolarity(uint8_t polarity)
This function used to set index polarity.
Definition: pan_qdec.h:180
void QDEC_SetCntResolution(uint8_t resolution)
This function used to set count resolution.
void QDEC_SetFilterThreshold(uint8_t threshold)
This function used to set filter threshold.
__STATIC_INLINE uint32_t QDEC_ClearEventCnt(uint8_t idx)
This function used to clear event count value.
Definition: pan_qdec.h:209
__STATIC_INLINE void QDEC_ClearRawIntFlag(uint32_t intMsk)
This function clear qdec raw interrupt flag.
Definition: pan_qdec.h:149