RA Flexible Software Package Documentation
Release v5.7.0
|
|
Functions | |
fsp_err_t | R_CTSU_Open (ctsu_ctrl_t *const p_ctrl, ctsu_cfg_t const *const p_cfg) |
Opens and configures the CTSU driver module. Implements ctsu_api_t::open. More... | |
fsp_err_t | R_CTSU_ScanStart (ctsu_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 R_CTSU_DataGet(). If a different control block scan should be run, check the scan is complete before executing. Implements ctsu_api_t::scanStart. More... | |
fsp_err_t | R_CTSU_DataGet (ctsu_ctrl_t *const p_ctrl, uint16_t *p_data) |
This function gets the sensor values as scanned by the CTSU. If initial offset tuning is enabled, The first several calls are used to tuning for the sensors. Implements ctsu_api_t::dataGet. More... | |
fsp_err_t | R_CTSU_OffsetTuning (ctsu_ctrl_t *const p_ctrl) |
This function tunes the offset register(SO). Call after the measurement is completed. If the return value is FSP_ERR_CTSU_INCOMPLETE_TUNING, tuning is not complete. Execute the measurement and this function call routine until the return value becomes FSP_SUCCESS. It is recommended to run this routine after R_CTSU_Open(). It can be recalled and tuned again. When the automatic judgement is enabled, after the offset tuning is completed,the baseline initialization bit flag is set. Implements ctsu_api_t::offsetTuning. More... | |
fsp_err_t | R_CTSU_ScanStop (ctsu_ctrl_t *const p_ctrl) |
This function scan stops the sensor as scanning by the CTSU. Implements ctsu_api_t::scanStop. More... | |
fsp_err_t | R_CTSU_CallbackSet (ctsu_ctrl_t *const p_api_ctrl, void(*p_callback)(ctsu_callback_args_t *), void const *const p_context, ctsu_callback_args_t *const p_callback_memory) |
fsp_err_t | R_CTSU_Close (ctsu_ctrl_t *const p_ctrl) |
Disables specified CTSU control block. Implements ctsu_api_t::close. More... | |
fsp_err_t | R_CTSU_SpecificDataGet (ctsu_ctrl_t *const p_ctrl, uint16_t *p_specific_data, ctsu_specific_data_type_t specific_data_type) |
This function gets the sensor specific data values as scanned by the CTSU. Call this function after calling the R_CTSU_DataGet() function. More... | |
fsp_err_t | R_CTSU_DataInsert (ctsu_ctrl_t *const p_ctrl, uint16_t *p_insert_data) |
This function inserts the value of the second argument as the measurement result value. Call this function after calling the R_CTSU_DataInsert() function. Implements ctsu_api_t::dataInsert. More... | |
fsp_err_t | R_CTSU_Diagnosis (ctsu_ctrl_t *const p_ctrl) |
Diagnosis the CTSU peripheral. Implements ctsu_api_t::diagnosis. More... | |
This HAL driver supports the Capacitive Touch Sensing Unit (CTSU). It implements the CTSU Interface.
The capacitive touch sensing unit HAL driver (r_ctsu) provides an API to control the CTSU peripheral. This module performs capacitance measurement based on various settings defined by the configuration. This module is configured via the QE for Capacitive Touch.
Configuration | Options | Default | Description |
---|---|---|---|
Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
Support for using DTC |
| Disabled | Enable DTC support for the CTSU module. |
Interrupt priority level | MCU Specific Options | Priority level of all CTSU interrupt (CSTU_WR,CTSU_RD,CTSU_FN) |
Configuration | Options | Default | Description |
---|---|---|---|
Scan Start Trigger | MCU Specific Options | CTSU Scan Start Trigger Select |
The first R_CTSU_Open function call sets CTSU peripheral interrupts. The user should provide a callback function to be invoked at the end of the CTSU scan sequence. The callback argument will contain information about the scan status.
The CTSU peripheral module uses PCLKB as its clock source. You can set the PCLKB frequency using the Clocks tab of the RA Configuration editor or by using the CGC Interface at run-time.
The TSn pins are sensor pins for the CTSU.
The TSCAP pin is used for an internal low-pass filter and must be connected to an external decoupling capacitor.
The CTSU module is a CTSU driver for the Touch module. The CTSU module assumes the access from the Touch middleware layer, and it is also accessible from an user application.
CTSU and CTSU2 are functionally different, so CTSU and CTSU2 are described in this application note as below.
Common description for CTSU and CTSU2 -> CTSU
Description only for CTSU -> CTSU1
Description only for CTSU2 -> CTSU2
Without mention, it means the common description for CTSU and CTSU2.
The CTSU module supports the following functions.
CTSU2 has three judgment type, which differ in processing and output data.
It is common to get three raw value for each element and calculate CCO correction, and then performs different processing.
Measurements can be started by a software trigger or by an external event triggered by the Event Link Controller (ELC).
As the measurement process is carried out by the CTSU2 peripheral, it does not use up main processor processing time.
The CTSU module processes INTCTSUWR and INTCTSURD if generated during a measurement. The data transfer controller (DTC) can also be used for these processes.
When the measurement complete interrupt (INTCTSUFN) process is complete, the application is notified in a callback function. Make sure you obtain the measurement results before the next measurement is started as internal processes are also executed when a measurement is completed.
Start the measurement with API function R_CTSU_ScanStart().
Obtain the measurement results with API function R_CTSU_DataGet().
The number of arrays in the second argument of R_CTSU_DataGet() is different between VMM and JMM.
VMM returns one measurement result for each element.
JMM returns three measurement results for each element.
The CTSU2 peripheral has a built-in correction circuit to handle the potential microvariations related to the manufacturing process of the sensor CCO MCU.
The module temporarily transitions to the correction process during initialization after power is turned on. In the correction process, the correction circuit is used to generate a correction coefficient (factor) to ensure accurate sensor measurement values.
When temperature correction is enabled, an external resistor connected to a TS terminal is used to periodically update the correction coefficient. By using an external resistor that is not dependent on temperature, you can even correct the temperature drift of the sensor CCO.
The CTSU2 peripheral was designed with a built-in offset current circuit in consideration of the amount of change in current due to touch. The offset current circuit cancels enough of the parasitic capacitance for it to fit within the sensor CCO dynamic range.
This module automatically adjusts the offset current setting. As the adjustment uses the normal measurement process, the combination of R_CTSU_ScanStart() and R_CTSU_DataGet() or the combination of R_CTSU_ScanStart() and R_CTSU_OffsetTuning() must be repeated several times after startup. Because the ctsu_element_cfg_t member “so” is the starting point for adjustments, you can set the appropriate value for “so” in order to reduce the number of times the two functions must be run to complete the adjustment. Normally, the value used for “so” is a value adjusted by QE for Capacitive Touch.
R_CTSU_OffsetTuning() was added in FSP 3.8.0. This API can also be used for initial offset adjustment, and offset adjustment can be performed again at any time. See example code of R_CTSU_OffsetTuning() for details.
Mode | Default target value |
---|---|
Self-capacitance | 15360 (37.5%) |
Self-capacitance using active shield | 6144 (15%) |
Mutual-capacitance | 10240 (20%) |
The percentage is for the CCO's input limit. 100% is the measured value 40960.
The default target value is based on 526us(CTSU1) or 256us(CTSU2).
When the measurement time is changed, the target value is adjusted by the ratio with the base time.
Example of target value in combination of CTSUSNUM and CTSUSDPA.
CTSU1 (CTSU clock = 32MHz, Self-capacitance mode)
Target value | CTSUSNUM | CTSUSDPA | Measurement time |
---|---|---|---|
15360 | 0x3 | 0x7 | 526usec |
30720 | 0x7 | 0x7 | 1052usec |
30720 | 0x3 | 0xF | 1052usec |
7680 | 0x1 | 0x7 | 263usec |
7680 | 0x3 | 0x3 | 263usec |
The measurement time changes depending on the combination of CTSUSNUM and CTSUSDPA.
In the above table, CTSUPRRTIO is the recommended value of 3, and CSTUPRMODE is the recommended value of 2.
When changing CTSUPRRATIO and CTSUPRMODE from the recommended values, follow the Hardware Manual for the measurement time.
CTSU2 (Self-capacitance mode)
Target value | Target value (multi frequency) | CTSUSNUM | Measurement time |
---|---|---|---|
7680 | 15360 (128us + 128us) | 0x7 | 128usec |
15360 | 30720 (256us + 256us) | 0xF | 256usec |
3840 | 7680 (64us + 64us) | 0x3 | 64usec |
The measurement time changes depending on CTSUSNUM.
If STCLK cannot be set to 0.5MHz, it will not support the table above.
When setting STCLK to other than 0.5MHz because the CTSU clock is not an integer, follow the hardware manual for the measurement time.
The CTSU1 peripheral measures at one drive frequency.
The drive frequency determines the amperage to the electrode and generally uses the value tuned with QE for Capacitive Touch.
The drive frequency is calculated as below.
It is determined by PCLK frequency input to CTSU, CTSU Count Source Select bit(CTSUCLK), and CTSU Sensor Drive pulse Division Control bit(CTSUSDPA). For example, If it is set PCLK =32MHz, CTSUCLK = PLCK/2, and CTSUSDPA = 1/16, then drive frequency is 0.5MHz. CTSUSDPA can change for each TS port.
The actual drive pulse is phase-shifted and frequency-spread with respect to the clock based on the drive frequency as a measure against external environmental noise. This module is fixed at initialization and sets the following.
CTSUSOFF = 0,CTSUSSMOD = 0,CTSUSSCNT = 3
The CTSU2 peripheral can measure in one of four drive frequencies to avoid synchronous noise.
With the default settings, the module takes measurements at three different frequencies. This data are called raw data. And calculate CCO correction. This data are called CCO correction data.
In VMM, After standardizing the results obtained at the three frequencies in accordance with the first frequency reference value, the measured value is determined based on majority in a process referred to as “normalization.”
The three values standardized to the first frequency reference value are called frequency correction data.
You can get the three correction data with R_CTSU_SpecificDataGet().
In VMM, three raw data, CCO correction data, and frequency correction data can be obtained with R_CTSU_SpecificDataGet().
In JMM, three raw data and three CCO correction data can be obtained with R_CTSU_SpecificDataGet().
Drive frequency is determined based on the config settings. The module sets registers according to the config settings, and sets the three drive frequencies.
Drive frequency is calculated in the following equation:
(PCLKB frequency / CLK / STCLK) x SUMULTIn / 2 / SDPA : n = 0, 1, 2
The figure below shows the settings for generating a 2MHz drive frequency when the PCLKB frequency is 32 MHz. SDPA can be set for each touch interface configuration.
The CTSU2 peripheral has a built-in function that outputs a shield signal in phase with the drive pulse from the shield terminal and the non-measurement terminal in order to shield against external influences while suppressing any increase in parasitic capacitance. This function can only be used during self-capacitance measurements.
This module allows the user to set a shield for each touch interface configuration.
For example, for the electrode configuration shown in , the members of ctsu_cfg_t should be set as follows. Other members have been omitted for the example.
.txvsel = CTSU_TXVSEL_INTERNAL_POWER,
.txvsel2 = CTSU_TXVSEL_MODE,
.md = CTSU_MODE_SELF_MULTI_SCAN,
.posel = CTSU_POSEL_SAME_PULSE,
.ctsuchac0 = 0x0F,
.ctsuchtrc0 = 0x08,
When the CTSU2 peripheral detects an abnormal measurement, it sets the status register bit to 1.
In the measurement complete interrupt process, the module reads ICOMP1, ICOMP0, and SENSOVF of the status register and notifies the results in the callback function. The status register is reset after the contents are read. For more details on abnormal measurements, refer to “member event” in the ctsu_callback_args_t callback function argument.
This function calculates the moving average of the measured results.
Set the number of times the moving average should be calculated in the config settings.
The CTSU peripheral has a built-in function that diagnoses its own inner circuit. This diagnosis function provides the API for diagnosing the inner circuit.
The diagnostic requirements are different for CTSU1 and CTSU2 providing 5 types of diagnosis for CTSU1 and 9 types for CTSU2.
The diagnosis function is executed by calling the API function. This is executed independently from the other measurements and does not affect them.
To enable the diagnosis function, set CTSU_CFG_DIAG_SUPPORT_ENABLE to 1.
For CTSU1, a 27pF condenser should be connected externally.
For CTSU2, Diagnosis function uses the ADC module.
If an error occurs in the ADC module used for Diagnosis mode, return FSP_ERR_ABORTED as the return value of R_CTSU_DataGet().
If an ADC error is returned, exit the function so as not to measure or close the ADC.
See ADC (r_adc) for ADC module errors.
Please pay particular attention to the following three points.
This module supports all three modes offered by the CTSU2 peripheral: self-capacitance, mutual-capacitance, and current measurement modes. The temperature correction mode is also offered as a mode for updating the correction coefficient.
The self-capacitance mode is used to measure the capacitance of each terminal (TS).
The CTSU2 peripheral measures the terminals in ascending order according to the TS numbers, then stores the data. For example, even if you want to use TS5, TS8, TS2, TS3 and TS6 in your application in that order, they will still be measured and stored in the order of TS2, TS3, TS5, TS6, and TS8. Therefore, you will need to reference buffer indexes [2], [4], [0], [1], and [3].
VMM returns one measurement result for each element.
JMM returns three measurement results for each element.
[CTSU1]
In default settings, the measurement period for each TS is wait-time plus approximately 526us.
[CTSU2]
In default settings, the measurement period for each TS is approximately 576us.
The mutual-capacitance mode is used to measure the capacitance generated between the receive TS (Rx) and transmit TS (Tx), and therefore requires at least two terminals.
The CTSU2 peripheral measures all specified combinations of Rx and Tx. For example, when Rx is TS1 and TS3, and Tx is TS2, TS7 and TS4, the combinations are measured in the following order and the data is stored.
TS3-TS2, TS3-TS4, TS3-TS7, TS10-TS2, TS10-TS4, TS10-TS7
To measure the mutual-capacitance generated between electrodes, the CTSU2 peripheral performs the measurement process on the same electrode twice.
The mutual-capacitance is obtained by inverting the phase relationship of the pulse output and switched capacitor in the primary and secondary measurements, and calculating the difference between the two measurements. This module does not calculate the difference, but outputs both primary and secondary measured result.
VMM returns two measurement results(one primary and one secondary) for each element.
JMM returns six measurement results(three primary and three secondary) for each element.
[CTSU1]
In default settings, the measurement period for each TS is twice of wait-time plus approximately 526us.
[CTSU2]
In default settings, the measurement period for each TS is approximately 1152us.
This mode provides fast measurement time by parallel scanning the RX lines with a CFC circuit. Operation is otherwise identical to normal CTSU mutual scanning.
The current measurement mode is used to measure the minute current input to the TS terminal. The order of measurement and data storage is the same as that of the self-capacitance mode. As this does not involve the switched capacitor operation, the measurement is only performed once. The measurement period for one TS under default settings is approximately 256us. The current measurement mode requires a longer stable wait time than the other modes, so the SST is set to 63.
The temperature correction mode is used to periodically update the correction coefficient using an external resistor connected to a TS terminal. This involves three processes as described below. Also refer to the timing chart in Figure of Temperature Correction Measurement Timing Chart.
Temperature correction uses the ADC module.
If an error occurs in the ADC module used for temperature correction, return FSP_ERR_ABORTED as the return value of R_CTSU_DataGet().
If an ADC error is returned, exit the function so as not to measure or close the ADC.
See ADC (r_adc) for ADC module errors.
Please pay articular attention to the following three points.
The diagnosis mode is a mode in which various internal measurement values are scanned by using this diagnosis function R_CTSU_Diagnosis().
Measurements are initiated by a software trigger or an external event which is triggered by the Event Link Controller (ELC).
The most common method is using a timer to carry out periodic measurements. Make sure to set the timer interval to allow the measurement and internal value update processes to complete before the next measurement period. The measurement period differs according to touch interface configuration and measurement mode.
The execution timing of software triggers and external triggers differ slightly.
Since a software trigger sets the start flag after setting the touch interface configuration with R_CTSU_ScanStart(), there is a slight delay after the timer event occurrence. However, as the delay is much smaller than the measurement period, a software trigger is recommended for most instances as it is easy to set.
An external trigger is recommended for applications in which this slight delay is not acceptable or that require low-power consumption operations. When using an external trigger with multiple touch interface configurations, use R_CTSU_ScanStart() to set another touch interface configuration after one measurement is completed.
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.
The flow of storing data in RAM is as follows.
(CTSU1)
(CTSU2 VMM)
(CTSU2 JMM)
There are two ways to add the user's filter.
Please check example.
User's filter additional Example
This is a basic example of minimal use of the CTSU in an application.
This is a optional example of using both Self-capacitance and Mutual-capacitance configurations in the same project.
This is an example of offset adjustment using R_CTSU_OffsetTuning().
After completing R_CTSU_Open (), perform initial offset adjustment.
Offset adjustment is performed again when the parasitic capacitance changes significantly due to changes in the surrounding environment and the count value becomes an abnormal value.
This is a Diagnosis function example of using the configuration in the basic example.
This is a user's filter additiional example of using the configuration in the basic example.
To perform user's filter calculation, change the num_moving_average of the element in the target ctsu_cfg_t to 1.
Perform user filter calculation and use R_CTSU_DataInsert() to input user filter calculation result.
Using the correction data obtained by R_CTSU_SpecificDataGet(). Perform user majority decision calculation & filter calculation and use R_CTSU_DataInsert() to input user majority decision calculation & filter calculation result.
Data Structures | |
struct | ctsu_ctsuwr_t |
struct | ctsu_self_buf_t |
struct | ctsu_mutual_buf_t |
struct | ctsu_correction_info_t |
struct | ctsu_instance_ctrl_t |
Enumerations | |
enum | ctsu_state_t |
enum | ctsu_tuning_t |
enum | ctsu_correction_status_t |
enum | ctsu_range_t |
struct ctsu_ctsuwr_t |
struct ctsu_self_buf_t |
struct ctsu_mutual_buf_t |
struct ctsu_correction_info_t |
Correction information
Data Fields | ||
---|---|---|
ctsu_correction_status_t | status | Correction status. |
ctsu_ctsuwr_t | ctsuwr | Correction scan parameter. |
volatile ctsu_self_buf_t | scanbuf | Correction scan buffer. |
uint16_t | first_val | 1st correction value |
uint16_t | second_val | 2nd correction value |
uint32_t | first_coefficient | 1st correction coefficient |
uint32_t | second_coefficient | 2nd correction coefficient |
uint32_t | ctsu_clock | CTSU clock [MHz]. |
struct ctsu_instance_ctrl_t |
CTSU private control block. DO NOT MODIFY. Initialization occurs when R_CTSU_Open() is called.
Data Fields | |
uint32_t | open |
Whether or not driver is open. | |
volatile ctsu_state_t | state |
CTSU run state. | |
ctsu_cap_t | cap |
CTSU Scan Start Trigger Select. | |
ctsu_md_t | md |
CTSU Measurement Mode Select(copy to cfg) | |
ctsu_tuning_t | tuning |
CTSU Initial offset tuning status. | |
uint16_t | num_elements |
Number of elements to scan. | |
uint16_t | wr_index |
Word index into ctsuwr register array. | |
uint16_t | rd_index |
Word index into scan data buffer. | |
uint8_t * | p_element_complete_flag |
Pointer to complete flag of each element. g_ctsu_element_complete_flag[] is set by Open API. | |
int32_t * | p_tuning_diff |
Pointer to difference from base value of each element. g_ctsu_tuning_diff[] is set by Open API. | |
uint16_t | average |
CTSU Moving average counter. | |
uint16_t | num_moving_average |
Copy from config by Open API. | |
uint8_t | ctsucr1 |
Copy from (atune1 << 3, md << 6) by Open API. CLK, ATUNE0, CSW, and PON is set by HAL driver. | |
ctsu_ctsuwr_t * | p_ctsuwr |
CTSUWR write register value. g_ctsu_ctsuwr[] is set by Open API. | |
ctsu_self_buf_t * | p_self_raw |
Pointer to Self raw data. g_ctsu_self_raw[] is set by Open API. | |
uint16_t * | p_self_corr |
Pointer to Self correction data. g_ctsu_self_corr[] is set by Open API. | |
ctsu_data_t * | p_self_data |
Pointer to Self moving average data. g_ctsu_self_data[] is set by Open API. | |
ctsu_mutual_buf_t * | p_mutual_raw |
Pointer to Mutual raw data. g_ctsu_mutual_raw[] is set by Open API. | |
uint16_t * | p_mutual_pri_corr |
Pointer to Mutual primary correction data. g_ctsu_self_corr[] is set by Open API. | |
uint16_t * | p_mutual_snd_corr |
Pointer to Mutual secondary correction data. g_ctsu_self_corr[] is set by Open API. | |
ctsu_data_t * | p_mutual_pri_data |
Pointer to Mutual primary moving average data. g_ctsu_mutual_pri_data[] is set by Open API. | |
ctsu_data_t * | p_mutual_snd_data |
Pointer to Mutual secondary moving average data. g_ctsu_mutual_snd_data[] is set by Open API. | |
ctsu_correction_info_t * | p_correction_info |
Pointer to correction info. | |
ctsu_txvsel_t | txvsel |
CTSU Transmission Power Supply Select. | |
ctsu_txvsel2_t | txvsel2 |
CTSU Transmission Power Supply Select 2 (CTSU2 Only) | |
uint8_t | ctsuchac0 |
TS00-TS07 enable mask. | |
uint8_t | ctsuchac1 |
TS08-TS15 enable mask. | |
uint8_t | ctsuchac2 |
TS16-TS23 enable mask. | |
uint8_t | ctsuchac3 |
TS24-TS31 enable mask. | |
uint8_t | ctsuchac4 |
TS32-TS39 enable mask. | |
uint8_t | ctsuchtrc0 |
TS00-TS07 mutual-tx mask. | |
uint8_t | ctsuchtrc1 |
TS08-TS15 mutual-tx mask. | |
uint8_t | ctsuchtrc2 |
TS16-TS23 mutual-tx mask. | |
uint8_t | ctsuchtrc3 |
TS24-TS31 mutual-tx mask. | |
uint8_t | ctsuchtrc4 |
TS32-TS39 mutual-tx mask. | |
uint16_t | self_elem_index |
self element index number for Current instance. | |
uint16_t | mutual_elem_index |
mutual element index number for Current instance. | |
uint16_t | ctsu_elem_index |
CTSU element index number for Current instance. | |
ctsu_cfg_t const * | p_ctsu_cfg |
Pointer to initial configurations. | |
IRQn_Type | write_irq |
Copy from config by Open API. CTSU_CTSUWR interrupt vector. | |
IRQn_Type | read_irq |
Copy from config by Open API. CTSU_CTSURD interrupt vector. | |
IRQn_Type | end_irq |
Copy from config by Open API. CTSU_CTSUFN interrupt vector. | |
void(* | p_callback )(ctsu_callback_args_t *) |
Callback provided when a CTSUFN occurs. | |
uint8_t | interrupt_reverse_flag |
Flag in which read interrupt and end interrupt are reversed. | |
ctsu_event_t | error_status |
error status variable to send to QE for serial tuning. | |
ctsu_callback_args_t * | p_callback_memory |
Pointer to non-secure memory that can be used to pass arguments to a callback in non-secure memory. | |
void const * | p_context |
Placeholder for user data. | |
bool | serial_tuning_enable |
Flag of serial tuning status. | |
uint16_t | serial_tuning_mutual_cnt |
Word index into ctsuwr register array. | |
uint16_t | tuning_self_target_value |
Target self value for initial offset tuning. | |
uint16_t | tuning_mutual_target_value |
Target mutual value for initial offset tuning. | |
enum ctsu_state_t |
enum ctsu_tuning_t |
enum ctsu_range_t |
fsp_err_t R_CTSU_Open | ( | ctsu_ctrl_t *const | p_ctrl, |
ctsu_cfg_t const *const | p_cfg | ||
) |
Opens and configures the CTSU driver module. Implements ctsu_api_t::open.
Example:
FSP_SUCCESS | CTSU 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 R_CTSU_ScanStart | ( | ctsu_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 R_CTSU_DataGet(). If a different control block scan should be run, check the scan is complete before executing. Implements ctsu_api_t::scanStart.
Example:
FSP_SUCCESS | CTSU successfully configured. |
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 R_CTSU_DataGet | ( | ctsu_ctrl_t *const | p_ctrl, |
uint16_t * | p_data | ||
) |
This function gets the sensor values as scanned by the CTSU. If initial offset tuning is enabled, The first several calls are used to tuning for the sensors. Implements ctsu_api_t::dataGet.
Example:
FSP_SUCCESS | CTSU successfully configured. |
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_CTSU_DIAG_NOT_YET | Diagnosis of data collected no yet. |
FSP_ERR_ABORTED | Operate error of Diagnosis ADC data collection ,since ADC use other |
fsp_err_t R_CTSU_OffsetTuning | ( | ctsu_ctrl_t *const | p_ctrl | ) |
This function tunes the offset register(SO). Call after the measurement is completed. If the return value is FSP_ERR_CTSU_INCOMPLETE_TUNING, tuning is not complete. Execute the measurement and this function call routine until the return value becomes FSP_SUCCESS. It is recommended to run this routine after R_CTSU_Open(). It can be recalled and tuned again. When the automatic judgement is enabled, after the offset tuning is completed,the baseline initialization bit flag is set. Implements ctsu_api_t::offsetTuning.
Example:
FSP_SUCCESS | CTSU successfully configured. |
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 R_CTSU_ScanStop | ( | ctsu_ctrl_t *const | p_ctrl | ) |
This function scan stops the sensor as scanning by the CTSU. Implements ctsu_api_t::scanStop.
FSP_SUCCESS | CTSU successfully scan stop. |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not open. |
fsp_err_t R_CTSU_CallbackSet | ( | ctsu_ctrl_t *const | p_api_ctrl, |
void(*)(ctsu_callback_args_t *) | p_callback, | ||
void const *const | p_context, | ||
ctsu_callback_args_t *const | p_callback_memory | ||
) |
Updates the user callback and has option of providing memory for callback structure. Implements ctsu_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_NO_CALLBACK_MEMORY | p_callback is non-secure and p_callback_memory is either secure or NULL. |
fsp_err_t R_CTSU_Close | ( | ctsu_ctrl_t *const | p_ctrl | ) |
Disables specified CTSU control block. Implements ctsu_api_t::close.
FSP_SUCCESS | CTSU successfully configured. |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not open. |
fsp_err_t R_CTSU_SpecificDataGet | ( | ctsu_ctrl_t *const | p_ctrl, |
uint16_t * | p_specific_data, | ||
ctsu_specific_data_type_t | specific_data_type | ||
) |
This function gets the sensor specific data values as scanned by the CTSU. Call this function after calling the R_CTSU_DataGet() function.
By setting the third argument to CTSU_SPECIFIC_RAW_DATA, RAW data can be output from the second argument.
By setting the third argument to CTSU_SPECIFIC_CCO_CORRECTION_DATA, the cco corrected data can be output from the second argument.
By setting the third argument to CTSU_SPECIFIC_CORRECTION_DATA, the frequency corrected data can be output from the second argument.
By setting the third argument to CTSU_SPECIFIC_SELECTED_FREQ, Get bitmap of the frequency values used in majority decision from the second argument.(CTSU2 Only) The bitmap is shown as follows.
2bit | 1bit | 0bit |
---|---|---|
3rd frequency value | 2nd frequency value | 1st frequency value |
Implements ctsu_api_t::specificDataGet.
Example:
FSP_SUCCESS | CTSU successfully configured. |
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_NOT_ENABLED | CTSU_SPECIFIC_SELECTED_FREQ is not enabled in CTSU1.(CTSU2 Only) |
fsp_err_t R_CTSU_DataInsert | ( | ctsu_ctrl_t *const | p_ctrl, |
uint16_t * | p_insert_data | ||
) |
This function inserts the value of the second argument as the measurement result value. Call this function after calling the R_CTSU_DataInsert() function. Implements ctsu_api_t::dataInsert.
Example:
FSP_SUCCESS | CTSU successfully configured. |
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 R_CTSU_Diagnosis | ( | ctsu_ctrl_t *const | p_ctrl | ) |
Diagnosis the CTSU peripheral. Implements ctsu_api_t::diagnosis.
Example:
FSP_SUCCESS | CTSU successfully configured. |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_CTSU_NOT_GET_DATA | The previous data has not been retrieved by DataGet. |
FSP_ERR_CTSU_DIAG_LDO_OVER_VOLTAGE | Diagnosis of LDO over voltage failed. |
FSP_ERR_CTSU_DIAG_CCO_HIGH | Diagnosis of CCO into 19.2uA failed. |
FSP_ERR_CTSU_DIAG_CCO_LOW | Diagnosis of CCO into 2.4uA failed. |
FSP_ERR_CTSU_DIAG_SSCG | Diagnosis of SSCG frequency failed. |
FSP_ERR_CTSU_DIAG_DAC | Diagnosis of non-touch count value failed. |
FSP_ERR_CTSU_DIAG_OUTPUT_VOLTAGE | Diagnosis of LDO output voltage failed. |
FSP_ERR_CTSU_DIAG_OVER_VOLTAGE | Diagnosis of over voltage detection circuit failed. |
FSP_ERR_CTSU_DIAG_OVER_CURRENT | Diagnosis of over current detection circuit failed. |
FSP_ERR_CTSU_DIAG_LOAD_RESISTANCE | Diagnosis of LDO internal resistance value failed. |
FSP_ERR_CTSU_DIAG_CURRENT_SOURCE | Diagnosis of LDO internal resistance value failed. |
FSP_ERR_CTSU_DIAG_SENSCLK_GAIN | Diagnosis of SENSCLK frequency gain failed. |
FSP_ERR_CTSU_DIAG_SUCLK_GAIN | Diagnosis of SUCLK frequency gain failed. |
FSP_ERR_CTSU_DIAG_CLOCK_RECOVERY | Diagnosis of SUCLK clock recovery function failed. |
FSP_ERR_CTSU_DIAG_CFC_GAIN | Diagnosis of CFC oscillator gain failed. |