Lines Matching refs:t

90   for (int t = 0; t < NHW_TIMER_TOTAL_INST ; t++) {  in nhw_timer_init()  local
91 struct timer_status *t_st = &nhw_timer_st[t]; in nhw_timer_init()
93 t_st->NRF_TIMER_regs = &NRF_TIMER_regs[t]; in nhw_timer_init()
100 t_st->base_freq = Timer_freqs[t]; in nhw_timer_init()
101 t_st->n_CCs = Timer_n_CCs[t]; in nhw_timer_init()
102 t_st->CC_timers = (bs_time_t *)bs_malloc(sizeof(bs_time_t)*Timer_n_CCs[t]); in nhw_timer_init()
103 t_st->oneshot_flag = (bool *)bs_calloc(Timer_n_CCs[t], sizeof(bool)); in nhw_timer_init()
110 t_st->dppi_map = nhw_timer_dppi_map[t]; in nhw_timer_init()
111 …t_st->subscribed_CAPTURE = (struct nhw_subsc_mem*)bs_calloc(Timer_n_CCs[t], sizeof(struct nhw_subs… in nhw_timer_init()
124 for (int t = 0; t< NHW_TIMER_TOTAL_INST; t++) { in nhw_timer_free() local
125 struct timer_status *t_st = &nhw_timer_st[t]; in nhw_timer_free()
146 static uint32_t time_to_counter(bs_time_t delta, int t){ in time_to_counter() argument
148 ticks = (delta * nhw_timer_st[t].base_freq) >> NRF_TIMER_regs[t].PRESCALER; in time_to_counter()
156 static bs_time_t counter_to_time(uint64_t counter, int t){ in counter_to_time() argument
158 Elapsed = (counter << NRF_TIMER_regs[t].PRESCALER) / nhw_timer_st[t].base_freq; in counter_to_time()
165 static uint32_t mask_from_bitmode(int t){ in mask_from_bitmode() argument
166 switch (NRF_TIMER_regs[t].BITMODE){ in mask_from_bitmode()
186 static uint64_t time_of_1_counter_wrap(int t){ in time_of_1_counter_wrap() argument
187 return counter_to_time((uint64_t)mask_from_bitmode(t) + 1, t); in time_of_1_counter_wrap()
196 for ( int t = 0 ; t < N_TIMERS ; t++){ in update_master_timer() local
197 struct timer_status *t_st = &nhw_timer_st[t]; in update_master_timer()
199 if ((t_st->is_running == true) && (NRF_TIMER_regs[t].MODE == 0)) { in update_master_timer()
214 static void update_cc_timer(int t, int cc) { in update_cc_timer() argument
215 struct timer_status *this = &nhw_timer_st[t]; in update_cc_timer()
217 if ((this->is_running == true) && (NRF_TIMER_regs[t].MODE == 0)) { in update_cc_timer()
219 + counter_to_time(NRF_TIMER_regs[t].CC[cc], t); in update_cc_timer()
221 next_match += time_of_1_counter_wrap(t); in update_cc_timer()
229 static void update_all_cc_timers(int t) { in update_all_cc_timers() argument
230 for (int cc = 0 ; cc < nhw_timer_st[t].n_CCs; cc++) { in update_all_cc_timers()
231 update_cc_timer(t, cc); in update_all_cc_timers()
235 static void nhw_timer_eval_interrupts(int t) { in nhw_timer_eval_interrupts() argument
240 struct timer_status *this = &nhw_timer_st[t]; in nhw_timer_eval_interrupts()
245 if (NRF_TIMER_regs[t].EVENTS_COMPARE[cc] && mask) { in nhw_timer_eval_interrupts()
251 if (TIMER_int_line[t] == false && new_int_line == true) { in nhw_timer_eval_interrupts()
252 TIMER_int_line[t] = true; in nhw_timer_eval_interrupts()
253 hw_irq_ctrl_raise_level_irq_line(nhw_timer_irq_map[t].cntl_inst, in nhw_timer_eval_interrupts()
254 nhw_timer_irq_map[t].int_nbr); in nhw_timer_eval_interrupts()
255 } else if (TIMER_int_line[t] == true && new_int_line == false) { in nhw_timer_eval_interrupts()
256 TIMER_int_line[t] = false; in nhw_timer_eval_interrupts()
258 hw_irq_ctrl_lower_level_irq_line(nhw_timer_irq_map[t].cntl_inst, in nhw_timer_eval_interrupts()
259 nhw_timer_irq_map[t].int_nbr); in nhw_timer_eval_interrupts()
263 void nhw_timer_TASK_START(int t){ in nhw_timer_TASK_START() argument
264 struct timer_status *this = &nhw_timer_st[t]; in nhw_timer_TASK_START()
269 if (NRF_TIMER_regs[t].MODE == 0) { //Timer mode in nhw_timer_TASK_START()
270 …this->start_t = nsi_hws_get_time() - counter_to_time(this->Counter, t); //If the counter is not ze… in nhw_timer_TASK_START()
271 update_all_cc_timers(t); in nhw_timer_TASK_START()
277 void nhw_timer_TASK_STOP(int t) { in nhw_timer_TASK_STOP() argument
278 struct timer_status *this = &nhw_timer_st[t]; in nhw_timer_TASK_STOP()
283 if (NRF_TIMER_regs[t].MODE == 0) { //Timer mode in nhw_timer_TASK_STOP()
284 …this->Counter = time_to_counter(nsi_hws_get_time() - this->start_t, t); //we save the value when t… in nhw_timer_TASK_STOP()
293 void nhw_timer_TASK_SHUTDOWN(int t) { in nhw_timer_TASK_SHUTDOWN() argument
294 struct timer_status *this = &nhw_timer_st[t]; in nhw_timer_TASK_SHUTDOWN()
313 void nhw_timer_TASK_CAPTURE(int t, int cc_n) { in nhw_timer_TASK_CAPTURE() argument
314 struct timer_status *this = &nhw_timer_st[t]; in nhw_timer_TASK_CAPTURE()
319 t, cc_n, this->n_CCs); in nhw_timer_TASK_CAPTURE()
321 if ((NRF_TIMER_regs[t].MODE != 0 /* Count mode */) || (this->is_running == false)) { in nhw_timer_TASK_CAPTURE()
322 NRF_TIMER_regs[t].CC[cc_n] = this->Counter & mask_from_bitmode(t); in nhw_timer_TASK_CAPTURE()
325 NRF_TIMER_regs[t].CC[cc_n] = time_to_counter(Elapsed,t) & mask_from_bitmode(t); in nhw_timer_TASK_CAPTURE()
328 update_cc_timer(t, cc_n); in nhw_timer_TASK_CAPTURE()
333 void nhw_timer_TASK_CLEAR(uint t) { in nhw_timer_TASK_CLEAR() argument
334 struct timer_status *this = &nhw_timer_st[t]; in nhw_timer_TASK_CLEAR()
337 if (NRF_TIMER_regs[t].MODE == 0) { in nhw_timer_TASK_CLEAR()
340 update_all_cc_timers(t); in nhw_timer_TASK_CLEAR()
345 static void nhw_timer_signal_COMPARE(uint t, uint cc) { in nhw_timer_signal_COMPARE() argument
346 struct timer_status *this = &nhw_timer_st[t]; in nhw_timer_signal_COMPARE()
350 nhw_timer_TASK_CLEAR(t); in nhw_timer_signal_COMPARE()
353 nhw_timer_TASK_STOP(t); in nhw_timer_signal_COMPARE()
358 nhw_timer_eval_interrupts(t); in nhw_timer_signal_COMPARE()
362 switch (t) { in nhw_timer_signal_COMPARE()
387 static void nhw_timer_signal_COMPARE_if(uint t, uint cc_n) { in nhw_timer_signal_COMPARE_if() argument
388 struct timer_status *this = &nhw_timer_st[t]; in nhw_timer_signal_COMPARE_if()
395 nhw_timer_signal_COMPARE(t, cc_n); in nhw_timer_signal_COMPARE_if()
398 void nhw_timer_TASK_COUNT(uint t) { in nhw_timer_TASK_COUNT() argument
399 struct timer_status *this = &nhw_timer_st[t]; in nhw_timer_TASK_COUNT()
401 if ((NRF_TIMER_regs[t].MODE != 0 /* Count mode */) && (this->is_running == true)) { in nhw_timer_TASK_COUNT()
402 this->Counter = (this->Counter + 1) & mask_from_bitmode(t); in nhw_timer_TASK_COUNT()
405 if (this->Counter == (NRF_TIMER_regs[t].CC[cc_n] & mask_from_bitmode(t))){ in nhw_timer_TASK_COUNT()
406 nhw_timer_signal_COMPARE_if(t, cc_n); in nhw_timer_TASK_COUNT()
412 void nhw_timer_regw_sideeffects_TASKS_START(uint t) { in nhw_timer_regw_sideeffects_TASKS_START() argument
413 if ( NRF_TIMER_regs[t].TASKS_START ){ in nhw_timer_regw_sideeffects_TASKS_START()
414 NRF_TIMER_regs[t].TASKS_START = 0; in nhw_timer_regw_sideeffects_TASKS_START()
415 nhw_timer_TASK_START(t); in nhw_timer_regw_sideeffects_TASKS_START()
419 void nhw_timer_regw_sideeffects_TASKS_STOP(uint t) { in nhw_timer_regw_sideeffects_TASKS_STOP() argument
420 if (NRF_TIMER_regs[t].TASKS_STOP) { in nhw_timer_regw_sideeffects_TASKS_STOP()
421 NRF_TIMER_regs[t].TASKS_STOP = 0; in nhw_timer_regw_sideeffects_TASKS_STOP()
422 nhw_timer_TASK_STOP(t); in nhw_timer_regw_sideeffects_TASKS_STOP()
426 void nhw_timer_regw_sideeffects_TASKS_SHUTDOWN(uint t) { in nhw_timer_regw_sideeffects_TASKS_SHUTDOWN() argument
427 if (NRF_TIMER_regs[t].TASKS_SHUTDOWN) { in nhw_timer_regw_sideeffects_TASKS_SHUTDOWN()
428 NRF_TIMER_regs[t].TASKS_SHUTDOWN = 0; in nhw_timer_regw_sideeffects_TASKS_SHUTDOWN()
429 nhw_timer_TASK_SHUTDOWN(t); in nhw_timer_regw_sideeffects_TASKS_SHUTDOWN()
433 void nhw_timer_regw_sideeffects_TASKS_CAPTURE(uint t, uint cc_n){ in nhw_timer_regw_sideeffects_TASKS_CAPTURE() argument
434 if ( NRF_TIMER_regs[t].TASKS_CAPTURE[cc_n] ){ in nhw_timer_regw_sideeffects_TASKS_CAPTURE()
435 NRF_TIMER_regs[t].TASKS_CAPTURE[cc_n] = 0; in nhw_timer_regw_sideeffects_TASKS_CAPTURE()
436 nhw_timer_TASK_CAPTURE(t,cc_n); in nhw_timer_regw_sideeffects_TASKS_CAPTURE()
440 void nhw_timer_regw_sideeffects_TASKS_CLEAR(uint t) { in nhw_timer_regw_sideeffects_TASKS_CLEAR() argument
441 if (NRF_TIMER_regs[t].TASKS_CLEAR) { in nhw_timer_regw_sideeffects_TASKS_CLEAR()
442 NRF_TIMER_regs[t].TASKS_CLEAR = 0; in nhw_timer_regw_sideeffects_TASKS_CLEAR()
443 nhw_timer_TASK_CLEAR(t); in nhw_timer_regw_sideeffects_TASKS_CLEAR()
447 void nhw_timer_regw_sideeffects_TASKS_COUNT(uint t) { in nhw_timer_regw_sideeffects_TASKS_COUNT() argument
448 if ( NRF_TIMER_regs[t].TASKS_COUNT ){ in nhw_timer_regw_sideeffects_TASKS_COUNT()
449 NRF_TIMER_regs[t].TASKS_COUNT = 0; in nhw_timer_regw_sideeffects_TASKS_COUNT()
450 nhw_timer_TASK_COUNT(t); in nhw_timer_regw_sideeffects_TASKS_COUNT()
498 void nhw_timer_regw_sideeffects_EVENTS_all(uint t) { in NHW_TIMER_REGW_SIDEFFECTS_SUBSCRIBE()
499 nhw_timer_eval_interrupts(t); in NHW_TIMER_REGW_SIDEFFECTS_SUBSCRIBE()
502 void nhw_timer_regw_sideeffects_INTENSET(uint t) { in nhw_timer_regw_sideeffects_INTENSET() argument
503 struct timer_status *this = &nhw_timer_st[t]; in nhw_timer_regw_sideeffects_INTENSET()
505 if ( NRF_TIMER_regs[t].INTENSET ){ in nhw_timer_regw_sideeffects_INTENSET()
506 this->INTEN |= NRF_TIMER_regs[t].INTENSET; in nhw_timer_regw_sideeffects_INTENSET()
507 NRF_TIMER_regs[t].INTENSET = this->INTEN; in nhw_timer_regw_sideeffects_INTENSET()
508 nhw_timer_eval_interrupts(t); in nhw_timer_regw_sideeffects_INTENSET()
512 void nhw_timer_regw_sideeffects_INTENCLR(uint t) { in nhw_timer_regw_sideeffects_INTENCLR() argument
513 struct timer_status *this = &nhw_timer_st[t]; in nhw_timer_regw_sideeffects_INTENCLR()
515 if ( NRF_TIMER_regs[t].INTENCLR ){ in nhw_timer_regw_sideeffects_INTENCLR()
516 this->INTEN &= ~NRF_TIMER_regs[t].INTENCLR; in nhw_timer_regw_sideeffects_INTENCLR()
517 NRF_TIMER_regs[t].INTENSET = this->INTEN; in nhw_timer_regw_sideeffects_INTENCLR()
518 NRF_TIMER_regs[t].INTENCLR = 0; in nhw_timer_regw_sideeffects_INTENCLR()
519 nhw_timer_eval_interrupts(t); in nhw_timer_regw_sideeffects_INTENCLR()
523 void nhw_timer_regw_sideeffects_CC(uint t, uint cc_n) { in nhw_timer_regw_sideeffects_CC() argument
524 struct timer_status *this = &nhw_timer_st[t]; in nhw_timer_regw_sideeffects_CC()
529 __func__, t, cc_n, this->n_CCs); in nhw_timer_regw_sideeffects_CC()
534 if ( (this->is_running == true) && ( NRF_TIMER_regs[t].MODE == 0 ) ) { in nhw_timer_regw_sideeffects_CC()
535 update_cc_timer(t, cc_n); in nhw_timer_regw_sideeffects_CC()
541 unsigned int t, cc; in nhw_hw_model_timer_timer_triggered() local
543 unsigned int t[N_TIMERS*N_MAX_CC]; in nhw_hw_model_timer_timer_triggered() member
550 for (t = 0 ; t < N_TIMERS ; t++) { in nhw_hw_model_timer_timer_triggered()
551 struct timer_status *t_st = &nhw_timer_st[t]; in nhw_hw_model_timer_timer_triggered()
553 if ( !((t_st->is_running == true) && (NRF_TIMER_regs[t].MODE == 0)) ) { in nhw_hw_model_timer_timer_triggered()
558 match.t[match.cnt] = t; in nhw_hw_model_timer_timer_triggered()
566 t = match.t[match.cnt]; in nhw_hw_model_timer_timer_triggered()
568 update_cc_timer(t,cc); //Next time it will match in nhw_hw_model_timer_timer_triggered()
569 nhw_timer_signal_COMPARE_if(t,cc); in nhw_hw_model_timer_timer_triggered()