MBot Software Library  v1.0
An API documentation to mbot_firmware repository
Functions
bhy_uc_driver.h File Reference

headfile of driver on MCU for bhy More...

#include "bhy_support.h"
#include "bhy_uc_driver_types.h"
Include dependency graph for bhy_uc_driver.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

BHY_RETURN_FUNCTION_TYPE bhy_driver_init (const uint8_t *bhy_fw_data)
 This function initializes the driver, the API and loads the ram patch into the sensor. More...
 
BHY_RETURN_FUNCTION_TYPE bhy_meta_event_set_config (bhy_meta_event_type_t meta_event_id, bhy_meta_event_fifo_type_t fifo_sel, uint8_t enable_state, uint8_t int_enable_state)
 this function configures meta event More...
 
BHY_RETURN_FUNCTION_TYPE bhy_meta_event_get_config (bhy_meta_event_type_t meta_event_id, bhy_meta_event_fifo_type_t fifo_sel, uint8_t *p_enable_state, uint8_t *p_int_enable_state)
 this function gets configuration from specific meta event More...
 
BHY_RETURN_FUNCTION_TYPE bhy_mapping_matrix_set (bhy_physical_sensor_index_type_t index, int8_t *p_mapping_matrix)
 This function set mapping matrix to a corresponding physical sensor. More...
 
BHY_RETURN_FUNCTION_TYPE bhy_mapping_matrix_get (bhy_physical_sensor_index_type_t index, int8_t *p_mapping_matrix)
 This function get mapping matrix from a corresponding physical sensor. More...
 
BHY_RETURN_FUNCTION_TYPE bhy_soft_passthru_write (uint8_t addr, uint8_t reg, uint8_t *data, uint8_t length, uint8_t increment_reg)
 Soft pass-through parameter write function. More...
 
BHY_RETURN_FUNCTION_TYPE bhy_soft_passthru_read (uint8_t addr, uint8_t reg, uint8_t *data, uint8_t length, uint8_t increment_reg)
 Soft pass-through parameter read function. More...
 
BHY_RETURN_FUNCTION_TYPE bhy_gp_register_write (bhy_gp_register_type_t gp_reg, uint8_t data)
 Write data to specific GP register. More...
 
BHY_RETURN_FUNCTION_TYPE bhy_gp_register_read (bhy_gp_register_type_t gp_reg, uint8_t *p_data)
 Write data to specific GP register. More...
 
BHY_RETURN_FUNCTION_TYPE bhy_enable_virtual_sensor (bhy_virtual_sensor_t sensor_id, uint8_t wakeup_status, uint16_t sample_rate, uint16_t max_report_latency_ms, uint8_t flush_sensor, uint16_t change_sensitivity, uint16_t dynamic_range)
 this functions enables the selected virtual sensor More...
 
BHY_RETURN_FUNCTION_TYPE bhy_disable_virtual_sensor (bhy_virtual_sensor_t sensor_id, uint8_t wakeup_status)
 this functions disables the selected virtual sensor More...
 
BHY_RETURN_FUNCTION_TYPE bhy_read_fifo (uint8_t *buffer, uint16_t buffer_size, uint16_t *bytes_read, uint16_t *bytes_left)
 this functions retrieves the fifo data,it needs a buffer of at least (BHY_I2C_REG_BUFFER_LENGTH + 1) bytes to work. it outputs the data into the variable buffer. the number of bytes read. More...
 
BHY_RETURN_FUNCTION_TYPE bhy_parse_next_fifo_packet (uint8_t **fifo_buffer, uint16_t *fifo_buffer_length, bhy_data_generic_t *fifo_data_output, bhy_data_type_t *fifo_data_type)
 this functions parse the packet in fifo and get the actual fifo data of sensors More...
 
BHY_RETURN_FUNCTION_TYPE bhy_update_system_timestamp (bhy_data_scalar_u16_t *timestamp_packet, uint32_t *system_timestamp)
 This function will detect the timestamp packet accordingly and update either the MSW or the LSW of the system timestamp. More...
 
