HPM SDK
HPMicro Software Development Kit
hpm_gwc_drv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef HPM_GWC_DRV_H
9 #define HPM_GWC_DRV_H
10 
18 #include "hpm_common.h"
19 #include "hpm_soc.h"
20 #include "hpm_gwc_regs.h"
21 
27 typedef struct gwc_ch_config {
28  bool freeze;
29  uint16_t start_col;
30  uint16_t start_row;
31  uint16_t end_col;
32  uint16_t end_row;
33  uint32_t ref_crc;
35 
39 typedef enum gwc_clk_pol {
43 
47 typedef struct gwc_config {
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
61 
70 void gwc_init(GWC_Type *ptr, gwc_config_t *cfg);
71 
77 void gwc_enable(GWC_Type *ptr);
78 
84 void gwc_disable(GWC_Type *ptr);
85 
94 static inline void gwc_enable_interrupt(GWC_Type *ptr, uint32_t mask)
95 {
96  ptr->IRQ_MASK &= ~mask;
97 }
98 
107 static inline void gwc_disable_interrupt(GWC_Type *ptr, uint32_t mask)
108 {
109  ptr->IRQ_MASK |= mask;
110 }
111 
118 static inline uint32_t gwc_get_status(GWC_Type *ptr)
119 {
120  return ptr->IRQ_STS;
121 }
122 
129 static inline void gwc_clear_status(GWC_Type *ptr, uint32_t mask)
130 {
131  ptr->IRQ_STS = mask;
132 }
133 
143 
153 void gwc_ch_init(GWC_Type *ptr, uint8_t ch_index, gwc_ch_config_t *cfg);
154 
161 static inline void gwc_ch_enable(GWC_Type *ptr, uint8_t ch_index)
162 {
163  assert(ch_index <= GWC_CHANNEL_CH15);
164  ptr->CHANNEL[ch_index].CFG0 |= GWC_CHANNEL_CFG0_ENABLE_MASK;
165 }
166 
173 static inline void gwc_ch_disable(GWC_Type *ptr, uint8_t ch_index)
174 {
175  assert(ch_index <= GWC_CHANNEL_CH15);
176  ptr->CHANNEL[ch_index].CFG0 &= ~GWC_CHANNEL_CFG0_ENABLE_MASK;
177 }
178 
185 static inline uint32_t gwc_ch_get_crc(GWC_Type *ptr, uint8_t ch_index)
186 {
187  assert(ch_index <= GWC_CHANNEL_CH15);
188  return ptr->CHANNEL[ch_index].CALCRC;
189 }
190 
191 #ifdef __cplusplus
192 }
193 #endif
194 
198 #endif /* HPM_GWC_DRV_H */
void gwc_disable(GWC_Type *ptr)
disable the gwc
Definition: hpm_gwc_drv.c:26
static void gwc_ch_enable(GWC_Type *ptr, uint8_t ch_index)
enable gwc channel
Definition: hpm_gwc_drv.h:161
static uint32_t gwc_get_status(GWC_Type *ptr)
get gwc status flag
Definition: hpm_gwc_drv.h:118
static void gwc_disable_interrupt(GWC_Type *ptr, uint32_t mask)
disable interrupts.
Definition: hpm_gwc_drv.h:107
static void gwc_clear_status(GWC_Type *ptr, uint32_t mask)
clear gwc status flag
Definition: hpm_gwc_drv.h:129
void gwc_init(GWC_Type *ptr, gwc_config_t *cfg)
init the gwc
Definition: hpm_gwc_drv.c:16
void gwc_get_default_config(gwc_config_t *cfg)
init the gwc
Definition: hpm_gwc_drv.c:11
static uint32_t gwc_ch_get_crc(GWC_Type *ptr, uint8_t ch_index)
get gwc channel calc crc
Definition: hpm_gwc_drv.h:185
gwc_clk_pol
gwc clk polarity
Definition: hpm_gwc_drv.h:39
struct gwc_config gwc_config_t
gwc config
void gwc_freeze_interrupt_control(GWC_Type *ptr)
disable change of interrupt masks
Definition: hpm_gwc_drv.c:31
static void gwc_ch_disable(GWC_Type *ptr, uint8_t ch_index)
disable gwc channel
Definition: hpm_gwc_drv.h:173
static void gwc_enable_interrupt(GWC_Type *ptr, uint32_t mask)
enable interrupts
Definition: hpm_gwc_drv.h:94
enum gwc_clk_pol gwc_clk_pol_t
gwc clk polarity
struct gwc_ch_config gwc_ch_config_t
gwc channel config
void gwc_enable(GWC_Type *ptr)
enable the gwc
Definition: hpm_gwc_drv.c:21
void gwc_ch_init(GWC_Type *ptr, uint8_t ch_index, gwc_ch_config_t *cfg)
init gwc channel
Definition: hpm_gwc_drv.c:36
@ gwc_clk_pol_normal
Definition: hpm_gwc_drv.h:40
@ gwc_clk_pol_invert
Definition: hpm_gwc_drv.h:41
#define GWC_CHANNEL_CFG0_ENABLE_MASK
Definition: hpm_gwc_regs.h:122
#define GWC_CHANNEL_CH15
Definition: hpm_gwc_regs.h:206
Definition: hpm_gwc_regs.h:12
__RW uint32_t CALCRC
Definition: hpm_gwc_regs.h:21
__RW uint32_t IRQ_MASK
Definition: hpm_gwc_regs.h:14
__RW uint32_t CFG0
Definition: hpm_gwc_regs.h:18
__RW uint32_t IRQ_STS
Definition: hpm_gwc_regs.h:15
struct GWC_Type::@598 CHANNEL[16]
gwc channel config
Definition: hpm_gwc_drv.h:27
uint16_t end_row
Definition: hpm_gwc_drv.h:32
uint32_t ref_crc
Definition: hpm_gwc_drv.h:33
uint16_t end_col
Definition: hpm_gwc_drv.h:31
uint16_t start_row
Definition: hpm_gwc_drv.h:30
bool freeze
Definition: hpm_gwc_drv.h:28
uint16_t start_col
Definition: hpm_gwc_drv.h:29
gwc config
Definition: hpm_gwc_drv.h:47
gwc_clk_pol_t clk_pol
Definition: hpm_gwc_drv.h:48