Lines Matching refs:obj

284         cyhal_lptimer_t *obj = _cyhal_lptimer_config_structs[instance];  in _cyhal_lptimer_irq_handler()  local
286 uint32_t c2_count = Cy_MCWDT_GetCount(obj->base, CY_MCWDT_COUNTER2); in _cyhal_lptimer_irq_handler()
288 Cy_MCWDT_ClearInterrupt(obj->base, (CY_MCWDT_CTR1 | CY_MCWDT_CTR2)); in _cyhal_lptimer_irq_handler()
290 Cy_MCWDT_ClearInterrupt(obj->base, (CY_MCWDT_CTR0 | CY_MCWDT_CTR1 | CY_MCWDT_CTR2)); in _cyhal_lptimer_irq_handler()
296 …Cy_MCWDT_SetInterruptMask(obj->base, Cy_MCWDT_GetInterruptMask(obj->base) & ~_cyhal_lptimer_counte… in _cyhal_lptimer_irq_handler()
299 if (obj->clear_int_mask) in _cyhal_lptimer_irq_handler()
302 Cy_MCWDT_SetInterruptMask(obj->base, 0); in _cyhal_lptimer_irq_handler()
304 Cy_WDC_InterruptDisable(obj->base, CY_WDC_COUNTER1); in _cyhal_lptimer_irq_handler()
308 if(obj->final_time - c2_count > 0 && obj->final_time > c2_count) in _cyhal_lptimer_irq_handler()
310 cyhal_lptimer_set_delay(obj, obj->final_time - c2_count); in _cyhal_lptimer_irq_handler()
315 …if (NULL != obj->callback_data.callback && ((obj->isr_instruction & _CYHAL_LPTIMER_ISR_CALL_USER_C… in _cyhal_lptimer_irq_handler()
317 …cyhal_lptimer_event_callback_t callback = (cyhal_lptimer_event_callback_t) obj->callback_data.call… in _cyhal_lptimer_irq_handler()
318 (callback)(obj->callback_data.callback_arg, CYHAL_LPTIMER_COMPARE_MATCH); in _cyhal_lptimer_irq_handler()
323 if ((obj->isr_instruction & _CYHAL_LPTIMER_ISR_CRITICAL_SECTION_MASK) != 0) in _cyhal_lptimer_irq_handler()
326 Cy_MCWDT_ClearInterrupt(obj->base, _cyhal_lptimer_counter_to_mask(obj->counter)); in _cyhal_lptimer_irq_handler()
327 …Cy_MCWDT_SetInterruptMask(obj->base, Cy_MCWDT_GetInterruptMask(obj->base) & ~_cyhal_lptimer_counte… in _cyhal_lptimer_irq_handler()
329 Cy_MCWDT_ClearInterrupt(obj->base, CY_MCWDT_CTR1); in _cyhal_lptimer_irq_handler()
330 Cy_MCWDT_SetInterruptMask(obj->base, 0); in _cyhal_lptimer_irq_handler()
334 obj->isr_instruction &= ~_CYHAL_LPTIMER_ISR_CRITICAL_SECTION_MASK; in _cyhal_lptimer_irq_handler()
351 static uint32_t _cyhal_lptimer_set_delay_common(cyhal_lptimer_t *obj, uint32_t delay) in _cyhal_lptimer_set_delay_common() argument
357 if ((Cy_MCWDT_GetEnabledStatus(obj->base, CY_MCWDT_COUNTER1) == 0UL) in _cyhal_lptimer_set_delay_common()
358 || (Cy_MCWDT_GetEnabledStatus(obj->base, CY_MCWDT_COUNTER2) == 0UL)) in _cyhal_lptimer_set_delay_common()
375 obj->counter = (delay > ((1 << 16)-1)) ? CY_MCWDT_COUNTER2 : CY_MCWDT_COUNTER1; in _cyhal_lptimer_set_delay_common()
377 uint32_t counter_value = Cy_MCWDT_GetCount(obj->base, obj->counter); in _cyhal_lptimer_set_delay_common()
381 Cy_MCWDT_Unlock(obj->base); in _cyhal_lptimer_set_delay_common()
382 if(obj->counter == CY_MCWDT_COUNTER1) in _cyhal_lptimer_set_delay_common()
387 …Cy_MCWDT_ResetCounters(obj->base, _cyhal_lptimer_counter_to_mask(obj->counter), _CYHAL_LPTIMER_RES… in _cyhal_lptimer_set_delay_common()
394 Cy_MCWDT_Lock(obj->base); in _cyhal_lptimer_set_delay_common()
399 …Cy_MCWDT_SetWarnLimit(obj->base, obj->counter, (uint16_t)match_value, _CYHAL_LPTIMER_SETMATCH_TIME… in _cyhal_lptimer_set_delay_common()
409 Cy_MCWDT_SetToggleBit(obj->base, toggle_bit); in _cyhal_lptimer_set_delay_common()
413 Cy_MCWDT_Lock(obj->base); in _cyhal_lptimer_set_delay_common()
415 Cy_MCWDT_ClearInterrupt(obj->base, _cyhal_lptimer_counter_to_mask(obj->counter)); in _cyhal_lptimer_set_delay_common()
416 Cy_MCWDT_SetInterruptMask(obj->base, _cyhal_lptimer_counter_to_mask(obj->counter)); in _cyhal_lptimer_set_delay_common()
420 static uint32_t _cyhal_lptimer_set_delay_common(cyhal_lptimer_t *obj, uint32_t delay) in _cyhal_lptimer_set_delay_common() argument
422 if ((Cy_MCWDT_GetEnabledStatus(obj->base, CY_MCWDT_COUNTER0) == 0UL) in _cyhal_lptimer_set_delay_common()
423 || (Cy_MCWDT_GetEnabledStatus(obj->base, CY_MCWDT_COUNTER1) == 0UL) in _cyhal_lptimer_set_delay_common()
424 || (Cy_MCWDT_GetEnabledStatus(obj->base, CY_MCWDT_COUNTER2) == 0UL)) in _cyhal_lptimer_set_delay_common()
456 Cy_MCWDT_ClearInterrupt(obj->base, CY_MCWDT_CTR1); in _cyhal_lptimer_set_delay_common()
457 uint16_t c0_old_match = (uint16_t)Cy_MCWDT_GetMatch(obj->base, CY_MCWDT_COUNTER0); in _cyhal_lptimer_set_delay_common()
477 uint16_t c0_current_ticks = (uint16_t)Cy_MCWDT_GetCount(obj->base, CY_MCWDT_COUNTER0); in _cyhal_lptimer_set_delay_common()
484 c0_current_ticks = (uint16_t)Cy_MCWDT_GetCount(obj->base, CY_MCWDT_COUNTER0); in _cyhal_lptimer_set_delay_common()
505 c0_new_ticks = (uint16_t)Cy_MCWDT_GetCount(obj->base, CY_MCWDT_COUNTER0); in _cyhal_lptimer_set_delay_common()
514 uint16_t c1_current_ticks = (uint16_t)Cy_MCWDT_GetCount(obj->base, CY_MCWDT_COUNTER1); in _cyhal_lptimer_set_delay_common()
523 Cy_MCWDT_SetMatch(obj->base, CY_MCWDT_COUNTER0, c0_match, _CYHAL_LPTIMER_SETMATCH_TIME_US); in _cyhal_lptimer_set_delay_common()
524 Cy_MCWDT_SetMatch(obj->base, CY_MCWDT_COUNTER1, c1_match, _CYHAL_LPTIMER_SETMATCH_TIME_US); in _cyhal_lptimer_set_delay_common()
527 Cy_MCWDT_SetInterruptMask(obj->base, CY_MCWDT_CTR1); in _cyhal_lptimer_set_delay_common()
529 Cy_WDC_InterruptEnable(obj->base, CY_MCWDT_COUNTER1); in _cyhal_lptimer_set_delay_common()
535 cy_rslt_t cyhal_lptimer_init(cyhal_lptimer_t *obj) in cyhal_lptimer_init() argument
537 CY_ASSERT(NULL != obj); in cyhal_lptimer_init()
539 obj->resource.type = CYHAL_RSC_INVALID; in cyhal_lptimer_init()
540 obj->clear_int_mask = false; in cyhal_lptimer_init()
541 obj->isr_instruction = 0; in cyhal_lptimer_init()
557 obj->resource = temp; in cyhal_lptimer_init()
564 obj->base = _CYHAL_LPTIMER_BASE_ADDRESSES[obj->resource.block_num]; in cyhal_lptimer_init()
566 obj->offset = 0; in cyhal_lptimer_init()
567 obj->final_time = 0; in cyhal_lptimer_init()
568 obj->counter = CY_MCWDT_COUNTER1; in cyhal_lptimer_init()
579 rslt = (cy_rslt_t) Cy_MCWDT_Init(obj->base, &cfg); in cyhal_lptimer_init()
584 obj->callback_data.callback = NULL; in cyhal_lptimer_init()
585 obj->callback_data.callback_arg = NULL; in cyhal_lptimer_init()
586 _cyhal_lptimer_config_structs[obj->resource.block_num] = obj; in cyhal_lptimer_init()
591 _cyhal_system_irq_t irqn = _CYHAL_MCWDT_IRQS[obj->resource.block_num]; in cyhal_lptimer_init()
598 Cy_MCWDT_Unlock(obj->base); in cyhal_lptimer_init()
599 … Cy_MCWDT_Enable(obj->base, (CY_MCWDT_CTR1 | CY_MCWDT_CTR2), _CYHAL_LPTIMER_RESET_TIME_US); in cyhal_lptimer_init()
600 Cy_MCWDT_Lock(obj->base); in cyhal_lptimer_init()
602 Cy_MCWDT_Enable(obj->base, _CYHAL_LPTIMER_CTRL, _CYHAL_LPTIMER_RESET_TIME_US); in cyhal_lptimer_init()
609 cyhal_lptimer_free(obj); in cyhal_lptimer_init()
615 void cyhal_lptimer_free(cyhal_lptimer_t *obj) in cyhal_lptimer_free() argument
617 if (CYHAL_RSC_INVALID != obj->resource.type) in cyhal_lptimer_free()
619 _cyhal_system_irq_t irqn = _CYHAL_MCWDT_IRQS[obj->resource.block_num]; in cyhal_lptimer_free()
622 cyhal_hwmgr_free(&(obj->resource)); in cyhal_lptimer_free()
623 obj->resource.type = CYHAL_RSC_INVALID; in cyhal_lptimer_free()
625 if (NULL != obj->base) in cyhal_lptimer_free()
628 Cy_MCWDT_Unlock(obj->base); in cyhal_lptimer_free()
631 Cy_MCWDT_Disable(obj->base, (CY_MCWDT_CTR1 | CY_MCWDT_CTR2), _CYHAL_LPTIMER_RESET_TIME_US); in cyhal_lptimer_free()
632 Cy_MCWDT_Lock(obj->base); in cyhal_lptimer_free()
634 Cy_MCWDT_Disable(obj->base, _CYHAL_LPTIMER_CTRL, _CYHAL_LPTIMER_RESET_TIME_US); in cyhal_lptimer_free()
640 Cy_MCWDT_DeInit(obj->base); in cyhal_lptimer_free()
642 obj->base = NULL; in cyhal_lptimer_free()
646 cy_rslt_t cyhal_lptimer_reload(cyhal_lptimer_t *obj) in cyhal_lptimer_reload() argument
654 obj->offset = Cy_MCWDT_GetCount(obj->base, CY_MCWDT_COUNTER2); in cyhal_lptimer_reload()
655 Cy_MCWDT_Unlock(obj->base); in cyhal_lptimer_reload()
656 Cy_MCWDT_ResetCounters(obj->base, CY_MCWDT_CTR1, _CYHAL_LPTIMER_RESET_TIME_US); in cyhal_lptimer_reload()
657 Cy_MCWDT_Lock(obj->base); in cyhal_lptimer_reload()
660 …Cy_MCWDT_ResetCounters(obj->base, (CY_MCWDT_CTR0 | CY_MCWDT_CTR1 | CY_MCWDT_CTR2), 2 * _CYHAL_LPTI… in cyhal_lptimer_reload()
665 cy_rslt_t cyhal_lptimer_set_match(cyhal_lptimer_t *obj, uint32_t ticks) in cyhal_lptimer_set_match() argument
667 obj->clear_int_mask = false; in cyhal_lptimer_set_match()
668 uint32_t c2_current = cyhal_lptimer_read(obj); in cyhal_lptimer_set_match()
674 obj->final_time = ticks + obj->offset; in cyhal_lptimer_set_match()
676 return _cyhal_lptimer_set_delay_common(obj, ticks - c2_current); in cyhal_lptimer_set_match()
679 cy_rslt_t cyhal_lptimer_set_delay(cyhal_lptimer_t *obj, uint32_t delay) in cyhal_lptimer_set_delay() argument
681 obj->clear_int_mask = true; in cyhal_lptimer_set_delay()
683 obj->final_time = (Cy_MCWDT_GetCount(obj->base, CY_MCWDT_COUNTER2) + delay); in cyhal_lptimer_set_delay()
685 return _cyhal_lptimer_set_delay_common(obj, delay); in cyhal_lptimer_set_delay()
688 uint32_t cyhal_lptimer_read(const cyhal_lptimer_t *obj) in cyhal_lptimer_read() argument
691 uint32_t ctr2_count = Cy_MCWDT_GetCount(obj->base, CY_MCWDT_COUNTER2); in cyhal_lptimer_read()
692 if(obj->offset > ctr2_count) in cyhal_lptimer_read()
694 return (uint32_t)((((uint64_t)1 << 32) - obj->offset) + ctr2_count); in cyhal_lptimer_read()
698 return ctr2_count - obj->offset; in cyhal_lptimer_read()
701 return Cy_MCWDT_GetCount(obj->base, CY_MCWDT_COUNTER2); in cyhal_lptimer_read()
705 void cyhal_lptimer_register_callback(cyhal_lptimer_t *obj, cyhal_lptimer_event_callback_t callback,… in cyhal_lptimer_register_callback() argument
707 CY_ASSERT(CYHAL_RSC_INVALID != obj->resource.block_num); in cyhal_lptimer_register_callback()
710 obj->callback_data.callback = (cy_israddress) callback; in cyhal_lptimer_register_callback()
711 obj->callback_data.callback_arg = callback_arg; in cyhal_lptimer_register_callback()
715 void cyhal_lptimer_enable_event(cyhal_lptimer_t *obj, cyhal_lptimer_event_t event, uint8_t intr_pri… in cyhal_lptimer_enable_event() argument
720 obj->isr_instruction &= ~_CYHAL_LPTIMER_ISR_CALL_USER_CB_MASK; in cyhal_lptimer_enable_event()
721 obj->isr_instruction |= (uint8_t)enable; in cyhal_lptimer_enable_event()
723 _cyhal_system_irq_t irqn =_CYHAL_MCWDT_IRQS[obj->resource.block_num]; in cyhal_lptimer_enable_event()
729 Cy_MCWDT_ClearInterrupt(obj->base, _cyhal_lptimer_counter_to_mask(obj->counter)); in cyhal_lptimer_enable_event()
730 Cy_MCWDT_SetInterruptMask(obj->base, _cyhal_lptimer_counter_to_mask(obj->counter)); in cyhal_lptimer_enable_event()
732 Cy_MCWDT_ClearInterrupt(obj->base, CY_MCWDT_CTR1); in cyhal_lptimer_enable_event()
733 Cy_MCWDT_SetInterruptMask(obj->base, CY_MCWDT_CTR1); in cyhal_lptimer_enable_event()
742 if (Cy_MCWDT_GetInterruptStatus(obj->base) != 0) in cyhal_lptimer_enable_event()
744 obj->isr_instruction |= _CYHAL_LPTIMER_ISR_CRITICAL_SECTION_MASK; in cyhal_lptimer_enable_event()
750 Cy_MCWDT_ClearInterrupt(obj->base, _cyhal_lptimer_counter_to_mask(obj->counter)); in cyhal_lptimer_enable_event()
751 …Cy_MCWDT_SetInterruptMask(obj->base, Cy_MCWDT_GetInterruptMask(obj->base) & ~_cyhal_lptimer_counte… in cyhal_lptimer_enable_event()
753 Cy_MCWDT_ClearInterrupt(obj->base, CY_MCWDT_CTR1); in cyhal_lptimer_enable_event()
754 Cy_MCWDT_SetInterruptMask(obj->base, 0); in cyhal_lptimer_enable_event()
762 void cyhal_lptimer_irq_trigger(cyhal_lptimer_t *obj) in cyhal_lptimer_irq_trigger() argument
764 CY_ASSERT(CYHAL_RSC_INVALID != obj->resource.block_num); in cyhal_lptimer_irq_trigger()
765 …cyhal_lptimer_event_callback_t callback = (cyhal_lptimer_event_callback_t) obj->callback_data.call… in cyhal_lptimer_irq_trigger()
766 (callback)(obj->callback_data.callback_arg, CYHAL_LPTIMER_COMPARE_MATCH); in cyhal_lptimer_irq_trigger()
769 void cyhal_lptimer_get_info(cyhal_lptimer_t *obj, cyhal_lptimer_info_t *info) in cyhal_lptimer_get_info() argument
771 CY_UNUSED_PARAMETER(obj); in cyhal_lptimer_get_info()