int main(void) { SystemInit(); debug_puts("Happy Face!\n"); SystemCoreClockUpdate(); uint32_t clock = SystemCoreClock; INIT_LEDS(); /* Setup the memory */ memory_init(); /* Start applications */ net_init(); radio_init(); init_current_time(); /* Switch to a stable clock source from the radio */ switch_to_stable_clock(); /* Setup the Repetitive Interrupt Timer (RIT) */ LPC_SC->PCONP |= (1 << 16); /* Power up the RIT, PCLK=CCLK/4 */ LPC_RIT->RICTRL = 1; /* Disable RIT, Clear interrupt */ NVIC_SetPriority(RIT_IRQn, 31); /* Set Lowest Priority */ NVIC_EnableIRQ(RIT_IRQn); /* Enable the interrupt */ LPC_RIT->RIMASK = 0; /* Compare all the bits */ LPC_RIT->RICOMPVAL = 500*25; /* 500µS on 25MHz PCLK */ /* Enable RIT, Halt on Debug, Clear on match */ LPC_RIT->RICTRL = (1<<3)|(0<<2)|(1<<1); /* Setup sleep mode */ LPC_SC->PCON &= ~0x3; /* Sleep or Deep Sleep mode */ SCB->SCR &= ~(1<<2); /* Sleep mode */ /* Sleep forever */ while(1) { __WFI(); } return 0; }
/****************************************************************************** ** Main Function main() ******************************************************************************/ int main (void) { unsigned long cycle = PWM_CYCLE, offset = 0; INIT_LEDS(); // initialize the GPIO's connected to LEDs turn_off_all_leds(); // Turnoff all LEDs init_VIC(); // Initialize Vectored interrupts if ( PWM_Init( 0 ) != TRUE ) { while( 1 ); /* fatal error */ } PWM_Set( cycle, offset ); PWM_Start(); while ( 1 ) { if ( match_counter != 0 ) { match_counter = 0; if( offset <= PWM_CYCLE ) { offset += PWM_OFFSET; } else { offset = 0; } PWM_Set( cycle, offset ); } } PWM_Stop() ; return 0; }