/** * @brief main routine for blinky example * @return Function should not exit. */ int main(void) { uint32_t sysTickRate; SystemCoreClockUpdate(); Board_Init(); Board_LED_Set(0, false); Board_LED_Set(1, true); /* The sysTick counter only has 24 bits of precision, so it will overflow quickly with a fast core clock. You can alter the sysTick divider to generate slower sysTick clock rates. */ Chip_Clock_SetSysTickClockDiv(1); /* A SysTick divider is present that scales the sysTick rate down from the core clock. Using the SystemCoreClock variable as a rate reference for the SysTick_Config() function won't work, so get the sysTick rate by calling Chip_Clock_GetSysTickClockRate() */ sysTickRate = Chip_Clock_GetSysTickClockRate(); /* Enable and setup SysTick Timer at a periodic rate */ SysTick_Config(sysTickRate / TICKRATE_HZ1); /* LEDs toggle in interrupt handlers */ while (1) { __WFI(); } return 0; }
void platform_early_init(void) { /* set up clocking for a board with an external oscillator */ Chip_SetupXtalClocking(); /* Set USB PLL input to main oscillator */ Chip_Clock_SetUSBPLLSource(SYSCTL_PLLCLKSRC_MAINOSC); /* Setup USB PLL (FCLKIN = 12MHz) * 4 = 48MHz MSEL = 3 (this is pre-decremented), PSEL = 1 (for P = 2) FCLKOUT = FCLKIN * (MSEL + 1) = 12MHz * 4 = 48MHz FCCO = FCLKOUT * 2 * P = 48MHz * 2 * 2 = 192MHz (within FCCO range) */ Chip_Clock_SetupUSBPLL(3, 1); /* Powerup USB PLL */ Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_USBPLL_PD); /* Wait for PLL to lock */ while (!Chip_Clock_IsUSBPLLLocked()) {} /* Set default system tick divder to 1 */ Chip_Clock_SetSysTickClockDiv(1); /* start the generic systick driver */ arm_cm_systick_init(Chip_Clock_GetMainClockRate()); lpc_debug_early_init(); }
int main(void) { uint32_t sysTickRate; Board_Init(); #ifdef DEBUG // Set up UART for debug init_uart(115200); putLineUART("\n"); #endif // Enable EEPROM clock and reset EEPROM controller Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_EEPROM); Chip_SYSCTL_PeriphReset(RESET_EEPROM); // Set up clocking for SD lib SystemCoreClockUpdate(); DWT_Init(); // Set up the FatFS Object f_mount(fatfs,"",0); // Initialize SD card Board_LED_Color(LED_CYAN); if(sd_reset(&cardinfo) != SD_OK) { error(ERROR_SD_INIT); } sd_state = SD_READY; // Setup config Board_LED_Color(LED_CYAN); configStart(); Board_LED_Color(LED_GREEN); // Allow MSC mode on startup msc_state = MSC_ENABLED; // Log startup log_string("Startup"); // Set up ADC for reading battery voltage read_vBat_setup(); // Initialize ring buffer used to buffer raw data samples rawBuff = RingBuffer_initWithBuffer(RAW_BUFF_SIZE, RAM1_BASE); // Set up MRT used by pb and daq Chip_MRT_Init(); NVIC_ClearPendingIRQ(MRT_IRQn); NVIC_EnableIRQ(MRT_IRQn); NVIC_SetPriority(MRT_IRQn, 0x02); // Set higher than systick, but lower than sampling // Initialize push button pb_init(); // Enable and setup SysTick Timer at a periodic rate Chip_Clock_SetSysTickClockDiv(1); sysTickRate = Chip_Clock_GetSysTickClockRate(); SysTick_Config(sysTickRate / TICKRATE_HZ1); // Idle and run systick loop until triggered or plugged in as a USB device system_state = STATE_IDLE; enterIdleTime = Chip_RTC_GetCount(LPC_RTC); // Wait for interrupts while (1) { __WFI(); } return 0 ; }
int main(void) { #if defined (__USE_LPCOPEN) // Read clock settings and update SystemCoreClock variable SystemCoreClockUpdate(); #if !defined(NO_BOARD_LIB) // Set up and initialize all required blocks and // functions related to the board hardware Board_Init(); // Set the LED to the state of "On" #endif #endif Timer aika(0, 30, 0, true); Timer ledi(0, 10, 0, true); Timer skooppi(0, 0, 300, true); // write code here that uses two timer objects // one is used to print current time every 30 seconds (use semihosting for printing) // second to switch led colour every 10 seconds // third to give a pulse on PIO0_10 every 300 ms // make the timer tick from main program - do not call object's methods from ISR // Otetaan käyttöön GPION 0,10 Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 10, (IOCON_DIGMODE_EN)); Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 10); // Force the counter to be placed into memory volatile static int i = 0 ; /* The sysTick counter only has 24 bits of precision, so it will overflow quickly with a fast core clock. You can alter the sysTick divider to generate slower sysTick clock rates. */ Chip_Clock_SetSysTickClockDiv(1); /* A SysTick divider is present that scales the sysTick rate down from the core clock. Using the SystemCoreClock variable as a rate reference for the SysTick_Config() function won't work, so get the sysTick rate by calling Chip_Clock_GetSysTickClockRate() */ uint32_t sysTickRate = Chip_Clock_GetSysTickClockRate(); /* Enable and setup SysTick Timer at a periodic rate */ SysTick_Config(sysTickRate / TICKRATE_HZ1); while(1){ // Enter an infinite loop, just incrementing a counter while(!flag) __WFI(); flag = false; if(aika.Tick()){ // Aika on loppu tässä // Tulosta aika semihostingilla //enter_critical(); printf("RealTimeClock after every 30secons.: %d.%d.%d\n", h,m,s); } if(ledi.Tick()){ //Aika on loppu tässä Board_LED_Set(q, false); q++; Board_LED_Set(q, true); if (q == 2){ q = 0; } } if(skooppi.Tick()){ //Aika on loppu tässä // pulssi if (pulssi == 0) { Chip_GPIO_SetPinState(LPC_GPIO, 0, 10, true); pulssi = 1; }else{ pulssi = 0; Chip_GPIO_SetPinState(LPC_GPIO, 0, 10, false); } } i++ ; } return 0 ; }