Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_lis2dh12

Driver for LIS2DH12 3-axis MEMS accelerometer. More...

Data Structures

struct  bc_lis2dh12_result_raw_t
 LIS2DH12 result in raw values. More...
 
struct  bc_lis2dh12_result_g_t
 LIS2DH12 result in g. More...
 
struct  bc_lis2dh12_alarm_t
 LIS2DH12 alarm set structure. More...
 

Typedefs

typedef struct bc_lis2dh12_t bc_lis2dh12_t
 LIS2DH12 instance.
 

Enumerations

enum  bc_lis2dh12_event_t {
  BC_LIS2DH12_EVENT_ERROR = 0,
  BC_LIS2DH12_EVENT_UPDATE = 1,
  BC_LIS2DH12_EVENT_ALARM = 2
}
 Callback events. More...
 
enum  bc_lis2dh12_resolution_t {
  BC_LIS2DH12_RESOLUTION_10BIT = 0,
  BC_LIS2DH12_RESOLUTION_12BIT = 1,
  BC_LIS2DH12_RESOLUTION_8BIT = 2
}
 Resolution and mode. More...
 
enum  bc_lis2dh12_scale_t {
  BC_LIS2DH12_SCALE_2G = 0,
  BC_LIS2DH12_SCALE_4G = 1,
  BC_LIS2DH12_SCALE_8G = 2,
  BC_LIS2DH12_SCALE_16G = 3
}
 

Functions

bool bc_lis2dh12_init (bc_lis2dh12_t *self, bc_i2c_channel_t i2c_channel, uint8_t i2c_address)
 Initialize LIS2DH12. More...
 
void bc_lis2dh12_set_event_handler (bc_lis2dh12_t *self, void(*event_handler)(bc_lis2dh12_t *, bc_lis2dh12_event_t, void *), void *event_param)
 Set callback function. More...
 
void bc_lis2dh12_set_update_interval (bc_lis2dh12_t *self, bc_tick_t interval)
 Set measurement interval. More...
 
bool bc_lis2dh12_measure (bc_lis2dh12_t *self)
 Start measurement manually. More...
 
bool bc_lis2dh12_get_result_raw (bc_lis2dh12_t *self, bc_lis2dh12_result_raw_t *result_raw)
 Get measured acceleration as raw value. More...
 
bool bc_lis2dh12_get_result_g (bc_lis2dh12_t *self, bc_lis2dh12_result_g_t *result_g)
 Get measured acceleration in g. More...
 
bool bc_lis2dh12_set_alarm (bc_lis2dh12_t *self, bc_lis2dh12_alarm_t *alarm)
 Enable or disable accelerometer threshold alarm. More...
 
bool bc_lis2dh12_set_resolution (bc_lis2dh12_t *self, bc_lis2dh12_resolution_t resolution)
 Set resolution. More...
 
bool bc_lis2dh12_set_scale (bc_lis2dh12_t *self, bc_lis2dh12_scale_t scale)
 Set scale. More...
 

Detailed Description

Driver for LIS2DH12 3-axis MEMS accelerometer.

Enumeration Type Documentation

Callback events.

Enumerator
BC_LIS2DH12_EVENT_ERROR 

Error event.

BC_LIS2DH12_EVENT_UPDATE 

Update event.

BC_LIS2DH12_EVENT_ALARM 

Alarm event.

Definition at line 14 of file bc_lis2dh12.h.

Resolution and mode.

Enumerator
BC_LIS2DH12_RESOLUTION_10BIT 

10-bit data output (Normal mode) (Default)

BC_LIS2DH12_RESOLUTION_12BIT 

12-bit data output (High-resolution mode)

BC_LIS2DH12_RESOLUTION_8BIT 

8-bit data output (Low-power mode)

Definition at line 29 of file bc_lis2dh12.h.

Enumerator
BC_LIS2DH12_SCALE_2G 

±2 g (Default)

BC_LIS2DH12_SCALE_4G 

±4 g.

BC_LIS2DH12_SCALE_8G 

±8 g.

BC_LIS2DH12_SCALE_16G 

±16 g.

Definition at line 42 of file bc_lis2dh12.h.

Function Documentation

bool bc_lis2dh12_get_result_g ( bc_lis2dh12_t self,
bc_lis2dh12_result_g_t result_g 
)

Get measured acceleration in g.

Parameters
[in]selfInstance
[in]result_gPointer to structure where result will be stored
Returns
true When value is valid
false When value is invalid

Definition at line 92 of file bc_lis2dh12.c.

Here is the call graph for this function:

bool bc_lis2dh12_get_result_raw ( bc_lis2dh12_t self,
bc_lis2dh12_result_raw_t result_raw 
)

Get measured acceleration as raw value.

Parameters
[in]selfInstance
[in]result_rawPointer to structure where result will be stored
Returns
true When value is valid
false When value is invalid

Definition at line 85 of file bc_lis2dh12.c.

Referenced by bc_lis2dh12_get_result_g().

Here is the caller graph for this function:

bool bc_lis2dh12_init ( bc_lis2dh12_t self,
bc_i2c_channel_t  i2c_channel,
uint8_t  i2c_address 
)

Initialize LIS2DH12.

Parameters
[in]selfInstance
[in]i2c_channelI2C channel
[in]i2c_addressI2C device address

Definition at line 25 of file bc_lis2dh12.c.

Here is the call graph for this function:

bool bc_lis2dh12_measure ( bc_lis2dh12_t self)

Start measurement manually.

Parameters
[in]selfInstance
Returns
true On success
false When other measurement is in progress

Definition at line 71 of file bc_lis2dh12.c.

Referenced by bc_lis2dh12_set_alarm(), and bc_lis2dh12_set_update_interval().

Here is the call graph for this function:

Here is the caller graph for this function:

bool bc_lis2dh12_set_alarm ( bc_lis2dh12_t self,
bc_lis2dh12_alarm_t alarm 
)

Enable or disable accelerometer threshold alarm.

Parameters
[in]selfInstance
[in]alarmPointer to structure with alarm configuration, if null then disable the alarm
Returns
true When configuration was successful
false When configuration was not successful

Definition at line 300 of file bc_lis2dh12.c.

Here is the call graph for this function:

void bc_lis2dh12_set_event_handler ( bc_lis2dh12_t self,
void(*)(bc_lis2dh12_t *, bc_lis2dh12_event_t, void *)  event_handler,
void *  event_param 
)

Set callback function.

Parameters
[in]selfInstance
[in]event_handlerFunction address
[in]event_paramOptional event parameter (can be NULL)

Definition at line 49 of file bc_lis2dh12.c.

bool bc_lis2dh12_set_resolution ( bc_lis2dh12_t self,
bc_lis2dh12_resolution_t  resolution 
)

Set resolution.

Parameters
[in]selfInstance
[in]resolution
Returns
true When configuration was successful
false When configuration was not successful

Definition at line 393 of file bc_lis2dh12.c.

Here is the call graph for this function:

bool bc_lis2dh12_set_scale ( bc_lis2dh12_t self,
bc_lis2dh12_scale_t  scale 
)

Set scale.

Parameters
[in]selfInstance
[in]scale
Returns
true When configuration was successful
false When configuration was not successful

Definition at line 404 of file bc_lis2dh12.c.

Here is the call graph for this function:

void bc_lis2dh12_set_update_interval ( bc_lis2dh12_t self,
bc_tick_t  interval 
)

Set measurement interval.

Parameters
[in]selfInstance
[in]intervalMeasurement interval

Definition at line 55 of file bc_lis2dh12.c.

Here is the call graph for this function: