|
| 1 | +/* |
| 2 | +* Copyright (c) 2018 Renesas Electronics Corporation and/or its affiliates |
| 3 | +* |
| 4 | +* SPDX-License-Identifier: BSD-3-Clause |
| 5 | +*/ |
| 6 | +/*********************************************************************************************************************** |
| 7 | +* File Name : rm_touch_qe.h |
| 8 | +* Description : This file contains the TOUCH API and should be included by the application which uses this API. |
| 9 | +***********************************************************************************************************************/ |
| 10 | + |
| 11 | +/*******************************************************************************************************************//** |
| 12 | + * @addtogroup TOUCH |
| 13 | + * @{ |
| 14 | + **********************************************************************************************************************/ |
| 15 | + |
| 16 | +#ifndef RM_TOUCH_H |
| 17 | +#define RM_TOUCH_H |
| 18 | + |
| 19 | +#include "platform.h" |
| 20 | + |
| 21 | +#include "rm_touch_qe_config.h" |
| 22 | +#include "rm_touch_qe_api.h" |
| 23 | +#include "r_ctsu_qe.h" |
| 24 | + |
| 25 | +/* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */ |
| 26 | +FSP_HEADER |
| 27 | + |
| 28 | +/*********************************************************************************************************************** |
| 29 | + * Macro definitions |
| 30 | + **********************************************************************************************************************/ |
| 31 | +#if (CTSU_CFG_AUTO_JUDGE_ENABLE == 1) |
| 32 | +#define TOUCH_AUTO_JUDGE_MONITOR (1) |
| 33 | +#endif |
| 34 | + |
| 35 | +/*********************************************************************************************************************** |
| 36 | + * Typedef definitions |
| 37 | + **********************************************************************************************************************/ |
| 38 | + |
| 39 | +#if (TOUCH_CFG_UART_TUNING_SUPPORT == 1) |
| 40 | + |
| 41 | +/** CTSU state number */ |
| 42 | +typedef enum e_touch_tuning_state |
| 43 | +{ |
| 44 | + TOUCH_TUNING_STATE_RESET, |
| 45 | + TOUCH_TUNING_STATE_INITIALIZE, |
| 46 | + TOUCH_TUNING_STATE_SCAN, |
| 47 | + TOUCH_TUNING_STATE_COMPLETE, |
| 48 | + TOUCH_TUNING_STATE_STOP |
| 49 | +} touch_tuning_state_t; |
| 50 | + |
| 51 | +typedef enum e_touch_tuning_mode |
| 52 | +{ |
| 53 | + TOUCH_TUNING_MODE_CORRECTION_1ST_VALUE, |
| 54 | + TOUCH_TUNING_MODE_CORRECTION_2ND_VALUE, |
| 55 | + TOUCH_TUNING_MODE_MEASURE_PHASE1, |
| 56 | + TOUCH_TUNING_MODE_MEASURE_PHASE2, |
| 57 | + TOUCH_TUNING_MODE_MEASURE_PHASE3, |
| 58 | + TOUCH_TUNING_MODE_QE_WATTING, |
| 59 | + TOUCH_TUNING_MODE_START, |
| 60 | + TOUCH_TUNING_MODE_FINISH, |
| 61 | +} touch_tuning_mode_t; |
| 62 | + |
| 63 | +typedef enum e_touch_tuning_scan |
| 64 | +{ |
| 65 | + TOUCH_TUNING_SCAN_SELF, |
| 66 | + TOUCH_TUNING_SCAN_MUTUAL, |
| 67 | + TOUCH_TUNING_SCAN_MUTUAL_CFC, |
| 68 | + TOUCH_TUNING_SCAN_CURRENT, |
| 69 | +} touch_tuning_scan_t; |
| 70 | + |
| 71 | +typedef struct st_ico |
| 72 | +{ |
| 73 | + uint16_t pri_sen; |
| 74 | + uint16_t snd_sen; |
| 75 | +} touch_tuning_ico_t; |
| 76 | + |
| 77 | +typedef struct |
| 78 | +{ |
| 79 | + uint32_t mska; |
| 80 | + uint32_t mskb; |
| 81 | +} touch_tuning_ts_msk_t; |
| 82 | +#endif |
| 83 | + |
| 84 | +/** Information of button */ |
| 85 | +typedef struct |
| 86 | +{ |
| 87 | + uint64_t status; ///< Touch result bitmap. |
| 88 | + uint16_t * p_threshold; ///< Pointer to Threshold value array. g_touch_button_threshold[] is set by Open API. |
| 89 | + uint16_t * p_hysteresis; ///< Pointer to Hysteresis value array. g_touch_button_hysteresis[] is set by Open API. |
| 90 | + uint16_t * p_reference; ///< Pointer to Reference value array. g_touch_button_reference[] is set by Open API. |
| 91 | + uint16_t * p_on_count; ///< Continuous touch counter. g_touch_button_on_count[] is set by Open API. |
| 92 | + uint16_t * p_off_count; ///< Continuous non-touch counter. g_touch_button_off_count[] is set by Open API. |
| 93 | + uint32_t * p_drift_buf; ///< Drift reference value. g_touch_button_drift_buf[] is set by Open API. |
| 94 | + uint16_t * p_drift_count; ///< Drift counter. g_touch_button_drift_count[] is set by Open API. |
| 95 | + uint8_t on_freq; ///< Copy from config by Open API. |
| 96 | + uint8_t off_freq; ///< Copy from config by Open API. |
| 97 | + uint16_t drift_freq; ///< Copy from config by Open API. |
| 98 | + uint16_t cancel_freq; ///< Copy from config by Open API. |
| 99 | +} touch_button_info_t; |
| 100 | + |
| 101 | +/** Information of slider */ |
| 102 | +typedef struct |
| 103 | +{ |
| 104 | + uint16_t * p_position; ///< Calculated Position data. g_touch_slider_position[] is set by Open API. |
| 105 | + uint16_t * p_threshold; ///< Copy from config by Open API. g_touch_slider_threshold[] is set by Open API. |
| 106 | +} touch_slider_info_t; |
| 107 | + |
| 108 | +/** Information of wheel */ |
| 109 | +typedef struct |
| 110 | +{ |
| 111 | + uint16_t * p_position; ///< Calculated Position data. g_touch_wheel_position[] is set by Open API. |
| 112 | + uint16_t * p_threshold; ///< Copy from config by Open API. g_touch_wheel_threshold[] is set by Open API. |
| 113 | +} touch_wheel_info_t; |
| 114 | + |
| 115 | +/** Information of pad */ |
| 116 | +typedef struct |
| 117 | +{ |
| 118 | + uint16_t * p_rx_coordinate; ///< RX coordinate |
| 119 | + uint16_t * p_tx_coordinate; ///< TX coordinate |
| 120 | + uint16_t * p_num_touch; ///< number of touch |
| 121 | + uint16_t * p_threshold; ///< Coordinate calculation threshold value. |
| 122 | + uint16_t * p_base_buf; ///< ScanData Base Value Buffer. |
| 123 | + uint16_t * p_rx_pixel; ///< X coordinate resolution |
| 124 | + uint16_t * p_tx_pixel; ///< Y coordinate resolution |
| 125 | + uint8_t * p_max_touch; ///< Maximum number of touch judgments used by the pad. |
| 126 | + int32_t * p_drift_buf; ///< Drift reference value. g_touch_button_drift_buf[] is set by Open API. |
| 127 | + uint16_t * p_drift_count; ///< Drift counter. g_touch_button_drift_count[] is set by Open API. |
| 128 | + uint8_t num_drift; ///< Copy from config by Open API. |
| 129 | +} touch_pad_info_t; |
| 130 | + |
| 131 | +/** Information of touch button judge(CTSU2) */ |
| 132 | +typedef struct st_touch_mm_info |
| 133 | +{ |
| 134 | + uint8_t id; |
| 135 | + uint8_t mm_index; |
| 136 | + uint16_t mm_result[CTSU_MAJORITY_MODE_ELEMENTS]; |
| 137 | + uint8_t majority_mode; |
| 138 | +} touch_mm_info_t; |
| 139 | + |
| 140 | +/** TOUCH private control block. DO NOT MODIFY. Initialization occurs when RM_TOUCH_Open() is called. */ |
| 141 | +typedef struct st_touch_instance_ctrl |
| 142 | +{ |
| 143 | + uint32_t open; ///< Whether or not driver is open. |
| 144 | + touch_button_info_t binfo; ///< Information of button. |
| 145 | + touch_slider_info_t sinfo; ///< Information of slider. |
| 146 | + touch_wheel_info_t winfo; ///< Information of wheel. |
| 147 | + bool serial_tuning_enable; ///< Flag of serial tuning status. |
| 148 | + touch_pad_info_t pinfo; ///< Information of pad. |
| 149 | + touch_cfg_t const * p_touch_cfg; ///< Pointer to initial configurations. |
| 150 | + ctsu_instance_t const * p_ctsu_instance; ///< Pointer to CTSU instance. |
| 151 | + touch_mm_info_t * p_touch_mm_info; ///< Pointer to information of touch button judge |
| 152 | +} touch_instance_ctrl_t; |
| 153 | + |
| 154 | + |
| 155 | +/********************************************************************************************************************** |
| 156 | + * Exported global variables |
| 157 | + **********************************************************************************************************************/ |
| 158 | + |
| 159 | +/** @cond INC_HEADER_DEFS_SEC */ |
| 160 | +/** Filled in Interface API structure for this Instance. */ |
| 161 | +extern const touch_api_t g_touch_on_ctsu; |
| 162 | + |
| 163 | +/** @endcond */ |
| 164 | + |
| 165 | +/********************************************************************************************************************** |
| 166 | + * Public Function Prototypes |
| 167 | + **********************************************************************************************************************/ |
| 168 | +fsp_err_t RM_TOUCH_Open(touch_ctrl_t * const p_ctrl, touch_cfg_t const * const p_cfg); |
| 169 | +fsp_err_t RM_TOUCH_ScanStart(touch_ctrl_t * const p_ctrl); |
| 170 | +fsp_err_t RM_TOUCH_DataGet(touch_ctrl_t * const p_ctrl, |
| 171 | + uint64_t * p_button_status, |
| 172 | + uint16_t * p_slider_position, |
| 173 | + uint16_t * p_wheel_position); |
| 174 | +fsp_err_t RM_TOUCH_PadDataGet(touch_ctrl_t * const p_ctrl, |
| 175 | + uint16_t * p_pad_rx_coordinate, |
| 176 | + uint16_t * p_pad_tx_coordinate, |
| 177 | + uint8_t * p_pad_num_touch); |
| 178 | +fsp_err_t RM_TOUCH_ScanStop(touch_ctrl_t * const p_ctrl); |
| 179 | +fsp_err_t RM_TOUCH_CallbackSet(touch_ctrl_t * const p_api_ctrl, |
| 180 | + void ( * p_callback)(touch_callback_args_t *), |
| 181 | + void const * const p_context, |
| 182 | + touch_callback_args_t * const p_callback_memory); |
| 183 | +fsp_err_t RM_TOUCH_Close(touch_ctrl_t * const p_ctrl); |
| 184 | +fsp_err_t RM_TOUCH_SensitivityRatioGet(touch_ctrl_t * const p_ctrl, |
| 185 | + touch_sensitivity_info_t * p_touch_sensitivity_info); |
| 186 | +fsp_err_t RM_TOUCH_ThresholdAdjust(touch_ctrl_t * const p_ctrl, touch_sensitivity_info_t * p_touch_sensitivity_info); |
| 187 | +fsp_err_t RM_TOUCH_DriftControl(touch_ctrl_t * const p_ctrl, uint16_t input_drift_freq); |
| 188 | +fsp_err_t RM_TOUCH_MonitorAddressGet (touch_ctrl_t * const p_ctrl, |
| 189 | + uint8_t ** pp_monitor_buf, |
| 190 | + uint8_t ** pp_monitor_id, |
| 191 | + uint16_t ** pp_monitor_size); |
| 192 | +/* Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */ |
| 193 | +FSP_FOOTER |
| 194 | + |
| 195 | +#endif // RM_TOUCH_H |
| 196 | + |
| 197 | +/*******************************************************************************************************************//** |
| 198 | + * @} (end addtogroup TOUCH) |
| 199 | + **********************************************************************************************************************/ |
0 commit comments