This is the documentation for the latest (main) development branch of Zephyr. If you are looking for the documentation of previous releases, use the drop-down menu on the left and select the desired version.

PS/2

Overview

The PS/2 connector first hit the market in 1987 on IBM’s desktop PC line of the same name before becoming an industry-wide standard for mouse and keyboard connections. Starting around 2007, USB superseded PS/2 and is the modern peripheral device connection standard. For legacy support on boards with a PS/2 connector, Zephyr provides these PS/2 driver APIs.

Configuration Options

Related configuration options:

API Reference

group ps2_interface

PS/2 Driver APIs.

Typedefs

typedef void (*ps2_callback_t)(const struct device *dev, uint8_t data)

PS/2 callback called when user types or click a mouse.

Parameters
  • dev – Pointer to the device structure for the driver instance.

  • data – Data byte passed pack to the user.

Functions

int ps2_config(const struct device *dev, ps2_callback_t callback_isr)

Configure a ps2 instance.

Parameters
  • dev – Pointer to the device structure for the driver instance.

  • callback_isr – called when PS/2 devices reply to a configuration command or when a mouse/keyboard send data to the client application.

Returns

  • 0 – If successful.

  • Negative – errno code if failure.

int ps2_write(const struct device *dev, uint8_t value)

Write to PS/2 device.

Parameters
  • dev – Pointer to the device structure for the driver instance.

  • value – Data for the PS2 device.

Returns

  • 0 – If successful.

  • Negative – errno code if failure.

int ps2_read(const struct device *dev, uint8_t *value)

Read slave-to-host values from PS/2 device.

Parameters
  • dev – Pointer to the device structure for the driver instance.

  • value – Pointer used for reading the PS/2 device.

Returns

  • 0 – If successful.

  • Negative – errno code if failure.

int ps2_enable_callback(const struct device *dev)

Enables callback.

Parameters
  • dev – Pointer to the device structure for the driver instance.

Returns

  • 0 – If successful.

  • Negative – errno code if failure.

int ps2_disable_callback(const struct device *dev)

Disables callback.

Parameters
  • dev – Pointer to the device structure for the driver instance.

Returns

  • 0 – If successful.

  • Negative – errno code if failure.