42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_in.h"
53#include "drv_spi_master.h"
66#define THUMBSTICK_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
68 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
69 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
70 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
71 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT );
78#define THUMBSTICK_RETVAL uint8_t
80#define THUMBSTICK_OK 0x00
81#define THUMBSTICK_INIT_ERROR 0xFF
82#define THUMBSTICK_FUNCTION_ERROR 0xEE
89#define THUMBSTICK_START_SINGLE_CONV 0x06
90#define THUMBSTICK_START_DIFF_CONV 0x04
97#define THUMBSTICK_VERTICAL 0x00
98#define THUMBSTICK_HORIZONTAL 0x60
105#define THUMBSTICK_POSITION_DEFAULT 0x01
106#define THUMBSTICK_POSITION_TOP 0x02
107#define THUMBSTICK_POSITION_RIGHT 0x03
108#define THUMBSTICK_POSITION_BOTTOM 0x04
109#define THUMBSTICK_POSITION_LEFT 0x05
116#define THUMBSTICK_BUTTON_INACTIVE 0x00
117#define THUMBSTICK_BUTTON_ACTIVE 0x01
124#define POSTION_SENS_DEFAULT 500
131#define THUMBSTICK_PRESS_BUTTON 0x00
#define THUMBSTICK_RETVAL
Definition thumbstick.h:78
void thumbstick_get_position(thumbstick_t *ctx, thumbstick_position_t *position)
Get thumbstick position by axis function.
uint8_t thumbstick_get_single_axis_postion(thumbstick_t *ctx, uint8_t axis)
Get thumbstick position by axis 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.
uint8_t thumbstick_set_sensitivity(uint16_t sensitivity)
Set thumbstick sensitivity.
uint8_t thumbstick_button_state(thumbstick_t *ctx)
Get state of thumbstick button function.
void thumbstick_cfg_setup(thumbstick_cfg_t *cfg)
Config Object Initialization function.
uint16_t thumbstick_read_rawadc(thumbstick_t *ctx, uint8_t type, uint8_t channel)
Generic read 2 byte of data function.
THUMBSTICK_RETVAL thumbstick_init(thumbstick_t *ctx, thumbstick_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition thumbstick.h:163
spi_master_chip_select_polarity_t cs_polarity
Definition thumbstick.h:179
pin_name_t sck
Definition thumbstick.h:168
spi_master_mode_t spi_mode
Definition thumbstick.h:178
pin_name_t mosi
Definition thumbstick.h:167
uint32_t spi_speed
Definition thumbstick.h:177
pin_name_t int_pin
Definition thumbstick.h:173
pin_name_t miso
Definition thumbstick.h:166
pin_name_t cs
Definition thumbstick.h:169
Click configuration structure definition.
Definition thumbstick.h:187
uint8_t horizontal
Definition thumbstick.h:189
uint8_t vertical
Definition thumbstick.h:188
Click ctx object definition.
Definition thumbstick.h:145
digital_out_t cs
Definition thumbstick.h:146
spi_master_t spi
Definition thumbstick.h:154
digital_in_t int_pin
Definition thumbstick.h:150
pin_name_t chip_select
Definition thumbstick.h:155