LibDriver PMW3901MB
Loading...
Searching...
No Matches
driver_pmw3901mb.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_PMW3901MB_H
38#define DRIVER_PMW3901MB_H
39
40#include <stdio.h>
41#include <stdint.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
62typedef struct pmw3901mb_motion_s
63{
64 uint8_t raw[12];
65 int16_t delta_x;
66 int16_t delta_y;
67 uint16_t surface_quality;
68 uint8_t raw_max;
69 uint8_t raw_average;
70 uint8_t raw_min;
71 uint8_t observation;
72 uint16_t shutter;
73 uint8_t is_valid;
75
79typedef struct pmw3901mb_handle_s
80{
81 uint8_t (*reset_gpio_init)(void);
82 uint8_t (*reset_gpio_deinit)(void);
83 uint8_t (*reset_gpio_write)(uint8_t value);
84 uint8_t (*spi_init)(void);
85 uint8_t (*spi_deinit)(void);
86 uint8_t (*spi_read)(uint8_t reg, uint8_t *buf, uint16_t len);
87 uint8_t (*spi_write)(uint8_t reg, uint8_t *buf, uint16_t len);
88 void (*delay_ms)(uint32_t ms);
89 void (*debug_print)(const char *const fmt, ...);
90 uint8_t inited;
92
108
112
119
126#define DRIVER_PMW3901MB_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
127
134#define DRIVER_PMW3901MB_LINK_SPI_INIT(HANDLE, FUC) (HANDLE)->spi_init = FUC
135
142#define DRIVER_PMW3901MB_LINK_SPI_DEINIT(HANDLE, FUC) (HANDLE)->spi_deinit = FUC
143
150#define DRIVER_PMW3901MB_LINK_SPI_READ(HANDLE, FUC) (HANDLE)->spi_read = FUC
151
158#define DRIVER_PMW3901MB_LINK_SPI_WRITE(HANDLE, FUC) (HANDLE)->spi_write = FUC
159
166#define DRIVER_PMW3901MB_LINK_RESET_GPIO_INIT(HANDLE, FUC) (HANDLE)->reset_gpio_init = FUC
167
174#define DRIVER_PMW3901MB_LINK_RESET_GPIO_DEINIT(HANDLE, FUC) (HANDLE)->reset_gpio_deinit = FUC
175
182#define DRIVER_PMW3901MB_LINK_RESET_GPIO_WRITE(HANDLE, FUC) (HANDLE)->reset_gpio_write = FUC
183
190#define DRIVER_PMW3901MB_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
191
198#define DRIVER_PMW3901MB_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
199
203
210
219uint8_t pmw3901mb_info(pmw3901mb_info_t *info);
220
233uint8_t pmw3901mb_init(pmw3901mb_handle_t *handle);
234
246uint8_t pmw3901mb_deinit(pmw3901mb_handle_t *handle);
247
259
271
282uint8_t pmw3901mb_reset(pmw3901mb_handle_t *handle);
283
295
308
322uint8_t pmw3901mb_delta_raw_to_delta_cm(pmw3901mb_handle_t *handle, int16_t raw, float height_m, float *cm);
323
335
347
363uint8_t pmw3901mb_get_frame(pmw3901mb_handle_t *handle, uint8_t frame[35][35]);
364
376uint8_t pmw3901mb_get_product_id(pmw3901mb_handle_t *handle, uint8_t *id);
377
389uint8_t pmw3901mb_get_inverse_product_id(pmw3901mb_handle_t *handle, uint8_t *id);
390
402uint8_t pmw3901mb_get_revision_id(pmw3901mb_handle_t *handle, uint8_t *id);
403
415uint8_t pmw3901mb_get_motion(pmw3901mb_handle_t *handle, uint8_t *motion);
416
428uint8_t pmw3901mb_set_motion(pmw3901mb_handle_t *handle, uint8_t motion);
429
441uint8_t pmw3901mb_get_delta_x(pmw3901mb_handle_t *handle, int16_t *delta);
442
454uint8_t pmw3901mb_get_delta_y(pmw3901mb_handle_t *handle, int16_t *delta);
455
468uint8_t pmw3901mb_get_motion_burst(pmw3901mb_handle_t *handle, uint8_t *burst, uint8_t len);
469
481uint8_t pmw3901mb_get_squal(pmw3901mb_handle_t *handle, uint8_t *squal);
482
494uint8_t pmw3901mb_get_raw_data_sum(pmw3901mb_handle_t *handle, uint8_t *sum);
495
507uint8_t pmw3901mb_get_max_raw_data(pmw3901mb_handle_t *handle, uint8_t *max);
508
520uint8_t pmw3901mb_get_min_raw_data(pmw3901mb_handle_t *handle, uint8_t *min);
521
533uint8_t pmw3901mb_get_shutter(pmw3901mb_handle_t *handle, uint16_t *shutter);
534
546uint8_t pmw3901mb_get_observation(pmw3901mb_handle_t *handle, uint8_t *observation);
547
559uint8_t pmw3901mb_set_observation(pmw3901mb_handle_t *handle, uint8_t observation);
560
573uint8_t pmw3901mb_get_raw_data_grab(pmw3901mb_handle_t *handle, uint8_t *grab, uint16_t len);
574
587uint8_t pmw3901mb_set_raw_data_grab(pmw3901mb_handle_t *handle, uint8_t *grab, uint16_t len);
588
600uint8_t pmw3901mb_get_raw_data_grab_status(pmw3901mb_handle_t *handle, uint8_t *status);
601
605
612
626uint8_t pmw3901mb_set_reg(pmw3901mb_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
627
641uint8_t pmw3901mb_get_reg(pmw3901mb_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
642
646
650
651#ifdef __cplusplus
652}
653#endif
654
655#endif
uint8_t pmw3901mb_init(pmw3901mb_handle_t *handle)
initialize the chip
uint8_t pmw3901mb_set_raw_data_grab(pmw3901mb_handle_t *handle, uint8_t *grab, uint16_t len)
set the raw data grab
uint8_t pmw3901mb_stop_frame_capture(pmw3901mb_handle_t *handle)
stop frame capture
uint8_t pmw3901mb_get_min_raw_data(pmw3901mb_handle_t *handle, uint8_t *min)
get the minimum raw data value
struct pmw3901mb_handle_s pmw3901mb_handle_t
pmw3901mb handle structure definition
uint8_t pmw3901mb_get_shutter(pmw3901mb_handle_t *handle, uint16_t *shutter)
get the shutter
uint8_t pmw3901mb_get_motion_burst(pmw3901mb_handle_t *handle, uint8_t *burst, uint8_t len)
get the motion burst
uint8_t pmw3901mb_set_observation(pmw3901mb_handle_t *handle, uint8_t observation)
set the observation
uint8_t pmw3901mb_set_motion(pmw3901mb_handle_t *handle, uint8_t motion)
set the motion
uint8_t pmw3901mb_get_motion(pmw3901mb_handle_t *handle, uint8_t *motion)
get the motion
struct pmw3901mb_info_s pmw3901mb_info_t
pmw3901mb information structure definition
uint8_t pmw3901mb_get_squal(pmw3901mb_handle_t *handle, uint8_t *squal)
get the surface quality
uint8_t pmw3901mb_get_delta_y(pmw3901mb_handle_t *handle, int16_t *delta)
get the delta y
uint8_t pmw3901mb_get_delta_x(pmw3901mb_handle_t *handle, int16_t *delta)
get the delta x
uint8_t pmw3901mb_get_frame(pmw3901mb_handle_t *handle, uint8_t frame[35][35])
get the frame
uint8_t pmw3901mb_get_max_raw_data(pmw3901mb_handle_t *handle, uint8_t *max)
get the maximum raw data value
uint8_t pmw3901mb_set_optimum_performance(pmw3901mb_handle_t *handle)
set the optimum performance
uint8_t pmw3901mb_power_up(pmw3901mb_handle_t *handle)
power up the chip
uint8_t pmw3901mb_shutdown(pmw3901mb_handle_t *handle)
shutdown the chip
uint8_t pmw3901mb_info(pmw3901mb_info_t *info)
get chip's information
uint8_t pmw3901mb_get_raw_data_sum(pmw3901mb_handle_t *handle, uint8_t *sum)
get the average raw data value
struct pmw3901mb_motion_s pmw3901mb_motion_t
pmw3901mb motion structure definition
uint8_t pmw3901mb_get_product_id(pmw3901mb_handle_t *handle, uint8_t *id)
get the product id
uint8_t pmw3901mb_get_inverse_product_id(pmw3901mb_handle_t *handle, uint8_t *id)
get the inverse product id
uint8_t pmw3901mb_get_raw_data_grab(pmw3901mb_handle_t *handle, uint8_t *grab, uint16_t len)
get the raw data grab
uint8_t pmw3901mb_delta_raw_to_delta_cm(pmw3901mb_handle_t *handle, int16_t raw, float height_m, float *cm)
convert the delta raw to the delta cm
uint8_t pmw3901mb_get_observation(pmw3901mb_handle_t *handle, uint8_t *observation)
get the observation
uint8_t pmw3901mb_deinit(pmw3901mb_handle_t *handle)
close the chip
uint8_t pmw3901mb_get_raw_data_grab_status(pmw3901mb_handle_t *handle, uint8_t *status)
get the raw data grab status
uint8_t pmw3901mb_reset(pmw3901mb_handle_t *handle)
reset the chip
uint8_t pmw3901mb_burst_read(pmw3901mb_handle_t *handle, pmw3901mb_motion_t *motion)
burst read data
uint8_t pmw3901mb_start_frame_capture(pmw3901mb_handle_t *handle)
start frame capture
uint8_t pmw3901mb_get_revision_id(pmw3901mb_handle_t *handle, uint8_t *id)
get the revision id
uint8_t pmw3901mb_get_reg(pmw3901mb_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
uint8_t pmw3901mb_set_reg(pmw3901mb_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
pmw3901mb handle structure definition
uint8_t(* spi_init)(void)
void(* delay_ms)(uint32_t ms)
uint8_t(* spi_read)(uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* spi_write)(uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* reset_gpio_deinit)(void)
void(* debug_print)(const char *const fmt,...)
uint8_t(* spi_deinit)(void)
uint8_t(* reset_gpio_init)(void)
uint8_t(* reset_gpio_write)(uint8_t value)
pmw3901mb information structure definition
pmw3901mb motion structure definition