thumbstick 2.0.0.0

Functions

void thumbstick_cfg_setup (thumbstick_cfg_t *cfg)
 Config Object Initialization function.
 
THUMBSTICK_RETVAL thumbstick_init (thumbstick_t *ctx, thumbstick_cfg_t *cfg)
 Initialization function.
 
void thumbstick_generic_transfer (thumbstick_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
 Generic transfer function.
 
uint16_t thumbstick_read_rawadc (thumbstick_t *ctx, uint8_t type, uint8_t channel)
 Generic read 2 byte of data function.
 
uint8_t thumbstick_get_single_axis_postion (thumbstick_t *ctx, uint8_t axis)
 Get thumbstick position by axis function.
 
void thumbstick_get_position (thumbstick_t *ctx, thumbstick_position_t *position)
 Get thumbstick position by axis function.
 
uint8_t thumbstick_button_state (thumbstick_t *ctx)
 Get state of thumbstick button function.
 
uint8_t thumbstick_set_sensitivity (uint16_t sensitivity)
 Set thumbstick sensitivity.
 

Detailed Description

Function Documentation

◆ thumbstick_button_state()

uint8_t thumbstick_button_state ( thumbstick_t * ctx)

Get state of thumbstick button function.

Returns
state of thumbstick button:
  - 1 : not active;
  - 0 : active;
*

@description Function return state of thumbstick button 0 or 1 by read state of INT pin from MCP3204 chip of the Thumbstick Click.

◆ thumbstick_cfg_setup()

void thumbstick_cfg_setup ( thumbstick_cfg_t * cfg)

Config Object Initialization function.

Parameters
cfgClick configuration structure.

@description This function initializes click configuration structure to init state.

Note
All used pins will be set to unconnected state.

◆ thumbstick_generic_transfer()

void thumbstick_generic_transfer ( thumbstick_t * ctx,
uint8_t * wr_buf,
uint16_t wr_len,
uint8_t * rd_buf,
uint16_t rd_len )

Generic transfer function.

Parameters
ctxClick object.
wr_bufWrite data buffer
wr_lenNumber of byte in write data buffer
rd_bufRead data buffer
rd_lenNumber of byte in read data buffer

@description Generic SPI transfer, for sending and receiving packages

◆ thumbstick_get_position()

void thumbstick_get_position ( thumbstick_t * ctx,
thumbstick_position_t * position )

Get thumbstick position by axis function.

Parameters
postionPotion data struct that stores data of axis thumbstic postion

@description Function get position of thumbstick.

◆ thumbstick_get_single_axis_postion()

uint8_t thumbstick_get_single_axis_postion ( thumbstick_t * ctx,
uint8_t axis )

Get thumbstick position by axis function.

Parameters
axis
  - Channel:
  - 0x00 : horizontal axis;
  - 0x60 : vertical axis;
*
Returns
8-bit data of position
  - 1 : Default         Position;
  - 2 : Top             Position;
  - 3 : Right           Position;
  - 4 : Bottom          Position;
  - 5 : Left            Position;
  - 0xEE: Error         Parameter;
*

@description Function get position of thumbstick, return position state value from 1 to 5 that calculeted by the value read ADC value from the MCP3204 chip.

◆ thumbstick_init()

THUMBSTICK_RETVAL thumbstick_init ( thumbstick_t * ctx,
thumbstick_cfg_t * cfg )

Initialization function.

Parameters
thumbstickClick object.
cfgClick configuration structure.

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

◆ thumbstick_read_rawadc()

uint16_t thumbstick_read_rawadc ( thumbstick_t * ctx,
uint8_t type,
uint8_t channel )

Generic read 2 byte of data function.

Parameters
type
  - Channel:
  - 0x06 : single channel adc;
  - 0x04 : difference channell adc;
*
channel
  - Channel:
  - 0x00 : horizontal channel;
  - 0x60 : vertical channel;
*
Returns
12-bit read ADC data

@description Function read 12-bit ADC data from selected channel from MCP3204 chip of the Thumbstick Click.

◆ thumbstick_set_sensitivity()

uint8_t thumbstick_set_sensitivity ( uint16_t sensitivity)

Set thumbstick sensitivity.

Parameters
sensitivityvariable that offsets changeing state of thumbstick sensing state
Returns
status
  - 0x00: OK               
  - 0xEE: Error
*

@description Function for setting sensitivity that state of thumbstick changes states.