MT2523 API Reference  LinkIt SDK v4
ACCDET

This section describes the programming interfaces of accessory detector (ACCDET) HAL driver. More...

Overview

This section describes the programming interfaces of accessory detector (ACCDET) HAL driver.

The hardware ACCDET detects the status of an earphone (plug-in/plug-out/hook-key), based on the suggested circuit. The de-bounce scheme is also supported to resist uncertain input noises. When the state is stable, the Pulse Width Modulation (PWM) unit of ACCDET enables the voltage of the comparator periodically to detect the plugging state. Very low-power consumption can be achieved if the detection feature is enabled and the PWM settings are defined according to the needs of the hardware being controlled. In order to compensate the delay between the detection login and comparator, the delay enabling scheme is adopted. Given the suitable delay number compared to the rising edge of PWM high pulse, the stable plugging state can be prorogated to digital detection logic. Then the correct plugging state can be detected and reported.

Terms and acronyms

The following provides descriptions to the terms commonly used in the ACCDET driver and how to use its various functions.

Terms Details
ACCDET Accessory detector is designed to detect the status of earphone (plug-in/plug-out/hook-key).
PWM Pulse Width Modulation (PWM) is a modulation technique that encodes a message into a pulsing signal. The main use is to allow the control of the power supplied to electrical devices, especially to inertial loads such as motors. For more information, please refer to introduction to PWM in Wikipedia.

For PWM, the term duty cycle describes the proportion of 'on' time to the regular interval or 'period' of time; a low duty cycle corresponds to low power, because the power is off for most of the time. Duty cycle is expressed in percent, 100% being fully on.

Supported features

As described above, to perform an accurate detection, the debounce time and proper PWM settings are supported. The supported features of ACCDET driver are listed below:

How to use this driver

Functions

hal_accdet_status_t hal_accdet_init (void)
 ACCDET initialize function. More...
 
hal_accdet_status_t hal_accdet_deinit (void)
 ACCDET deinitialization function. More...
 
hal_accdet_status_t hal_accdet_enable (void)
 ACCDET enable function. More...
 
hal_accdet_status_t hal_accdet_disable (void)
 ACCDET disable function. More...
 
hal_accdet_status_t hal_accdet_register_callback (hal_accdet_callback_t accdet_callback, void *user_data)
 register callback function for ACCDET interrupt. More...
 
hal_accdet_status_t hal_accdet_set_debounce_time (const hal_accdet_debounce_time_t *debounce_time)
 set debounce time for the ACCDET. More...
 

Modules

 Enum
 
 Struct
 
 Typedef
 

Function Documentation

hal_accdet_status_t hal_accdet_deinit ( void  )

ACCDET deinitialization function.

Returns
HAL_ACCDET_STATUS_OK, ACCDET module is successfully deinitialized.
hal_accdet_status_t hal_accdet_disable ( void  )

ACCDET disable function.

Disable the ACCDET module.

Returns
HAL_ACCDET_STATUS_OK, ACCDET module is successfully disabled.
hal_accdet_status_t hal_accdet_enable ( void  )

ACCDET enable function.

Enable the ACCDET module.

Returns
HAL_ACCDET_STATUS_OK, ACCDET module is successfully enabled.
hal_accdet_status_t hal_accdet_init ( void  )

ACCDET initialize function.

Returns
HAL_ACCDET_STATUS_ERROR_BUSY, ACCDET is busy.
HAL_ACCDET_STATUS_OK, ACCDET module is successfully initialized.
hal_accdet_status_t hal_accdet_register_callback ( hal_accdet_callback_t  accdet_callback,
void *  user_data 
)

register callback function for ACCDET interrupt.

Parameters
[in]accdet_callbackis the pointer to the ACCDET callback function.
[in]user_datais the user data of callback function.
Returns
HAL_ACCDET_STATUS_OK, the callback function of the ACCDET is registered successfully.
HAL_ACCDET_STATUS_INVALID_PARAMETER, accdet_callback is NULL.
hal_accdet_status_t hal_accdet_set_debounce_time ( const hal_accdet_debounce_time_t debounce_time)

set debounce time for the ACCDET.

Parameters
[in]debounce_timeis pointer of the debounce value structure of ACCDET, the unit of debounce is millisecond.
Returns
HAL_ACCDET_STATUS_OK, the debounce time of ACCDET is set successfully.
HAL_ACCDET_STATUS_INVALID_PARAMETER, debounce_time is NULL.