Go to the documentation of this file.
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
336 #endif // _THUMBSTICK_H_
uint8_t vertical
Definition: thumbstick.h:188
pin_name_t chip_select
Definition: thumbstick.h:155
pin_name_t cs
Definition: thumbstick.h:169
void thumbstick_get_position(thumbstick_t *ctx, thumbstick_position_t *position)
Get thumbstick position by axis function.
uint8_t thumbstick_set_sensitivity(uint16_t sensitivity)
Set thumbstick sensitivity.
uint8_t horizontal
Definition: thumbstick.h:189
#define THUMBSTICK_RETVAL
Definition: thumbstick.h:78
spi_master_mode_t spi_mode
Definition: thumbstick.h:178
pin_name_t int_pin
Definition: thumbstick.h:173
digital_in_t int_pin
Definition: thumbstick.h:150
digital_out_t cs
Definition: thumbstick.h:146
Click configuration structure definition.
Definition: thumbstick.h:163
uint8_t thumbstick_get_single_axis_postion(thumbstick_t *ctx, uint8_t axis)
Get thumbstick position by axis function.
Click configuration structure definition.
Definition: thumbstick.h:187
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.
pin_name_t miso
Definition: thumbstick.h:166
spi_master_t spi
Definition: thumbstick.h:154
void thumbstick_cfg_setup(thumbstick_cfg_t *cfg)
Config Object Initialization function.
Click ctx object definition.
Definition: thumbstick.h:145
pin_name_t sck
Definition: thumbstick.h:168
uint32_t spi_speed
Definition: thumbstick.h:177
spi_master_chip_select_polarity_t cs_polarity
Definition: thumbstick.h:179
uint16_t thumbstick_read_rawadc(thumbstick_t *ctx, uint8_t type, uint8_t channel)
Generic read 2 byte of data function.
uint8_t thumbstick_button_state(thumbstick_t *ctx)
Get state of thumbstick button function.
THUMBSTICK_RETVAL thumbstick_init(thumbstick_t *ctx, thumbstick_cfg_t *cfg)
Initialization function.
pin_name_t mosi
Definition: thumbstick.h:167