| ISF 2.1 Intelligent Sensing Framework for Kinetis with Processor Expert

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

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 {
68 isf_duration_t Period;
69 bm_callback_t *pCallback;
70 void *pCbData;
71 uint32 Cur_period;
72 bm_callback_token_t nToken;
73
74 } bm_cb_config_t;
75
76 typedef struct
77 {
78 BM_VOLATILE int32 cb_list_cur_cnt;
79 BM_VOLATILE bm_callback_token_t cb_token_registered_mask;
80 BM_VOLATILE bm_callback_token_t cb_token_active_mask;
81
82 BM_VOLATILE uint32 time_keeper_usec;
83 BM_VOLATILE uint32 pipeline_index;
84 BM_VOLATILE uint32 cb_events[BM_PIPELINE_STAGES];
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
bm_statechange_query
boolean bm_statechange_query(void)
Tells caller if there a change in the state of the bus manager. Change could be: ...
Definition: bus_management.c:1001
bm_cb_config_t
Definition: bm_internal.h:66
bm_t::cb_token_registered_mask
BM_VOLATILE bm_callback_token_t cb_token_registered_mask
Definition: bm_internal.h:79
bm_cb_occurred_query
boolean bm_cb_occurred_query(void)
Tells caller if a callback was scheduled to be called since setting bus manager for powerdown mode...
Definition: bus_management.c:1061
bm_cb_config_t::Cur_period
uint32 Cur_period
Definition: bm_internal.h:71
isf_bm.h
API definitions, types, and macros for the Intelligent Sensing Framework (ISF) Bus Manager (BM)...
bm_statechange_reset
void bm_statechange_reset(void)
Reset the state change.
Definition: bus_management.c:1028
uint32
unsigned long uint32
This defines uint32 as unsigned long.
Definition: isf_types.h:36
bm_callback_token_t
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
bm_powerdown
uint32 bm_powerdown(void)
Prepare bm for powerdown state. Called by power manager. .
Definition: bus_management.c:937
bm_cb_config_t::Period
isf_duration_t Period
Definition: bm_internal.h:68
bm_cb_config_t::nToken
bm_callback_token_t nToken
Definition: bm_internal.h:72
BM_PIPELINE_STAGES
#define BM_PIPELINE_STAGES
Definition: bm_internal.h:64
bm_cb_config_t::pCbData
void * pCbData
Definition: bm_internal.h:70
bm_t::cb_token_active_mask
BM_VOLATILE bm_callback_token_t cb_token_active_mask
Definition: bm_internal.h:80
bm_callback_t
void( bm_callback_t)(void *)
Type for the prototype for a Bus Manager periodic callback function.
Definition: isf_bm.h:71
bm_cb_config_t::pCallback
bm_callback_t * pCallback
Definition: bm_internal.h:69
bm_t::time_keeper_usec
BM_VOLATILE uint32 time_keeper_usec
Definition: bm_internal.h:82
bm_t
Definition: bm_internal.h:76
bm_t::cb_list_cur_cnt
BM_VOLATILE int32 cb_list_cur_cnt
Definition: bm_internal.h:78
BM_VOLATILE
#define BM_VOLATILE
Definition: bm_internal.h:33
isf_duration_t
uint32 isf_duration_t
ISF time duration in microseconds.
Definition: isf.h:59
int32
long int32
This defines int32 as long.
Definition: isf_types.h:32
bm_t::pipeline_index
BM_VOLATILE uint32 pipeline_index
Definition: bm_internal.h:83
isf_comm.h
isf_comm.h defines the common types for the Communications Service Family of the Intelligent Sensing ...
bm_active_cb_query
boolean bm_active_cb_query(void)
Tells caller if there are active callbacks. .
Definition: bus_management.c:1085
bm
bm_t bm
Definition: bus_management.c:46
- © Freescale Semiconductor, Inc. 2015. All Rights Reserved.