ISF  2.2 rev 5
Intelligent Sensing Framework for Kinetis with Processor Expert
bm_internal.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2015, Freescale Semiconductor, Inc.
4  *
5 */
6 
7 /*!
8  * @file bm_internal.h
9  * @brief ISF bus management internal header file.
10  *
11  */
12 
13 
14 #ifndef BM_INTERNAL_H
15 #define BM_INTERNAL_H
16 #include "isf.h"
17 #include "BM_pit_instance.h"
18 #include <isf_comm.h>
19 #include "isf_bm.h"
20 //#define BM_LOW_LEVEL_GPIOS
21 //#define BM_DEBUG_TRACE_BUFFER
22 
23 
24 //#define BM_DEBUG
25 
26 #ifdef BM_DEBUG
27 #define BM_VOLATILE volatile // Make volatile so we can see in debug
28 #define BM_STATIC
29 #else
30 #define BM_VOLATILE volatile // Vars could be changed in isr, so make it volatile
31 #define BM_STATIC static // Internal variables for release
32 #endif
33 
34 // Specifies the minimum time, in usec, to the next call back. If the time to next
35 // cb is less than this value, then the bm isr will force the next cb to occur
36 // immediately. We need to do this because we try to program into the timer a
37 // small value that is less than the isr execution time, then when the interrupt
38 // occur for that small time, the bm timer will time out again during the servicing
39 // of the isr and will generate another interrupt. When this happens we will
40 // immediately get an interrupt as soon as we exit the isr, even if we reprogrammed
41 // the timer to a new value and clearing the timer flag when exiting the isr. This
42 // could be due to the interrupt controller latching the interrupt when it happens
43 // during isr execution. Therefore clearing the timer flag does not help.
44 //
45 // In the timer isr we also reset the timer and reload the modulo with 0xffff as
46 // the very first thing. This aids in preventing the situation stated above and
47 // allows us to keep this mininum time lower because we only need to make sure that
48 // the timer will not generate an interrupt when we leave the isr up to reentering
49 // the isr (that's when we clear it).
50 #define BM_MINIMUM_CB_TIMELEFT_USEC (100)
51 #if OS_MQXLITE
52 #define BM_ALLOC_MEM_ZERO(x) _lwmem_alloc_system_zero(x)
53 #define BM_FREE_MEM(x) _lwmem_free(x)
54 #else
55 #define BM_ALLOC_MEM_ZERO(x) OSA_MemAllocZero(x)
56 #define BM_FREE_MEM(x) OSA_MemFree(x)
57 #endif
58 
59 #define BM_MIN_REMAINING_THRESHOLD_USEC (10)
60 
61 // TODO - Need to calculate and set this PIT Scaler value from PEx
62 
63 #define BM_FULL_PERIOD 1
64 #define BM_CURRENT_PERIOD 2
65 #define BM_PIPELINE_STAGES 2
66 
67 typedef struct
68 {
71  void *pCbData;
74 
76 
77 typedef struct
78 {
82 
86 } bm_t;
87 
88 
89 
90 extern bm_t bm;
91 
92 bool bm_active_cb_query(void);
93 uint32 bm_powerdown(void);
94 bool bm_statechange_query(void);
95 bool bm_cb_occurred_query(void);
96 void bm_statechange_reset(void);
97 
98 
99 
100 //#pragma pack(pop)
101 
102 
103 #endif // BM_INTERNAL_H
104 
105 
BM_VOLATILE bm_callback_token_t cb_token_registered_mask
Definition: bm_internal.h:80
uint32 Cur_period
Definition: bm_internal.h:72
API definitions, types, and macros for the Intelligent Sensing Framework (ISF) Bus Manager (BM)...
void bm_statechange_reset(void)
Reset the state change.
bool bm_cb_occurred_query(void)
Tells caller if a callback was scheduled to be called since setting bus manager for powerdown mode...
uint32 bm_callback_token_t
This type defines the Bus Manager token. Each callback registered with the Bus Manager receives a uni...
Definition: isf_bm.h:79
uint32 bm_powerdown(void)
Prepare bm for powerdown state. Called by power manager. .
header for current pit instance.
isf_duration_t Period
Definition: bm_internal.h:69
bm_callback_token_t nToken
Definition: bm_internal.h:73
bool bm_active_cb_query(void)
Tells caller if there are active callbacks. .
#define BM_PIPELINE_STAGES
Definition: bm_internal.h:65
void * pCbData
Definition: bm_internal.h:71
BM_VOLATILE bm_callback_token_t cb_token_active_mask
Definition: bm_internal.h:81
bm_callback_t * pCallback
Definition: bm_internal.h:70
BM_VOLATILE uint32 time_keeper_usec
Definition: bm_internal.h:83
BM_VOLATILE int32 cb_list_cur_cnt
Definition: bm_internal.h:79
bool bm_statechange_query(void)
Tells caller if there a change in the state of the bus manager. Change could be: ...
#define BM_VOLATILE
Definition: bm_internal.h:30
uint32 isf_duration_t
ISF time duration in microseconds.
Definition: isf.h:84
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.
Definition: isf_bm.h:71
signed long int int32
Definition: isf_types.h:74
BM_VOLATILE uint32 pipeline_index
Definition: bm_internal.h:84
isf_comm.h defines the common types for the Communications Service Family of the Intelligent Sensing ...
unsigned long int uint32
Definition: isf_types.h:78
bm_t bm