Lines Matching refs:obj

280         cyhal_lptimer_t *obj = _cyhal_lptimer_config_structs[instance];  in _cyhal_lptimer_irq_handler()  local
282 uint32_t c2_count = Cy_MCWDT_GetCount(obj->base, CY_MCWDT_COUNTER2); in _cyhal_lptimer_irq_handler()
284 Cy_MCWDT_ClearInterrupt(obj->base, (CY_MCWDT_CTR1 | CY_MCWDT_CTR2)); in _cyhal_lptimer_irq_handler()
286 Cy_MCWDT_ClearInterrupt(obj->base, (CY_MCWDT_CTR0 | CY_MCWDT_CTR1 | CY_MCWDT_CTR2)); in _cyhal_lptimer_irq_handler()
292 …Cy_MCWDT_SetInterruptMask(obj->base, Cy_MCWDT_GetInterruptMask(obj->base) & ~_cyhal_lptimer_counte… in _cyhal_lptimer_irq_handler()
295 if (obj->clear_int_mask) in _cyhal_lptimer_irq_handler()
298 Cy_MCWDT_SetInterruptMask(obj->base, 0); in _cyhal_lptimer_irq_handler()
300 Cy_WDC_InterruptDisable(obj->base, CY_WDC_COUNTER1); in _cyhal_lptimer_irq_handler()
304 if(obj->final_time - c2_count > 0 && obj->final_time > c2_count) in _cyhal_lptimer_irq_handler()
306 cyhal_lptimer_set_delay(obj, obj->final_time - c2_count); in _cyhal_lptimer_irq_handler()
311 …if (NULL != obj->callback_data.callback && ((obj->isr_instruction & _CYHAL_LPTIMER_ISR_CALL_USER_C… in _cyhal_lptimer_irq_handler()
313 …cyhal_lptimer_event_callback_t callback = (cyhal_lptimer_event_callback_t) obj->callback_data.call… in _cyhal_lptimer_irq_handler()
314 (callback)(obj->callback_data.callback_arg, CYHAL_LPTIMER_COMPARE_MATCH); in _cyhal_lptimer_irq_handler()
319 if ((obj->isr_instruction & _CYHAL_LPTIMER_ISR_CRITICAL_SECTION_MASK) != 0) in _cyhal_lptimer_irq_handler()
322 Cy_MCWDT_ClearInterrupt(obj->base, _cyhal_lptimer_counter_to_mask(obj->counter)); in _cyhal_lptimer_irq_handler()
323 …Cy_MCWDT_SetInterruptMask(obj->base, Cy_MCWDT_GetInterruptMask(obj->base) & ~_cyhal_lptimer_counte… in _cyhal_lptimer_irq_handler()
325 Cy_MCWDT_ClearInterrupt(obj->base, CY_MCWDT_CTR1); in _cyhal_lptimer_irq_handler()
326 Cy_MCWDT_SetInterruptMask(obj->base, 0); in _cyhal_lptimer_irq_handler()
330 obj->isr_instruction &= ~_CYHAL_LPTIMER_ISR_CRITICAL_SECTION_MASK; in _cyhal_lptimer_irq_handler()
347 static uint32_t _cyhal_lptimer_set_delay_common(cyhal_lptimer_t *obj, uint32_t delay) in _cyhal_lptimer_set_delay_common() argument
353 if ((Cy_MCWDT_GetEnabledStatus(obj->base, CY_MCWDT_COUNTER1) == 0UL) in _cyhal_lptimer_set_delay_common()
354 || (Cy_MCWDT_GetEnabledStatus(obj->base, CY_MCWDT_COUNTER2) == 0UL)) in _cyhal_lptimer_set_delay_common()
371 obj->counter = (delay > ((1 << 16)-1)) ? CY_MCWDT_COUNTER2 : CY_MCWDT_COUNTER1; in _cyhal_lptimer_set_delay_common()
373 uint32_t counter_value = Cy_MCWDT_GetCount(obj->base, obj->counter); in _cyhal_lptimer_set_delay_common()
377 Cy_MCWDT_Unlock(obj->base); in _cyhal_lptimer_set_delay_common()
378 if(obj->counter == CY_MCWDT_COUNTER1) in _cyhal_lptimer_set_delay_common()
383 …Cy_MCWDT_ResetCounters(obj->base, _cyhal_lptimer_counter_to_mask(obj->counter), _CYHAL_LPTIMER_RES… in _cyhal_lptimer_set_delay_common()
390 Cy_MCWDT_Lock(obj->base); in _cyhal_lptimer_set_delay_common()
395 …Cy_MCWDT_SetWarnLimit(obj->base, obj->counter, (uint16_t)match_value, _CYHAL_LPTIMER_SETMATCH_TIME… in _cyhal_lptimer_set_delay_common()
405 Cy_MCWDT_SetToggleBit(obj->base, toggle_bit); in _cyhal_lptimer_set_delay_common()
409 Cy_MCWDT_Lock(obj->base); in _cyhal_lptimer_set_delay_common()
411 Cy_MCWDT_ClearInterrupt(obj->base, _cyhal_lptimer_counter_to_mask(obj->counter)); in _cyhal_lptimer_set_delay_common()
412 Cy_MCWDT_SetInterruptMask(obj->base, _cyhal_lptimer_counter_to_mask(obj->counter)); in _cyhal_lptimer_set_delay_common()
416 static uint32_t _cyhal_lptimer_set_delay_common(cyhal_lptimer_t *obj, uint32_t delay) in _cyhal_lptimer_set_delay_common() argument
418 if ((Cy_MCWDT_GetEnabledStatus(obj->base, CY_MCWDT_COUNTER0) == 0UL) in _cyhal_lptimer_set_delay_common()
419 || (Cy_MCWDT_GetEnabledStatus(obj->base, CY_MCWDT_COUNTER1) == 0UL) in _cyhal_lptimer_set_delay_common()
420 || (Cy_MCWDT_GetEnabledStatus(obj->base, CY_MCWDT_COUNTER2) == 0UL)) in _cyhal_lptimer_set_delay_common()
452 Cy_MCWDT_ClearInterrupt(obj->base, CY_MCWDT_CTR1); in _cyhal_lptimer_set_delay_common()
453 uint16_t c0_old_match = (uint16_t)Cy_MCWDT_GetMatch(obj->base, CY_MCWDT_COUNTER0); in _cyhal_lptimer_set_delay_common()
473 uint16_t c0_current_ticks = (uint16_t)Cy_MCWDT_GetCount(obj->base, CY_MCWDT_COUNTER0); in _cyhal_lptimer_set_delay_common()
480 c0_current_ticks = (uint16_t)Cy_MCWDT_GetCount(obj->base, CY_MCWDT_COUNTER0); in _cyhal_lptimer_set_delay_common()
501 c0_new_ticks = (uint16_t)Cy_MCWDT_GetCount(obj->base, CY_MCWDT_COUNTER0); in _cyhal_lptimer_set_delay_common()
510 uint16_t c1_current_ticks = (uint16_t)Cy_MCWDT_GetCount(obj->base, CY_MCWDT_COUNTER1); in _cyhal_lptimer_set_delay_common()
519 Cy_MCWDT_SetMatch(obj->base, CY_MCWDT_COUNTER0, c0_match, _CYHAL_LPTIMER_SETMATCH_TIME_US); in _cyhal_lptimer_set_delay_common()
520 Cy_MCWDT_SetMatch(obj->base, CY_MCWDT_COUNTER1, c1_match, _CYHAL_LPTIMER_SETMATCH_TIME_US); in _cyhal_lptimer_set_delay_common()
523 Cy_MCWDT_SetInterruptMask(obj->base, CY_MCWDT_CTR1); in _cyhal_lptimer_set_delay_common()
525 Cy_WDC_InterruptEnable(obj->base, CY_MCWDT_COUNTER1); in _cyhal_lptimer_set_delay_common()
531 cy_rslt_t cyhal_lptimer_init(cyhal_lptimer_t *obj) in cyhal_lptimer_init() argument
533 CY_ASSERT(NULL != obj); in cyhal_lptimer_init()
535 obj->resource.type = CYHAL_RSC_INVALID; in cyhal_lptimer_init()
536 obj->clear_int_mask = false; in cyhal_lptimer_init()
537 obj->isr_instruction = 0; in cyhal_lptimer_init()
553 obj->resource = temp; in cyhal_lptimer_init()
560 obj->base = _CYHAL_LPTIMER_BASE_ADDRESSES[obj->resource.block_num]; in cyhal_lptimer_init()
562 obj->offset = 0; in cyhal_lptimer_init()
563 obj->final_time = 0; in cyhal_lptimer_init()
564 obj->counter = CY_MCWDT_COUNTER1; in cyhal_lptimer_init()
575 rslt = (cy_rslt_t) Cy_MCWDT_Init(obj->base, &cfg); in cyhal_lptimer_init()
580 obj->callback_data.callback = NULL; in cyhal_lptimer_init()
581 obj->callback_data.callback_arg = NULL; in cyhal_lptimer_init()
582 _cyhal_lptimer_config_structs[obj->resource.block_num] = obj; in cyhal_lptimer_init()
587 _cyhal_system_irq_t irqn = _CYHAL_MCWDT_IRQS[obj->resource.block_num]; in cyhal_lptimer_init()
594 Cy_MCWDT_Unlock(obj->base); in cyhal_lptimer_init()
595 … Cy_MCWDT_Enable(obj->base, (CY_MCWDT_CTR1 | CY_MCWDT_CTR2), _CYHAL_LPTIMER_RESET_TIME_US); in cyhal_lptimer_init()
596 Cy_MCWDT_Lock(obj->base); in cyhal_lptimer_init()
598 Cy_MCWDT_Enable(obj->base, _CYHAL_LPTIMER_CTRL, _CYHAL_LPTIMER_RESET_TIME_US); in cyhal_lptimer_init()
605 cyhal_lptimer_free(obj); in cyhal_lptimer_init()
611 void cyhal_lptimer_free(cyhal_lptimer_t *obj) in cyhal_lptimer_free() argument
613 if (CYHAL_RSC_INVALID != obj->resource.type) in cyhal_lptimer_free()
615 _cyhal_system_irq_t irqn = _CYHAL_MCWDT_IRQS[obj->resource.block_num]; in cyhal_lptimer_free()
618 cyhal_hwmgr_free(&(obj->resource)); in cyhal_lptimer_free()
619 obj->resource.type = CYHAL_RSC_INVALID; in cyhal_lptimer_free()
621 if (NULL != obj->base) in cyhal_lptimer_free()
624 Cy_MCWDT_Unlock(obj->base); in cyhal_lptimer_free()
627 Cy_MCWDT_Disable(obj->base, (CY_MCWDT_CTR1 | CY_MCWDT_CTR2), _CYHAL_LPTIMER_RESET_TIME_US); in cyhal_lptimer_free()
628 Cy_MCWDT_Lock(obj->base); in cyhal_lptimer_free()
630 Cy_MCWDT_Disable(obj->base, _CYHAL_LPTIMER_CTRL, _CYHAL_LPTIMER_RESET_TIME_US); in cyhal_lptimer_free()
636 Cy_MCWDT_DeInit(obj->base); in cyhal_lptimer_free()
638 obj->base = NULL; in cyhal_lptimer_free()
642 cy_rslt_t cyhal_lptimer_reload(cyhal_lptimer_t *obj) in cyhal_lptimer_reload() argument
650 obj->offset = Cy_MCWDT_GetCount(obj->base, CY_MCWDT_COUNTER2); in cyhal_lptimer_reload()
651 Cy_MCWDT_Unlock(obj->base); in cyhal_lptimer_reload()
652 Cy_MCWDT_ResetCounters(obj->base, CY_MCWDT_CTR1, _CYHAL_LPTIMER_RESET_TIME_US); in cyhal_lptimer_reload()
653 Cy_MCWDT_Lock(obj->base); in cyhal_lptimer_reload()
656 …Cy_MCWDT_ResetCounters(obj->base, (CY_MCWDT_CTR0 | CY_MCWDT_CTR1 | CY_MCWDT_CTR2), 2 * _CYHAL_LPTI… in cyhal_lptimer_reload()
661 cy_rslt_t cyhal_lptimer_set_match(cyhal_lptimer_t *obj, uint32_t ticks) in cyhal_lptimer_set_match() argument
663 obj->clear_int_mask = false; in cyhal_lptimer_set_match()
664 uint32_t c2_current = cyhal_lptimer_read(obj); in cyhal_lptimer_set_match()
670 obj->final_time = ticks + obj->offset; in cyhal_lptimer_set_match()
672 return _cyhal_lptimer_set_delay_common(obj, ticks - c2_current); in cyhal_lptimer_set_match()
675 cy_rslt_t cyhal_lptimer_set_delay(cyhal_lptimer_t *obj, uint32_t delay) in cyhal_lptimer_set_delay() argument
677 obj->clear_int_mask = true; in cyhal_lptimer_set_delay()
679 obj->final_time = (Cy_MCWDT_GetCount(obj->base, CY_MCWDT_COUNTER2) + delay); in cyhal_lptimer_set_delay()
681 return _cyhal_lptimer_set_delay_common(obj, delay); in cyhal_lptimer_set_delay()
684 uint32_t cyhal_lptimer_read(const cyhal_lptimer_t *obj) in cyhal_lptimer_read() argument
687 uint32_t ctr2_count = Cy_MCWDT_GetCount(obj->base, CY_MCWDT_COUNTER2); in cyhal_lptimer_read()
688 if(obj->offset > ctr2_count) in cyhal_lptimer_read()
690 return (uint32_t)((((uint64_t)1 << 32) - obj->offset) + ctr2_count); in cyhal_lptimer_read()
694 return ctr2_count - obj->offset; in cyhal_lptimer_read()
697 return Cy_MCWDT_GetCount(obj->base, CY_MCWDT_COUNTER2); in cyhal_lptimer_read()
701 void cyhal_lptimer_register_callback(cyhal_lptimer_t *obj, cyhal_lptimer_event_callback_t callback,… in cyhal_lptimer_register_callback() argument
703 CY_ASSERT(CYHAL_RSC_INVALID != obj->resource.block_num); in cyhal_lptimer_register_callback()
706 obj->callback_data.callback = (cy_israddress) callback; in cyhal_lptimer_register_callback()
707 obj->callback_data.callback_arg = callback_arg; in cyhal_lptimer_register_callback()
711 void cyhal_lptimer_enable_event(cyhal_lptimer_t *obj, cyhal_lptimer_event_t event, uint8_t intr_pri… in cyhal_lptimer_enable_event() argument
716 obj->isr_instruction &= ~_CYHAL_LPTIMER_ISR_CALL_USER_CB_MASK; in cyhal_lptimer_enable_event()
717 obj->isr_instruction |= (uint8_t)enable; in cyhal_lptimer_enable_event()
719 _cyhal_system_irq_t irqn =_CYHAL_MCWDT_IRQS[obj->resource.block_num]; in cyhal_lptimer_enable_event()
725 Cy_MCWDT_ClearInterrupt(obj->base, _cyhal_lptimer_counter_to_mask(obj->counter)); in cyhal_lptimer_enable_event()
726 Cy_MCWDT_SetInterruptMask(obj->base, _cyhal_lptimer_counter_to_mask(obj->counter)); in cyhal_lptimer_enable_event()
728 Cy_MCWDT_ClearInterrupt(obj->base, CY_MCWDT_CTR1); in cyhal_lptimer_enable_event()
729 Cy_MCWDT_SetInterruptMask(obj->base, CY_MCWDT_CTR1); in cyhal_lptimer_enable_event()
738 if (Cy_MCWDT_GetInterruptStatus(obj->base) != 0) in cyhal_lptimer_enable_event()
740 obj->isr_instruction |= _CYHAL_LPTIMER_ISR_CRITICAL_SECTION_MASK; in cyhal_lptimer_enable_event()
746 Cy_MCWDT_ClearInterrupt(obj->base, _cyhal_lptimer_counter_to_mask(obj->counter)); in cyhal_lptimer_enable_event()
747 …Cy_MCWDT_SetInterruptMask(obj->base, Cy_MCWDT_GetInterruptMask(obj->base) & ~_cyhal_lptimer_counte… in cyhal_lptimer_enable_event()
749 Cy_MCWDT_ClearInterrupt(obj->base, CY_MCWDT_CTR1); in cyhal_lptimer_enable_event()
750 Cy_MCWDT_SetInterruptMask(obj->base, 0); in cyhal_lptimer_enable_event()
758 void cyhal_lptimer_irq_trigger(cyhal_lptimer_t *obj) in cyhal_lptimer_irq_trigger() argument
760 CY_ASSERT(CYHAL_RSC_INVALID != obj->resource.block_num); in cyhal_lptimer_irq_trigger()
761 …cyhal_lptimer_event_callback_t callback = (cyhal_lptimer_event_callback_t) obj->callback_data.call… in cyhal_lptimer_irq_trigger()
762 (callback)(obj->callback_data.callback_arg, CYHAL_LPTIMER_COMPARE_MATCH); in cyhal_lptimer_irq_trigger()
765 void cyhal_lptimer_get_info(cyhal_lptimer_t *obj, cyhal_lptimer_info_t *info) in cyhal_lptimer_get_info() argument
767 CY_UNUSED_PARAMETER(obj); in cyhal_lptimer_get_info()