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:
Initialize the joystick: sl_si91x_joystick_init
Start joystick data acquisition: sl_si91x_joystick_start
Retrieve the joystick position: sl_si91x_joystick_get_position
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#
Enumeration for identifying the position of the joystick.
Enumeration for the joystick state (ENABLE/DISABLE).
Functions#
To configure and initialize the joystick.
To get the direction/position of the joystick.
To start or enable the joystick.
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. |
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. |
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.
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 - Operation is successful.
SL_STATUS_FAIL - Function failed.
For more information on status codes, see SL STATUS DOCUMENTATION.
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.
[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.
Pre-conditions:
Returns
Status code indicating the result:
SL_STATUS_OK - Operation is successful.
SL_STATUS_NOT_READY - Module is not ready for the requested operation (Joystick is in disabled state).
For more information on status codes, see SL STATUS DOCUMENTATION.
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.
[in] | state | Joystick enable/disable state, see sl_joystick_state_t. |
This API starts or enables the joystick by setting its state to enabled.
Pre-conditions:
sl_si91x_joystick_init must be called before this function.
Returns
Status code indicating the result:
SL_STATUS_OK - Operation is successful.
SL_STATUS_ABORT - Operation is aborted (Joystick is in disabled state).
For more information on status codes, see SL STATUS DOCUMENTATION.
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.
[in] | state | Joystick enable/disable state, see sl_joystick_state_t. |
This API stops or disables the joystick by setting its state to disabled.
Pre-conditions:
sl_si91x_joystick_init must be called before this function.
sl_si91x_joystick_start must be called before this function.
Returns
Status code indicating the result:
SL_STATUS_OK - Operation is successful.
SL_STATUS_BUSY - Module is busy (Joystick is in enabled state).
For more information on status codes, see SL STATUS DOCUMENTATION.
154
of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/sl_joystick/inc/sl_si91x_joystick.h