#include <types.h>
#include <compiler.h>
#include "sdrv_acmp.h"
#include "sdrv_common.h"
Go to the source code of this file.
|
| status_t | sdrv_acmp_init (sdrv_acmp_t *dev, sdrv_acmp_config_t *acmp_cfg, sdrv_acmp_callback callback) |
| |
| status_t | sdrv_acmp_start (sdrv_acmp_t *dev, bool start) |
| |
| status_t | sdrv_acmp_it_trigger_start (sdrv_acmp_t *dev, uint8_t qstart, uint8_t qend, uint8_t cur_entry_pt, bool trigger_start) |
| |
| status_t | sdrv_acmp_it_update_valid_irq (sdrv_acmp_t *dev, uint32_t *state, uint32_t wait_time) |
| |
| status_t | sdrv_acmp_power_ctrl (sdrv_acmp_t *dev, bool down) |
| |
| status_t | sdrv_acmp_enable_low_power (sdrv_acmp_t *dev, bool cmp_en, bool dac_en, uint8_t req_n_dly) |
| |
| status_t | sdrv_acmp_set_callback (sdrv_acmp_t *dev, sdrv_acmp_callback callback) |
| |
| status_t | sdrv_acmp_deinit (sdrv_acmp_t *dev) |
| |
- Copyright
- Copyright (c) 2022 Semidrive Semiconductor. All rights reserved.
◆ ACMP_CH_POLAR_NEG
| #define ACMP_CH_POLAR_NEG 0U |
◆ ACMP_CH_POLAR_POS
| #define ACMP_CH_POLAR_POS 1U |
◆ ACMP_DIFF_CH_SEL
| #define ACMP_DIFF_CH_SEL |
( |
|
ch_p, |
|
|
|
ch_n, |
|
|
|
mux |
|
) |
| (((mux & 0x7u) << 6) | ((ch_p & 0x7u) << 3) | (ch_n & 0x7u)) |
◆ ACMP_SINGLE_CH_SEL
| #define ACMP_SINGLE_CH_SEL |
( |
|
ch, |
|
|
|
polar, |
|
|
|
mux |
|
) |
| (((mux & 0x7u) << 6) | ((polar & 0x1u) << 3) | (ch & 0x7u)) |
◆ sdrv_acmp_callback
| typedef int(* sdrv_acmp_callback) (struct sdrv_acmp_dev *dev, uint32_t state) |
◆ sdrv_acmp_config_t
◆ sdrv_acmp_csel_cfg_t
◆ sdrv_acmp_index_cfg_t
◆ sdrv_acmp_t
◆ sdrv_acmp_csel_t
| Enumerator |
|---|
| ACMP_CSEL_0 | Acmp first compare select controller
|
| ACMP_CSEL_1 | Acmp second compare select controller
|
| ACMP_CSEL_2 | Acmp third compare select controller
|
| ACMP_CSEL_3 | Acmp fourth compare select controller
|
◆ sdrv_acmp_error
ACMP status error code.
| Enumerator |
|---|
| SDRV_ACMP_STATUS_INVALID_PARAM | |
| SDRV_ACMP_STATUS_WRONG_MODE | |
◆ sdrv_acmp_hcfg_t
| Enumerator |
|---|
| ACMP_HCFG_NO | Acmp without windows
|
| ACMP_HCFG_50_mV | Acmp with windows, 50 mV
|
| ACMP_HCFG_100_mV | Acmp With windows, 100 mV
|
◆ sdrv_acmp_index_t
| Enumerator |
|---|
| ACMP_INDEX_0 | Acmp config select index num, max index is 31
|
| ACMP_INDEX_1 | |
| ACMP_INDEX_2 | |
| ACMP_INDEX_3 | |
| ACMP_INDEX_4 | |
| ACMP_INDEX_5 | |
| ACMP_INDEX_6 | |
| ACMP_INDEX_7 | |
| ACMP_INDEX_8 | |
| ACMP_INDEX_9 | |
| ACMP_INDEX_10 | |
| ACMP_INDEX_11 | |
| ACMP_INDEX_12 | |
| ACMP_INDEX_13 | |
| ACMP_INDEX_14 | |
| ACMP_INDEX_15 | |
| ACMP_INDEX_16 | |
| ACMP_INDEX_17 | |
| ACMP_INDEX_18 | |
| ACMP_INDEX_19 | |
| ACMP_INDEX_20 | |
| ACMP_INDEX_21 | |
| ACMP_INDEX_22 | |
| ACMP_INDEX_23 | |
| ACMP_INDEX_24 | |
| ACMP_INDEX_25 | |
| ACMP_INDEX_26 | |
| ACMP_INDEX_27 | |
| ACMP_INDEX_28 | |
| ACMP_INDEX_29 | |
| ACMP_INDEX_30 | |
| ACMP_INDEX_31 | |
◆ sdrv_acmp_mode_t
| Enumerator |
|---|
| ACMP_HT_MODE | Acmp hardware trigger mode
|
| ACMP_IT_MODE | Acmp internal trigger mode
|
◆ sdrv_acmp_pol_adj_t
| Enumerator |
|---|
| ACMP_POL_ADJ_DIRECTLY | Acmp analog output directly
|
| ACMP_POL_ADJ_INVERT | Acmp invert raw analog output
|
◆ sdrv_acmp_reg_sel_t
| Enumerator |
|---|
| ACMP_SEL_REFP1 | Acmp select internal reference voltage REFP1
|
| ACMP_SEL_REFP2 | Acmp select internal reference voltage REFP2 or extern reference voltage
|
◆ sdrv_acmp_sd_sel_t
| Enumerator |
|---|
| ACMP_SEL_SINGLE | Acmp single-ended comparison mode
|
| ACMP_SEL_DIFF | Acmp differential comparison mode
|
◆ sdrv_acmp_deinit()
sdrv acmp deinit
This function stops acmp and deletes acmp initilization. Acmp must be de-initiated before entering lowpower mode.
- Parameters
-
- Returns
- SDRV_STATUS_OK represents success
◆ sdrv_acmp_enable_low_power()
| status_t sdrv_acmp_enable_low_power |
( |
sdrv_acmp_t * |
dev, |
|
|
bool |
cmp_en, |
|
|
bool |
dac_en, |
|
|
uint8_t |
req_n_dly |
|
) |
| |
sdrv acmp allows analog competitor and dac enter lowpower mode
This function allows competitor and dac recv q channel low power request. And than if the lowpower request is received, the competitor and dac will enter low power mode after req_n_dly clock cycle.
- Parameters
-
| [in] | dev | sdrv acmp device |
| [in] | cmp_en | competitor enable or disable |
| [in] | dac_en | dac enable or disable |
| [in] | req_n_dly | enter lowpower mode delay number |
- Returns
- SDRV_STATUS_OK represents success
◆ sdrv_acmp_init()
sdrv acmp init
This function initializes acmp device and attach callback function.
- Parameters
-
| [in] | dev | sdrv acmp device |
| [in] | acmp_cfg | sdrv acmp configuration parameters |
| [in] | callback | sdrv acmp callback function |
- Returns
- SDRV_STATUS_OK represents success or other error code
◆ sdrv_acmp_it_trigger_start()
| status_t sdrv_acmp_it_trigger_start |
( |
sdrv_acmp_t * |
dev, |
|
|
uint8_t |
qstart, |
|
|
uint8_t |
qend, |
|
|
uint8_t |
cur_entry_pt, |
|
|
bool |
trigger_start |
|
) |
| |
sdrv acmp IT mode trigger start
This function is used to stop or restart trigger with differnet id numbers in IT mode. The new comparation will use the same comparation parameters with the former comparation. If the parameters need to be modified, acmp should be stopped and reinitialized.
- Parameters
-
| [in] | dev | sdrv acmp device |
| [in] | qstart | sdrv acmp trigger start id number for loop |
| [in] | qend | sdrv acmp trigger end id number for loop |
| [in] | cur_entry_pt | sdrv acmp trigger first access id number |
| [in] | trigger_start | acmp IT mode trigger start |
- Returns
- SDRV_STATUS_OK represents success
◆ sdrv_acmp_it_update_valid_irq()
| status_t sdrv_acmp_it_update_valid_irq |
( |
sdrv_acmp_t * |
dev, |
|
|
uint32_t * |
state, |
|
|
uint32_t |
wait_time |
|
) |
| |
sdrv acmp IT mode update valid irq state
This function is used to workaround for multiple trigger if interrupt is required in IT mode. Occurrence scenario: Only appers in multiple triggers of IT mode, but this is not a problem if not changing the configuration(index and analog config) at next trigger. At the end of each trigger, if acmp voltage comparision result is pulled up one clock cycle before next trigger, the interrupt generated by this trigger will update to the register ID of the next trigger. Other functions of ACMP are not affected.
How to use this function: Call the function at beginning of acmp callback function.
- Parameters
-
| [in] | dev | sdrv acmp device |
| [in] | state | sdrv acmp irq state |
| [in] | wait_time | check irq valid wait time, the period should be longer than terminal time. |
- Returns
- SDRV_STATUS_OK represents success
◆ sdrv_acmp_power_ctrl()
sdrv acmp power ctrl
This function sets the sdrv acmp power mode. The status is default power on after acmp initilization. If the acmp comparation is finished, the power mode can be set to power down to reduce power consumption.
- Parameters
-
| [in] | dev | sdrv acmp device |
| [in] | down | 0 power on (default), 1 power down |
- Returns
- SDRV_STATUS_OK represents success
◆ sdrv_acmp_set_callback()
sdrv acmp set callback
This function is used to set the sdrv acmp callback function separately, after acmp initilization.
- Parameters
-
| [in] | dev | sdrv acmp device |
| [in] | callback | acmp callback function |
- Returns
- SDRV_STATUS_OK represents success
◆ sdrv_acmp_start()
sdrv acmp start
This function is used to start or stop acmp comparation. All the parameters are remained when acmp stop, and the previous comparation will restart when acmp start.
- Parameters
-
| [in] | dev | sdrv acmp dev |
| [in] | start | sdrv acmp start |
- Returns
- SDRV_STATUS_OK represents success