qtmc.h File Reference

QTM Hardware Check service. More...

`#include <3ds/types.h>`

Go to the source code of this file.

## Functions

Result | qtmcInit (void)
| Initializes `qtm:c`. More...
void | qtmcExit (void)
| Exits `qtm:c`.
Handle * | qtmcGetSessionHandle (void)
| Returns a pointer to the current `qtm:c` session handle.
Result | QTMC_StartHardwareCheck (void)
| Starts the QTM Hardware Check API. More...
Result | QTMC_StopHardwareCheck (void)
| Stops the QTM Hardware Check API. More...
Result | QTMC_SetBarrierPattern (u32 pattern)
Result | QTMC_WaitAndCheckExpanderWorking (bool *outWorking)
| Waits for the expander management thread to (re)initalize the TI TCA6416A I2C->Parallel expander, then checks if that expander is behaving as expected (responds with the port direction config it has been configured with): it checks whether all ports have been configured as outputs. More...
Result | QTMC_SetIrLedStatusOverride (bool on)
| Temporarily overrides IR LED state. More...

## Detailed Description

QTM Hardware Check service.

Allows direct control over the parallax barrier's pattern and polarity phase through the TI TCA6416A I2C->Parallel expander, as well as control over IR LED state even when camera is used by user.

TI TCA6416A I2C->Parallel expander is located on bus I2C1 (PA 0x10161000) device ID 0x40.

The top screen parallax barrier was covered by patent US20030234980A1.

## Function Documentation

## QTMC_SetIrLedStatusOverride()

Result QTMC_SetIrLedStatusOverride | ( | bool | on | ) |

Temporarily overrides IR LED state.

Requires "manual control" from `qtm:u` to be disabled, and has lower priority than it. Same implementation as QTMS_SetIrLedStatusOverride.

Parameters

  on | Whether to turn the IR LED on or off.

Returns
  `0xD82183F8` if API not started, `0xC8A18005` if manual control was enabled or if the operation failed, or `0xC8A18009` if QTM is unavailable (in particular, QTM is always unavailable on N2DSXL). Otherwise, 0 (success).

## QTMC_StartHardwareCheck()

Result QTMC_StartHardwareCheck | ( | void |  | ) |

Starts the QTM Hardware Check API.

This must be called before using any other `qtm:c` command, and causes barrier pattern to be overriden by what was last set in QTMC_SetBarrierPattern, even in 2D mode. Also allows IR LED state to be overridden even if user uses the inner camera.

Returns
  `0xD82183F9` if already started, otherwise 0 (success).

## QTMC_StopHardwareCheck()

Result QTMC_StopHardwareCheck | ( | void |  | ) |

Stops the QTM Hardware Check API.

Restore normal barrier and IR LED management behavior.

Returns
  `0xD82183F8` if API not started, otherwise 0 (success).

## QTMC_WaitAndCheckExpanderWorking()

Result QTMC_WaitAndCheckExpanderWorking | ( | bool * | outWorking | ) |

Waits for the expander management thread to (re)initalize the TI TCA6416A I2C->Parallel expander, then checks if that expander is behaving as expected (responds with the port direction config it has been configured with): it checks whether all ports have been configured as outputs.

On N2DSXL, this function waits forever and never returns.

In detail, the hardware init procedure for the expander is as follows (as done by the expander mgmt. thread):

- configure enable expander pin on SoC: set GPIO3.bit11 to OUTPUT, then set to 1
- on the expander (I2C1 deviceId 0x40), set all ports to OUTPUT (regId 0x06, 0x07)
- on the expander, write 0 (all-transparent mask/2D) to the data registers (regId 0x02, 0x03)

Parameters

  [out] | outWorking | Where to write the working status to. If true, expander is present working. If false, the expander is present but is misbehaving. If the function does not return, then expander is missing (e.g. on N2DSXL).

Returns
  `0xD82183F8` if API not started, otherwise 0 (success).

## qtmcInit()

Result qtmcInit | ( | void |  | ) |

Initializes `qtm:c`.

Only 3 sessions (2 until 9.3.0 sysupdate) for ALL services COMBINED, including the main services, can be open at a time.