Joystick#


Introduction#

The SI91x joystick driver is a platform-level software module responsible for managing joystick controls. It provides an interface for initializing, starting, stopping, and reading the joystick's position. The joystick module reads different voltage levels based on the joystick's position to determine its orientation.

The sl_joystick_state_t enumeration defines the states for enabling or disabling joystick data acquisition. The sl_joystick_position_t enumeration defines the possible positions of the joystick, including not pressed, center, north, east, south, and west. These positions correspond to the physical orientation of the joystick.

  • For more information on configuring available parameters, see the respective peripheral example readme document.

Usage#

After defining the joystick configuration structures and passing an instance of sl_joystick_state_t and sl_joystick_position_t, the following functions can be used to initiate and configure the joystick module. The typical flow for implementation is as follows:

  1. Initialize the joystick: sl_si91x_joystick_init

  2. Start joystick data acquisition: sl_si91x_joystick_start

  3. Retrieve the joystick position: sl_si91x_joystick_get_position

  4. Stop joystick data acquisition: sl_si91x_joystick_stop

These functions enable easy integration of joystick controls into applications, providing a consistent interface for reading and managing joystick input.

Enumerations#

enum
SL_JOYSTICK_NONE
SL_JOYSTICK_C
SL_JOYSTICK_N
SL_JOYSTICK_E
SL_JOYSTICK_S
SL_JOYSTICK_W
}

Enumeration for identifying the position of the joystick.

enum
SL_JOYSTICK_DISABLED
SL_JOYSTICK_ENABLED
}

Enumeration for the joystick state (ENABLE/DISABLE).

Functions#

sl_status_t

To configure and initialize the joystick.

sl_status_t
sl_si91x_joystick_get_position(sl_joystick_state_t state, sl_joystick_position_t *pos)

To get the direction/position of the joystick.

sl_status_t
sl_si91x_joystick_start(sl_joystick_state_t state)

To start or enable the joystick.

sl_status_t
sl_si91x_joystick_stop(sl_joystick_state_t state)

To stop or disable the joystick.

Enumeration Documentation#

sl_joystick_position_t#

sl_joystick_position_t

Enumeration for identifying the position of the joystick.

Enumerator
SL_JOYSTICK_NONE

Not pressed.

SL_JOYSTICK_C

Center.

SL_JOYSTICK_N

North.

SL_JOYSTICK_E

East.

SL_JOYSTICK_S

South.

SL_JOYSTICK_W

West.


Definition at line 62 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/sl_joystick/inc/sl_si91x_joystick.h

sl_joystick_state_t#

sl_joystick_state_t

Enumeration for the joystick state (ENABLE/DISABLE).

Enumerator
SL_JOYSTICK_DISABLED

Joystick data acquisition is disabled.

SL_JOYSTICK_ENABLED

Joystick data acquisition is enabled.


Definition at line 74 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/sl_joystick/inc/sl_si91x_joystick.h

Function Documentation#

sl_si91x_joystick_init#

sl_status_t sl_si91x_joystick_init (void )

To configure and initialize the joystick.

Parameters
N/A

This API initializes the hoystick by configuring the ADC to read different voltages based on the Joystick's position.

Returns

  • Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Operation is successful.

    • SL_STATUS_FAIL (0x0001) - Function failed.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 94 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/sl_joystick/inc/sl_si91x_joystick.h

sl_si91x_joystick_get_position#

sl_status_t sl_si91x_joystick_get_position (sl_joystick_state_t state, sl_joystick_position_t * pos)

To get the direction/position of the joystick.

Parameters
[in]state

Joystick enable/disable state, see sl_joystick_state_t.

[out]pos

Position of the joystick, see sl_joystick_position_t.

This API retrieves the current direction or position of the joystick.

Returns

  • Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Operation is successful.

    • SL_STATUS_NOT_READY (0x0003) - Module is not ready for the requested operation (Joystick is in disabled state).

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 115 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/sl_joystick/inc/sl_si91x_joystick.h

sl_si91x_joystick_start#

sl_status_t sl_si91x_joystick_start (sl_joystick_state_t state)

To start or enable the joystick.

Parameters
[in]state

Joystick enable/disable state, see sl_joystick_state_t.

This API starts or enables the joystick by setting its state to enabled.

Returns

  • Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Operation is successful.

    • SL_STATUS_ABORT (0x0006) - Operation is aborted (Joystick is in disabled state).

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 134 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/sl_joystick/inc/sl_si91x_joystick.h

sl_si91x_joystick_stop#

sl_status_t sl_si91x_joystick_stop (sl_joystick_state_t state)

To stop or disable the joystick.

Parameters
[in]state

Joystick enable/disable state, see sl_joystick_state_t.

This API stops or disables the joystick by setting its state to disabled.

Returns

  • Status code indicating the result:

    • SL_STATUS_OK (0x0000) - Operation is successful.

    • SL_STATUS_BUSY (0x0004) - Module is busy (Joystick is in enabled state).

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 154 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/sl_joystick/inc/sl_si91x_joystick.h