1 /* 2 * Copyright (c) 2021-2022 HPMicro 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 * 6 */ 7 8 9 #ifndef HPM_PDM_H 10 #define HPM_PDM_H 11 12 typedef struct { 13 __RW uint32_t CTRL; /* 0x0: Control Register */ 14 __RW uint32_t CH_CTRL; /* 0x4: Channel Control Register */ 15 __W uint32_t ST; /* 0x8: Status Register */ 16 __RW uint32_t CH_CFG; /* 0xC: Channel Configuration Register */ 17 __RW uint32_t CIC_CFG; /* 0x10: CIC configuration register */ 18 __RW uint32_t CTRL_INBUF; /* 0x14: In Buf Control Register */ 19 __RW uint32_t CTRL_FILT0; /* 0x18: Filter 0 Control Register */ 20 __RW uint32_t CTRL_FILT1; /* 0x1C: Filter 1 Control Register */ 21 __RW uint32_t RUN; /* 0x20: Run Register */ 22 __RW uint32_t MEMADDR; /* 0x24: Memory Access Address */ 23 __RW uint32_t MEMDATA; /* 0x28: Memory Access Data */ 24 __RW uint32_t HPF_MA; /* 0x2C: HPF A Coef Register */ 25 __RW uint32_t HPF_B; /* 0x30: HPF B Coef Register */ 26 } PDM_Type; 27 28 29 /* Bitfield definition for register: CTRL */ 30 /* 31 * SFTRST (RW) 32 * 33 * software reset the module. Self-clear. 34 */ 35 #define PDM_CTRL_SFTRST_MASK (0x80000000UL) 36 #define PDM_CTRL_SFTRST_SHIFT (31U) 37 #define PDM_CTRL_SFTRST_SET(x) (((uint32_t)(x) << PDM_CTRL_SFTRST_SHIFT) & PDM_CTRL_SFTRST_MASK) 38 #define PDM_CTRL_SFTRST_GET(x) (((uint32_t)(x) & PDM_CTRL_SFTRST_MASK) >> PDM_CTRL_SFTRST_SHIFT) 39 40 /* 41 * SOF_FEDGE (RW) 42 * 43 * asserted if the falling edge of the ref fclk from DAO is the start of a new frame. This is used to to align DAO feedback signal. 44 */ 45 #define PDM_CTRL_SOF_FEDGE_MASK (0x800000UL) 46 #define PDM_CTRL_SOF_FEDGE_SHIFT (23U) 47 #define PDM_CTRL_SOF_FEDGE_SET(x) (((uint32_t)(x) << PDM_CTRL_SOF_FEDGE_SHIFT) & PDM_CTRL_SOF_FEDGE_MASK) 48 #define PDM_CTRL_SOF_FEDGE_GET(x) (((uint32_t)(x) & PDM_CTRL_SOF_FEDGE_MASK) >> PDM_CTRL_SOF_FEDGE_SHIFT) 49 50 /* 51 * USE_COEF_RAM (RW) 52 * 53 * Asserted to use Coef RAM instead of Coef ROM 54 */ 55 #define PDM_CTRL_USE_COEF_RAM_MASK (0x100000UL) 56 #define PDM_CTRL_USE_COEF_RAM_SHIFT (20U) 57 #define PDM_CTRL_USE_COEF_RAM_SET(x) (((uint32_t)(x) << PDM_CTRL_USE_COEF_RAM_SHIFT) & PDM_CTRL_USE_COEF_RAM_MASK) 58 #define PDM_CTRL_USE_COEF_RAM_GET(x) (((uint32_t)(x) & PDM_CTRL_USE_COEF_RAM_MASK) >> PDM_CTRL_USE_COEF_RAM_SHIFT) 59 60 /* 61 * FILT_CRX_ERR_IE (RW) 62 * 63 * data accessed out of boundary error interruput enable. The error happens when the module cannot calculate the enough number of data in time. 64 */ 65 #define PDM_CTRL_FILT_CRX_ERR_IE_MASK (0x80000UL) 66 #define PDM_CTRL_FILT_CRX_ERR_IE_SHIFT (19U) 67 #define PDM_CTRL_FILT_CRX_ERR_IE_SET(x) (((uint32_t)(x) << PDM_CTRL_FILT_CRX_ERR_IE_SHIFT) & PDM_CTRL_FILT_CRX_ERR_IE_MASK) 68 #define PDM_CTRL_FILT_CRX_ERR_IE_GET(x) (((uint32_t)(x) & PDM_CTRL_FILT_CRX_ERR_IE_MASK) >> PDM_CTRL_FILT_CRX_ERR_IE_SHIFT) 69 70 /* 71 * OFIFO_OVFL_ERR_IE (RW) 72 * 73 * output fifo overflow error interrupt enable 74 */ 75 #define PDM_CTRL_OFIFO_OVFL_ERR_IE_MASK (0x40000UL) 76 #define PDM_CTRL_OFIFO_OVFL_ERR_IE_SHIFT (18U) 77 #define PDM_CTRL_OFIFO_OVFL_ERR_IE_SET(x) (((uint32_t)(x) << PDM_CTRL_OFIFO_OVFL_ERR_IE_SHIFT) & PDM_CTRL_OFIFO_OVFL_ERR_IE_MASK) 78 #define PDM_CTRL_OFIFO_OVFL_ERR_IE_GET(x) (((uint32_t)(x) & PDM_CTRL_OFIFO_OVFL_ERR_IE_MASK) >> PDM_CTRL_OFIFO_OVFL_ERR_IE_SHIFT) 79 80 /* 81 * CIC_OVLD_ERR_IE (RW) 82 * 83 * CIC overload error interrupt enable 84 */ 85 #define PDM_CTRL_CIC_OVLD_ERR_IE_MASK (0x20000UL) 86 #define PDM_CTRL_CIC_OVLD_ERR_IE_SHIFT (17U) 87 #define PDM_CTRL_CIC_OVLD_ERR_IE_SET(x) (((uint32_t)(x) << PDM_CTRL_CIC_OVLD_ERR_IE_SHIFT) & PDM_CTRL_CIC_OVLD_ERR_IE_MASK) 88 #define PDM_CTRL_CIC_OVLD_ERR_IE_GET(x) (((uint32_t)(x) & PDM_CTRL_CIC_OVLD_ERR_IE_MASK) >> PDM_CTRL_CIC_OVLD_ERR_IE_SHIFT) 89 90 /* 91 * CIC_SAT_ERR_IE (RW) 92 * 93 * Error interrupt enable 94 * This bit controls the generation of an interrupt when an error condition (CIC saturation) occurs. 95 * 0: Error interrupt is masked 96 * 1: Error interrupt is enabled 97 */ 98 #define PDM_CTRL_CIC_SAT_ERR_IE_MASK (0x10000UL) 99 #define PDM_CTRL_CIC_SAT_ERR_IE_SHIFT (16U) 100 #define PDM_CTRL_CIC_SAT_ERR_IE_SET(x) (((uint32_t)(x) << PDM_CTRL_CIC_SAT_ERR_IE_SHIFT) & PDM_CTRL_CIC_SAT_ERR_IE_MASK) 101 #define PDM_CTRL_CIC_SAT_ERR_IE_GET(x) (((uint32_t)(x) & PDM_CTRL_CIC_SAT_ERR_IE_MASK) >> PDM_CTRL_CIC_SAT_ERR_IE_SHIFT) 102 103 /* 104 * DEC_AFT_CIC (RW) 105 * 106 * decimation rate after CIC. Now it is forced to be 3. 107 */ 108 #define PDM_CTRL_DEC_AFT_CIC_MASK (0xF000U) 109 #define PDM_CTRL_DEC_AFT_CIC_SHIFT (12U) 110 #define PDM_CTRL_DEC_AFT_CIC_SET(x) (((uint32_t)(x) << PDM_CTRL_DEC_AFT_CIC_SHIFT) & PDM_CTRL_DEC_AFT_CIC_MASK) 111 #define PDM_CTRL_DEC_AFT_CIC_GET(x) (((uint32_t)(x) & PDM_CTRL_DEC_AFT_CIC_MASK) >> PDM_CTRL_DEC_AFT_CIC_SHIFT) 112 113 /* 114 * CAPT_DLY (RW) 115 * 116 * Capture cycle delay>=0, should be less than PDM_CLK_HFDIV 117 */ 118 #define PDM_CTRL_CAPT_DLY_MASK (0x780U) 119 #define PDM_CTRL_CAPT_DLY_SHIFT (7U) 120 #define PDM_CTRL_CAPT_DLY_SET(x) (((uint32_t)(x) << PDM_CTRL_CAPT_DLY_SHIFT) & PDM_CTRL_CAPT_DLY_MASK) 121 #define PDM_CTRL_CAPT_DLY_GET(x) (((uint32_t)(x) & PDM_CTRL_CAPT_DLY_MASK) >> PDM_CTRL_CAPT_DLY_SHIFT) 122 123 /* 124 * PDM_CLK_HFDIV (RW) 125 * 126 * The clock divider will work at least 4. 127 * 0: div-by-2, 128 * 1: div-by-4 129 * . . . 130 * n: div-by-2*(n+1) 131 */ 132 #define PDM_CTRL_PDM_CLK_HFDIV_MASK (0x78U) 133 #define PDM_CTRL_PDM_CLK_HFDIV_SHIFT (3U) 134 #define PDM_CTRL_PDM_CLK_HFDIV_SET(x) (((uint32_t)(x) << PDM_CTRL_PDM_CLK_HFDIV_SHIFT) & PDM_CTRL_PDM_CLK_HFDIV_MASK) 135 #define PDM_CTRL_PDM_CLK_HFDIV_GET(x) (((uint32_t)(x) & PDM_CTRL_PDM_CLK_HFDIV_MASK) >> PDM_CTRL_PDM_CLK_HFDIV_SHIFT) 136 137 /* 138 * PDM_CLK_DIV_BYPASS (RW) 139 * 140 * asserted to bypass the pdm clock divider 141 */ 142 #define PDM_CTRL_PDM_CLK_DIV_BYPASS_MASK (0x4U) 143 #define PDM_CTRL_PDM_CLK_DIV_BYPASS_SHIFT (2U) 144 #define PDM_CTRL_PDM_CLK_DIV_BYPASS_SET(x) (((uint32_t)(x) << PDM_CTRL_PDM_CLK_DIV_BYPASS_SHIFT) & PDM_CTRL_PDM_CLK_DIV_BYPASS_MASK) 145 #define PDM_CTRL_PDM_CLK_DIV_BYPASS_GET(x) (((uint32_t)(x) & PDM_CTRL_PDM_CLK_DIV_BYPASS_MASK) >> PDM_CTRL_PDM_CLK_DIV_BYPASS_SHIFT) 146 147 /* 148 * PDM_CLK_OE (RW) 149 * 150 * pdm_clk_output_en 151 */ 152 #define PDM_CTRL_PDM_CLK_OE_MASK (0x2U) 153 #define PDM_CTRL_PDM_CLK_OE_SHIFT (1U) 154 #define PDM_CTRL_PDM_CLK_OE_SET(x) (((uint32_t)(x) << PDM_CTRL_PDM_CLK_OE_SHIFT) & PDM_CTRL_PDM_CLK_OE_MASK) 155 #define PDM_CTRL_PDM_CLK_OE_GET(x) (((uint32_t)(x) & PDM_CTRL_PDM_CLK_OE_MASK) >> PDM_CTRL_PDM_CLK_OE_SHIFT) 156 157 /* 158 * HPF_EN (RW) 159 * 160 * pdm high pass filter enable. This order-1 HPF only applies to the PDM mic data. 161 */ 162 #define PDM_CTRL_HPF_EN_MASK (0x1U) 163 #define PDM_CTRL_HPF_EN_SHIFT (0U) 164 #define PDM_CTRL_HPF_EN_SET(x) (((uint32_t)(x) << PDM_CTRL_HPF_EN_SHIFT) & PDM_CTRL_HPF_EN_MASK) 165 #define PDM_CTRL_HPF_EN_GET(x) (((uint32_t)(x) & PDM_CTRL_HPF_EN_MASK) >> PDM_CTRL_HPF_EN_SHIFT) 166 167 /* Bitfield definition for register: CH_CTRL */ 168 /* 169 * CH_POL (RW) 170 * 171 * Asserted to select PDM_CLK high level captured, otherwise to select PDM_CLK low level captured. 172 */ 173 #define PDM_CH_CTRL_CH_POL_MASK (0xFF0000UL) 174 #define PDM_CH_CTRL_CH_POL_SHIFT (16U) 175 #define PDM_CH_CTRL_CH_POL_SET(x) (((uint32_t)(x) << PDM_CH_CTRL_CH_POL_SHIFT) & PDM_CH_CTRL_CH_POL_MASK) 176 #define PDM_CH_CTRL_CH_POL_GET(x) (((uint32_t)(x) & PDM_CH_CTRL_CH_POL_MASK) >> PDM_CH_CTRL_CH_POL_SHIFT) 177 178 /* 179 * CH_EN (RW) 180 * 181 * Asserted to enable the channel. 182 * Ch8 & 9 are refs. 183 * Ch0-7 are pdm mics. 184 */ 185 #define PDM_CH_CTRL_CH_EN_MASK (0x3FFU) 186 #define PDM_CH_CTRL_CH_EN_SHIFT (0U) 187 #define PDM_CH_CTRL_CH_EN_SET(x) (((uint32_t)(x) << PDM_CH_CTRL_CH_EN_SHIFT) & PDM_CH_CTRL_CH_EN_MASK) 188 #define PDM_CH_CTRL_CH_EN_GET(x) (((uint32_t)(x) & PDM_CH_CTRL_CH_EN_MASK) >> PDM_CH_CTRL_CH_EN_SHIFT) 189 190 /* Bitfield definition for register: ST */ 191 /* 192 * FILT_CRX_ERR (W1C) 193 * 194 * data accessed out of boundary error 195 */ 196 #define PDM_ST_FILT_CRX_ERR_MASK (0x8U) 197 #define PDM_ST_FILT_CRX_ERR_SHIFT (3U) 198 #define PDM_ST_FILT_CRX_ERR_SET(x) (((uint32_t)(x) << PDM_ST_FILT_CRX_ERR_SHIFT) & PDM_ST_FILT_CRX_ERR_MASK) 199 #define PDM_ST_FILT_CRX_ERR_GET(x) (((uint32_t)(x) & PDM_ST_FILT_CRX_ERR_MASK) >> PDM_ST_FILT_CRX_ERR_SHIFT) 200 201 /* 202 * OFIFO_OVFL_ERR (W1C) 203 * 204 * output fifo overflow error. The reason may be sampling frequency mismatch, either fast or slow. 205 */ 206 #define PDM_ST_OFIFO_OVFL_ERR_MASK (0x4U) 207 #define PDM_ST_OFIFO_OVFL_ERR_SHIFT (2U) 208 #define PDM_ST_OFIFO_OVFL_ERR_SET(x) (((uint32_t)(x) << PDM_ST_OFIFO_OVFL_ERR_SHIFT) & PDM_ST_OFIFO_OVFL_ERR_MASK) 209 #define PDM_ST_OFIFO_OVFL_ERR_GET(x) (((uint32_t)(x) & PDM_ST_OFIFO_OVFL_ERR_MASK) >> PDM_ST_OFIFO_OVFL_ERR_SHIFT) 210 211 /* 212 * CIC_OVLD_ERR (W1C) 213 * 214 * CIC overload error. write 1 clear 215 */ 216 #define PDM_ST_CIC_OVLD_ERR_MASK (0x2U) 217 #define PDM_ST_CIC_OVLD_ERR_SHIFT (1U) 218 #define PDM_ST_CIC_OVLD_ERR_SET(x) (((uint32_t)(x) << PDM_ST_CIC_OVLD_ERR_SHIFT) & PDM_ST_CIC_OVLD_ERR_MASK) 219 #define PDM_ST_CIC_OVLD_ERR_GET(x) (((uint32_t)(x) & PDM_ST_CIC_OVLD_ERR_MASK) >> PDM_ST_CIC_OVLD_ERR_SHIFT) 220 221 /* 222 * CIC_SAT_ERR (W1C) 223 * 224 * CIC saturation. Write 1 clear 225 */ 226 #define PDM_ST_CIC_SAT_ERR_MASK (0x1U) 227 #define PDM_ST_CIC_SAT_ERR_SHIFT (0U) 228 #define PDM_ST_CIC_SAT_ERR_SET(x) (((uint32_t)(x) << PDM_ST_CIC_SAT_ERR_SHIFT) & PDM_ST_CIC_SAT_ERR_MASK) 229 #define PDM_ST_CIC_SAT_ERR_GET(x) (((uint32_t)(x) & PDM_ST_CIC_SAT_ERR_MASK) >> PDM_ST_CIC_SAT_ERR_SHIFT) 230 231 /* Bitfield definition for register: CH_CFG */ 232 /* 233 * CH9_TYPE (RW) 234 * 235 */ 236 #define PDM_CH_CFG_CH9_TYPE_MASK (0xC0000UL) 237 #define PDM_CH_CFG_CH9_TYPE_SHIFT (18U) 238 #define PDM_CH_CFG_CH9_TYPE_SET(x) (((uint32_t)(x) << PDM_CH_CFG_CH9_TYPE_SHIFT) & PDM_CH_CFG_CH9_TYPE_MASK) 239 #define PDM_CH_CFG_CH9_TYPE_GET(x) (((uint32_t)(x) & PDM_CH_CFG_CH9_TYPE_MASK) >> PDM_CH_CFG_CH9_TYPE_SHIFT) 240 241 /* 242 * CH8_TYPE (RW) 243 * 244 */ 245 #define PDM_CH_CFG_CH8_TYPE_MASK (0x30000UL) 246 #define PDM_CH_CFG_CH8_TYPE_SHIFT (16U) 247 #define PDM_CH_CFG_CH8_TYPE_SET(x) (((uint32_t)(x) << PDM_CH_CFG_CH8_TYPE_SHIFT) & PDM_CH_CFG_CH8_TYPE_MASK) 248 #define PDM_CH_CFG_CH8_TYPE_GET(x) (((uint32_t)(x) & PDM_CH_CFG_CH8_TYPE_MASK) >> PDM_CH_CFG_CH8_TYPE_SHIFT) 249 250 /* 251 * CH7_TYPE (RW) 252 * 253 */ 254 #define PDM_CH_CFG_CH7_TYPE_MASK (0xC000U) 255 #define PDM_CH_CFG_CH7_TYPE_SHIFT (14U) 256 #define PDM_CH_CFG_CH7_TYPE_SET(x) (((uint32_t)(x) << PDM_CH_CFG_CH7_TYPE_SHIFT) & PDM_CH_CFG_CH7_TYPE_MASK) 257 #define PDM_CH_CFG_CH7_TYPE_GET(x) (((uint32_t)(x) & PDM_CH_CFG_CH7_TYPE_MASK) >> PDM_CH_CFG_CH7_TYPE_SHIFT) 258 259 /* 260 * CH6_TYPE (RW) 261 * 262 */ 263 #define PDM_CH_CFG_CH6_TYPE_MASK (0x3000U) 264 #define PDM_CH_CFG_CH6_TYPE_SHIFT (12U) 265 #define PDM_CH_CFG_CH6_TYPE_SET(x) (((uint32_t)(x) << PDM_CH_CFG_CH6_TYPE_SHIFT) & PDM_CH_CFG_CH6_TYPE_MASK) 266 #define PDM_CH_CFG_CH6_TYPE_GET(x) (((uint32_t)(x) & PDM_CH_CFG_CH6_TYPE_MASK) >> PDM_CH_CFG_CH6_TYPE_SHIFT) 267 268 /* 269 * CH5_TYPE (RW) 270 * 271 */ 272 #define PDM_CH_CFG_CH5_TYPE_MASK (0xC00U) 273 #define PDM_CH_CFG_CH5_TYPE_SHIFT (10U) 274 #define PDM_CH_CFG_CH5_TYPE_SET(x) (((uint32_t)(x) << PDM_CH_CFG_CH5_TYPE_SHIFT) & PDM_CH_CFG_CH5_TYPE_MASK) 275 #define PDM_CH_CFG_CH5_TYPE_GET(x) (((uint32_t)(x) & PDM_CH_CFG_CH5_TYPE_MASK) >> PDM_CH_CFG_CH5_TYPE_SHIFT) 276 277 /* 278 * CH4_TYPE (RW) 279 * 280 */ 281 #define PDM_CH_CFG_CH4_TYPE_MASK (0x300U) 282 #define PDM_CH_CFG_CH4_TYPE_SHIFT (8U) 283 #define PDM_CH_CFG_CH4_TYPE_SET(x) (((uint32_t)(x) << PDM_CH_CFG_CH4_TYPE_SHIFT) & PDM_CH_CFG_CH4_TYPE_MASK) 284 #define PDM_CH_CFG_CH4_TYPE_GET(x) (((uint32_t)(x) & PDM_CH_CFG_CH4_TYPE_MASK) >> PDM_CH_CFG_CH4_TYPE_SHIFT) 285 286 /* 287 * CH3_TYPE (RW) 288 * 289 */ 290 #define PDM_CH_CFG_CH3_TYPE_MASK (0xC0U) 291 #define PDM_CH_CFG_CH3_TYPE_SHIFT (6U) 292 #define PDM_CH_CFG_CH3_TYPE_SET(x) (((uint32_t)(x) << PDM_CH_CFG_CH3_TYPE_SHIFT) & PDM_CH_CFG_CH3_TYPE_MASK) 293 #define PDM_CH_CFG_CH3_TYPE_GET(x) (((uint32_t)(x) & PDM_CH_CFG_CH3_TYPE_MASK) >> PDM_CH_CFG_CH3_TYPE_SHIFT) 294 295 /* 296 * CH2_TYPE (RW) 297 * 298 */ 299 #define PDM_CH_CFG_CH2_TYPE_MASK (0x30U) 300 #define PDM_CH_CFG_CH2_TYPE_SHIFT (4U) 301 #define PDM_CH_CFG_CH2_TYPE_SET(x) (((uint32_t)(x) << PDM_CH_CFG_CH2_TYPE_SHIFT) & PDM_CH_CFG_CH2_TYPE_MASK) 302 #define PDM_CH_CFG_CH2_TYPE_GET(x) (((uint32_t)(x) & PDM_CH_CFG_CH2_TYPE_MASK) >> PDM_CH_CFG_CH2_TYPE_SHIFT) 303 304 /* 305 * CH1_TYPE (RW) 306 * 307 */ 308 #define PDM_CH_CFG_CH1_TYPE_MASK (0xCU) 309 #define PDM_CH_CFG_CH1_TYPE_SHIFT (2U) 310 #define PDM_CH_CFG_CH1_TYPE_SET(x) (((uint32_t)(x) << PDM_CH_CFG_CH1_TYPE_SHIFT) & PDM_CH_CFG_CH1_TYPE_MASK) 311 #define PDM_CH_CFG_CH1_TYPE_GET(x) (((uint32_t)(x) & PDM_CH_CFG_CH1_TYPE_MASK) >> PDM_CH_CFG_CH1_TYPE_SHIFT) 312 313 /* 314 * CH0_TYPE (RW) 315 * 316 * Type of Channel 0 317 * 2'b00: dec-by-3 wiith filter type0 (CIC Compenstation+norm filter) 318 * 2'b01: dec-by-3 with filter type 1 (No CIC compenstation, only norm filter) 319 */ 320 #define PDM_CH_CFG_CH0_TYPE_MASK (0x3U) 321 #define PDM_CH_CFG_CH0_TYPE_SHIFT (0U) 322 #define PDM_CH_CFG_CH0_TYPE_SET(x) (((uint32_t)(x) << PDM_CH_CFG_CH0_TYPE_SHIFT) & PDM_CH_CFG_CH0_TYPE_MASK) 323 #define PDM_CH_CFG_CH0_TYPE_GET(x) (((uint32_t)(x) & PDM_CH_CFG_CH0_TYPE_MASK) >> PDM_CH_CFG_CH0_TYPE_SHIFT) 324 325 /* Bitfield definition for register: CIC_CFG */ 326 /* 327 * POST_SCALE (RW) 328 * 329 * the shift value after CIC results. 330 */ 331 #define PDM_CIC_CFG_POST_SCALE_MASK (0xFC00U) 332 #define PDM_CIC_CFG_POST_SCALE_SHIFT (10U) 333 #define PDM_CIC_CFG_POST_SCALE_SET(x) (((uint32_t)(x) << PDM_CIC_CFG_POST_SCALE_SHIFT) & PDM_CIC_CFG_POST_SCALE_MASK) 334 #define PDM_CIC_CFG_POST_SCALE_GET(x) (((uint32_t)(x) & PDM_CIC_CFG_POST_SCALE_MASK) >> PDM_CIC_CFG_POST_SCALE_SHIFT) 335 336 /* 337 * SGD (RW) 338 * 339 * Sigma_delta_order[1:0] 340 * 2'b00: 7 341 * 2'b01: 6 342 * 2'b10: 5 343 * Others: unused 344 */ 345 #define PDM_CIC_CFG_SGD_MASK (0x300U) 346 #define PDM_CIC_CFG_SGD_SHIFT (8U) 347 #define PDM_CIC_CFG_SGD_SET(x) (((uint32_t)(x) << PDM_CIC_CFG_SGD_SHIFT) & PDM_CIC_CFG_SGD_MASK) 348 #define PDM_CIC_CFG_SGD_GET(x) (((uint32_t)(x) & PDM_CIC_CFG_SGD_MASK) >> PDM_CIC_CFG_SGD_SHIFT) 349 350 /* 351 * CIC_DEC_RATIO (RW) 352 * 353 * CIC decimation factor 354 */ 355 #define PDM_CIC_CFG_CIC_DEC_RATIO_MASK (0xFFU) 356 #define PDM_CIC_CFG_CIC_DEC_RATIO_SHIFT (0U) 357 #define PDM_CIC_CFG_CIC_DEC_RATIO_SET(x) (((uint32_t)(x) << PDM_CIC_CFG_CIC_DEC_RATIO_SHIFT) & PDM_CIC_CFG_CIC_DEC_RATIO_MASK) 358 #define PDM_CIC_CFG_CIC_DEC_RATIO_GET(x) (((uint32_t)(x) & PDM_CIC_CFG_CIC_DEC_RATIO_MASK) >> PDM_CIC_CFG_CIC_DEC_RATIO_SHIFT) 359 360 /* Bitfield definition for register: CTRL_INBUF */ 361 /* 362 * MAX_PTR (RW) 363 * 364 * The buf size-1 for each channel 365 */ 366 #define PDM_CTRL_INBUF_MAX_PTR_MASK (0x3FC00000UL) 367 #define PDM_CTRL_INBUF_MAX_PTR_SHIFT (22U) 368 #define PDM_CTRL_INBUF_MAX_PTR_SET(x) (((uint32_t)(x) << PDM_CTRL_INBUF_MAX_PTR_SHIFT) & PDM_CTRL_INBUF_MAX_PTR_MASK) 369 #define PDM_CTRL_INBUF_MAX_PTR_GET(x) (((uint32_t)(x) & PDM_CTRL_INBUF_MAX_PTR_MASK) >> PDM_CTRL_INBUF_MAX_PTR_SHIFT) 370 371 /* 372 * PITCH (RW) 373 * 374 * The spacing between starting address of adjacent channels 375 */ 376 #define PDM_CTRL_INBUF_PITCH_MASK (0x3FF800UL) 377 #define PDM_CTRL_INBUF_PITCH_SHIFT (11U) 378 #define PDM_CTRL_INBUF_PITCH_SET(x) (((uint32_t)(x) << PDM_CTRL_INBUF_PITCH_SHIFT) & PDM_CTRL_INBUF_PITCH_MASK) 379 #define PDM_CTRL_INBUF_PITCH_GET(x) (((uint32_t)(x) & PDM_CTRL_INBUF_PITCH_MASK) >> PDM_CTRL_INBUF_PITCH_SHIFT) 380 381 /* 382 * START_ADDR (RW) 383 * 384 * The starting address of channel 0 in filter data buffer 385 */ 386 #define PDM_CTRL_INBUF_START_ADDR_MASK (0x7FFU) 387 #define PDM_CTRL_INBUF_START_ADDR_SHIFT (0U) 388 #define PDM_CTRL_INBUF_START_ADDR_SET(x) (((uint32_t)(x) << PDM_CTRL_INBUF_START_ADDR_SHIFT) & PDM_CTRL_INBUF_START_ADDR_MASK) 389 #define PDM_CTRL_INBUF_START_ADDR_GET(x) (((uint32_t)(x) & PDM_CTRL_INBUF_START_ADDR_MASK) >> PDM_CTRL_INBUF_START_ADDR_SHIFT) 390 391 /* Bitfield definition for register: CTRL_FILT0 */ 392 /* 393 * COEF_LEN_M0 (RW) 394 * 395 * Coef length of filter type 2'b00 in coef memory 396 */ 397 #define PDM_CTRL_FILT0_COEF_LEN_M0_MASK (0xFF00U) 398 #define PDM_CTRL_FILT0_COEF_LEN_M0_SHIFT (8U) 399 #define PDM_CTRL_FILT0_COEF_LEN_M0_SET(x) (((uint32_t)(x) << PDM_CTRL_FILT0_COEF_LEN_M0_SHIFT) & PDM_CTRL_FILT0_COEF_LEN_M0_MASK) 400 #define PDM_CTRL_FILT0_COEF_LEN_M0_GET(x) (((uint32_t)(x) & PDM_CTRL_FILT0_COEF_LEN_M0_MASK) >> PDM_CTRL_FILT0_COEF_LEN_M0_SHIFT) 401 402 /* 403 * COEF_START_ADDR (RW) 404 * 405 * Starting address of Coef of filter type 2'b00 in coef memory 406 */ 407 #define PDM_CTRL_FILT0_COEF_START_ADDR_MASK (0xFFU) 408 #define PDM_CTRL_FILT0_COEF_START_ADDR_SHIFT (0U) 409 #define PDM_CTRL_FILT0_COEF_START_ADDR_SET(x) (((uint32_t)(x) << PDM_CTRL_FILT0_COEF_START_ADDR_SHIFT) & PDM_CTRL_FILT0_COEF_START_ADDR_MASK) 410 #define PDM_CTRL_FILT0_COEF_START_ADDR_GET(x) (((uint32_t)(x) & PDM_CTRL_FILT0_COEF_START_ADDR_MASK) >> PDM_CTRL_FILT0_COEF_START_ADDR_SHIFT) 411 412 /* Bitfield definition for register: CTRL_FILT1 */ 413 /* 414 * COEF_LEN_M1 (RW) 415 * 416 * Coef length of filter type 2'b01 in coef memory 417 */ 418 #define PDM_CTRL_FILT1_COEF_LEN_M1_MASK (0xFF00U) 419 #define PDM_CTRL_FILT1_COEF_LEN_M1_SHIFT (8U) 420 #define PDM_CTRL_FILT1_COEF_LEN_M1_SET(x) (((uint32_t)(x) << PDM_CTRL_FILT1_COEF_LEN_M1_SHIFT) & PDM_CTRL_FILT1_COEF_LEN_M1_MASK) 421 #define PDM_CTRL_FILT1_COEF_LEN_M1_GET(x) (((uint32_t)(x) & PDM_CTRL_FILT1_COEF_LEN_M1_MASK) >> PDM_CTRL_FILT1_COEF_LEN_M1_SHIFT) 422 423 /* 424 * COEF_START_ADDR (RW) 425 * 426 * Starting address of Coef of filter type 2'b01 in coef memory 427 */ 428 #define PDM_CTRL_FILT1_COEF_START_ADDR_MASK (0xFFU) 429 #define PDM_CTRL_FILT1_COEF_START_ADDR_SHIFT (0U) 430 #define PDM_CTRL_FILT1_COEF_START_ADDR_SET(x) (((uint32_t)(x) << PDM_CTRL_FILT1_COEF_START_ADDR_SHIFT) & PDM_CTRL_FILT1_COEF_START_ADDR_MASK) 431 #define PDM_CTRL_FILT1_COEF_START_ADDR_GET(x) (((uint32_t)(x) & PDM_CTRL_FILT1_COEF_START_ADDR_MASK) >> PDM_CTRL_FILT1_COEF_START_ADDR_SHIFT) 432 433 /* Bitfield definition for register: RUN */ 434 /* 435 * PDM_EN (RW) 436 * 437 * Asserted to enable the module 438 */ 439 #define PDM_RUN_PDM_EN_MASK (0x1U) 440 #define PDM_RUN_PDM_EN_SHIFT (0U) 441 #define PDM_RUN_PDM_EN_SET(x) (((uint32_t)(x) << PDM_RUN_PDM_EN_SHIFT) & PDM_RUN_PDM_EN_MASK) 442 #define PDM_RUN_PDM_EN_GET(x) (((uint32_t)(x) & PDM_RUN_PDM_EN_MASK) >> PDM_RUN_PDM_EN_SHIFT) 443 444 /* Bitfield definition for register: MEMADDR */ 445 /* 446 * ADDR (RW) 447 * 448 * 0--0x0FFFFFFF: COEF_RAM 449 * 0x10000000--0x1FFFFFFF: DATA_RAM 450 */ 451 #define PDM_MEMADDR_ADDR_MASK (0xFFFFFFFFUL) 452 #define PDM_MEMADDR_ADDR_SHIFT (0U) 453 #define PDM_MEMADDR_ADDR_SET(x) (((uint32_t)(x) << PDM_MEMADDR_ADDR_SHIFT) & PDM_MEMADDR_ADDR_MASK) 454 #define PDM_MEMADDR_ADDR_GET(x) (((uint32_t)(x) & PDM_MEMADDR_ADDR_MASK) >> PDM_MEMADDR_ADDR_SHIFT) 455 456 /* Bitfield definition for register: MEMDATA */ 457 /* 458 * DATA (RW) 459 * 460 * The data write-to/read-from buffer 461 */ 462 #define PDM_MEMDATA_DATA_MASK (0xFFFFFFFFUL) 463 #define PDM_MEMDATA_DATA_SHIFT (0U) 464 #define PDM_MEMDATA_DATA_SET(x) (((uint32_t)(x) << PDM_MEMDATA_DATA_SHIFT) & PDM_MEMDATA_DATA_MASK) 465 #define PDM_MEMDATA_DATA_GET(x) (((uint32_t)(x) & PDM_MEMDATA_DATA_MASK) >> PDM_MEMDATA_DATA_SHIFT) 466 467 /* Bitfield definition for register: HPF_MA */ 468 /* 469 * COEF (RW) 470 * 471 * Composite value of coef A of the Order-1 HPF 472 */ 473 #define PDM_HPF_MA_COEF_MASK (0xFFFFFFFFUL) 474 #define PDM_HPF_MA_COEF_SHIFT (0U) 475 #define PDM_HPF_MA_COEF_SET(x) (((uint32_t)(x) << PDM_HPF_MA_COEF_SHIFT) & PDM_HPF_MA_COEF_MASK) 476 #define PDM_HPF_MA_COEF_GET(x) (((uint32_t)(x) & PDM_HPF_MA_COEF_MASK) >> PDM_HPF_MA_COEF_SHIFT) 477 478 /* Bitfield definition for register: HPF_B */ 479 /* 480 * COEF (RW) 481 * 482 * coef B of the Order-1 HPF 483 */ 484 #define PDM_HPF_B_COEF_MASK (0xFFFFFFFFUL) 485 #define PDM_HPF_B_COEF_SHIFT (0U) 486 #define PDM_HPF_B_COEF_SET(x) (((uint32_t)(x) << PDM_HPF_B_COEF_SHIFT) & PDM_HPF_B_COEF_MASK) 487 #define PDM_HPF_B_COEF_GET(x) (((uint32_t)(x) & PDM_HPF_B_COEF_MASK) >> PDM_HPF_B_COEF_SHIFT) 488 489 490 491 492 #endif /* HPM_PDM_H */