/ * @brief * Configure ACMP device * * @details * * @note * * @param[in] dev * Pointer to device descriptor * * @param[in] cmd * ACMP control command * * @param[in] args * Arguments * * @return * Error code ******************************************************************************/
| 90 | * Error code |
| 91 | ******************************************************************************/ |
| 92 | static rt_err_t rt_acmp_control( |
| 93 | rt_device_t dev, |
| 94 | rt_uint8_t cmd, |
| 95 | void *args) |
| 96 | { |
| 97 | RT_ASSERT(dev != RT_NULL); |
| 98 | |
| 99 | struct efm32_acmp_device_t *acmp; |
| 100 | |
| 101 | acmp = (struct efm32_acmp_device_t *)(dev->user_data); |
| 102 | |
| 103 | switch (cmd) |
| 104 | { |
| 105 | case RT_DEVICE_CTRL_SUSPEND: |
| 106 | /* Suspend device */ |
| 107 | dev->flag |= RT_DEVICE_FLAG_SUSPENDED; |
| 108 | ACMP_Disable(acmp->acmp_device); |
| 109 | break; |
| 110 | |
| 111 | case RT_DEVICE_CTRL_RESUME: |
| 112 | /* Resume device */ |
| 113 | dev->flag &= ~RT_DEVICE_FLAG_SUSPENDED; |
| 114 | ACMP_Enable(acmp->acmp_device); |
| 115 | break; |
| 116 | |
| 117 | case RT_DEVICE_CTRL_ACMP_INIT: |
| 118 | { |
| 119 | rt_bool_t int_en = false; |
| 120 | struct efm32_acmp_control_t *control; |
| 121 | |
| 122 | control = (struct efm32_acmp_control_t *)args; |
| 123 | acmp_debug("ACMP: control -> init start\n"); |
| 124 | |
| 125 | /* Configure ACMPn */ |
| 126 | if (control->init == RT_NULL) |
| 127 | { |
| 128 | return -RT_ERROR; |
| 129 | } |
| 130 | ACMP_Init(acmp->acmp_device, control->init); |
| 131 | ACMP_ChannelSet(acmp->acmp_device, control->negInput, control->posInput); |
| 132 | if (control->output != RT_NULL) |
| 133 | { |
| 134 | ACMP_GPIOSetup( |
| 135 | acmp->acmp_device, |
| 136 | control->output->location, |
| 137 | control->output->enable, |
| 138 | control->output->invert); |
| 139 | int_en = true; |
| 140 | } |
| 141 | if (control->hook.cbFunc != RT_NULL) |
| 142 | { |
| 143 | acmp->hook.cbFunc = control->hook.cbFunc; |
| 144 | acmp->hook.userPtr = control->hook.userPtr; |
| 145 | int_en = true; |
| 146 | } |
| 147 | |
| 148 | if (int_en) |
| 149 | { |
nothing calls this directly
no test coverage detected