16 #include "fsl_pit_hal.h"
17 #include "fsl_pit_driver.h"
23 #if (MAX_BM_CALLBACKS > 32)
28 #error MAX_BM_CALLBACKS exceeds maximum
31 #define BM_TOKEN_STARTING_VAL (0x100) // Must be a non-zero value!
48 #define BM_TASK_NAME ISF_TASK_BM_NAME
50 #define BM_TASK_STACK_SIZE ISF_TASK_BM_STACK_SIZE
52 #define BM_TASK_PRIORITY ISF_TASK_BM_PRIORITY
59 #ifdef BM_DEBUG_TRACE_BUFFER
63 volatile uint32 current_period_before_adj;
64 volatile uint32 current_period_after_adj;
65 volatile uint32 cb_timeleft[2];
69 #define BM_DEBUG_TRACEBUF_MAX 50
70 volatile int32 bmdebug_idx = 0;
71 volatile uint32 bmdebug_isr_cnt = 0;
72 volatile bm_debug_t bmdebug[BM_DEBUG_TRACEBUF_MAX];
113 else if (pCallback == NULL)
158 if ( (!ret_token) || (pCb == NULL) )
200 __disable_interrupt();
202 OSA_EnterCritical(kCriticalDisableInt);
224 __enable_interrupt();
226 OSA_ExitCritical(kCriticalDisableInt);
471 #ifdef BM_DEBUG_TRACE_BUFFER
472 _mem_zero((
void*)bmdebug,
sizeof(bm_debug_t) * BM_DEBUG_TRACEBUF_MAX);
496 (task_param_t)(NULL),
547 callbacks |= (1 << i);
574 #ifdef BM_LOW_LEVEL_GPIOS
575 GPIO_DRV_WritePinOutput(J1_2, 1);
584 #ifdef BM_DEBUG_TRACE_BUFFER
600 #ifdef BM_DEBUG_TRACE_BUFFER
608 bmdebug[bmdebug_idx].cb_event = callbacks;
613 if (bmdebug_idx >= BM_DEBUG_TRACEBUF_MAX)
619 #ifdef BM_LOW_LEVEL_GPIOS
620 if ((callbacks & 0x01) == 0x01)
622 GPIO_DRV_WritePinOutput(J1_3, 1);
624 GPIO_DRV_WritePinOutput(J1_3, 0);
627 if ((callbacks & 0x02) == 0x02)
629 GPIO_DRV_WritePinOutput(J1_4, 1);
631 GPIO_DRV_WritePinOutput(J1_4, 0);
645 #ifdef BM_LOW_LEVEL_GPIOS
646 GPIO_DRV_WritePinOutput(J1_2, 0);
686 callbacks = _lwevent_get_signalled();
696 if (callbacks & (1 << i))
760 new_token = (1 << bit);
963 uint64 remainingtime_usec = 0;
988 return (
uint32)remainingtime_usec;
BM_VOLATILE bm_callback_token_t cb_token_registered_mask
uint32 isf_time_util_get_usec(void)
This API returns the time in microseconds.
void isf_system_sync(void)
This function synchronizes the user tasks and the system initialization.
#define BM_MINIMUM_CB_TIMELEFT_USEC
void isr_bm_callback_tmr(void *dummy)
#define ISF_BM_PIT_INSTANCE
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)...
#define BM_TASK_STACK_SIZE
bool bm_cb_occurred_query(void)
Tells caller if a callback was scheduled to be called since setting bus manager for powerdown mode...
#define MAX_BM_PERIOD_USEC
The maximum period of a callback is provided in microseconds. Attempting to register a callback perio...
bool bm_statechange_query(void)
Tells caller if there a change in the state of the bus manager. Change could be: ...
void BM_task(os_task_param_t task_init_data)
BM Task . .
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.
uint32 bm_get_num_callback(void)
This API returns the number of callbacks registered.
void bm_reset_period(void)
BM_STATIC BM_VOLATILE bm_cb_config_t * gpBm_cb_list[MAX_BM_CALLBACKS]
bm_callback_token_t nToken
bool bm_active_cb_query(void)
Tells caller if there are active callbacks. .
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 BM_ALLOC_MEM_ZERO(x)
#define MAX_BM_CALLBACKS
The maximum number of callbacks registered with the Bus Manager.
task_param_t os_task_param_t
#define BM_PIPELINE_STAGES
BM_VOLATILE uint32 cb_events[BM_PIPELINE_STAGES]
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
bm_callback_t * pCallback
BM_VOLATILE uint32 time_keeper_usec
isf_status_t bm_init(void)
Bus management initialization .
BM_STATIC BM_VOLATILE bool gBm_firsttime_flag
BM_STATIC BM_VOLATILE bool gBm_state_change
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.
Main ISF header file. Contains code common to all ISF components.
void( bm_callback_t)(void *)
Type for the prototype for a Bus Manager periodic callback function.
OSA_TASK_DEFINE(BM, BM_TASK_STACK_SIZE)
void bm_statechange_reset(void)
Reset the state change.
BM_STATIC BM_VOLATILE bool gBm_cb_occurred
The isf_init.h file contains the task initialization attributes required for initialization of the fo...
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_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 semaphore_t sema_bm_access
#define MIN_BM_PERIOD_USEC
The minimum period of a callback is provided in microseconds. Attempting to register a callback perio...
#define ISF_BM_PIT_CHANNEL_NO
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.
BM_STATIC event_t event_bm_callback