int main(void){ unsigned long status; Switch_Init(); // PA5 is input status = Switch_Input(); // 0x00 or 0x20 status = Switch_Input(); // 0x00 or 0x20 Board_Init(); // initialize PF0 and PF4 and make them inputs // make PF3-1 out (PF3-1 built-in LEDs) GPIO_PORTF_DIR_R |= (RED|BLUE|GREEN); // disable alt funct on PF3-1 GPIO_PORTF_AFSEL_R &= ~(RED|BLUE|GREEN); // enable digital I/O on PF3-1 GPIO_PORTF_DEN_R |= (RED|BLUE|GREEN); // configure PF3-1 as GPIO GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFF000F)+0x00000000; GPIO_PORTF_AMSEL_R = 0; // disable analog functionality on PF while(1){ status = Board_Input(); switch(status){ // switches are negative logic on PF0 and PF4 case 0x01: LEDS = BLUE; break; // SW1 pressed case 0x10: LEDS = RED; break; // SW2 pressed case 0x00: LEDS = GREEN; break; // both switches pressed case 0x11: LEDS = 0; break; // neither switch pressed default: LEDS = (RED|GREEN|BLUE);// unexpected return value } } }
/** * @brief Main entry point * @return Nothing */ int main(void) { volatile uint32_t status; SystemCoreClockUpdate(); Board_Init(); /* Initialize the OTP Controller */ status = Chip_OTP_Init(); /* Fix as per Errata, required for some LPC43xx parts */ OTP_fix(0, 0, 0, 0); /* Set Boot Source */ /* Please note that this function is commented to avoid accidental * programming of OTP values (which can result in not booting of boards). * Make sure that you understand the OTP programming before you * try this example */ #if (defined(BOARD_KEIL_MCB_1857) || defined(BOARD_KEIL_MCB_4357)) //status = Chip_OTP_ProgBootSrc(CHIP_OTP_BOOTSRC_PINS); #else //status = Chip_OTP_ProgBootSrc(CHIP_OTP_BOOTSRC_SPIFI); #endif while (1); }
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" Board_LED_Set(0, true); #endif #endif // TODO: insert code here Chip_SWM_MovablePortPinAssign(SWM_SWO_O, 1, 2); SysTick_Config(SystemCoreClock / 1000); printf("Started\n"); Setup(); i2cTest(); // Force the counter to be placed into memory volatile static int i = 0 ; // Enter an infinite loop, just incrementing a counter while(1) { i++ ; } return 0 ; }
int main(void) { SystemCoreClockUpdate(); Board_Init(); Board_LED_Set(0, false); // SW4 setup Chip_GPIO_SetDir(LPC_GPIO, 1, 31, false); sw4 = debounce_add(DEBOUNCE_TIME / DEBOUNCE_CYCLE, is_sw4_pushed, NULL); // RGB Rojo Chip_GPIO_SetDir(LPC_GPIO, 2, 0, true); // RGB Verde Chip_GPIO_SetDir(LPC_GPIO, 2, 1, true); // RGB Azul Chip_GPIO_SetDir(LPC_GPIO, 0, 26, true); queue_init(&queue, 1, EventQueue, AlarmTimeoutPush, AlarmTimeoutPop, MutexQueue); StartOS(AppMode1); while (1) { } return 0; }
/** * @brief Main program body * @return Does not return */ int main(void) { /* Generic Initialization */ SystemCoreClockUpdate(); /* Board_Init calls Chip_GPIO_Init and enables GPIO clock if needed, Chip_GPIO_Init is not called again */ Board_Init(); Board_LED_Set(0, false); /* Configure GPIO interrupt pin as input */ Chip_GPIO_SetPinDIRInput(LPC_GPIO, GPIO_INTERRUPT_PORT, GPIO_INTERRUPT_PIN); /* Configure the GPIO interrupt */ Chip_GPIOINT_SetIntFalling(LPC_GPIOINT, GPIO_INTERRUPT_PORT, 1 << GPIO_INTERRUPT_PIN); /* Enable interrupt in the NVIC */ NVIC_ClearPendingIRQ(GPIO_INTERRUPT_NVIC_NAME); NVIC_EnableIRQ(GPIO_INTERRUPT_NVIC_NAME); /* Wait for interrupts - LED will toggle on each wakeup event */ while (1) { __WFI(); } return 0; }
/** * @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; }
/** * @brief Main routine for I2C example * @return Function should not exit */ int main(void) { /* Generic Initialization */ SystemCoreClockUpdate(); Board_Init(); Board_LED_Set(0, false); /* Setup I2C at the board level (usually pin muxing) */ Init_I2C_PinMux(); /* Allocate I2C handle, setup I2C rate, and initialize I2C clocking */ setupI2CSlave(); /* Enable the interrupt for the I2C */ NVIC_EnableIRQ(I2C_IRQn); /* Setup I2C receive slave mode - this will setup a non-blocking I2C mode which will be handled via the I2C interrupt */ readI2CSlave(); /* From master first */ /* I2C slave handler loop - wait for requests from master and receive or send data */ while (1) { /* Sleep while waiting for I2C master requests */ __WFI(); /* All I2C slave processing is performed in the I2C IRQ handler, so there is nothing to really do here */ } return 0; }
/** * @brief Main program body * @return int */ int main(void) { int tmp = 0; int activityIndex = 0; int writeVal = 0; SystemCoreClockUpdate(); Board_Init(); i2c_app_init(I2C0, SPEED_100KHZ); /* Loop forever */ while (1) { /* Toggle LED to show activity. */ tmp = ShowActivity(tmp); /* Test for activity time */ if ((tmp & ACTIVITY_MASK) == 0) { /* Toggle between writes and reads */ switch (activityIndex++ & 1) { case 0: /* Perform target board I2CM write */ WriteBoard_I2CM(writeVal++ & 1); break; case 1: default: /* Perform target board I2CM read */ ReadBoard_I2CM(); break; } } } return 0; }
/** * @brief main routine for hello world example * @return Function should not exit. */ int main(void) { volatile uint32_t *vt; uint32_t cpu_id; SystemCoreClockUpdate(); Board_Init(); /* Enable SysTick Timer */ SysTick_Config(SystemCoreClock / TICKRATE_HZ); /* Display system information */ __disable_irq(); DEBUGOUT("System Clock: %uMHz\r\n", SystemCoreClock / 1000000); DEBUGOUT("Device ID: 0x%04X\r\n", Chip_SYSCTL_GetDeviceID()); vt = &(SCB->VTOR); cpu_id = SCB->CPUID; DEBUGOUT("VTOR Address: 0x%08X\r\n", (uint32_t) vt); DEBUGOUT("CPU ID: 0x%08X\r\n", (uint32_t) cpu_id); __enable_irq(); /* Loop forever */ while (1) { __WFI(); } // return 0; }
/** * @brief Main UART program body * @return Doesn't return */ int main(void) { /* initialize the board */ SystemCoreClockUpdate(); Board_Init(); Board_CMP_Init(); /* initialize the CMP */ Chip_CMP_Init(); /* Power-up */ Chip_CMP_EnableCurrentSrc(CMP_ENCTRL_ENABLE); Chip_CMP_EnableBandGap(CMP_ENCTRL_ENABLE); Chip_CMP_Enable(CMP_ID, CMP_ENCTRL_ENABLE); /* Positive and negative references, both edges, no hysteresis */ Chip_CMP_SetPosVoltRef(CMP_ID, CMP_INPUT_CMPx_IN0); Chip_CMP_SetNegVoltRef(CMP_ID, CMP_INPUT_INTERNAL_09VBG); Chip_CMP_SetHysteresis(CMP_ID, CMP_HYS_NONE); while (1) { if (Chip_CMP_GetCmpStatus(CMP_ID)) { Board_LED_Set(0, false); } else { Board_LED_Set(0, true); } } return 0; }
/** * @brief main routine for blinky example * @return Function should not exit. */ int main(void) { uint32_t timerFreq; /* Generic Initialization */ SystemCoreClockUpdate(); Board_Init(); /* Enable timer 1 clock */ Chip_TIMER_Init(LPC_TIMER0); /* Timer rate is system clock rate */ timerFreq = Chip_Clock_GetSystemClockRate(); /* Timer setup for match and interrupt at TICKRATE_HZ */ Chip_TIMER_Reset(LPC_TIMER0); Chip_TIMER_MatchEnableInt(LPC_TIMER0, 1); Chip_TIMER_SetMatch(LPC_TIMER0, 1, (timerFreq / TICKRATE_HZ1)); Chip_TIMER_ResetOnMatchEnable(LPC_TIMER0, 1); Chip_TIMER_Enable(LPC_TIMER0); /* Enable timer interrupt */ NVIC_ClearPendingIRQ(TIMER0_IRQn); NVIC_EnableIRQ(TIMER0_IRQn); /* LEDs toggle in interrupt handlers */ while (1) { __WFI(); } return 0; }
/** * @brief Main routine for SSP example * @return Nothing */ int main(void) { SystemCoreClockUpdate(); Board_Init(); /* SSP initialization */ Board_SSP_Init(LPC_SSP); Chip_SSP_Init(LPC_SSP); ssp_format.frameFormat = SSP_FRAMEFORMAT_SPI; ssp_format.bits = SSP_DATA_BITS; ssp_format.clockMode = SSP_CLOCK_MODE0; Chip_SSP_SetFormat(LPC_SSP, ssp_format.bits, ssp_format.frameFormat, ssp_format.clockMode); Chip_SSP_Enable(LPC_SSP); /* Initialize GPDMA controller */ Chip_GPDMA_Init(LPC_GPDMA); /* Setting GPDMA interrupt */ NVIC_DisableIRQ(DMA_IRQn); NVIC_SetPriority(DMA_IRQn, ((0x01 << 3) | 0x01)); NVIC_EnableIRQ(DMA_IRQn); /* Setting SSP interrupt */ NVIC_EnableIRQ(SSP_IRQ); appSSPMainMenu(); /* DeInitialize SSP peripheral */ Chip_SSP_DeInit(LPC_SSP); return 0; }
/** * @brief main routine for ADC example * @return Function should not exit */ int main(void) { uint16_t dataADC; int j; SystemCoreClockUpdate(); Board_Init(); Init_ADC_PinMux(); DEBUGSTR("ADC Demo\r\n"); /* ADC Init */ Chip_ADC_Init(LPC_ADC, &ADCSetup); Chip_ADC_EnableChannel(LPC_ADC, ADC_CH0, ENABLE); while (1) { /* Start A/D conversion */ Chip_ADC_SetStartMode(LPC_ADC, ADC_START_NOW, ADC_TRIGGERMODE_RISING); /* Waiting for A/D conversion complete */ while (Chip_ADC_ReadStatus(LPC_ADC, ADC_CH0, ADC_DR_DONE_STAT) != SET) {} /* Read ADC value */ Chip_ADC_ReadValue(LPC_ADC, ADC_CH0, &dataADC); /* Print ADC value */ DEBUGOUT("ADC value is 0x%x\r\n", dataADC); /* Delay */ j = 500000; while (j--) {} } /* Should not run to here */ return 0; }
/** * @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 Main routine for SPI example * @return Function should not exit */ int main(void) { /* Generic Initialization */ SystemCoreClockUpdate(); Board_Init(); /* Clear activity LED */ Board_LED_Set(0, false); /* Setup SPI pin muxing */ Init_SPI_PinMux(); /* Allocate SPI handle, setup rate, and initialize clocking */ setupSpiMaster(); /* Enable SPI0 interrupt */ NVIC_EnableIRQ(SPI0_IRQn); /* Loop forever */ while (1) { /* Write simple message over SPI */ WriteSpiMssg(xferArray, sizeof(xferArray) / sizeof(xferArray[0])); /* Toggle LED to show activity. */ Board_LED_Toggle(0); } /* Code never reaches here. Only used to satisfy standard main() */ return 0; }
/** * @brief main routine for USB example * @return Function should not exit. */ int main(void) { /* Initialize board and chip */ SystemCoreClockUpdate(); Board_Init(); /* Init USB subsystem and LibUSBDevice */ libusbdev_init(USB_STACK_MEM_BASE, USB_STACK_MEM_SIZE); while (1) { /* wait until host is connected */ while (libusbdev_Connected() == 0) { /* Sleep until next IRQ happens */ __WFI(); } while (libusbdev_Connected()) { if (libusbdev_QueueReadDone() != -1) { /* Dummy process read data ......*/ /* requeue read request */ libusbdev_QueueReadReq(g_rxBuff, PACKET_BUFFER_SIZE); } if (libusbdev_QueueSendDone() == 0) { /* Queue send request */ libusbdev_QueueSendReq(g_rxBuff, PACKET_BUFFER_SIZE); } } } }
/* Sets up system hardware */ static void prvSetupHardware(void) { Board_Init(); /* Initial LED0 state is off */ Board_LED_Set(0, false); }
/** * @brief main routine for ATIMER example * @return Nothing (function should not exit) */ int main(void) { bool On = false; SystemCoreClockUpdate(); Board_Init(); /* Init Alarm Timer with Preset Count for about 1s */ Chip_ATIMER_Init(LPC_ATIMER, PresetCount); /* Init EVRT */ Chip_EVRT_Init(); /* Enable EVRT in order to be able to read the ATIMER interrupt */ Chip_EVRT_ConfigIntSrcActiveType(EVRT_SRC_ATIMER, EVRT_SRC_ACTIVE_HIGH_LEVEL); /* Enable Alarm Timer Source */ Chip_EVRT_SetUpIntSrc(EVRT_SRC_ATIMER, ENABLE); /* Enable NVIC */ NVIC_EnableIRQ(EVENTROUTER_IRQn); /* Clear the interrupt states */ ATIMER_ClearInts(); /* Enable Alarm Timer */ Chip_ATIMER_IntEnable(LPC_ATIMER); while (1) { /* Sleep until ATIMER fires */ __WFI(); On = (bool) !On; Board_LED_Set(1, On); } }
int main(void) { //preparing the chip & board SystemCoreClockUpdate(); Board_Init(); PWM_Init(); PWM_SetCycle(400,1000); //the actual code Chip_ADC_Init(_LPC_ADC_ID, &ADCSetup); Chip_ADC_EnableChannel(_LPC_ADC_ID, _ADC_CHANNLE, ENABLE); Chip_ADC_SetBurstCmd(_LPC_ADC_ID, ENABLE); //int i; SysTick_Config(SystemCoreClock / TICKRATE_HZ1); while(1) { __WFI(); /* if(rotation_counter==MEMORY_CAPACITY){ //not rotation_cycle? for(i=0;i<MEMORY_CAPACITY;i++){ DEBUGOUT("%d \n",rotation_debug_holder[i]);//,rotation_debug_holder2[i]); } rotation_counter++; } */ } return 0 ; }
/** * @brief Main routine for I2C example * @return Function should not exit */ int main(void) { uint8_t rxbuf[RX_SZ + 2]; /* Generic Initialization */ SystemCoreClockUpdate(); Board_Init(); /* Initialize the PinMux and setup the memory for ROM driver */ uartrom_init(); /* Configure the ADC */ uartrom_config(); uartrom_regcb();/* Register call-back functions */ ROM_UART_Send(hUART, msg, sizeof(msg) - 1); while (!tx_done) { __WFI(); } while (1) { rx_done = 0; ROM_UART_Receive(hUART, rxbuf, RX_SZ); while (!rx_done) { __WFI(); } tx_done = 0; ROM_UART_Send(hUART, rxbuf, rx_done); while (!tx_done) { __WFI(); } } return 0; }
static void initHardware(void) { SystemCoreClockUpdate(); SysTick_Config(SystemCoreClock/1000); Board_Init(); Board_LED_Set(0, false); /* Timer */ Chip_TIMER_Init(LPC_TIMER1); Chip_TIMER_PrescaleSet(LPC_TIMER1, #ifdef lpc1769 Chip_Clock_GetPeripheralClockRate(SYSCTL_PCLK_TIMER1) / 1000000 - 1 #else Chip_Clock_GetRate(CLK_MX_TIMER1) / 1000000 - 1 #endif ); /* Match 0 (period) */ Chip_TIMER_MatchEnableInt(LPC_TIMER1, 0); Chip_TIMER_ResetOnMatchEnable(LPC_TIMER1, 0); Chip_TIMER_StopOnMatchDisable(LPC_TIMER1, 0); Chip_TIMER_SetMatch(LPC_TIMER1, 0, 1000); /* Match 1 (duty) */ Chip_TIMER_MatchEnableInt(LPC_TIMER1, 1); Chip_TIMER_ResetOnMatchDisable(LPC_TIMER1, 1); Chip_TIMER_StopOnMatchDisable(LPC_TIMER1, 1); Chip_TIMER_SetMatch(LPC_TIMER1, 1, 100); Chip_TIMER_Reset(LPC_TIMER1); Chip_TIMER_Enable(LPC_TIMER1); NVIC_EnableIRQ(TIMER1_IRQn); }
/** * @brief main routine for example * @return Function should not exit. */ int main(void) { USBD_API_INIT_PARAM_T usb_param; USB_CORE_DESCS_T desc; ErrorCode_t ret = LPC_OK; /* Initialize board and chip */ SystemCoreClockUpdate(); Board_Init(); /* Init millisecond timer tick driver */ systick_init(); /* enable clocks and pinmux */ usb_pin_clk_init(); /* initialize call back structures */ memset((void *) &usb_param, 0, sizeof(USBD_API_INIT_PARAM_T)); usb_param.usb_reg_base = LPC_USB_BASE + 0x200; usb_param.max_num_ep = 2; usb_param.mem_base = USB_STACK_MEM_BASE; usb_param.mem_size = USB_STACK_MEM_SIZE; /* Set the USB descriptors */ desc.device_desc = (uint8_t *) USB_DeviceDescriptor; desc.string_desc = (uint8_t *) USB_StringDescriptor; /* Note, to pass USBCV test full-speed only devices should have both * descriptor arrays point to same location and device_qualifier set * to 0. */ desc.high_speed_desc = USB_FsConfigDescriptor; desc.full_speed_desc = USB_FsConfigDescriptor; desc.device_qualifier = 0; /* USB Initialization */ ret = USBD_API->hw->Init(&g_hUsb, &desc, &usb_param); if (ret == LPC_OK) { /* Mice are generally low or full speed devices and not high speed. */ USBD_API->hw->ForceFullSpeed(g_hUsb, 1); ret = Keyboard_init(g_hUsb, (USB_INTERFACE_DESCRIPTOR *) &USB_FsConfigDescriptor[sizeof(USB_CONFIGURATION_DESCRIPTOR)], &usb_param.mem_base, &usb_param.mem_size); if (ret == LPC_OK) { /* enable USB interrupts */ NVIC_EnableIRQ(USB_IRQn); /* now connect */ USBD_API->hw->Connect(g_hUsb, 1); } } while (1) { /* Do Keyboard tasks */ Keyboard_Tasks(); /* Sleep until next IRQ happens */ __WFI(); } }
/* Sets up system hardware */ static void prvSetupHardware(void) { SystemCoreClockUpdate(); Board_Init(); /* Initial LED0 state is off */ Board_LED_Set(0, false); }
static void initHardware(void) { SystemCoreClockUpdate(); Board_Init(); Board_LED_Set(0, false); }
/** * @brief main routine for timer example * @return Function should not exit. */ int main(void) { uint32_t timerBaseClock; SystemCoreClockUpdate(); Board_Init(); Board_LED_Set(0, false); Board_LED_Set(1, false); /* Initialize Timer 0 and Timer 1 */ Chip_TIMER_Init(LPC_TIMER0); Chip_TIMER_Init(LPC_TIMER1); /* Setup prescale value on Timer 0 to PCLK */ Chip_TIMER_PrescaleSet(LPC_TIMER0, 0); /* Setup prescale value on Timer 1 for lower resolution */ Chip_TIMER_PrescaleSet(LPC_TIMER1, PRESCALE_HZ2); /* Reset timers */ Chip_TIMER_Reset(LPC_TIMER0); Chip_TIMER_Reset(LPC_TIMER1); /* Enable both timers to generate interrupts when time matches */ Chip_TIMER_MatchEnableInt(LPC_TIMER0, 1); Chip_TIMER_MatchEnableInt(LPC_TIMER1, 1); /* Get rate of timer base clock */ timerBaseClock = Chip_Clock_GetAsyncSyscon_ClockRate(); /* Setup Timer 0 for a match every 1s */ Chip_TIMER_SetMatch(LPC_TIMER0, 1, (timerBaseClock / TICKRATE_HZ1)); /* Setup Timer 1 for a match twice in a second */ Chip_TIMER_SetMatch(LPC_TIMER1, 1, (timerBaseClock / ((PRESCALE_HZ2 + 1) * TICKRATE_HZ2)) ); /* Setup both timers to restart when match occurs */ Chip_TIMER_ResetOnMatchEnable(LPC_TIMER0, 1); Chip_TIMER_ResetOnMatchEnable(LPC_TIMER1, 1); /* Start both timers */ Chip_TIMER_Enable(LPC_TIMER0); Chip_TIMER_Enable(LPC_TIMER1); /* Clear both timers of any pending interrupts */ NVIC_ClearPendingIRQ(CT32B0_IRQn); NVIC_ClearPendingIRQ(CT32B1_IRQn); /* Enable both timer interrupts */ NVIC_EnableIRQ(CT32B0_IRQn); NVIC_EnableIRQ(CT32B1_IRQn); /* Wait for timers to generate interrupts (LEDs toggle in interrupt handlers) */ while (1) { __WFI(); } return 0; }
/* Sets up system hardware */ static void prvSetupHardware(void) { SystemCoreClockUpdate(); Board_Init(); /* LED0 is used for the link status, on = PHY cable detected */ /* Initial LED state is off to show an unconnected cable state */ Board_LED_Set(0, false); }
/** Configures the board hardware and chip peripherals for the demo's functionality. */ static void SetupHardware(void) { SystemCoreClockUpdate(); Board_Init(); Chip_USB_Init(); USB_Init(FlashDisk_MS_Interface.Config.PortNumber, USB_MODE_Host); /* Hardware Initialization */ Board_Debug_Init(); }
int main(void) { Dice noppa; uint32_t sysTickRate; #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" Board_LED_Set(0, true); #endif #endif sysTickRate = Chip_Clock_GetSysTickClockRate(); // Määritellään nappi PB1 toimimaan inputtina Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 0, (IOCON_MODE_PULLUP | IOCON_DIGMODE_EN | IOCON_INV_EN)); Chip_GPIO_SetPinDIRInput(LPC_GPIO, 1, 0); // Määritellään nappi PC0 toimimaan inputtina Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 8, (IOCON_MODE_PULLUP | IOCON_DIGMODE_EN | IOCON_INV_EN)); Chip_GPIO_SetPinDIRInput(LPC_GPIO, 0, 8); /* Enable and setup SysTick Timer at a periodic rate */ SysTick_Config(sysTickRate / TICKRATE_HZ1); noppa.SetValue(0); while(1) { if (Chip_GPIO_GetPinState(LPC_GPIO, 1,0)) { noppa.SetValue(0); while(Chip_GPIO_GetPinState(LPC_GPIO, 1,0)) { } if(!Chip_GPIO_GetPinState(LPC_GPIO, 1,0)) { noppa.SetValue(calc); } } // Testinappi, kaikki ledit syttyy if (Chip_GPIO_GetPinState(LPC_GPIO, 0,8)) { while(Chip_GPIO_GetPinState(LPC_GPIO, 0,8)) { noppa.SetValue(7); } noppa.SetValue(0); } } return 0; }
/** * @brief main routine for CLKOUT example * @return Function should not exit. */ int main(void) { CHIP_SYSCTL_CLKOUTSRC_T clkoutClks; SystemCoreClockUpdate(); Board_Init(); Board_LED_Set(0, false); /* Enable and setup SysTick Timer at a 100Hz rate */ SysTick_Config(Chip_Clock_GetSysTickClockRate() / 100); /* Enable the power to the WDT */ Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_WDTOSC_PD); /* Setup SCT PLL */ Chip_SYSCTL_PowerDown(SYSCTL_POWERDOWN_SCTPLL_PD); Chip_Clock_SetSCTPLLSource(SYSCTL_PLLCLKSRC_MAINOSC); Chip_Clock_SetupSCTPLL(5, 2); Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_SCTPLL_PD); /* Wait for PLL to lock */ while (!Chip_Clock_IsSCTPLLLocked()) {} /* Enable RTC Oscillator */ Chip_Clock_EnableRTCOsc(); /* Enable SWM clocking prior to switch matrix operations */ Chip_SWM_Init(); Chip_GPIO_Init(LPC_GPIO); /* Setup pin as CLKOUT */ Chip_SWM_MovablePortPinAssign(SWM_CLK_OUT_O, CLKOUT_PORT, CLKOUT_PIN); /* Configure as a digital pin with no pullups/pulldowns */ Chip_IOCON_PinMuxSet(LPC_IOCON, CLKOUT_PORT, CLKOUT_PIN, (IOCON_MODE_INACT | IOCON_DIGMODE_EN)); /* Cycle through all clock sources for the CLKOUT pin */ while (1) { for (clkoutClks = SYSCTL_CLKOUTSRC_IRC; clkoutClks <= SYSCTL_CLKOUTSRC_RTC32K; clkoutClks++) { /* Setup CLKOUT pin for specific clock with a divider of 1 */ Chip_Clock_SetCLKOUTSource(clkoutClks, 1); /* Wait 5 seconds */ ticks100 = 0; while (ticks100 < 500) { __WFI(); } } } /* Disable CLKOUT pin by setting divider to 0 */ Chip_Clock_SetCLKOUTSource(SYSCTL_CLKOUTSRC_MAINSYSCLK, 0); return 0; }
/* Sets up system hardware */ static void prvSetupHardware(void) { SystemCoreClockUpdate(); Board_Init(); /* Initial LED0 state is off */ Board_LED_Set(0, false); // SW4 Chip_GPIO_SetDir(LPC_GPIO, 1, 31, false); }