42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
67#define JOYSTICK2_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
69 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
70 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
71 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT );
78#define JOYSTICK2_RETVAL uint8_t
80#define JOYSTICK2_OK 0x00
81#define JOYSTICK2_INIT_ERROR 0xFF
88#define JOYSTICK2_DEVICE_SLAVE_ADDR_0_0 0x70
89#define JOYSTICK2_DEVICE_SLAVE_ADDR_0_1 0x71
90#define JOYSTICK2_DEVICE_SLAVE_ADDR_1_0 0x72
91#define JOYSTICK2_DEVICE_SLAVE_ADDR_1_1 0x73
98#define JOYSTICK2_CMD_INPUT_PORT 0x00
99#define JOYSTICK2_CMD_OUTPUT_PORT 0x01
100#define JOYSTICK2_CMD_POLARITY_INVERSION 0x02
101#define JOYSTICK2_CMD_CONFIGURATION 0x03
108#define JOYSTICK2_CFG_ENABLE_ALL_PORT 0xFF
109#define JOYSTICK2_CFG_DISABLE_ALL_PORT 0x00
110#define JOYSTICK2_CFG_ENABLE_BUTTON 0x02
111#define JOYSTICK2_CFG_ENABLE_LEFT_POS 0x01
112#define JOYSTICK2_CFG_ENABLE_RIGHT_POS 0x10
113#define JOYSTICK2_CFG_ENABLE_UP_POS 0x08
114#define JOYSTICK2_CFG_ENABLE_DOWN_POS 0x04
121#define JOYSTICK2_POSITION_LEFT 0x01
122#define JOYSTICK2_POSITION_RIGHT 0x10
123#define JOYSTICK2_POSITION_UP 0x08
124#define JOYSTICK2_POSITION_DOWN 0x04
125#define JOYSTICK2_BUTTON_ACTIVE 0x02
#define JOYSTICK2_RETVAL
Definition joystick2.h:78
void joystick2_cfg_setup(joystick2_cfg_t *cfg)
Config Object Initialization function.
void joystick2_set_cfg_register(joystick2_t *ctx, uint8_t cfg_data)
Functions for configuration joystick.
uint8_t joystick2_get_position(joystick2_t *ctx)
Functions for get Joystick position.
JOYSTICK2_RETVAL joystick2_init(joystick2_t *ctx, joystick2_cfg_t *cfg)
Initialization function.
void joystick2_generic_write(joystick2_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
void joystick2_reset(joystick2_t *ctx)
Functions for reset module.
void joystick2_generic_read(joystick2_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void joystick2_default_cfg(joystick2_t *ctx)
Click Default Configuration function.
uint8_t joystick2_get_interrupt_state(joystick2_t *ctx)
Functions for read interrupt state.
Click configuration structure definition.
Definition joystick2.h:162
uint32_t i2c_speed
Definition joystick2.h:175
pin_name_t scl
Definition joystick2.h:165
pin_name_t int_pin
Definition joystick2.h:171
pin_name_t sda
Definition joystick2.h:166
pin_name_t rst
Definition joystick2.h:170
uint8_t i2c_address
Definition joystick2.h:176
Click ctx object definition.
Definition joystick2.h:139
digital_in_t int_pin
Definition joystick2.h:146
i2c_master_t i2c
Definition joystick2.h:150
digital_out_t rst
Definition joystick2.h:142
uint8_t slave_address
Definition joystick2.h:154