joystick3 2.1.0.0
joystick3.h File Reference

This file contains API for Joystick 3 Click Driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_spi_master.h"
#include "spi_specifics.h"

Go to the source code of this file.

Data Structures

struct  joystick3_t
 Joystick 3 Click context object. More...
 
struct  joystick3_cfg_t
 Joystick 3 Click configuration object. More...
 

Macros

#define JOYSTICK3_ADC_START_BIT   0x04
 Joystick 3 ADC calculation values.
 
#define JOYSTICK3_ADC_SINGLE_ENDED   0x02
 
#define JOYSTICK3_ADC_CHANNEL_X   0x00
 
#define JOYSTICK3_ADC_CHANNEL_Y   0x40
 
#define JOYSTICK3_ADC_DATA_RESOLUTION   0x0FFF
 
#define JOYSTICK3_ADC_DATA_RESOLUTION_HALF   ( ( float ) JOYSTICK3_ADC_DATA_RESOLUTION / 2 )
 
#define JOYSTICK3_RADIANS_TO_DEGREES   57.295779513
 Joystick 3 angle and position calculation values.
 
#define JOYSTICK3_ANGLE_ZERO_OFFSET   180.0
 
#define JOYSTICK3_PI_RAD_OFFSET   1.0
 
#define JOYSTICK3_NEUTRAL_POSITION_OFFSET   ( ( float ) JOYSTICK3_ADC_DATA_RESOLUTION / 8 )
 
#define JOYSTICK3_FULL_ANGLE   360.0f
 
#define JOYSTICK3_ZERO_ANGLE   0.0f
 
#define JOYSTICK3_ANGLE_POSITION_STEP   45.0f
 
#define JOYSTICK3_POSITION_NEUTRAL   0
 Joystick 3 position values.
 
#define JOYSTICK3_POSITION_UP   1
 
#define JOYSTICK3_POSITION_UPPER_RIGHT   2
 
#define JOYSTICK3_POSITION_RIGHT   3
 
#define JOYSTICK3_POSITION_LOWER_RIGHT   4
 
#define JOYSTICK3_POSITION_DOWN   5
 
#define JOYSTICK3_POSITION_LOWER_LEFT   6
 
#define JOYSTICK3_POSITION_LEFT   7
 
#define JOYSTICK3_POSITION_UPPER_LEFT   8
 
#define JOYSTICK3_SET_DATA_SAMPLE_EDGE   SET_SPI_DATA_SAMPLE_EDGE
 Data sample selection.
 
#define JOYSTICK3_SET_DATA_SAMPLE_MIDDLE   SET_SPI_DATA_SAMPLE_MIDDLE
 
#define JOYSTICK3_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Enumerations

enum  joystick3_return_value_t { JOYSTICK3_OK = 0 , JOYSTICK3_ERROR = -1 }
 Joystick 3 Click return value data. More...
 

Functions

void joystick3_cfg_setup (joystick3_cfg_t *cfg)
 Joystick 3 configuration object setup function.
 
err_t joystick3_init (joystick3_t *ctx, joystick3_cfg_t *cfg)
 Joystick 3 initialization function.
 
err_t joystick3_read_raw_adc (joystick3_t *ctx, uint16_t *raw_x, uint16_t *raw_y)
 Joystick 3 read raw adc function.
 
float joystick3_get_angle (uint16_t raw_x, uint16_t raw_y)
 Joystick 3 get angle function.
 
uint8_t joystick3_get_position (uint16_t raw_x, uint16_t raw_y)
 Joystick 3 get position function.
 

Detailed Description

This file contains API for Joystick 3 Click Driver.

Enumeration Type Documentation

◆ joystick3_return_value_t

Joystick 3 Click return value data.

Predefined enum values for driver return values.

Enumerator
JOYSTICK3_OK 
JOYSTICK3_ERROR