27 #if (MAX_BM_CALLBACKS > 32)
32 #error MAX_BM_CALLBACKS exceeds maximum
35 #define BM_TOKEN_STARTING_VAL (0x100) // Must be a non-zero value!
50 #ifdef BM_DEBUG_TRACE_BUFFER
54 volatile uint32 current_period_before_adj;
55 volatile uint32 current_period_after_adj;
56 volatile uint32 cb_timeleft[2];
60 #define BM_DEBUG_TRACEBUF_MAX 50
61 volatile int32 bmdebug_idx = 0;
62 volatile uint32 bmdebug_isr_cnt = 0;
63 volatile bm_debug_t bmdebug[BM_DEBUG_TRACEBUF_MAX];
68 #ifdef BM_DEBUG_LATENCY_TEST
69 volatile uint32 gBm_latency_timestamp[8] = {0,0,0,0,0,0,0,0};
107 else if (pCallback == NULL)
152 if ( (!ret_token) || (pCb == NULL) )
187 __disable_interrupt();
209 __enable_interrupt();
284 .isTimerChained =
FALSE,
433 #ifdef BM_DEBUG_TRACE_BUFFER
434 _mem_zero((
void*)bmdebug,
sizeof(bm_debug_t) * BM_DEBUG_TRACEBUF_MAX);
437 #ifdef BM_DEBUG_LATENCY_TEST
439 SIM_SCGC6 |= SIM_SCGC6_TPM0_MASK;
500 callbacks |= (1 << i);
516 #define PTE20 (1 << 20)
517 #define PTE21 (1 << 21)
518 #define PTE22 (1 << 22)
527 #ifdef BM_LOW_LEVEL_GPIOS
531 #ifdef BM_DEBUG_LATENCY_TEST
541 #ifdef BM_DEBUG_TRACE_BUFFER
557 #ifdef BM_DEBUG_TRACE_BUFFER
565 bmdebug[bmdebug_idx].cb_event = callbacks;
570 if (bmdebug_idx >= BM_DEBUG_TRACEBUF_MAX)
576 #ifdef BM_DEBUG_LATENCY_TEST
581 #ifdef BM_LOW_LEVEL_GPIOS
582 if ((callbacks & 0x01) == 0x01)
589 if ((callbacks & 0x02) == 0x02)
601 #ifdef BM_DEBUG_LATENCY_TEST
610 #ifdef BM_DEBUG_LATENCY_TEST
615 #ifdef BM_LOW_LEVEL_GPIOS
656 callbacks = _lwevent_get_signalled();
659 #ifdef BM_DEBUG_LATENCY_TEST
669 if (callbacks & (1 << i))
672 #ifdef BM_DEBUG_LATENCY_TEST
736 new_token = (1 << bit);
939 uint64 remainingtime_usec = 0;
967 return (
uint32)remainingtime_usec;
void SetPortE_Gpio(uint32 gpio_mask, uint8 hilow)
ISF board support header files.
unsigned char uint8
This defines uint8 as unsigned char.
BM_VOLATILE bm_callback_token_t cb_token_registered_mask
uint32 isf_time_util_get_usec(void)
This API returns the time in microseconds.
BM_STATIC BM_VOLATILE boolean gBm_firsttime_flag
boolean bm_cb_occurred_query(void)
Tells caller if a callback was scheduled to be called since setting bus manager for powerdown mode...
#define BM_MINIMUM_CB_TIMELEFT_USEC
unsigned long long uint64
This defines uint64 as unsigned long long.
API definitions, types, and macros for the Intelligent Sensing Framework (ISF) Bus Manager (BM)...
boolean bm_active_cb_query(void)
Tells caller if there are active callbacks. .
#define MAX_BM_PERIOD_USEC
The maximum period of a callback is provided in microseconds. Attempting to register a callback perio...
void pit_set_timer_period_us(uint32_t timer, uint32_t us)
Set timer period in microsecond units.
void pit_init_module(bool isRunInDebug)
Initialize PIT module.
#define BM_ALLOC_MEM_ZERO(x)
unsigned long uint32
This defines uint32 as unsigned long.
uint32 bm_find_smallest_active_period(int8 period_type)
Find the smallest current period. .
uint32 bm_callback_token_t
This type defines the Bus Manager token. Each callback registered with the Bus Manager receives a uni...
isf_status_t bm_unregister_callback(bm_callback_token_t aToken)
This API unregisters one or more callbacks.
void pit_init_channel(uint32_t timer, const pit_user_config_t *config)
Initialize PIT channel.
uint32 bm_get_num_callback(void)
This API returns the number of callbacks registered.
BM_STATIC LWSEM_STRUCT sema_bm_access
void pit_hal_clear_interrupt_flag(uint32_t timer)
Clear timer interrupt flag.
void bm_reset_period(void)
BM_STATIC BM_VOLATILE bm_cb_config_t * gpBm_cb_list[MAX_BM_CALLBACKS]
bm_callback_token_t nToken
void pit_timer_stop(uint32_t timer)
Stop timer counting.
void bm_sort_cb_list(void)
Sort the callback list based on period in ascending order (callback with smallest period is first in ...
uint32 bm_powerdown(void)
Prepare bm for powerdown state. Called by power manager. .
#define BM_ALL_TOKENS
This value specifies an action to be taken on all callbacks registered with the Bus Manager...
#define MAX_BM_CALLBACKS
The maximum number of callbacks registered with the Bus Manager.
#define BM_PIPELINE_STAGES
BM_VOLATILE uint32 cb_events[BM_PIPELINE_STAGES]
BM_STATIC BM_VOLATILE boolean gBm_state_change
bm_callback_token_t bm_register_periodic_callback(isf_duration_t aPeriod, bm_callback_t *pCallback, void *pCbData)
This API schedules a callback at the specified period.
BM_VOLATILE bm_callback_token_t cb_token_active_mask
void( bm_callback_t)(void *)
Type for the prototype for a Bus Manager periodic callback function.
bm_callback_t * pCallback
BM_VOLATILE uint32 time_keeper_usec
isf_status_t bm_init(void)
Bus management initialization .
uint32 bm_update_cb_list(void)
BM_VOLATILE int32 cb_list_cur_cnt
ISF bus management internal header file.
#define BM_CURRENT_PERIOD
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.
isf_status_t bm_start(boolean aSync, bm_callback_token_t aTokens)
This API sets one or more callback(s) to the active state.
uint32 isf_duration_t
ISF time duration in microseconds.
long int32
This defines int32 as long.
Main ISF header file. Contains code common to all ISF components.
void isr_bm_callback_tmr(pointer dummy)
void bm_statechange_reset(void)
Reset the state change.
void pit_hal_timer_reset(uint32_t timer)
Start timer counting.
void pit_timer_start(uint32_t timer)
Start timer counting.
bm_callback_token_t bm_generate_token(void)
Bus management generate token. This token generator assigns one bit out of 32 bits as a token value...
BM_STATIC LWEVENT_STRUCT event_bm_callback
#define TIMER_TPM_START()
BM_VOLATILE uint32 pipeline_index
#define BM_ERROR
This value specifies a general Bus Manager error. If an error occurs in registering a callback...
int32 isf_status_t
ISF return status type.
BM_STATIC BM_VOLATILE boolean gBm_cb_occurred
#define MIN_BM_PERIOD_USEC
The minimum period of a callback is provided in microseconds. Attempting to register a callback perio...
fsl_pit_driver.h defines structures and types for the PIT driver.
PIT timer configuration structure.
boolean bm_statechange_query(void)
Tells caller if there a change in the state of the bus manager. Change could be: ...
void bm_timer_init(boolean bEnableirq, uint32 usec)
Timer initialization .
Bus managment internal header file.
int bm_find_cb(bm_callback_token_t aToken)
Find the callback associated with the given a token. .
void task_bm(uint32 initial_data)
Bus Manager Task - main task to handle communication via mailboxes with the host.
#define TIMER_TPM_GET_CNT()