# TPRecvCallback

## C Specification

      #include <nitro/spi.h>

      typedef void (*TPRecvCallback)(
              TPRequestCommand    command,
              TPRequestResult     result,
              u16                 index );

## Description

This is the format of the the user callback that is called each time a request to the subprocessor is processed, and each time that a touch panel value is periodically received as the result of autosampling.

The `command` value identifies for which request the results are acquired. The `result` value acquires whether or not it was processed properly. The `index` value acquires the index of the most recent data when autosampling is in use.

`TP_REQUEST_COMMAND_SAMPLING` | Requests sampling one time. Send with `TP_RequestSampling*`.
`TP_REQUEST_COMMAND_AUTO_ON` | Requests to start autosampling. Send with `TP_RequestAutoSamplingStart`.
`TP_REQUEST_COMMAND_AUTO_OFF` | Requests to stop autosampling. Send with `TP_RequestAutoSamplingStop`.
`TP_REQUEST_COMMAND_SET_STABILITY` | Requests to set chattering provision parameters. Send with `TP_RequestSetStability`.
`TP_REQUEST_COMMAND_AUTO_SAMPLING` | This callback is called each time data is set by autosampling.

`TP_RESULT_SUCCESS` | Successful end
`TP_RESULT_INVALID_PARAMETER` | Parameters in the request that was sent are incorrect.
`TP_RESULT_INVALID_STATUS` | Cannot process this instruction in current status.
`TP_RESULT_INVALID_EXCLUSIVE` | Sub processor's peripheral device interface is in busy status.
`TP_RESULT_PXI_BUSY` | Request failed because communication between CPUs is busy

Argument enumerator types are defined below.

    // Type of instruction issued to the touch panel
    typedef enum {
        TP_REQUEST_COMMAND_SAMPLING         = 0x0,  // Sample one time
        TP_REQUEST_COMMAND_AUTO_ON          = 0x1,  // Start autosampling
        TP_REQUEST_COMMAND_AUTO_OFF         = 0x2,  // Stop autosampling
        TP_REQUEST_COMMAND_SETUP_STABILITY  = 0x3,  // Set chattering provision value
        TP_REQUEST_COMMAND_AUTO_SAMPLING    = 0x10 // Receive autosampling results
    } TPRequestCommand;

    // Type of results from the touch panel
    typedef enum {
        TP_RESULT_SUCCESS = 0 ,             // Success
        TP_RESULT_INVALID_PARAMETER ,       // Invalid parameter
        TP_RESULT_ILLEGAL_STATUS ,          // In current status cannot receive instructions
        TP_RESULT_EXCLUSIVE ,               // SPI device is busy
        TP_RESULT_PXI_BUSY                  // The PXI communication with ARM7 is busy
    } TPRequestResult;

## Arguments

`command` | Type of request command
`result` | Process results
`index` | Index value of autosampling callback

## Return Values

None

## See Also

`TP_SetCallback`, `TP_RequestSampling`, `TP_RequestAutoSamplingStart`, `TP_RequestAutoSamplingStop`, `TP_RequestSetStability`

## Revision History

04/16/2004 Initial version