/ * @brief * * * @param[in] acmp * Pointer to the ACMP peripheral register block. * * @param[in] init * Pointer to initialization structure used to configure ACMP for capacative * sensing operation. ******************************************************************************/
| 265 | * sensing operation. |
| 266 | ******************************************************************************/ |
| 267 | void ACMP_Init(ACMP_TypeDef *acmp, const ACMP_Init_TypeDef *init) |
| 268 | { |
| 269 | /* Make sure the module exists on the selected chip */ |
| 270 | EFM_ASSERT(ACMP_REF_VALID(acmp)); |
| 271 | |
| 272 | /* Make sure biasprog is within bounds */ |
| 273 | EFM_ASSERT(init->biasProg < 16); |
| 274 | |
| 275 | /* Set control register. No need to set interrupt modes */ |
| 276 | acmp->CTRL = (init->fullBias << _ACMP_CTRL_FULLBIAS_SHIFT) |
| 277 | | (init->halfBias << _ACMP_CTRL_HALFBIAS_SHIFT) |
| 278 | | (init->biasProg << _ACMP_CTRL_BIASPROG_SHIFT) |
| 279 | | (init->interruptOnFallingEdge << _ACMP_CTRL_IFALL_SHIFT) |
| 280 | | (init->interruptOnRisingEdge << _ACMP_CTRL_IRISE_SHIFT) |
| 281 | | (init->warmTime << _ACMP_CTRL_WARMTIME_SHIFT) |
| 282 | | (init->hysteresisLevel << _ACMP_CTRL_HYSTSEL_SHIFT) |
| 283 | | (init->inactiveValue << _ACMP_CTRL_INACTVAL_SHIFT); |
| 284 | |
| 285 | acmp->INPUTSEL = (init->lowPowerReferenceEnabled << _ACMP_INPUTSEL_LPREF_SHIFT) |
| 286 | | (init->vddLevel << _ACMP_INPUTSEL_VDDLEVEL_SHIFT); |
| 287 | |
| 288 | /* Enable ACMP if requested. |
| 289 | * Note: BITBAND_Peripheral() function is used for setting/clearing single |
| 290 | * bit peripheral register bitfields. */ |
| 291 | BITBAND_Peripheral(&(acmp->CTRL), |
| 292 | (uint32_t)_ACMP_CTRL_EN_SHIFT, |
| 293 | (uint32_t)init->enable); |
| 294 | } |
| 295 | |
| 296 | |
| 297 | /** @} (end addtogroup ACMP) */ |
no test coverage detected