| ISF 2.2 rev 5 Intelligent Sensing Framework for Kinetis with Processor Expert

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

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 {
69 isf_duration_t Period;
70 bm_callback_t *pCallback;
71 void *pCbData;
72 uint32 Cur_period;
73 bm_callback_token_t nToken;
74
75 } bm_cb_config_t;
76
77 typedef struct
78 {
79 BM_VOLATILE int32 cb_list_cur_cnt;
80 BM_VOLATILE bm_callback_token_t cb_token_registered_mask;
81 BM_VOLATILE bm_callback_token_t cb_token_active_mask;
82
83 BM_VOLATILE uint32 time_keeper_usec;
84 BM_VOLATILE uint32 pipeline_index;
85 BM_VOLATILE uint32 cb_events[BM_PIPELINE_STAGES];
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_cb_config_t
Definition: bm_internal.h:67
bm_t::cb_token_registered_mask
BM_VOLATILE bm_callback_token_t cb_token_registered_mask
Definition: bm_internal.h:80
bm_cb_config_t::Cur_period
uint32 Cur_period
Definition: bm_internal.h:72
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:1049
bm_cb_occurred_query
bool 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:1088
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:961
BM_pit_instance.h
header for current pit instance.
bm_cb_config_t::Period
isf_duration_t Period
Definition: bm_internal.h:69
bm_cb_config_t::nToken
bm_callback_token_t nToken
Definition: bm_internal.h:73
bm_active_cb_query
bool bm_active_cb_query(void)
Tells caller if there are active callbacks. .
Definition: bus_management.c:1112
BM_PIPELINE_STAGES
#define BM_PIPELINE_STAGES
Definition: bm_internal.h:65
bm_cb_config_t::pCbData
void * pCbData
Definition: bm_internal.h:71
bm_t::cb_token_active_mask
BM_VOLATILE bm_callback_token_t cb_token_active_mask
Definition: bm_internal.h:81
bm_cb_config_t::pCallback
bm_callback_t * pCallback
Definition: bm_internal.h:70
bm_t::time_keeper_usec
BM_VOLATILE uint32 time_keeper_usec
Definition: bm_internal.h:83
bm_t
Definition: bm_internal.h:77
bm_t::cb_list_cur_cnt
BM_VOLATILE int32 cb_list_cur_cnt
Definition: bm_internal.h:79
bm_statechange_query
bool bm_statechange_query(void)
Tells caller if there a change in the state of the bus manager. Change could be: ...
Definition: bus_management.c:1022
BM_VOLATILE
#define BM_VOLATILE
Definition: bm_internal.h:30
isf_duration_t
uint32 isf_duration_t
ISF time duration in microseconds.
Definition: isf.h:84
isf.h
Main ISF header file. Contains code common to all ISF components.
bm_callback_t
void( bm_callback_t)(void *)
Type for the prototype for a Bus Manager periodic callback function.
Definition: isf_bm.h:71
int32
signed long int int32
Definition: isf_types.h:74
bm_t::pipeline_index
BM_VOLATILE uint32 pipeline_index
Definition: bm_internal.h:84
isf_comm.h
isf_comm.h defines the common types for the Communications Service Family of the Intelligent Sensing ...
uint32
unsigned long int uint32
Definition: isf_types.h:78
bm
bm_t bm
Definition: bus_management.c:45
- © Freescale Semiconductor, Inc. 2016. All Rights Reserved.