TOUCH APIs
Important
The TOUCH API v1.0 is the lastest and stable TOUCH APIs. All new applications should use TOUCH API v1.0.
Touch User Guide
Touch module have three different types of working modes, which are automatic calibrattion mode, manul calibration mode and scan mode. The scan mode must work based on the automatic calibration mode or manul mode. When the touch channel has been calibrated, then set multi channels that neet to scan and enable the scan mode. The automatic calibration mode and manul calibration mode are used as follows:
Touch APIs
bk_touch_gpio_init()
- init the touch gpio pin
bk_touch_enable()
- enable the touch module funtion
bk_touch_disable()
- enable the touch module funtion
bk_touch_config()
- config the touch parameters to enable touch work
bk_touch_calibration_start()
- start calibrating the touch channel
bk_touch_scan_mode_enable()
- enable or disable scan mode of touch module
bk_touch_manul_mode_enable()
- enable manul mode of touch module
bk_touch_manul_mode_disable()
- disable manul mode of touch module
bk_touch_scan_mode_multi_channl_set()
- set multi channels that need to scan
bk_touch_int_enable()
- enable or disable touch interrupt
bk_touch_get_calib_value()
- get the calibration value of touch channel
bk_touch_get_touch_status()
- get the status of touch channel
bk_touch_register_touch_isr()
- register touch isr
API Reference
Header File
Functions
-
bk_err_t bk_touch_gpio_init(touch_channel_t touch_id)
Init the touch gpio pin.
This API init the GPIO pin corresponding to touch channel:
Unmap gpio pin function
Change gpio pin function to touch
Configure gpio to be high impedance
This API should be called before any other TOUCH APIs.
- Parameters
- – touch_id: touch channel, channel 0 ~ channel 15
- Returns
BK_OK: succeed
others: other errors.
-
bk_err_t bk_touch_enable(touch_channel_t touch_id)
enable touch function
This API enable the touch function:
Select the touch channel
Power on the touch module
- Parameters
- – touch_id: touch channel, channel 0 ~ channel 15
- Returns
BK_OK: succeed
others: other errors.
-
bk_err_t bk_touch_disable(void)
disable touch function
This API disable the touch function:
Power down the touch module
- Parameters
- – None
- Returns
BK_OK: succeed
-
bk_err_t bk_touch_config(const touch_config_t *touch_config)
config touch function
This API config the touch function:
Set touch sensitivity level, the smaller the value, the more sensitive. The range of level value from 0 to 3
Set touch detect threshold, the range of value from 0 to 7.
Set touch detect range, 8pF/12pF/19pF/27pF
Usage example:
touch_config_t touch_config; touch_config.sensitivity_level = TOUCH_SENSITIVITY_LEVLE_3; touch_config.detect_threshold = TOUCH_DETECT_THRESHOLD_6; touch_config.detect_range = TOUCH_DETECT_RANGE_27PF; bk_touch_config(&touch_config);
- Parameters
- – touch_config: the config of touch work mode
- Returns
BK_OK: succeed
-
bk_err_t bk_touch_calibration_start(void)
start calibrating touch channel
This API start calibrating the touch channel that selected.
- Parameters
- – None
- Returns
BK_OK: succeed
-
bk_err_t bk_touch_scan_mode_enable(uint32_t enable)
enable/disable scan mode of touch channel
This API enable or disable the scan mode of touch channel.
- Parameters
- – enable: enable —— 1; disable —— 0;
- Returns
BK_OK: succeed
-
bk_err_t bk_touch_adc_mode_enable(uint32_t enable)
enable/disable adc mode of touch channel
This API enable or disable the adc mode of touch channel.
- Parameters
- – enable: enable —— 1; disable —— 0;
- Returns
BK_OK: succeed
-
bk_err_t bk_touch_manul_mode_enable(uint32_t calib_value)
enable manul calibration mode of touch channel
This API enable the manul calibration mode of touch channel:
set the calibration value of manul mode;
enable the manul calibretion mode;
- Parameters
- – calib_value: calibration value of manul mode, the max value is 0x1FF;
- Returns
BK_OK: succeed
-
bk_err_t bk_touch_manul_mode_disable(void)
disable manul calibration mode of touch channel
This API disable the manul calibration mode of touch channel
- Parameters
- – None
- Returns
BK_OK: succeed
-
bk_err_t bk_touch_scan_mode_multi_channl_set(touch_channel_t touch_id)
set multi channels that need to scan
This API set multi channels that need to scan
- Parameters
- – touch_id: the multi channels that need to scan. See the enum of touch_channel_t.
- Returns
BK_OK: succeed
-
bk_err_t bk_touch_int_enable(touch_channel_t touch_id, uint32_t enable)
enable/disable touch channel interrupt
This API enable or disable the touch channel interrupt:
register the interrupt service handle;
enable or disable the touch interrupt;
- Parameters
- – touch_id: touch channel, channel 0 ~ channel 15;
enable: enable —— 1; disable —— 0;
- Returns
BK_OK: succeed
-
uint32_t bk_touch_get_calib_value(void)
get the calibration value of touch channel
This API get the calibration value of touch channel.
- Parameters
- – None
- Returns
calib_value: the max value is 0x1FF.
-
uint32_t bk_touch_get_touch_status(void)
get the status of touch channel
This API get the status of touch channel:
- Parameters
- – None
- Returns
touch_status: the touch status of every channel. One bit corresponding to one channel. 1 —— the channel is touched; 0 —— the channel is idle.
-
bk_err_t bk_touch_digital_tube_init(void)
init the digital tube of touch
This API init the digital tube:
- Parameters
- – None
- Returns
BK_OK: succeed
-
void bk_touch_digital_tube_display(uint8_t disp_value)
display the value in the digital tube
This API display the value in the digital tube
- Parameters
- – disp_value: the value need to display;
- Returns
None
-
void bk_touch_wakeup_channel_set(touch_channel_t channel)
get the touch channel for low voltage and deepsleep wake up
This API get the touch channel for low voltage and deepsleep wake up
- Parameters
- – channel: touch channel, channel 0 ~ channel 15. See the enum of touch_channel_t.
- Returns
None
-
uint32_t bk_touch_wakeup_channel_get(void)
set the touch channel for low voltage and deepsleep wake up
This API set the touch channel for low voltage and deepsleep wake up
- Parameters
- – None
- Returns
s_touch_wakeup_channel: the channel number of touch
-
bk_err_t bk_touch_pm_init(void)
Register touch low voltage and deepsleep config.
This API register touch low voltage and deepsleep config
- Parameters
- – None
- Returns
BK_OK: succeed
others: other errors.
-
bk_err_t bk_touch_register_touch_isr(touch_channel_t touch_id, touch_isr_t isr, void *param)
Register touch isr.
This API register touch isr
- Parameters
- – touch_id: touch channel, channel 0 ~ channel 15;
isr: touch isr callback;
param: touch isr callback parameter;
- Returns
BK_OK: succeed
others: other errors.
API Typedefs
Header File
Structures
-
struct touch_int_config_t
-
struct touch_config_t
Public Members
-
touch_sensitivity_level_t sensitivity_level
sensitivity_level
-
touch_detect_threshold_t detect_threshold
detect_threshold
-
touch_detect_range_t detect_range
detect_range
-
touch_sensitivity_level_t sensitivity_level
Macros
-
BK_ERR_TOUCH_ID
Type Definitions
-
typedef void (*touch_isr_t)(void *param)
Enumerations
-
enum touch_channel_t
Values:
-
enumerator BK_TOUCH_0
touch channel 0
-
enumerator BK_TOUCH_1
touch channel 1
-
enumerator BK_TOUCH_2
touch channel 2
-
enumerator BK_TOUCH_3
touch channel 3
-
enumerator BK_TOUCH_4
touch channel 4
-
enumerator BK_TOUCH_5
touch channel 5
-
enumerator BK_TOUCH_6
touch channel 6
-
enumerator BK_TOUCH_7
touch channel 7
-
enumerator BK_TOUCH_8
touch channel 8
-
enumerator BK_TOUCH_9
touch channel 9
-
enumerator BK_TOUCH_10
touch channel 10
-
enumerator BK_TOUCH_11
touch channel 11
-
enumerator BK_TOUCH_12
touch channel 12
-
enumerator BK_TOUCH_13
touch channel 13
-
enumerator BK_TOUCH_14
touch channel 14
-
enumerator BK_TOUCH_15
touch channel 15
-
enumerator BK_TOUCH_MAX
-
enumerator BK_TOUCH_0
-
enum touch_sensitivity_level_t
Values:
-
enumerator TOUCH_SENSITIVITY_LEVLE_0
-
enumerator TOUCH_SENSITIVITY_LEVLE_1
-
enumerator TOUCH_SENSITIVITY_LEVLE_2
-
enumerator TOUCH_SENSITIVITY_LEVLE_3
-
enumerator TOUCH_SENSITIVITY_LEVLE_0
-
enum touch_detect_threshold_t
Values:
-
enumerator TOUCH_DETECT_THRESHOLD_0
-
enumerator TOUCH_DETECT_THRESHOLD_1
-
enumerator TOUCH_DETECT_THRESHOLD_2
-
enumerator TOUCH_DETECT_THRESHOLD_3
-
enumerator TOUCH_DETECT_THRESHOLD_4
-
enumerator TOUCH_DETECT_THRESHOLD_5
-
enumerator TOUCH_DETECT_THRESHOLD_6
-
enumerator TOUCH_DETECT_THRESHOLD_7
-
enumerator TOUCH_DETECT_THRESHOLD_0