Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ------------------------------------------------------------------------------------------------------
- // CTimer(Num) Enable/disable
- // result is true:successfull otherwise false
- bool _Chip_Timer_Enable(void *pPeri, uint32_t ChannelBitMask, bool NewState)
- {
- //bool res = false;
- int32_t PeriIndex = _Chip_CTimer_Get_PeriIndex(pPeri);
- // Check:
- SYS_ASSERT( pPeri != NULL); // check
- if(NewState == true)
- {
- NVIC_ClearPendingIRQ((IRQn_Type) CTIM_IRQ[PeriIndex]); // Clear pending NVIC interrupt flag
- NVIC_EnableIRQ(((IRQn_Type) CTIM_IRQ[PeriIndex])); // Enable NVIC interrupt
- ((_CHIP_CTIMER_T*)pPeri)->TCR &= ~(1 << 1); // Clear reset counter
- ((_CHIP_CTIMER_T*)pPeri)->TCR |= (1 << 0); // Run Timer - must be after clear reset bit !!!!!!!!!!!
- }
- else
- {
- // ToDo: check active channel. If nothing active stop timer and disable complette:
- ((_CHIP_CTIMER_T*)pPeri)->TCR &= ~(1 << 0); // Stop Timer
- ((_CHIP_CTIMER_T*)pPeri)->TCR &= ~(1 << 1); // Clear reset counter
- NVIC_DisableIRQ((IRQn_Type) (CTIM_IRQ[PeriIndex])); // Disable NVIC interrupt
- }
- return(true); // nothing to check. return Seccess
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement