/** * @brief MRT example main function * @return Status (This function will not return) */ int main(void) { int mrtch; /* Generic Initialization */ SystemCoreClockUpdate(); Board_Init(); DEBUGSTR("LPC15xx MRT Example \r\n"); /* MRT Initialization and disable all timers */ Chip_MRT_Init(); for (mrtch = 0; mrtch < MRT_CHANNELS_NUM; mrtch++) { Chip_MRT_SetDisabled(Chip_MRT_GetRegPtr(mrtch)); } /* Enable the interrupt for the MRT */ NVIC_EnableIRQ(MRT_IRQn); /* Enable timers 0 and 1 in repeat mode with different rates */ setupMRT(0, MRT_MODE_REPEAT, 2);/* 2Hz rate */ setupMRT(1, MRT_MODE_REPEAT, 5);/* 5Hz rate */ /* Enable timer 2 in single one mode with the interrupt restarting the timer */ setupMRT(2, MRT_MODE_ONESHOT, 7); /* Will fire in 1/7 seconds */ /* All processing and MRT reset in the interrupt handler */ while (1) { __WFI(); } return 0; }
/** * @brief MRT example main function * @return Status (This function will not return) */ int main(void) { int mrtch; static uint32_t mSecShot; /* Generic Initialization */ SystemCoreClockUpdate(); Board_Init(); DEBUGSTR("LPC8xx MRT Example \r\n"); /* MRT Initialization and disable all timers */ Chip_MRT_Init(); for (mrtch = 0; mrtch < MRT_CHANNELS_NUM; mrtch++) { Chip_MRT_SetDisabled(Chip_MRT_GetRegPtr(mrtch)); } /* Enable the interrupt for the MRT */ NVIC_EnableIRQ(MRT_IRQn); /* Enable timers 0 and 1 in repeat mode with different rates */ setupMRT(0, MRT_MODE_REPEAT, 5);/* 5Hz rate */ setupMRT(1, MRT_MODE_REPEAT, 4);/* 4Hz rate */ /* Enable timer 2 in single one mode with the interrupt restarting the timer */ setupMRT(2, MRT_MODE_ONESHOT, 500); /* Will fire in (1/500) seconds */ mSecShot = 100; Board_LED_Set(0, false); /* Timer 3 processing loop - places timer 3 into one shot mode whenever it has been handled in the IRQ handler */ while (1) { if (!t3Fired) { t3Fired = true; setupMRT(3, MRT_MODE_ONESHOT, mSecShot);/* Will fire in (1/mSecShot) seconds */ Board_LED_Toggle(2); mSecShot += 10; if (mSecShot > 1000) { mSecShot = 100; } } __WFI(); } return 0; }