ISF  2.2 rev 5
Intelligent Sensing Framework for Kinetis with Processor Expert
isf_bm.h File Reference

API definitions, types, and macros for the Intelligent Sensing Framework (ISF) Bus Manager (BM). More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MAX_BM_CALLBACKS   (8)
 The maximum number of callbacks registered with the Bus Manager. More...
 
#define MAX_BM_PERIOD_USEC   (60 * 1000 * 1000)
 The maximum period of a callback is provided in microseconds. Attempting to register a callback period greater than this value results in an error. More...
 
#define MIN_BM_PERIOD_USEC   (100)
 The minimum period of a callback is provided in microseconds. Attempting to register a callback period less than this value results in an error. More...
 
#define BM_TOKEN_VAL_MAX   ((bm_callback_token_t)(1 << (MAX_BM_CALLBACKS-1)))
 The largest token value assigned to a bus management callback. More...
 
#define BM_TOKEN_VAL_ERROR   ((bm_callback_token_t)(1 << ((sizeof(bm_callback_token_t)*8)-1)))
 This value is returned when the token value for the BM callback is incorrect. More...
 
#define BM_ERROR   BM_TOKEN_VAL_ERROR
 This value specifies a general Bus Manager error. If an error occurs in registering a callback, this token error value is logically OR'd with the specific nature of the error and returned. More...
 
#define BM_ALL_TOKENS   ((bm_callback_token_t)((1 << MAX_BM_CALLBACKS)-1))
 This value specifies an action to be taken on all callbacks registered with the Bus Manager. More...
 

Typedefs

typedef void( bm_callback_t) (void *)
 Type for the prototype for a Bus Manager periodic callback function. More...
 
typedef uint32 bm_callback_token_t
 This type defines the Bus Manager token. Each callback registered with the Bus Manager receives a unique token value of this type. Certain Bus Manager API calls require the token value as an input parameter such as bm_start(), bm_stop(), and bm_unregister_callback(). More...
 

Functions

isf_status_t bm_init (void)
 This API initializes the Bus Manager. More...
 
bm_callback_token_t bm_register_periodic_callback (isf_duration_t aPeriod, bm_callback_t *apCallback, void *apCbData)
 This API schedules a callback at the specified period. More...
 
isf_status_t bm_unregister_callback (bm_callback_token_t aTokens)
 This API unregisters one or more callbacks. More...
 
isf_status_t bm_start (boolean aSync, bm_callback_token_t aTokens)
 This API sets one or more callback(s) to the active state. More...
 
isf_status_t bm_stop (bm_callback_token_t aTokens)
 This API stops one or more callback(s) by setting them to the inactive state. More...
 
uint32 bm_get_num_callback (void)
 This API returns the number of callbacks registered. More...
 
void isr_bm_callback_tmr (void *dummy)
 

Detailed Description

API definitions, types, and macros for the Intelligent Sensing Framework (ISF) Bus Manager (BM).

Definition in file isf_bm.h.

Macro Definition Documentation

#define BM_ALL_TOKENS   ((bm_callback_token_t)((1 << MAX_BM_CALLBACKS)-1))

This value specifies an action to be taken on all callbacks registered with the Bus Manager.

Definition at line 62 of file isf_bm.h.

Referenced by bm_start(), and bm_stop().

#define BM_ERROR   BM_TOKEN_VAL_ERROR

This value specifies a general Bus Manager error. If an error occurs in registering a callback, this token error value is logically OR'd with the specific nature of the error and returned.

Definition at line 57 of file isf_bm.h.

Referenced by Analog_1_fsl_Sensor_Generic_Analog_Configure(), bm_register_periodic_callback(), bm_start(), bm_stop(), bm_unregister_callback(), Custom_1_fsl_Sensor_Custom_Configure(), Custom_1_fsl_Sensor_Custom_EndData(), Custom_1_fsl_Sensor_Custom_StartData(), fsl_fxas21002_i2cspi_3D_gyro_Configure(), fsl_fxas21002_i2cspi_3D_gyro_EndData(), fsl_fxas21002_i2cspi_3D_gyro_StartData(), fsl_fxlc95000_Configure(), fsl_fxlc95000_EndData(), fsl_fxlc95000_StartData(), fsl_fxls8471_i2cspi_3D_accel_Configure(), fsl_fxls8471_i2cspi_3D_accel_EndData(), fsl_fxls8471_i2cspi_3D_accel_StartData(), fsl_fxls8952_i2c_3D_accel_Configure(), fsl_fxls8952_i2c_3D_accel_EndData(), fsl_fxls8952_i2c_3D_accel_StartData(), fsl_fxos8700_i2cspi_6D_AccMag_Configure(), fsl_fxos8700_i2cspi_6D_AccMag_EndData(), fsl_fxos8700_i2cspi_6D_AccMag_StartData(), fsl_mag3110_i2c_3D_mag_Configure(), fsl_mag3110_i2c_3D_mag_EndData(), fsl_mag3110_i2c_3D_mag_StartData(), fsl_mma8491q_i2c_3D_accel_Configure(), fsl_mma8491q_i2c_3D_accel_EndData(), fsl_mma8491q_i2c_3D_accel_Shutdown(), fsl_mma8491q_i2c_3D_accel_StartData(), fsl_mma865x_i2c_3D_accel_Configure(), fsl_mma865x_i2c_3D_accel_EndData(), fsl_mma865x_i2c_3D_accel_StartData(), fsl_mma955x_Configure(), fsl_mma955x_EndData(), fsl_mma955x_StartData(), fsl_mpl3115_i2c_1D_press_Configure(), fsl_mpl3115_i2c_1D_press_EndData(), fsl_mpl3115_i2c_1D_press_StartData(), and rli_ci_app_callback().

#define BM_TOKEN_VAL_ERROR   ((bm_callback_token_t)(1 << ((sizeof(bm_callback_token_t)*8)-1)))

This value is returned when the token value for the BM callback is incorrect.

Definition at line 51 of file isf_bm.h.

#define BM_TOKEN_VAL_MAX   ((bm_callback_token_t)(1 << (MAX_BM_CALLBACKS-1)))

The largest token value assigned to a bus management callback.

Definition at line 46 of file isf_bm.h.

#define MAX_BM_CALLBACKS   (8)

The maximum number of callbacks registered with the Bus Manager.

Definition at line 29 of file isf_bm.h.

Referenced by bm_generate_token(), and bm_register_periodic_callback().

#define MAX_BM_PERIOD_USEC   (60 * 1000 * 1000)

The maximum period of a callback is provided in microseconds. Attempting to register a callback period greater than this value results in an error.

Definition at line 35 of file isf_bm.h.

Referenced by bm_find_smallest_active_period(), and bm_register_periodic_callback().

#define MIN_BM_PERIOD_USEC   (100)

The minimum period of a callback is provided in microseconds. Attempting to register a callback period less than this value results in an error.

Definition at line 41 of file isf_bm.h.

Referenced by bm_register_periodic_callback().

Typedef Documentation

typedef void( bm_callback_t) (void *)

Type for the prototype for a Bus Manager periodic callback function.

Definition at line 71 of file isf_bm.h.

This type defines the Bus Manager token. Each callback registered with the Bus Manager receives a unique token value of this type. Certain Bus Manager API calls require the token value as an input parameter such as bm_start(), bm_stop(), and bm_unregister_callback().

Definition at line 79 of file isf_bm.h.

Function Documentation

uint32 bm_get_num_callback ( void  )

This API returns the number of callbacks registered.

The number of registered callbacks is returned regardless of their state, active or inactive.

Returns
bm_get_num_callback() returns a value of type uint32 providing the number of callbacks currently registered with the Bus Manager whether they are in the active or inactive state.
Constraints:
None
Reentrant: Yes
Link Libraries:
isf_core.lib

Definition at line 252 of file bus_management.c.

References bm_t::cb_list_cur_cnt, and sema_bm_access.

isf_status_t bm_init ( void  )

This API initializes the Bus Manager.

The Bus Manager requires a one time initialization at system startup performed by this API call. It creates and initializes internal variables. In addition, it installs an interrupt service routine for a hardware timer to be used by the Bus Manager to schedule callbacks.

Returns
isf_status_t bm_init() returns a value of type isf_status_t providing the status of the initialization operation.
Return values
ISF_SUCCESSThis value is returned if the initialization completed successfully.
ISF_ERR_LIB_INITThis value is returned if the interrupt service routine for the TPM timer used by the Bus Manager could not be installed.
Constraints:
The following constraints must be observed when using this function. If these constraints are not met, this API returns an error.
  • There must not be any installed interrupt routines for the TPM timer used by the Bus Manager.
Reentrant: No
Link Libraries:
isf_core.lib

This API initializes the Bus Manager.

Returns
ISF_SUCCESS if initialization is successful. ISF_ERR_LIB_INIT if initialization failed.
Errors:

Constraints:

Reentrant: No.
Link Libraries:

See also

Definition at line 445 of file bus_management.c.

bm_callback_token_t bm_register_periodic_callback ( isf_duration_t  aPeriod,
bm_callback_t apCallback,
void *  apCbData 
)

This API schedules a callback at the specified period.

The Bus Manager schedules periodic sensor data automatically. It allows a registered callback to be automatically invoked at the specified period. Multiple callbacks registered for the same frequency are executed serially by the Bus Manager. If registration of the callback is successful, the callback is set to the inactive state. The API function bm_start() can be called to make the callback active.

Parameters
[in]aPeriodThe period (1/frequency) between successive callback invocations in microseconds.
[in]apCallbackThe pointer to the callback function to be registered.
[in]apCbDataThe pointer passed to the callback function each time it is invoked. This pointer may be used to pass specific data to the callback function.
Returns
bm_register_periodic_callback() returns a token of type bm_callback_token_t if the callback registration is successful.
Return values
COMM_ERROR_NULL_PTRThis error value and the most significant bit of the macro BM_ERROR is returned if the callback function pointer is NULL.
COMM_ERROR_NOEXISTThis error value and the most significant bit of the macro BM_ERROR is returned if either of the following conditions are true:
Constraints:
The following constraints must be observed when using this function. If these constraints are not met, this API returns an error.
  • aPeriod must be within the valid range of MIN_BM_PERIOD_USEC to MAX_BM_PERIOD_USEC for the bus being initialized.
  • apCallback callback function pointer must not be NULL.
  • The number of callbacks registered must not exceed the maximum specified by MAX_BM_CALLBACKS.
Reentrant: Yes
Link Libraries:
isf_core.lib

Definition at line 94 of file bus_management.c.

References BM_ALLOC_MEM_ZERO, BM_ERROR, bm_generate_token(), bm_sort_cb_list(), bm_t::cb_list_cur_cnt, bm_t::cb_token_registered_mask, COMM_ERROR_NOEXIST, COMM_ERROR_NULL_PTR, bm_cb_config_t::Cur_period, gBm_state_change, gpBm_cb_list, MAX_BM_CALLBACKS, MAX_BM_PERIOD_USEC, MIN_BM_PERIOD_USEC, bm_cb_config_t::nToken, bm_cb_config_t::pCallback, bm_cb_config_t::pCbData, bm_cb_config_t::Period, sema_bm_access, and TRUE.

Referenced by Analog_1_fsl_Sensor_Generic_Analog_Configure(), Custom_1_fsl_Sensor_Custom_Configure(), fsl_fxas21002_i2cspi_3D_gyro_Configure(), fsl_fxlc95000_Configure(), fsl_fxls8471_i2cspi_3D_accel_Configure(), fsl_fxls8952_i2c_3D_accel_Configure(), fsl_fxos8700_i2cspi_6D_AccMag_Configure(), fsl_mag3110_i2c_3D_mag_Configure(), fsl_mma8491q_i2c_3D_accel_Configure(), fsl_mma865x_i2c_3D_accel_Configure(), fsl_mma955x_Configure(), fsl_mpl3115_i2c_1D_press_Configure(), and rli_ci_app_callback().