BHY_RETURN_FUNCTION_TYPE bhy_write_parameter_page (uint8_t page, uint8_t parameter, uint8_t *data, uint8_t length)
 This function writes arbitrary data to an arbitrary parameter page. More...
 
BHY_RETURN_FUNCTION_TYPE bhy_read_parameter_page (uint8_t page, uint8_t parameter, uint8_t *data, uint8_t length)
 This function reads arbitrary data from an arbitrary parameter page. More...
 
BHY_RETURN_FUNCTION_TYPE bhy_set_sic_matrix (float *sic_matrix)
 This function write a new SIC matrix to the BHy. More...
 
BHY_RETURN_FUNCTION_TYPE bhy_get_sic_matrix (float *sic_matrix)
 This function reads out the current SIC matrix from BHy. More...
 
void bhy_print_debug_packet (bhy_data_debug_t *packet, void(*debug_print_ptr)(const uint8_t *))
 This function outputs the debug data to function pointer You need to provide a function that takes as argument a zero-terminated string and prints it. More...
 
BHY_RETURN_FUNCTION_TYPE bhy_sync_cus_evt_size (void)
 This function get all the custom sensor data length according reading information from hub. More...
 
int8_t bhy_get_cus_evt_size (bhy_virtual_sensor_t sensor_id)
 This function get the specific custom sensor data length according reading information from hub. More...
 
BHY_RETURN_FUNCTION_TYPE bhy_install_sensor_callback (bhy_virtual_sensor_t sensor_id, uint8_t wakeup_status, void(*sensor_callback)(bhy_data_generic_t *, bhy_virtual_sensor_t))
 
BHY_RETURN_FUNCTION_TYPE bhy_install_timestamp_callback (uint8_t wakeup_status, void(*timestamp_callback)(bhy_data_scalar_u16_t *))
 
BHY_RETURN_FUNCTION_TYPE bhy_install_meta_event_callback (bhy_meta_event_type_t meta_event_id, void(*meta_event_callback)(bhy_data_meta_event_t *, bhy_meta_event_type_t))
 
BHY_RETURN_FUNCTION_TYPE bhy_uninstall_sensor_callback (bhy_virtual_sensor_t sensor_id, uint8_t wakeup_status)
 
BHY_RETURN_FUNCTION_TYPE bhy_uninstall_timestamp_callback (uint8_t wakeup_status)
 
BHY_RETURN_FUNCTION_TYPE bhy_uninstall_meta_event_callback (bhy_meta_event_type_t meta_event_id)
 

Detailed Description

headfile of driver on MCU for bhy

Copyright (C) 2015 - 2016 Bosch Sensortec GmbH

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

Neither the name of the copyright holder nor the names of the contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE

The information provided is believed to be accurate and reliable. The copyright holder assumes no responsibility for the consequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. No license is granted by implication or otherwise under any patent or patent rights of the copyright holder.

Date
12/19/2016

Function Documentation

◆ bhy_disable_virtual_sensor()

BHY_RETURN_FUNCTION_TYPE bhy_disable_virtual_sensor ( bhy_virtual_sensor_t  sensor_id,
uint8_t  wakeup_status 
)

this functions disables the selected virtual sensor

Parameters
[in]sensor_idsensor ID
[in]wakeup_statusstatus of WAKEUP OR NONWAKEUP
Return values
resultof execution

◆ bhy_driver_init()

BHY_RETURN_FUNCTION_TYPE bhy_driver_init ( const uint8_t *  bhy_fw_data)

This function initializes the driver, the API and loads the ram patch into the sensor.

Parameters
[in]bhy_fw_datapointer to the firmware of bhy
Return values
resultof execution

◆ bhy_enable_virtual_sensor()

BHY_RETURN_FUNCTION_TYPE bhy_enable_virtual_sensor ( bhy_virtual_sensor_t  sensor_id,
uint8_t  wakeup_status,
uint16_t  sample_rate,
uint16_t  max_report_latency_ms,
uint8_t  flush_sensor,
uint16_t  change_sensitivity,
uint16_t  dynamic_range 
)

this functions enables the selected virtual sensor

