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