Here is the call graph for this function:

Here is the caller graph for this function:

isf_status_t bm_start ( boolean  aSync,
bm_callback_token_t  aTokens 
)

This API sets one or more callback(s) to the active state.

The start operation sets the callback(s) associated with the specified token values to the active state. A callback in the active state is invoked at its specified period. Multiple callbacks are specified by performing a logical OR of the token values. Any callbacks specified by this API call already in the active state, remain in the active state and their current timings are not affected. In addition to setting callbacks to the active state, this API can also synchronize the callback timings. The timings of all the active callbacks are reset to start running at the same time reference. The bm_stop() API call changes a callback to the inactive state.

Parameters
[in]aSyncThe parameter is set to TRUE to reset the timings of the active callbacks and start them running at the same time reference. The parameter is set to FALSE to leave all active callback timings as they are.
[in]aTokensThis parameter specifies the token value(s) of callback(s) to be set to the active state. More than one callback is specified by performing a logical OR of the token values associated with the registered callbacks.
Returns
isf_status_t bm_start() returns a value of type isf_status_t providing the status of the start operation.
Return values
ISF_SUCCESSThis value is returned if the callback(s) is set to the active state successfully.
COMM_ERROR_NOEXISTThis value is returned if at least one of the token values specified is invalid because it is not associated with a registered callback.
Constraints:
The following constraints must be observed when using this function. If these constraints are not met, this API returns an error.
  • aTokens value must be associated with the registered callback(s).
Reentrant: Yes
Link Libraries:
isf_core.lib
See also
bm_stop()

Definition at line 278 of file bus_management.c.

References BM_ALL_TOKENS, BM_ERROR, bm_reset_period(), bm_update_cb_list(), bm_t::cb_events, bm_t::cb_list_cur_cnt, bm_t::cb_token_active_mask, bm_t::cb_token_registered_mask, COMM_ERROR_NOEXIST, ISF_BM_PIT_CHANNEL_NO, ISF_BM_PIT_INSTANCE, ISF_SUCCESS, bm_t::pipeline_index, sema_bm_access, and bm_t::time_keeper_usec.

Referenced by Custom_1_fsl_Sensor_Custom_StartData(), fsl_fxas21002_i2cspi_3D_gyro_StartData(), fsl_fxlc95000_StartData(), fsl_fxls8471_i2cspi_3D_accel_StartData(), fsl_fxls8952_i2c_3D_accel_StartData(), fsl_fxos8700_i2cspi_6D_AccMag_StartData(), fsl_mag3110_i2c_3D_mag_StartData(), fsl_mma8491q_i2c_3D_accel_PeriodicCallback(), fsl_mma8491q_i2c_3D_accel_StartData(), fsl_mma865x_i2c_3D_accel_StartData(), fsl_mma955x_StartData(), fsl_mpl3115_i2c_1D_press_StartData(), and rli_ci_app_callback().

Here is the call graph for this function:

Here is the caller graph for this function:

isf_status_t bm_stop ( bm_callback_token_t  aTokens)

This API stops one or more callback(s) by setting them to the inactive state.

The stop operation sets the the callback(s) associated with the specified token values to the inactive state. A callback in the inactive state is not invoked. Multiple callbacks are specified by performing a logical OR of the token values. Any callbacks specified by this API call already inactive will remain in the inactive state. To change a callback to the active state, the bm_start() API call is used.

Parameters
[in]aTokensThis parameter specifies the token value(s) of callback(s) to be set to the inactive state. More than one callback is specified by performing a logical OR of the token values associated with the registered callbacks.
Returns
isf_status_t bm_stop()returns a value of type isf_status_t providing the status of the stop operation.
Return values
ISF_SUCCESSThe callback(s) stopped successfully.
COMM_ERROR_NOEXISTAt least one of the token values specified is invalid because it is not associated with a registered callback.
Constraints:
The following constraints must be observed when using this function. If these constraints are not met, this API returns an error.
  • aTokens value must be associated with registered callback(s).
