Changeset 263 for soft/giet_vm/giet_drivers/tim_driver.c
- Timestamp:
- Dec 19, 2013, 9:36:48 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_drivers/tim_driver.c
r258 r263 16 16 // - "user" timers : requested by the task in the mapping_info data structure. 17 17 // For each user timer, the timer_id is stored in the context of the task. 18 // The global index is cluster_ id* (NB_PROCS_MAX + NB_TIM_CHANNELS) + local_id18 // The global index is cluster_xy * (NB_PROCS_MAX + NB_TIM_CHANNELS) + local_id 19 19 // 20 20 // The NB_PROCS_MAX and NB_TIM_CHANNELS values must be defined in the … … 25 25 // The virtual base address of the segment associated to a channel is: 26 26 // 27 // seg_tim_base + cluster_ id* vseg_cluster_increment + TIMER_SPAN * timer_id27 // seg_tim_base + cluster_xy * vseg_cluster_increment + TIMER_SPAN * timer_id 28 28 // 29 29 // The seg_tim_base and vseg_cluster_increment values must be defined … … 35 35 #include <utils.h> 36 36 37 #if !defined( NB_CLUSTERS)38 # error: You must define NB_CLUSTERSin the hard_config.h file37 #if !defined(X_SIZE) 38 # error: You must define X_SIZE in the hard_config.h file 39 39 #endif 40 40 41 #if (NB_CLUSTERS > 256) 42 # error: NB_CLUSTERS cannot be larger than 256! 41 #if !defined(Y_SIZE) 42 # error: You must define X_SIZE in the hard_config.h file 43 #endif 44 45 #if !defined(X_WIDTH) 46 # error: You must define X_WIDTH in the hard_config.h file 47 #endif 48 49 #if !defined(Y_WIDTH) 50 # error: You must define X_WIDTH in the hard_config.h file 43 51 #endif 44 52 45 53 #if !defined(NB_PROCS_MAX) 46 54 # error: You must define NB_PROCS_MAX in the hard_config.h file 47 #endif48 49 #if (NB_PROCS_MAX > 8)50 # error: NB_PROCS_MAX cannot be larger than 8!51 55 #endif 52 56 … … 59 63 #endif 60 64 61 #if !defined( USE_XICU )62 # error: You must define USE_XICU in the hard_config.h file63 #endif64 65 65 /////////////////// Timer global variables //////////////////////////////////////// 66 66 … … 68 68 69 69 #if (NB_TIM_CHANNELS > 0) 70 in_unckdata volatile unsigned char _user_timer_event[ NB_CLUSTERS *NB_TIM_CHANNELS]71 = { [0 ... (( NB_CLUSTERS *NB_TIM_CHANNELS) - 1)] = 0 };70 in_unckdata volatile unsigned char _user_timer_event[X_SIZE*Y_SIZE*NB_TIM_CHANNELS] 71 = { [0 ... ((X_SIZE*Y_SIZE*NB_TIM_CHANNELS) - 1)] = 0 }; 72 72 #endif 73 73 … … 80 80 // Returns 0 if success, > 0 if error. 81 81 ////////////////////////////////////////////////////////////////////////////// 82 unsigned int _timer_start( unsigned int cluster_ id,82 unsigned int _timer_start( unsigned int cluster_xy, 83 83 unsigned int local_id, 84 84 unsigned int period) 85 85 { 86 86 // parameters checking 87 if (cluster_id >= NB_CLUSTERS) return 1; 87 unsigned int x = cluster_xy >> Y_WIDTH; 88 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 89 if (x >= X_SIZE) return 1; 90 if (y >= Y_SIZE) return 1; 88 91 if (local_id >= NB_TIM_CHANNELS) return 1; 89 92 90 93 unsigned int* timer_address = (unsigned int *) ((unsigned int)&seg_tim_base + 91 (cluster_ id* (unsigned int)&vseg_cluster_increment));94 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 92 95 93 96 timer_address[local_id * TIMER_SPAN + TIMER_PERIOD] = period; … … 102 105 // Returns 0 if success, > 0 if error. 103 106 ////////////////////////////////////////////////////////////////////////////// 104 unsigned int _timer_stop( unsigned int cluster_ id,107 unsigned int _timer_stop( unsigned int cluster_xy, 105 108 unsigned int local_id) 106 109 { 107 110 // parameters checking 108 if (cluster_id >= NB_CLUSTERS) return 1; 111 unsigned int x = cluster_xy >> Y_WIDTH; 112 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 113 if (x >= X_SIZE) return 1; 114 if (y >= Y_SIZE) return 1; 109 115 if (local_id >= NB_TIM_CHANNELS) return 1; 110 116 111 117 unsigned int* timer_address = (unsigned int *) ((unsigned int)&seg_tim_base + 112 (cluster_ id* (unsigned int)&vseg_cluster_increment));118 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 113 119 114 120 timer_address[local_id * TIMER_SPAN + TIMER_MODE] = 0; … … 124 130 // Returns 0 if success, > 0 if error. 125 131 ////////////////////////////////////////////////////////////////////////////// 126 unsigned int _timer_reset_irq( unsigned int cluster_ id,132 unsigned int _timer_reset_irq( unsigned int cluster_xy, 127 133 unsigned int local_id ) 128 134 { 129 135 // parameters checking 130 if (cluster_id >= NB_CLUSTERS) return 1; 136 unsigned int x = cluster_xy >> Y_WIDTH; 137 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 138 if (x >= X_SIZE) return 1; 139 if (y >= Y_SIZE) return 1; 131 140 if (local_id >= NB_TIM_CHANNELS) return 1; 132 141 133 142 unsigned int * timer_address = (unsigned int *) ((unsigned int)&seg_tim_base + 134 (cluster_ id* (unsigned int)&vseg_cluster_increment));143 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 135 144 136 145 timer_address[local_id * TIMER_SPAN + TIMER_RESETIRQ] = 0; … … 147 156 // This function is called during a context switch (user or preemptive) 148 157 //////////////////////////////////////////////////////////////////////i////// 149 unsigned int _timer_reset_cpt( unsigned int cluster_ id,158 unsigned int _timer_reset_cpt( unsigned int cluster_xy, 150 159 unsigned int local_id) 151 160 { 152 161 // parameters checking 153 if (cluster_id >= NB_CLUSTERS) return 1; 162 unsigned int x = cluster_xy >> Y_WIDTH; 163 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 164 if (x >= X_SIZE) return 1; 165 if (y >= Y_SIZE) return 1; 154 166 if (local_id >= NB_TIM_CHANNELS) return 1; 155 167 156 168 // We suppose that the TIMER_MODE register value is 0x3 157 169 unsigned int * timer_address = (unsigned int *) ((unsigned int)&seg_tim_base + 158 (cluster_ id* (unsigned int)&vseg_cluster_increment));170 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 159 171 160 172 unsigned int period = timer_address[local_id * TIMER_SPAN + TIMER_PERIOD];
Note: See TracChangeset
for help on using the changeset viewer.