LibDriver MMA7660FC
Loading...
Searching...
No Matches
driver_mma7660fc.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_MMA7660FC_H
38#define DRIVER_MMA7660FC_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
67
85
95
104
113
122
148
165
180
184typedef struct mma7660fc_handle_s
185{
186 uint8_t (*iic_init)(void);
187 uint8_t (*iic_deinit)(void);
188 uint8_t (*iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
189 uint8_t (*iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
190 void (*receive_callback)(uint8_t type);
191 void (*delay_ms)(uint32_t ms);
192 void (*debug_print)(const char *const fmt, ...);
193 uint8_t inited;
195
211
215
222
229#define DRIVER_MMA7660FC_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
230
237#define DRIVER_MMA7660FC_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
238
245#define DRIVER_MMA7660FC_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
246
253#define DRIVER_MMA7660FC_LINK_IIC_READ(HANDLE, FUC) (HANDLE)->iic_read = FUC
254
261#define DRIVER_MMA7660FC_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC
262
269#define DRIVER_MMA7660FC_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
270
277#define DRIVER_MMA7660FC_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
278
285#define DRIVER_MMA7660FC_LINK_RECEIVE_CALLBACK(HANDLE, FUC) (HANDLE)->receive_callback = FUC
286
290
297
306uint8_t mma7660fc_info(mma7660fc_info_t *info);
307
319
330uint8_t mma7660fc_init(mma7660fc_handle_t *handle);
331
343uint8_t mma7660fc_deinit(mma7660fc_handle_t *handle);
344
358uint8_t mma7660fc_read(mma7660fc_handle_t *handle, int8_t raw[3], float g[3]);
359
371uint8_t mma7660fc_get_tilt_status(mma7660fc_handle_t *handle, uint8_t *status);
372
385
398
410uint8_t mma7660fc_set_sleep_count(mma7660fc_handle_t *handle, uint8_t count);
411
423uint8_t mma7660fc_get_sleep_count(mma7660fc_handle_t *handle, uint8_t *count);
424
437
450
463
476
489
502
515
528
541
554
567
580
593
606
619
632
645
658
671
684
697
710
723
736
749
762
775
788
801
814
827
840
853
866
879uint8_t mma7660fc_set_tap_detection_threshold(mma7660fc_handle_t *handle, uint8_t threshold);
880
892uint8_t mma7660fc_get_tap_detection_threshold(mma7660fc_handle_t *handle, uint8_t *threshold);
893
906
919
932
945
958
971
983uint8_t mma7660fc_set_tap_pulse_debounce_count(mma7660fc_handle_t *handle, uint8_t count);
984
996uint8_t mma7660fc_get_tap_pulse_debounce_count(mma7660fc_handle_t *handle, uint8_t *count);
997
1009uint8_t mma7660fc_tap_pulse_debounce_convert_to_register(mma7660fc_handle_t *handle, float ms, uint8_t *reg);
1010
1022uint8_t mma7660fc_tap_pulse_debounce_convert_to_data(mma7660fc_handle_t *handle, uint8_t reg, float *ms);
1023
1027
1034
1048uint8_t mma7660fc_set_reg(mma7660fc_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
1049
1063uint8_t mma7660fc_get_reg(mma7660fc_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
1064
1068
1072
1073#ifdef __cplusplus
1074}
1075#endif
1076
1077#endif
mma7660fc_status_t
mma7660fc status enumeration definition
uint8_t mma7660fc_get_sleep_count(mma7660fc_handle_t *handle, uint8_t *count)
get sleep count
uint8_t mma7660fc_set_auto_wake_up(mma7660fc_handle_t *handle, mma7660fc_bool_t enable)
enable or disable auto wake up
uint8_t mma7660fc_get_auto_sleep_interrupt(mma7660fc_handle_t *handle, mma7660fc_bool_t *enable)
get auto sleep interrupt status
uint8_t mma7660fc_init(mma7660fc_handle_t *handle)
initialize the chip
mma7660fc_interrupt_pin_type_t
mma7660fc interrupt pin type enumeration definition
mma7660fc_bool_t
mma7660fc bool enumeration definition
uint8_t mma7660fc_get_shake_x_interrupt(mma7660fc_handle_t *handle, mma7660fc_bool_t *enable)
get shake x interrupt status
uint8_t mma7660fc_set_shake_x_interrupt(mma7660fc_handle_t *handle, mma7660fc_bool_t enable)
enable or disable shake x interrupt
uint8_t mma7660fc_get_shake_y_interrupt(mma7660fc_handle_t *handle, mma7660fc_bool_t *enable)
get shake y interrupt status
uint8_t mma7660fc_get_tap_y_detection(mma7660fc_handle_t *handle, mma7660fc_bool_t *enable)
get tap y detection status
uint8_t mma7660fc_get_shake_z_interrupt(mma7660fc_handle_t *handle, mma7660fc_bool_t *enable)
get shake z interrupt status
uint8_t mma7660fc_get_auto_wake_up(mma7660fc_handle_t *handle, mma7660fc_bool_t *enable)
get auto wake up status
uint8_t mma7660fc_set_sleep_counter_prescaler(mma7660fc_handle_t *handle, mma7660fc_sleep_counter_prescaler_t prescaler)
set sleep counter prescaler
uint8_t mma7660fc_get_tilt_status(mma7660fc_handle_t *handle, uint8_t *status)
get tilt status
uint8_t mma7660fc_set_interrupt_pin_type(mma7660fc_handle_t *handle, mma7660fc_interrupt_pin_type_t type)
set interrupt pin type
uint8_t mma7660fc_tap_pulse_debounce_convert_to_data(mma7660fc_handle_t *handle, uint8_t reg, float *ms)
convert the register raw data to tap pulse debounce
uint8_t mma7660fc_get_auto_sleep(mma7660fc_handle_t *handle, mma7660fc_bool_t *enable)
get auto sleep status
uint8_t mma7660fc_read(mma7660fc_handle_t *handle, int8_t raw[3], float g[3])
read the data
uint8_t mma7660fc_set_tap_detection_threshold(mma7660fc_handle_t *handle, uint8_t threshold)
set tap detection threshold
uint8_t mma7660fc_deinit(mma7660fc_handle_t *handle)
close the chip
uint8_t mma7660fc_set_shake_z_interrupt(mma7660fc_handle_t *handle, mma7660fc_bool_t enable)
enable or disable shake z interrupt
uint8_t mma7660fc_tap_pulse_debounce_convert_to_register(mma7660fc_handle_t *handle, float ms, uint8_t *reg)
convert tap pulse debounce to the register raw data
uint8_t mma7660fc_get_sleep_counter_prescaler(mma7660fc_handle_t *handle, mma7660fc_sleep_counter_prescaler_t *prescaler)
get sleep counter prescaler
uint8_t mma7660fc_get_update_interrupt(mma7660fc_handle_t *handle, mma7660fc_bool_t *enable)
get update interrupt status
uint8_t mma7660fc_info(mma7660fc_info_t *info)
get chip's information
uint8_t mma7660fc_set_tilt_debounce_filter(mma7660fc_handle_t *handle, mma7660fc_tilt_debounce_filter_t filter)
set tilt debounce filter
uint8_t mma7660fc_set_auto_wake_rate(mma7660fc_handle_t *handle, mma7660fc_auto_wake_rate_t rate)
set auto wake rate
struct mma7660fc_info_s mma7660fc_info_t
mma7660fc information structure definition
uint8_t mma7660fc_get_tap_pulse_debounce_count(mma7660fc_handle_t *handle, uint8_t *count)
get tap pulse debounce count
uint8_t mma7660fc_get_up_down_right_left_interrupt(mma7660fc_handle_t *handle, mma7660fc_bool_t *enable)
get up down right left interrupt status
uint8_t mma7660fc_set_mode(mma7660fc_handle_t *handle, mma7660fc_mode_t mode)
set mode
uint8_t mma7660fc_set_auto_sleep_interrupt(mma7660fc_handle_t *handle, mma7660fc_bool_t enable)
enable or disable auto sleep interrupt
uint8_t mma7660fc_get_front_back_interrupt(mma7660fc_handle_t *handle, mma7660fc_bool_t *enable)
get front back interrupt status
uint8_t mma7660fc_get_tilt_debounce_filter(mma7660fc_handle_t *handle, mma7660fc_tilt_debounce_filter_t *filter)
get tilt debounce filter
uint8_t mma7660fc_get_tap_detection_rate(mma7660fc_handle_t *handle, mma7660fc_auto_sleep_rate_t *rate)
get tap detection rate
struct mma7660fc_handle_s mma7660fc_handle_t
mma7660fc handle structure definition
mma7660fc_interrupt_active_level_t
mma7660fc interrupt active level enumeration definition
uint8_t mma7660fc_set_update_interrupt(mma7660fc_handle_t *handle, mma7660fc_bool_t enable)
enable or disable update interrupt status
uint8_t mma7660fc_set_front_back_interrupt(mma7660fc_handle_t *handle, mma7660fc_bool_t enable)
enable or disable front back interrupt
uint8_t mma7660fc_set_tap_interrupt(mma7660fc_handle_t *handle, mma7660fc_bool_t enable)
enable or disable tap interrupt
uint8_t mma7660fc_set_tap_x_detection(mma7660fc_handle_t *handle, mma7660fc_bool_t enable)
enable or disable tap x detection
uint8_t mma7660fc_get_tap_z_detection(mma7660fc_handle_t *handle, mma7660fc_bool_t *enable)
get tap z detection status
uint8_t mma7660fc_set_tap_y_detection(mma7660fc_handle_t *handle, mma7660fc_bool_t enable)
enable or disable tap y detection
uint8_t mma7660fc_set_auto_sleep(mma7660fc_handle_t *handle, mma7660fc_bool_t enable)
enable or disable auto sleep
mma7660fc_sleep_counter_prescaler_t
mma7660fc sleep counter prescaler enumeration definition
uint8_t mma7660fc_get_tap_detection_threshold(mma7660fc_handle_t *handle, uint8_t *threshold)
get tap detection threshold
uint8_t mma7660fc_set_interrupt_active_level(mma7660fc_handle_t *handle, mma7660fc_interrupt_active_level_t level)
set interrupt active level
uint8_t mma7660fc_set_tap_pulse_debounce_count(mma7660fc_handle_t *handle, uint8_t count)
set tap pulse debounce count
mma7660fc_auto_sleep_rate_t
mma7660fc auto sleep rate enumeration definition
uint8_t mma7660fc_irq_handler(mma7660fc_handle_t *handle)
irq handler
mma7660fc_tilt_debounce_filter_t
mma7660fc tilt debounce filter enumeration definition
uint8_t mma7660fc_get_mode(mma7660fc_handle_t *handle, mma7660fc_mode_t *mode)
get mode
mma7660fc_mode_t
mma7660fc mode enumeration definition
uint8_t mma7660fc_get_interrupt_active_level(mma7660fc_handle_t *handle, mma7660fc_interrupt_active_level_t *level)
get interrupt active level
uint8_t mma7660fc_get_auto_wake_rate(mma7660fc_handle_t *handle, mma7660fc_auto_wake_rate_t *rate)
get auto wake rate
uint8_t mma7660fc_set_tap_detection_rate(mma7660fc_handle_t *handle, mma7660fc_auto_sleep_rate_t rate)
set tap detection rate
uint8_t mma7660fc_get_auto_sleep_status(mma7660fc_handle_t *handle, mma7660fc_bool_t *enable)
get auto sleep status
uint8_t mma7660fc_set_shake_y_interrupt(mma7660fc_handle_t *handle, mma7660fc_bool_t enable)
enable or disable shake y interrupt
uint8_t mma7660fc_set_sleep_count(mma7660fc_handle_t *handle, uint8_t count)
set sleep count
uint8_t mma7660fc_get_interrupt_pin_type(mma7660fc_handle_t *handle, mma7660fc_interrupt_pin_type_t *type)
get interrupt pin type
uint8_t mma7660fc_get_auto_wake_up_status(mma7660fc_handle_t *handle, mma7660fc_bool_t *enable)
get auto wake up status
uint8_t mma7660fc_get_tap_interrupt(mma7660fc_handle_t *handle, mma7660fc_bool_t *enable)
get tap interrupt status
uint8_t mma7660fc_get_tap_x_detection(mma7660fc_handle_t *handle, mma7660fc_bool_t *enable)
get tap x detection status
uint8_t mma7660fc_set_tap_z_detection(mma7660fc_handle_t *handle, mma7660fc_bool_t enable)
enable or disable tap z detection
uint8_t mma7660fc_set_up_down_right_left_interrupt(mma7660fc_handle_t *handle, mma7660fc_bool_t enable)
enable or disable up down right left interrupt
mma7660fc_auto_wake_rate_t
mma7660fc auto wake rate enumeration definition
@ MMA7660FC_STATUS_LEFT
@ MMA7660FC_STATUS_TAP
@ MMA7660FC_STATUS_RIGHT
@ MMA7660FC_STATUS_FRONT
@ MMA7660FC_STATUS_SHAKE
@ MMA7660FC_STATUS_AUTO_SLEEP
@ MMA7660FC_STATUS_UP
@ MMA7660FC_STATUS_BACK
@ MMA7660FC_STATUS_AUTO_WAKE_UP
@ MMA7660FC_STATUS_DOWN
@ MMA7660FC_STATUS_UPDATE
@ MMA7660FC_INTERRUPT_PIN_TYPE_PUSH_PULL
@ MMA7660FC_INTERRUPT_PIN_TYPE_OPEN_DRAIN
@ MMA7660FC_BOOL_FALSE
@ MMA7660FC_BOOL_TRUE
@ MMA7660FC_INTERRUPT_ACTIVE_LEVEL_LOW
@ MMA7660FC_INTERRUPT_ACTIVE_LEVEL_HIGH
@ MMA7660FC_SLEEP_COUNTER_PRESCALER_16
@ MMA7660FC_SLEEP_COUNTER_PRESCALER_1
@ MMA7660FC_AUTO_SLEEP_RATE_1
@ MMA7660FC_AUTO_SLEEP_RATE_120
@ MMA7660FC_AUTO_SLEEP_RATE_64
@ MMA7660FC_AUTO_SLEEP_RATE_8
@ MMA7660FC_AUTO_SLEEP_RATE_2
@ MMA7660FC_AUTO_SLEEP_RATE_16
@ MMA7660FC_AUTO_SLEEP_RATE_32
@ MMA7660FC_AUTO_SLEEP_RATE_4
@ MMA7660FC_TILT_DEBOUNCE_FILTER_DISABLE
@ MMA7660FC_TILT_DEBOUNCE_FILTER_5
@ MMA7660FC_TILT_DEBOUNCE_FILTER_2
@ MMA7660FC_TILT_DEBOUNCE_FILTER_8
@ MMA7660FC_TILT_DEBOUNCE_FILTER_4
@ MMA7660FC_TILT_DEBOUNCE_FILTER_3
@ MMA7660FC_TILT_DEBOUNCE_FILTER_7
@ MMA7660FC_TILT_DEBOUNCE_FILTER_6
@ MMA7660FC_MODE_STANDBY
@ MMA7660FC_MODE_ACTIVE
@ MMA7660FC_MODE_TEST
@ MMA7660FC_AUTO_WAKE_RATE_16
@ MMA7660FC_AUTO_WAKE_RATE_8
@ MMA7660FC_AUTO_WAKE_RATE_32
@ MMA7660FC_AUTO_WAKE_RATE_1
uint8_t mma7660fc_set_reg(mma7660fc_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
uint8_t mma7660fc_get_reg(mma7660fc_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
mma7660fc handle structure definition
void(* delay_ms)(uint32_t ms)
void(* receive_callback)(uint8_t type)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
mma7660fc information structure definition