/* * app_bridge.h * * Created on: Nov 2, 2023 * Author: juraj */ #ifndef MODULES_NBUS_INC_APP_BRIDGE_H_ #define MODULES_NBUS_INC_APP_BRIDGE_H_ #include "mcu_platform.h" typedef enum { TYPE_UNKNOWN = 0xFF, TYPE_ACCELEROMETER = 0, TYPE_GYROSCOPE, TYPE_MAGNETOMETER, TYPE_TEMPERATURE, TYPE_HUMIDITY, TYPE_PRESSURE, TYPE_HEART_RATE, TYPE_DEVIATION_DISTANCE, } nBus_sensorType_t; typedef enum { PARAM_NONE = 0xFF, PARAM_TIMEBASE = 0, PARAM_RESOLUTION, PARAM_GAIN, PARAM_OFFSET, PARAM_SAMPLERATE, PARAM_RANGE, PARAM_RANGE0, PARAM_FILTER } nBus_param_t; /** * @brief Definuje formát dát senzora. */ typedef struct __attribute__((packed)) { /** Bit určujúci či sú dáta znamienkové. * 0 = ungigned, 1 = signed */ uint8_t sign : 1; /** Násobok základnej meranej jednotky (mili, micro, kilo, deka, mega, ...) * uložený v logaritmickom tvare (pr. 2 -> 10^2). * @note: povolený rozsah [-64 , +63] */ uint8_t unit_multiplier : 7; /** Násobok meranej hodnoty uložený v logaritmickom tvare (pr. 1 -> 10^1). * @note: povolený rozsah [-128 , +127] */ uint8_t value_multiplier : 8; /** Počet bajtov meranej hodnoty. * @note: povolený rozsah [1 , 8] */ uint8_t byte_length : 4; /** Počet vzoriek meranej hodnoty. * @note: povolený rozsah [1 , 16] */ uint8_t samples : 4; } nBus_sensorFormat_t; #define PARAM_VALUE_NONE 0x7FFFFFFF nBus_param_t *nbus_interface_allParams(); uint8_t nbus_interface_allParamsCount(); nBus_sensorType_t *nbus_interface_allTypes(); uint8_t nbus_interface_allTypesCount(); typedef struct { void (*init)(void *hw_interface, void *hw_config); void (*reset)(); nBus_sensorType_t (*getType)(uint8_t sensor_index); uint8_t (*getSensorCount)(); uint8_t (*getData)(uint8_t sensor_index, uint8_t *data); uint8_t (*setData)(uint8_t *data); uint8_t (*hasParam)(uint8_t sensor_index, nBus_param_t param_name); int32_t (*getParam)(uint8_t sensor_index, nBus_param_t param_name); nBus_param_t (*setParam)(uint8_t sensor_index, nBus_param_t param_name, int32_t param_value); void (*start)(void); void (*stop)(void); void (*read)(void); uint8_t (*store)(void); uint8_t (*calibrate)(uint8_t subslaveIndex, uint8_t calibrationParamsNum, uint8_t *calibrationParams); nBus_sensorFormat_t (*getSensorFormat)(uint8_t sensor_index); } nBusAppInterface_t; #endif /* MODULES_NBUS_INC_APP_BRIDGE_H_ */