joystick  2.0.0.0
Functions
Public function

Functions

void joystick_cfg_setup (joystick_cfg_t *cfg)
 Config Object Initialization function. More...
 
JOYSTCIK_RETVAL joystick_init (joystick_t *ctx, joystick_cfg_t *cfg)
 Initialization function. More...
 
void joystick_default_cfg (joystick_t *ctx)
 Click Default Configuration function. More...
 
void joystick_generic_write (joystick_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
 Generic write function. More...
 
void joystick_generic_read (joystick_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
 Generic read function. More...
 
void joystick_set_default_configuration (joystick_t *ctx)
 Set default configuration function. More...
 
uint8_t joystick_check_id_code (joystick_t *ctx)
 Check sensor ID code function. More...
 
uint8_t joystick_check_id_version (joystick_t *ctx)
 Check sensor ID version function. More...
 
void joystick_set_low_power_mode (joystick_t *ctx, uint8_t timings)
 Set Low Power Mode function. More...
 
void joystick_set_scaling_factor (joystick_t *ctx, uint8_t scaling_factor)
 Set scaling factor function. More...
 
void joystick_disabled_interrupt (joystick_t *ctx)
 Set interrupt disabled function. More...
 
void joystick_enabled_interrupt (joystick_t *ctx)
 Set interrupt enabled function. More...
 
void joystick_invert_spinning (joystick_t *ctx)
 Invert the channel voltage function. More...
 
uint8_t joystick_get_position (joystick_t *ctx)
 Get joystick position function. More...
 
uint8_t joystick_get_interrupt (joystick_t *ctx)
 Get state of interrupt pin function. More...
 
uint8_t joystick_press_button (joystick_t *ctx)
 Get state of Joystick button function. More...
 
void joystick_soft_reset (joystick_t *ctx)
 General soft reset function. More...
 
void joystick_hardware_reset (joystick_t *ctx)
 General hardware reset function. More...
 

Detailed Description

Function Documentation

◆ joystick_cfg_setup()

void joystick_cfg_setup ( joystick_cfg_t cfg)

Config Object Initialization function.

Parameters
cfgClick configuration structure.

This function initializes click configuration structure to init state.

Note
All used pins will be set to unconnected state.

◆ joystick_check_id_code()

uint8_t joystick_check_id_code ( joystick_t ctx)

Check sensor ID code function.

Parameters
ctxClick object.
Returns
sensor ID code
  • 1 : OK
  • 0 : ERROR

Function read and return sensor ID code from ID Code register.

◆ joystick_check_id_version()

uint8_t joystick_check_id_version ( joystick_t ctx)

Check sensor ID version function.

Parameters
ctxClick object.
Returns
sensor ID version
  • 1 : OK
  • 0 : ERROR

Function read and return sensor ID version from ID Version register.

◆ joystick_default_cfg()

void joystick_default_cfg ( joystick_t ctx)

Click Default Configuration function.

Parameters
ctxClick object.

This function executes default configuration for Joystick click.

◆ joystick_disabled_interrupt()

void joystick_disabled_interrupt ( joystick_t ctx)

Set interrupt disabled function.

Parameters
ctxClick object.

Set interrupt disabled function

Function set interrupt output is disabled.

◆ joystick_enabled_interrupt()

void joystick_enabled_interrupt ( joystick_t ctx)

Set interrupt enabled function.

Parameters
ctxClick object.

Function set interrupt output is enabled.

◆ joystick_generic_read()

void joystick_generic_read ( joystick_t ctx,
uint8_t  reg,
uint8_t *  data_buf,
uint8_t  len 
)

Generic read function.

Parameters
ctxClick object.
regRegister address.
data_bufOutput data buf
lenNumber of the bytes to be read

This function reads data from the desired register.

◆ joystick_generic_write()

void joystick_generic_write ( joystick_t ctx,
uint8_t  reg,
uint8_t *  data_buf,
uint8_t  len 
)

Generic write function.

Parameters
ctxClick object.
regRegister address.
data_bufData buf to be written.
lenNumber of the bytes in data buf.

This function writes data to the desired register.

◆ joystick_get_interrupt()

uint8_t joystick_get_interrupt ( joystick_t ctx)

Get state of interrupt pin function.

Parameters
ctxClick object.
Returns
state of INT pin:
  • 0 : active low;
  • 1 : open drain;

Function read state of interrupt ( INT ) pin, and return 0 or 1.

◆ joystick_get_position()

uint8_t joystick_get_position ( joystick_t ctx)

Get joystick position function.

Parameters
ctxClick object.
Returns
8-bit data of position
  • 0 : Start Position;
  • 1 : Top Position;
  • 2 : Top-Right Position;
  • 3 : Right Position;
  • 4 : Bottom-Right Position;
  • 5 : Bottom Position;
  • 6 : Bottom-Left Position;
  • 7 : Left Position;
  • 8 : Top-Left Position;

Function get position of miniature joystick module ( N50P105 ), return position state value from 0 to 8 that calculeted by the value read from the register of the AS5013 Hall IC.

◆ joystick_hardware_reset()

void joystick_hardware_reset ( joystick_t ctx)

General hardware reset function.

Parameters
ctxClick object.

Function hardware reset register of the AS5013 Hall IC, by set RST pin high.

◆ joystick_init()

JOYSTCIK_RETVAL joystick_init ( joystick_t ctx,
joystick_cfg_t cfg 
)

Initialization function.

Parameters
joystickClick object.
cfgClick configuration structure.

This function initializes all necessary pins and peripherals used for this click.

◆ joystick_invert_spinning()

void joystick_invert_spinning ( joystick_t ctx)

Invert the channel voltage function.

Parameters
ctxClick object.

Function set invert the channel voltage, set to invert the magnet polarity.

◆ joystick_press_button()

uint8_t joystick_press_button ( joystick_t ctx)

Get state of Joystick button function.

Parameters
ctxClick object.
Returns
state of CS pin:
  • 0 : not active;
  • 1 : active;

Function read state of Joystick button ( CS ) pin, and return 0 or 1.

◆ joystick_set_default_configuration()

void joystick_set_default_configuration ( joystick_t ctx)

Set default configuration function.

Parameters
ctxClick object.

Function set default configuration, set required Test bits of Control Register 2, set maximum sensitivity, set scaling Factor to 90.8% and reset read value by writing configuration 1 register.

◆ joystick_set_low_power_mode()

void joystick_set_low_power_mode ( joystick_t ctx,
uint8_t  timings 
)

Set Low Power Mode function.

Parameters
ctxClick object.
timingstimings by setting the low power timebase

Function set default configuration, The measurements are triggered with an internal low power oscillator the user can select between 8 different timings by setting the low power timebase.

  • 0 : 20 ms;
  • 1 : 40 ms;
  • 2 : 80 ms;
  • 3 : 100 ms;
  • 4 : 140 ms;
  • 5 : 200 ms;
  • 6 : 260 ms;
  • 7 : 320 ms;

◆ joystick_set_scaling_factor()

void joystick_set_scaling_factor ( joystick_t ctx,
uint8_t  scaling_factor 
)

Set scaling factor function.

Parameters
ctxClick object.
[in]scalingFactorscaling factor

Function set scaling factor value of the XY coordinates to fit to the 8-bit X and Y_res_int register (full dynamic range);

  • 31 : 31.3 %;
  • 30 : 32.2 %;
  • 29 : 33.4 %;
  • 28 : 34.6 %;
  • 27 : 35.7 %;
  • 26 : 37.1 %;
  • 25 : 38.5 %;
  • 24 : 40.0 %;
  • 23 : 41.6 %;
  • 22 : 43.6 %;
  • 21 : 45.5 %;
  • 20 : 47.7 %;
  • 19 : 50.0 %;
  • 18 : 52.5 %;
  • 17 : 55.5 %;
  • 16 : 58.8 %;
  • 15 : 62.5 %;
  • 14 : 66.6 %;
  • 13 : 71.5 %;
  • 12 : 77.0 %;
  • 11 : 83.4 %;
  • 10 : 90.8 %;
  • 9 : 100.0 %;
  • 8 : 111.1 %;
  • 7 : 125.0 %;
  • 6 : 142.8 %;
  • 5 : 166.6 %;
  • 4 : 200.0 %;
  • 3 : 250.0 %;
  • 2 : 333.4 %;
  • 1 : 500.0 %;

◆ joystick_soft_reset()

void joystick_soft_reset ( joystick_t ctx)

General soft reset function.

Parameters
ctxClick object.

Function soft reset register of the AS5013 Hall IC. All the internal registers are loaded with their reset value. The Control Register 1 is loaded as well with the value 0xF0, then the Soft_rst bit goes back to 0 (Normal mode) once the internal reset sequence is finished.