39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_spi_master.h"
74#define JOYSTICK3_ADC_START_BIT 0x04
75#define JOYSTICK3_ADC_SINGLE_ENDED 0x02
76#define JOYSTICK3_ADC_CHANNEL_X 0x00
77#define JOYSTICK3_ADC_CHANNEL_Y 0x40
78#define JOYSTICK3_ADC_DATA_RESOLUTION 0x0FFF
79#define JOYSTICK3_ADC_DATA_RESOLUTION_HALF ( ( float ) JOYSTICK3_ADC_DATA_RESOLUTION / 2 )
85#define JOYSTICK3_RADIANS_TO_DEGREES 57.295779513
86#define JOYSTICK3_ANGLE_ZERO_OFFSET 180.0
87#define JOYSTICK3_PI_RAD_OFFSET 1.0
88#define JOYSTICK3_NEUTRAL_POSITION_OFFSET ( ( float ) JOYSTICK3_ADC_DATA_RESOLUTION / 8 )
89#define JOYSTICK3_FULL_ANGLE 360.0f
90#define JOYSTICK3_ZERO_ANGLE 0.0f
91#define JOYSTICK3_ANGLE_POSITION_STEP 45.0f
97#define JOYSTICK3_POSITION_NEUTRAL 0
98#define JOYSTICK3_POSITION_UP 1
99#define JOYSTICK3_POSITION_UPPER_RIGHT 2
100#define JOYSTICK3_POSITION_RIGHT 3
101#define JOYSTICK3_POSITION_LOWER_RIGHT 4
102#define JOYSTICK3_POSITION_DOWN 5
103#define JOYSTICK3_POSITION_LOWER_LEFT 6
104#define JOYSTICK3_POSITION_LEFT 7
105#define JOYSTICK3_POSITION_UPPER_LEFT 8
115#define JOYSTICK3_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
116#define JOYSTICK3_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
134#define JOYSTICK3_MAP_MIKROBUS( cfg, mikrobus ) \
135 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
136 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
137 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
138 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS );
err_t joystick3_read_raw_adc(joystick3_t *ctx, uint16_t *raw_x, uint16_t *raw_y)
Joystick 3 read raw adc function.
uint8_t joystick3_get_position(uint16_t raw_x, uint16_t raw_y)
Joystick 3 get position function.
float joystick3_get_angle(uint16_t raw_x, uint16_t raw_y)
Joystick 3 get angle function.
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.
joystick3_return_value_t
Joystick 3 Click return value data.
Definition joystick3.h:180
@ JOYSTICK3_OK
Definition joystick3.h:181
@ JOYSTICK3_ERROR
Definition joystick3.h:182
This file contains SPI specific macros, functions, etc.
Joystick 3 Click configuration object.
Definition joystick3.h:161
spi_master_chip_select_polarity_t cs_polarity
Definition joystick3.h:171
pin_name_t sck
Definition joystick3.h:165
spi_master_mode_t spi_mode
Definition joystick3.h:170
pin_name_t mosi
Definition joystick3.h:164
uint32_t spi_speed
Definition joystick3.h:169
pin_name_t miso
Definition joystick3.h:163
pin_name_t cs
Definition joystick3.h:166
Joystick 3 Click context object.
Definition joystick3.h:148
spi_master_t spi
Definition joystick3.h:150
pin_name_t chip_select
Definition joystick3.h:152