Reentrant: Yes
Link Libraries:
isf_core.lib
See also
bm_start()

Definition at line 349 of file bus_management.c.

References BM_ALL_TOKENS, BM_ERROR, bm_t::cb_list_cur_cnt, bm_t::cb_token_active_mask, bm_t::cb_token_registered_mask, COMM_ERROR_NOEXIST, gBm_state_change, ISF_SUCCESS, sema_bm_access, and TRUE.

Referenced by Custom_1_fsl_Sensor_Custom_EndData(), fsl_fxas21002_i2cspi_3D_gyro_EndData(), fsl_fxlc95000_EndData(), fsl_fxls8471_i2cspi_3D_accel_EndData(), fsl_fxls8952_i2c_3D_accel_EndData(), fsl_fxos8700_i2cspi_6D_AccMag_EndData(), fsl_mag3110_i2c_3D_mag_EndData(), fsl_mma8491q_i2c_3D_accel_EndData(), fsl_mma8491q_read_data_OneShotCallback(), fsl_mma865x_i2c_3D_accel_EndData(), fsl_mma955x_EndData(), fsl_mpl3115_i2c_1D_press_EndData(), and rli_ci_app_callback().

Here is the caller graph for this function:

isf_status_t bm_unregister_callback ( bm_callback_token_t  aTokens)

This API unregisters one or more callbacks.

The Bus Manager allows the removal of a registered callback. After a call to this function, unregistered callbacks no longer exist. To specify the callback to be unregistered, the token returned by bm_register_periodic_callback() is passed to bm_unregister_callback(). Multiple callbacks can be specified by performing a logical OR of the token values. The callback can be in the active or inactive state when it is unregistered.

Parameters
[in]aTokensThis parameter specifies the token value(s) of the callback(s) that are to be unregistered. More than one callback is specified by performing a logical OR of the token values associated with the registered callbacks.
Returns
bm_unregister_callback() returns a value of type isf_status_t indicating the status of the unregister operation.
Return values
ISF_SUCCESSThis value is returned if the callbacks unregistered successfully.
COMM_ERROR_NOEXISTThis value is returned if at least one of the token values specified in aTokens is invalid because it is not associated with a registered callback.
Constraints:
The following constraints must be observed when using this function. If these constraints are not met, this API returns an error.
  • aTokens value must be associated with registered callback(s).
Reentrant: Yes
Link Libraries:
isf_core.lib
See also
bm_register_periodic_callback()

Definition at line 178 of file bus_management.c.

References BM_ERROR, bm_find_cb(), BM_FREE_MEM, bm_t::cb_list_cur_cnt, bm_t::cb_token_active_mask, bm_t::cb_token_registered_mask, COMM_ERROR_NOEXIST, gBm_state_change, gpBm_cb_list, ISF_SUCCESS, sema_bm_access, and TRUE.

Referenced by Custom_1_fsl_Sensor_Custom_Shutdown(), fsl_fxas21002_i2cspi_3D_gyro_Shutdown(), fsl_fxlc95000_Configure(), fsl_fxlc95000_Shutdown(), fsl_fxls8471_i2cspi_3D_accel_Shutdown(), fsl_fxls8952_i2c_3D_accel_Shutdown(), fsl_fxos8700_i2cspi_6D_AccMag_Shutdown(), fsl_mag3110_i2c_3D_mag_Shutdown(), fsl_mma8491q_i2c_3D_accel_Shutdown(), fsl_mma865x_i2c_3D_accel_Shutdown(), fsl_mma955x_Configure(), fsl_mma955x_Shutdown(), fsl_mpl3115_i2c_1D_press_Shutdown(), and rli_ci_app_callback().

Here is the call graph for this function:

Here is the caller graph for this function:

void isr_bm_callback_tmr ( void *  dummy)

Definition at line 570 of file bus_management.c.