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_i2c_master.h"
74#define TFMINI_CMD_HEADER 0x5A
75#define TFMINI_CMD_ID_FW_VERSION 0x01
76#define TFMINI_CMD_ID_SYSTEM_RESET 0x02
77#define TFMINI_CMD_ID_FRAME_RATE 0x03
78#define TFMINI_CMD_ID_TRIGGER_DETECTION 0x04
79#define TFMINI_CMD_ID_OUTPUT_FORMAT 0x05
80#define TFMINI_CMD_ID_BAUD_RATE 0x06
81#define TFMINI_CMD_ID_ENABLE_OUTPUT 0x07
82#define TFMINI_CMD_ID_COM_SELECTION 0x0A
83#define TFMINI_CMD_ID_SLAVE_ADDRESS 0x0B
84#define TFMINI_CMD_ID_DATA_FRAME 0x00
85#define TFMINI_CMD_ID_IO_MODE_ENABLE 0x3B
86#define TFMINI_CMD_ID_RESTORE_FACTORY 0x10
87#define TFMINI_CMD_ID_SAVE_SETTINGS 0x11
93#define TFMINI_HEADER 0x59
94#define TFMINI_FRAME_SIZE 0x07
95#define TFMINI_MAX_BYTES_BEFORE_HEADER 100
96#define TFMINI_LOW_SIGNAL_STRENGTH -1
97#define TFMINI_SIGNAL_STRENGTH_SATURATION -2
98#define TFMINI_AMBIENT_LIGHT_SATURATION -4
99#define TFMINI_NO_HEADER_FOUND -5
100#define TFMINI_WRONG_CHECKSUM -6
107#define DRV_BUFFER_SIZE 500
114#define TFMINI_SET_DEV_ADDR 0x10
132#define TFMINI_MAP_MIKROBUS( cfg, mikrobus ) \
133 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
134 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
135 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
136 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX );
#define DRV_BUFFER_SIZE
TFmini driver buffer size.
Definition tfmini.h:107
#define TFMINI_FRAME_SIZE
Definition tfmini.h:94
err_t tfmini_init(tfmini_t *ctx, tfmini_cfg_t *cfg)
TFmini initialization function.
err_t tfmini_change_interface(tfmini_t *ctx, tfmini_drv_t drv_sel)
TFmini change interface function.
err_t tfmini_default_cfg(tfmini_t *ctx)
TFmini default configuration function.
err_t tfmini_send_frame(tfmini_t *ctx, tfmini_frame_t frame)
TFmini send frame function.
err_t tfmini_factory_default(tfmini_t *ctx)
TFmini factory default function.
err_t tfmini_get_response(tfmini_t *ctx, tfmini_frame_t *frame)
TFmini get response function.
err_t tfmini_get_firmware_version(tfmini_t *ctx, uint32_t *fw_version)
TFmini get firmware version function.
err_t tfmini_set_frame_rate(tfmini_t *ctx, uint16_t frame_rate)
TFmini set frame rate function.
err_t tfmini_get_measurement(tfmini_t *ctx, int16_t *distance, int16_t *strength, float *temperature)
TFmini get measurement function.
void tfmini_drv_interface_selection(tfmini_cfg_t *cfg, tfmini_drv_t drv_sel)
TFmini driver interface setup function.
err_t tfmini_system_reset(tfmini_t *ctx)
TFmini system reset function.
void tfmini_cfg_setup(tfmini_cfg_t *cfg)
TFmini configuration object setup function.
err_t tfmini_save_settings(tfmini_t *ctx)
TFmini save settings function.
TFmini Click configuration object.
Definition tfmini.h:188
uint32_t baud_rate
Definition tfmini.h:196
uint32_t i2c_speed
Definition tfmini.h:201
bool uart_blocking
Definition tfmini.h:197
uart_data_bits_t data_bit
Definition tfmini.h:198
pin_name_t tx_pin
Definition tfmini.h:193
tfmini_drv_t drv_sel
Definition tfmini.h:204
pin_name_t rx_pin
Definition tfmini.h:192
uart_stop_bits_t stop_bit
Definition tfmini.h:200
pin_name_t scl
Definition tfmini.h:190
uart_parity_t parity_bit
Definition tfmini.h:199
pin_name_t sda
Definition tfmini.h:191
uint8_t i2c_address
Definition tfmini.h:202
TFmini Click command frame definition structure.
Definition tfmini.h:157
uint8_t cmd_id
Definition tfmini.h:158
uint8_t payload_len
Definition tfmini.h:160
TFmini Click context object.
Definition tfmini.h:169
uart_t uart
Definition tfmini.h:172
i2c_master_t i2c
Definition tfmini.h:171
tfmini_drv_t drv_sel
Definition tfmini.h:179
uint8_t slave_address
Definition tfmini.h:178
tfmini_drv_t
TFmini Click driver selector.
Definition tfmini.h:146
@ TFMINI_DRV_SEL_I2C
Definition tfmini.h:148
@ TFMINI_DRV_SEL_UART
Definition tfmini.h:147
tfmini_return_value_t
TFmini Click return value data.
Definition tfmini.h:213
@ TFMINI_ERROR
Definition tfmini.h:215
@ TFMINI_OK
Definition tfmini.h:214