Parameters
[in]sensor_idsensor ID
[in]wakeup_statusstatus after wakeup
[in]sample_ratesample rate
[in]max_report_latency_msmax report latency,unit is millisecond
[in]flush_sensorhow to flush the fifo of sensor
[in]change_sensitivitywhether to change the sensitivity
[in]dynamic_rangedynamic range
Return values
resultof execution

◆ bhy_get_cus_evt_size()

int8_t bhy_get_cus_evt_size ( bhy_virtual_sensor_t  sensor_id)

This function get the specific custom sensor data length according reading information from hub.

Parameters
[in]sensor_idpointer to sensor_id
Return values
resultof data length

◆ bhy_get_sic_matrix()

BHY_RETURN_FUNCTION_TYPE bhy_get_sic_matrix ( float *  sic_matrix)

This function reads out the current SIC matrix from BHy.

Parameters
[in]sic_matrixpointer to SIC matrix
Return values
resultof execution

◆ bhy_gp_register_read()

BHY_RETURN_FUNCTION_TYPE bhy_gp_register_read ( bhy_gp_register_type_t  gp_reg,
uint8_t *  data 
)

Write data to specific GP register.

Parameters
[in]gp_regGP register address
[in]datapointer to receive buffer
Return values
resultof execution

◆ bhy_gp_register_write()

BHY_RETURN_FUNCTION_TYPE bhy_gp_register_write ( bhy_gp_register_type_t  gp_reg,
uint8_t  data 
)

Write data to specific GP register.

Parameters
[in]gp_regGP register address
[in]datadata to be written to GP register
Return values
resultof execution

◆ bhy_mapping_matrix_get()

BHY_RETURN_FUNCTION_TYPE bhy_mapping_matrix_get ( bhy_physical_sensor_index_type_t  index,
int8_t *  mapping_matrix 
)

This function get mapping matrix from a corresponding physical sensor.

Parameters
[in]indexphysical sensor index
[in]mapping_matrixpointer to a int8_t mapping_matrix[9]
Return values
resultof execution

◆ bhy_mapping_matrix_set()

BHY_RETURN_FUNCTION_TYPE bhy_mapping_matrix_set ( bhy_physical_sensor_index_type_t  index,
int8_t *  mapping_matrix 
)

This function set mapping matrix to a corresponding physical sensor.

Parameters
[in]indexphysical sensor index
[in]mapping_matrixpointer to a int8_t mapping_matrix[9]
Return values
resultof execution

◆ bhy_meta_event_get_config()

BHY_RETURN_FUNCTION_TYPE bhy_meta_event_get_config ( bhy_meta_event_type_t  meta_event_id,
bhy_meta_event_fifo_type_t  fifo_sel,
uint8_t *  p_enable_state,
uint8_t *  p_int_enable_state 
)

this function gets configuration from specific meta event

Parameters
[in]meta_event_idID of meta event
[in]fifo_selto choose the FIFO
[in]p_enable_statepointer of enable state of bhy
[in]p_int_enable_statepointer of the enable state of interrupt
Return values
resultof execution

◆ bhy_meta_event_set_config()

BHY_RETURN_FUNCTION_TYPE bhy_meta_event_set_config ( bhy_meta_event_type_t  meta_event_id,
bhy_meta_event_fifo_type_t  fifo_sel,
uint8_t  enable_state,
uint8_t  int_enable_state 
)

this function configures meta event

Parameters
[in]meta_event_idID of meta event
[in]fifo_selto choose the FIFO
[in]enable_stateenable state of bhy
[in]int_enable_stateenable state of interrupt
Return values
resultof execution

◆ bhy_parse_next_fifo_packet()

BHY_RETURN_FUNCTION_TYPE bhy_parse_next_fifo_packet ( uint8_t **  fifo_buffer,
uint16_t *  fifo_buffer_length,
bhy_data_generic_t fifo_data_output,
bhy_data_type_t *  fifo_data_type 
)

this functions parse the packet in fifo and get the actual fifo data of sensors

Parameters
[in]fifo_bufferpointer of fifo
[in]fifo_buffer_lengthsize of the fifo
[out]fifo_data_outputthe actual fifo data of sensors
[out]fifo_data_typedata type of fifo data
Return values
resultof execution

