static void Init_UART_PinMux(void) { #if defined(BOARD_NXP_LPCXPRESSO_1549) Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 13, (IOCON_MODE_INACT | IOCON_DIGMODE_EN)); Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 18, (IOCON_MODE_INACT | IOCON_DIGMODE_EN)); /* UART signal muxing via SWM */ Chip_SWM_MovablePortPinAssign(SWM_UART0_RXD_I, 0, 13); Chip_SWM_MovablePortPinAssign(SWM_UART0_TXD_O, 0, 18); #else #error "No UART setup defined" #endif }
/* UART Pin mux function - note that SystemInit() may already setup your pin muxing at system startup */ static void Init_UART_PinMux(void) { #if defined(BOARD_NXP_LPCXPRESSO_1549) /* UART signals on pins PIO0_13 (FUNC0, U0_TXD) and PIO0_18 (FUNC0, U0_RXD) */ Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 13, (IOCON_FUNC0 | IOCON_MODE_INACT | IOCON_DIGMODE_EN)); Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 18, (IOCON_FUNC0 | IOCON_MODE_INACT | IOCON_DIGMODE_EN)); /* UART signal muxing via SWM */ Chip_SWM_MovablePortPinAssign(SWM_UART0_RXD_I, 0, 13); Chip_SWM_MovablePortPinAssign(SWM_UART0_TXD_O, 0, 18); #else #warning "No UART nmuxing defined for this example" #endif }
static void Init_UART_PinMux(void) { #if defined(BOARD_NXP_LPCXPRESSO_1549) /* Disables pull-ups/pull-downs and enable digital mode */ Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 13, (IOCON_MODE_INACT | IOCON_DIGMODE_EN)); Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 18, (IOCON_MODE_INACT | IOCON_DIGMODE_EN)); /* UART signal muxing via SWM */ Chip_SWM_MovablePortPinAssign(SWM_UART0_RXD_I, 0, 13); Chip_SWM_MovablePortPinAssign(SWM_UART0_TXD_O, 0, 18); #else #warning "No UART nmuxing defined for this example" #endif }
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 ; }
static void pwm_2_init(void) { uint8_t i = 0; /* Setup Board specific output pin */ /* Enable SWM clock before altering SWM */ Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM); /* Connect SCT outputs. */ for(i = 2; i < 4; i++) { Chip_SWM_MovablePortPinAssign(pwm_config[i].pin_mov, pwm_config[i].port, pwm_config[i].pin); } /* Disable SWM clock after altering SWM */ Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM); Chip_SCTPWM_Init(LPC_SCT2); Chip_SCTPWM_SetRate(LPC_SCT2, PWM_2_RATE); for(i = 2; i < 4; i++) { /* Use SCT2_OUTx pin. */ Chip_SCTPWM_SetOutPin(pwm_config[i].sct, pwm_config[i].index, i - 2); /* Start with 0% duty cycle */ Chip_SCTPWM_SetDutyCycle(pwm_config[i].sct, pwm_config[i].index, 0); } Chip_SCTPWM_Start(LPC_SCT2); return; }
/** * @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; }