RA Flexible Software Package Documentation
Release v5.6.0
|
|
Functions | |
fsp_err_t | RM_TOUCH_Open (touch_ctrl_t *const p_ctrl, touch_cfg_t const *const p_cfg) |
Opens and configures the TOUCH Middle module. Implements touch_api_t::open. More... | |
fsp_err_t | RM_TOUCH_ScanStart (touch_ctrl_t *const p_ctrl) |
This function should be called each time a periodic timer expires. If initial offset tuning is enabled, The first several calls are used to tuning for the sensors. Before starting the next scan, first get the data with RM_TOUCH_DataGet(). If a different control block scan should be run, check the scan is complete before executing. Implements touch_api_t::scanStart. More... | |
fsp_err_t | RM_TOUCH_DataGet (touch_ctrl_t *const p_ctrl, uint64_t *p_button_status, uint16_t *p_slider_position, uint16_t *p_wheel_position) |
Gets the 64-bit mask indicating which buttons are pressed. Also, this function gets the current position of where slider or wheel is being pressed. If initial offset tuning is enabled, The first several calls are used to tuning for the sensors. Implements touch_api_t::dataGet. More... | |
fsp_err_t | RM_TOUCH_PadDataGet (touch_ctrl_t *const p_ctrl, uint16_t *p_pad_rx_coordinate, uint16_t *p_pad_tx_coordinate, uint8_t *p_pad_num_touch) |
This function gets the current position of pad is being pressed. Implements touch_api_t::padDataGet , g_touch_on_ctsu. More... | |
fsp_err_t | RM_TOUCH_ScanStop (touch_ctrl_t *const p_ctrl) |
Scan stop specified TOUCH control block. Implements touch_api_t::scanStop. More... | |
fsp_err_t | RM_TOUCH_CallbackSet (touch_ctrl_t *const p_api_ctrl, void(*p_callback)(touch_callback_args_t *), void const *const p_context, touch_callback_args_t *const p_callback_memory) |
fsp_err_t | RM_TOUCH_Close (touch_ctrl_t *const p_ctrl) |
Disables specified TOUCH control block. Implements touch_api_t::close. More... | |
fsp_err_t | RM_TOUCH_SensitivityRatioGet (touch_ctrl_t *const p_ctrl, touch_sensitivity_info_t *p_touch_sensitivity_info) |
Get the touch sensitivity ratio. Implements touch_api_t::sensitivityRatioGet. More... | |
fsp_err_t | RM_TOUCH_ThresholdAdjust (touch_ctrl_t *const p_ctrl, touch_sensitivity_info_t *p_touch_sensitivity_info) |
Adjust the touch judgment threshold. Implements touch_api_t::thresholdAdjust. More... | |
fsp_err_t | RM_TOUCH_DriftControl (touch_ctrl_t *const p_ctrl, uint16_t input_drift_freq) |
Control drift correction. Implements touch_api_t::driftControl. More... | |
This module supports the Capacitive Touch Sensing Unit (CTSU). It implements the Touch Middleware Interface.
The Touch Middleware uses the CTSU (r_ctsu) API and provides application-level APIs for scanning touch buttons, sliders, and wheels. This module is configured via the QE for Capacitive Touch.
This module supports the QE monitor function. The monitor determines whether to use debugger or serial communications, determines the type of the information from QE and sends only the necessary information. This module supports the serial tuning function with the standalone version of QE. Generates a configuration configuration file by UART communication with QE.
Configuration | Options | Default | Description |
---|---|---|---|
Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
Support for QE monitoring using UART |
| Disabled | Enable SCI_UART support for QE monitoring. |
Support for QE Tuning using UART |
| Disabled | Enable SCI_UART support for QE Tuning. |
Type of chattering suppression |
| TypeA : Counter of exceed threshold is hold within hysteresis range | TypeA of chattering suppression : Counter of exceed threshold is hold within hysteresis range. / TypeB of chattering suppression : Counter of exceed threshold is reset within hysteresis range. |
Configuration | Options | Default | Description |
---|
Refer to the CTSU (r_ctsu) section for details.
Refer to the CTSU (r_ctsu) section for details.
Refer to the CTSU (r_ctsu) section for details.
The module determines whether the button has been touched based on the change in capacitance and detects the position of the slider or wheel. This requires continued periodic measurements of capacitance. When developing your application, make sure to periodically call RM_TOUCH_ScanStart() and RM_TOUCH_DataGet(). For more details, refer to the sample application.
Touch detection has three modes in CTSU2.
A touch button is not a mechanical button in which the ON/OF state is switched by hardware. The ON/OFF state is determined via software.
First, a reference value is created based on measurement results in the non-touch state. The initial reference value is the first measured value. The threshold is then determined with an arbitrary offset. If a measured value exceeds the threshold, the button is determined to be in the ON state, if it does not exceed the threshold, it is in the OFF state.
Processing for self-capacitance and mutual capacitance are basically the same. However, because the amount of capacitance decreases when a mutual capacitance button is touched, the user needs to set the threshold based on decreasing measured values to determine the ON/OFF state.
You can set the threshold for each button separately in the configuration settings (threshold in touch_button_cfg_t). The following functions are also included to deal with issues such as chattering suppression and changes in the external environment which affect actual touch recognition.
VMM : Creates one reference value and one threshold value for each button.
JMM : Creates three reference values and three threshold values for each button.
As a chattering countermeasure, you can confirm the ON/OFF state after a set number of consecutive ON or OFF determinations.
In the configuration settings (on_freq and off_freq in touch_cfg_t) set the number of consecutive ON or OFF states. You can do this for all buttons in the touch interface configuration. Be aware that, although this is an effective solution to improving chattering, the greater the number of consecutive states, the slower the response to actual touch.
This is another chattering countermeasure. Offset the constant to the threshold after the state goes to ON, and prevent chattering by using hysteresis as the OFF-to-ON and ON-to-OFF threshold.
You can set the hysteresis value for each button in the configuration settings (hysteresis in touch_button_cfg_t). The larger the hysteresis, the more effective the countermeasure is in suppressing chattering. However, keep in mind that this will make it more difficult to return the state from ON-to-OFF of OFF-to-ON.
VMM : One hysteresis for each button.
JMM : Three hysteresis for each button.
As a countermeasure for changes in the external environment, the drift correction process refreshes the reference value.
After averaging the measured value in the OFF state over a set period, if the button is in the touch OFF state after a set period, the reference value is refreshed. The drift correction is only executed in the OFF state and is cleared when touch ON is determined.
Set the period in the configuration settings (drift_freq in touch_cfg_t). You can do this for all buttons in the touch interface configuration. This allows you to adjust the ability to determine the touch state despite changes in the external environment.
VMM : Drift corrects one baseline value per button.
JMM : Drift corrects three baseline value per button.
Strong noise or other sudden environment changes can disable the drift correction process, preventing return from the ON state. The press and hold cancel function implements the drift correction process and returns the button from the ON state by forcibly turning the state to OFF after a certain number of consecutive ON state periods.
Set the number of consecutive ON periods required for the press and hold cancel function to return the button to the OFF state in the configuration settings (cancel_freq in touch_cfg_t). You can do this for all buttons in the touch interface configuration.
This build option is a function to supplement the above functions (Positive Noise Filter/Negative Noise Filter and Hysteresis) for performing touch judgment.
This build option changes the processing method for Counter of exceed threshold to TypeA or TypeB.
TypeA of chattering suppression : Counter of exceed threshold is hold within hysteresis range.
TypeB of chattering suppression : Counter of exceed threshold is reset within hysteresis range.
Configure a slider with multiple terminals to be measured (TS) physically arranged in a straight line. Configure a wheel with multiple terminals physically arranged in a circle.
The touch position is calculated from the measured values of the TS in the configuration. The calculation method for sliders and wheels is fundamentally the same.
Slider | Wheel | |
---|---|---|
Electrode type | Self capacitance only | Self capacitance only |
Number of electrodes | 3-10 | 4+ |
Touch position output range | 1-100 | 1-360 |
Default value (no touch) | 0xFFFF | 0xFFFF |
When QE tuning, a measurement is performed with a finger touching the button and the tuned parameters are output in the configuration file. The setting value of the threshold is 60% of the touch sensitivity between touch and non-touch state, and the setting value of the hysteresis coefficient is 5% of the threshold.
This module provides the functions for dynamic adjusting of these threshold and hysteresis coefficient.
They are two functions as below.
When changing the touch determination threshold ratio from 60% QE set to 70% user specified, the touch determination thresholds are as below.
If you want to make this setting, set the member of the second argument as follows. It is also necessary to set the ratio of the amount of touch change and the hysteresis value.
*p_touch_sensitivity_ratio = 100,
old_threshold_ratio = 60,
new_threshold_ratio = 70,
new_hysteresis_ratio = 5
When changing the kind of the overlay panel, the touch sensitivity differs from the one QE tuned. Wanting to use the software as it is without re-tuning. If you use a thicker overlay than that at QE tuning, the touch sensitivity decreases, and a touch may not be determined because of the same touch determination threshold. This function adjusts the touch determination threshold based on the ratio of the touch sensitivity after changing the overlay to the touch sensitivity at the QE tuning.
RM_TOUCH_SensitivityRatioGet() outputs the ratio of the current touch sensitivity assuming that the touch sensitivity at the QE setting is 100%.
The following figure shows the case where an overlay panel is thinner and the touch sensitivity increases.
Following figure shows the case where an overlay panel is thicker and the touch sensitivity decreases.
RM_TOUCH_ThresholdAdjust() sets the new touch determination threshold and the hysteresis value by using the touch sensitivity ratio obtained with RM_TOUCH_SensitivityRatioGet() as arguments.
Example of calculation 1:
The touch sensitivity ratio is 140%, and the threshold set by QE is 1500.
Threshold = 140 * 1500 / 100 = 2100
*p_touch_sensitivity_ratio = 140,
old_threshold_ratio = 60,
new_threshold_ratio = 60,
new_hysteresis_ratio = 5
Example of calculation 2:
The touch sensitivity ratio is 60%, and the threshold set by QE is 1500.
Threshold = 60 * 1500 / 100 = 900
*p_touch_sensitivity_ratio = 60,
old_threshold_ratio = 60,
new_threshold_ratio = 60,
new_hysteresis_ratio = 5
RM_TOUCH_DriftContorol() set the second argument to 0 to stop the drift correction function.
When calculating the ratio of the touch change amount using RM_TOUCH_SensitivityRatioGet(), the touch change amount decreases due to the thick overlay, and the threshold value is not exceeded even if touched. Prevents the reference value from drifting.
Enable UART communication to PC and ‘tuning mode’. In tuning mode, the MCU transmits the ratio of the touch sensitivity in the touch state to the PC in real time. A user sends a command to decide the ratio while monitoring on the PC. The MCU stores the received ratio in the data flash. Make sure that the ratio stored in the data flash is read at the software activation, and the touch determination threshold is adjusted based on this stored value.
Configure a pad with multiple terminals physically arranged in cross.
The current position is Calculated from the measured values of the CTSU mutual scanning in the configuration.
Use RM_TOUCH_PadDataGet().
Pad is subject so some limitations:
Pad | |
---|---|
Electrode type | CFC mutual capacitance only |
Number of electrodes | RX(TS-CFC)3+, TX(Any TS)3+ |
Touch position output range | rx_coodinate:(0 ~ rx_pixel), tx_coodinate:(0 ~ tx_pixsel) |
Default value (no touch) | rx_coodinate:0xFFFF, tx_coodinate:0xFFFF |
Pixel range | rx_pixel:(1 ~ 65535), tx_pixsel:(1 ~ 65535) |
Pitch for each terminal can be set with QE. Pitch's default value is 64.
The relationship between pixel and pitch : Pixel = Pitch × number of TS - 1
In r_ctsu and rm_touch module, Non-Secure Callable Guard Functions are only generated from QE for Capacitive Touch. QE can be used for tuning in secure or flat project, but not in non-secure project. If you want to use in non-secure project, copy the output file from secure or flat project. Refer to QE Help for more information.
This is a basic example of minimal use of the TOUCH in an application.
This is a optional example of using both Self-capacitance and Mutual-capacitance. Refer to the Multi Mode Example in CTSU usage notes.
Data Structures | |
struct | touch_button_info_t |
struct | touch_slider_info_t |
struct | touch_wheel_info_t |
struct | touch_pad_info_t |
struct | touch_mm_info_t |
struct | touch_instance_ctrl_t |
struct touch_button_info_t |
Information of button
struct touch_slider_info_t |
struct touch_wheel_info_t |
struct touch_pad_info_t |
Information of pad
struct touch_mm_info_t |
Information of touch button judge(CTSU2)
struct touch_instance_ctrl_t |
TOUCH private control block. DO NOT MODIFY. Initialization occurs when RM_TOUCH_Open() is called.
Data Fields | ||
---|---|---|
uint32_t | open | Whether or not driver is open. |
touch_button_info_t | binfo | Information of button. |
touch_slider_info_t | sinfo | Information of slider. |
touch_wheel_info_t | winfo | Information of wheel. |
bool | serial_tuning_enable | Flag of serial tuning status. |
touch_pad_info_t | pinfo | Information of pad. |
touch_cfg_t const * | p_touch_cfg | Pointer to initial configurations. |
ctsu_instance_t const * | p_ctsu_instance | Pointer to CTSU instance. |
touch_mm_info_t * | p_touch_mm_info | Pointer to information of touch button judge. |
fsp_err_t RM_TOUCH_Open | ( | touch_ctrl_t *const | p_ctrl, |
touch_cfg_t const *const | p_cfg | ||
) |
Opens and configures the TOUCH Middle module. Implements touch_api_t::open.
Example:
FSP_SUCCESS | TOUCH successfully configured. |
FSP_ERR_ASSERTION | Null pointer, or one or more configuration options is invalid. |
FSP_ERR_ALREADY_OPEN | Module is already open. This module can only be opened once. |
FSP_ERR_INVALID_ARGUMENT | Configuration parameter error. |
fsp_err_t RM_TOUCH_ScanStart | ( | touch_ctrl_t *const | p_ctrl | ) |
This function should be called each time a periodic timer expires. If initial offset tuning is enabled, The first several calls are used to tuning for the sensors. Before starting the next scan, first get the data with RM_TOUCH_DataGet(). If a different control block scan should be run, check the scan is complete before executing. Implements touch_api_t::scanStart.
FSP_SUCCESS | Successfully started. |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_CTSU_SCANNING | Scanning this instance or other. |
FSP_ERR_CTSU_NOT_GET_DATA | The previous data has not been retrieved by DataGet. |
fsp_err_t RM_TOUCH_DataGet | ( | touch_ctrl_t *const | p_ctrl, |
uint64_t * | p_button_status, | ||
uint16_t * | p_slider_position, | ||
uint16_t * | p_wheel_position | ||
) |
Gets the 64-bit mask indicating which buttons are pressed. Also, this function gets the current position of where slider or wheel is being pressed. If initial offset tuning is enabled, The first several calls are used to tuning for the sensors. Implements touch_api_t::dataGet.
FSP_SUCCESS | Successfully data decoded. |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_INVALID_DATA | Accuracy of data is not guaranteed. |
FSP_ERR_CTSU_SCANNING | Scanning this instance. |
FSP_ERR_CTSU_INCOMPLETE_TUNING | Incomplete initial offset tuning. |
fsp_err_t RM_TOUCH_PadDataGet | ( | touch_ctrl_t *const | p_ctrl, |
uint16_t * | p_pad_rx_coordinate, | ||
uint16_t * | p_pad_tx_coordinate, | ||
uint8_t * | p_pad_num_touch | ||
) |
This function gets the current position of pad is being pressed. Implements touch_api_t::padDataGet , g_touch_on_ctsu.
FSP_SUCCESS | Successfully data decoded. |
FSP_ERR_ASSERTION | Null pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_INVALID_DATA | Accuracy of data is not guaranteed. |
FSP_ERR_CTSU_SCANNING | Scanning this instance. |
fsp_err_t RM_TOUCH_ScanStop | ( | touch_ctrl_t *const | p_ctrl | ) |
Scan stop specified TOUCH control block. Implements touch_api_t::scanStop.
FSP_SUCCESS | Successfully closed. |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not open. |
fsp_err_t RM_TOUCH_CallbackSet | ( | touch_ctrl_t *const | p_api_ctrl, |
void(*)(touch_callback_args_t *) | p_callback, | ||
void const *const | p_context, | ||
touch_callback_args_t *const | p_callback_memory | ||
) |
Updates the user callback and has option of providing memory for callback structure. Implements touch_api_t::callbackSet
FSP_SUCCESS | Callback updated successfully. |
FSP_ERR_ASSERTION | A required pointer is NULL. |
FSP_ERR_NOT_OPEN | The control block has not been opened. |
fsp_err_t RM_TOUCH_Close | ( | touch_ctrl_t *const | p_ctrl | ) |
Disables specified TOUCH control block. Implements touch_api_t::close.
FSP_SUCCESS | Successfully closed. |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not open. |
fsp_err_t RM_TOUCH_SensitivityRatioGet | ( | touch_ctrl_t *const | p_ctrl, |
touch_sensitivity_info_t * | p_touch_sensitivity_info | ||
) |
Get the touch sensitivity ratio. Implements touch_api_t::sensitivityRatioGet.
FSP_SUCCESS | Successfully touch sensitivity ratio got. |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_CTSU_SCANNING | Scanning this instance. |
FSP_ERR_CTSU_INCOMPLETE_TUNING | Incomplete initial offset tuning. |
fsp_err_t RM_TOUCH_ThresholdAdjust | ( | touch_ctrl_t *const | p_ctrl, |
touch_sensitivity_info_t * | p_touch_sensitivity_info | ||
) |
Adjust the touch judgment threshold. Implements touch_api_t::thresholdAdjust.
FSP_SUCCESS | Successfully touch judgment threshold was adjusted. |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not open. |
fsp_err_t RM_TOUCH_DriftControl | ( | touch_ctrl_t *const | p_ctrl, |
uint16_t | input_drift_freq | ||
) |
Control drift correction. Implements touch_api_t::driftControl.
FSP_SUCCESS | Successfully drift correction was controlled. |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not open. |