◆ bhy_print_debug_packet()

void bhy_print_debug_packet ( bhy_data_debug_t packet,
void(*)(const uint8_t *)  debug_print_ptr 
)

This function outputs the debug data to function pointer You need to provide a function that takes as argument a zero-terminated string and prints it.

Parameters
[in]packetdebug message
[in]debug_print_ptrprint function
Return values
resultof execution

◆ bhy_read_fifo()

BHY_RETURN_FUNCTION_TYPE bhy_read_fifo ( uint8_t *  buffer,
uint16_t  buffer_size,
uint16_t *  bytes_read,
uint16_t *  bytes_left 
)

this functions retrieves the fifo data,it needs a buffer of at least (BHY_I2C_REG_BUFFER_LENGTH + 1) bytes to work. it outputs the data into the variable buffer. the number of bytes read.

Parameters
[in]bufferpointer of buffer
[in]buffer_sizesize of the buffer in bytes
[out]bytes_readthe bytes in fifo which have been read
[out]bytes_leftthe bytes left in fifo which have not been read
Return values
resultof execution

◆ bhy_read_parameter_page()

BHY_RETURN_FUNCTION_TYPE bhy_read_parameter_page ( uint8_t  page,
uint8_t  parameter,
uint8_t *  data,
uint8_t  length 
)

This function reads arbitrary data from an arbitrary parameter page.

Parameters
[in]pageselect the page of parameter
[in]parameterselect the parameter
[out]datadata to be read from parameter
[in]lengthlength of data
Return values
resultof execution

◆ bhy_set_sic_matrix()

BHY_RETURN_FUNCTION_TYPE bhy_set_sic_matrix ( float *  sic_matrix)

This function write a new SIC matrix to the BHy.

Parameters
[in]sic_matrixpointer to SIC matrix
Return values
resultof execution

◆ bhy_soft_passthru_read()

BHY_RETURN_FUNCTION_TYPE bhy_soft_passthru_read ( uint8_t  addr,
uint8_t  reg,
uint8_t *  data,
uint8_t  length,
uint8_t  increment_reg 
)

Soft pass-through parameter read function.

Parameters
[in]addrphysical sensor index
[in]regregister address to be written
[out]datapointer to data to be written
[in]length
[in]increment_regif true, the function will automatically increment the register between successive 4-bytes transfers
Return values
resultof execution

◆ bhy_soft_passthru_write()

BHY_RETURN_FUNCTION_TYPE bhy_soft_passthru_write ( uint8_t  addr,
uint8_t  reg,
uint8_t *  data,
uint8_t  length,
uint8_t  increment_reg 
)

Soft pass-through parameter write function.

Parameters
[in]addrphysical sensor index
[in]regregister address to be written
[in]datapointer to data to be written
[in]length
[in]increment_regif true, the function will automatically increment the register between successive 4-bytes transfers
Return values
resultof execution

◆ bhy_sync_cus_evt_size()

BHY_RETURN_FUNCTION_TYPE bhy_sync_cus_evt_size ( void  )

This function get all the custom sensor data length according reading information from hub.

Parameters
[in]none
Return values
resultof execution

◆ bhy_update_system_timestamp()

BHY_RETURN_FUNCTION_TYPE bhy_update_system_timestamp ( bhy_data_scalar_u16_t timestamp_packet,
uint32_t *  system_timestamp 
)

This function will detect the timestamp packet accordingly and update either the MSW or the LSW of the system timestamp.

system_timestamp is only valid after LSW comes.

Parameters
[in]timestamp_packettimestamp of packets
[in/out]system_timestamp timestamp of system
Return values
resultof execution

◆ bhy_write_parameter_page()

BHY_RETURN_FUNCTION_TYPE bhy_write_parameter_page ( uint8_t  page,
uint8_t  parameter,
uint8_t *  data,
uint8_t  length 
)

This function writes arbitrary data to an arbitrary parameter page.

Parameters
[in]pageselect the page of parameter
[in]parameterselect the parameter
[in]datadata to be written to parameter
[in]lengthlength of data
Return values
resultof execution