# TP_RequestAutoSamplingStart

## Syntax

  `#include <nitro/spi.h>`

      u32 TP_RequestAutoSamplingStart(
                  u16 vcount,
                  u16 frequence,
                  TPData samplingBufs[],
                  u16 bufSize );

## Arguments

vcount | Base V-Count value for auto-sampling. If you specify a value greater than or equal to `HW_LCD_LINES`, which indicates the vertical line count, `TP_RESULT_INVALID_PARAMETER` will be returned.
frequence | The number of samples taken during one frame. (Maximum of 4). If you specify a value of 5 or greater, `TP_RESULT_INVALID_PARAMETER` will be returned.
samplingBufs | The pointer that sets the buffer in which auto sampling values are stored.
bufSize | The element count of the buffer passed by samplingBufs.

## Return Values

Returns 0 if the request succeeds; returns non-zero value if it fails. For details, see `TPRequestResult`.

## Description

This function issues a request to ARM7 to begin auto sampling touch panel values and waits for the request to complete internally. This is the synchronous version of the `TP_RequestAutoSamplingStartAsync` function.
After this request is accepted, sampling is carried out periodically and values are stored in the array specified by samplingBufs. The auto-sampling interval is the uniform interval at which VAlarm samples data: frequence times per frame, based on the value set in vcount.
However, the span of time over which the V-Count values range from 200 to 214 is not used for sampling. This is because the V-Count values may be changed by the `GX_SetVCount` function. If the V-count value to be sampled is contained in this interval, sampling is delayed until line 215.
If a user callback is set with the `TP_SetCallback` function, notification is given by a callback each time a value is saved.
After this function clears samplingBufs, the buffer will be used as a loop buffer. The `TP_GetLatestIndexInAuto` function can be used to get the index of the data that was last saved.
When auto-sampling, it is possible that the sampling value for (newest index + 1) will be unexpectedly overwritten by an interrupt. If you are using the sampling values from one frame all together, you can avoid this by securing an area of size equivalent to at least (frequence + 1).

## Note

This function uses an interrupt to wait for a completion response from ARM7. Note that if this function is called while FIFO receive interrupts from ARM7 are prohibited, it will not return from wait.

## See Also

`TP_RequestAutoSamplingStop
TP_GetLatestRawPointInAuto
TP_GetLatestCalibratedPointInAuto
TP_GetLatestIndexInAuto
TP_RequestAutoSamplingStartAsync
TPData`

## Revision History

2009/04/28 Added conditions on the arguments and added `TPRequestResult` to the return value description.
2007/10/29 Added explanations.
2007/10/16 Added an explanation for unused V-Count values.
2006/09/01 Modified the description of `bufSize`.
2004/04/21 Created an asynchronous version and made this version synchronous.
2004/04/16 Initial version.

CONFIDENTIAL