void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTB_IDX); CLOCK_SYS_EnablePortClock(PORTC_IDX); CLOCK_SYS_EnablePortClock(PORTD_IDX); CLOCK_SYS_EnablePortClock(PORTE_IDX); #if FSL_FEATURE_SIM_OPT_HAS_RTC_CLOCK_OUT_SELECTION configure_rtc_pins(0); #endif if(PMC_HAL_GetAckIsolation(PMC_BASE_PTR) != 0) { PMC_HAL_ClearAckIsolation(PMC_BASE_PTR); } /* Init board clock */ BOARD_ClockInit(); setup_uart_pins(kPortMuxAlt3); DbgConsole_Init(BOARD_DEBUG_UART_INSTANCE, BOARD_LOW_POWER_UART_BAUD, kDebugConsoleUART); }
void CLOCK_ENABLE_ALL_PORTS() { CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTB_IDX); CLOCK_SYS_EnablePortClock(PORTC_IDX); CLOCK_SYS_EnablePortClock(PORTE_IDX); }
void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTC_IDX); CLOCK_SYS_EnablePortClock(PORTD_IDX); CLOCK_SYS_EnablePortClock(PORTE_IDX); /* Init board clock */ BOARD_ClockInit(); dbg_uart_init(); /*Set Flexio clock source*/ CLOCK_HAL_SetLircCmd(MCG, true); CLOCK_HAL_SetLircSelMode(MCG,kMcgliteLircSel2M); CLOCK_SYS_SetFlexioSrc(0U, kClockFlexioSrcMcgIrClk); configure_flexio_pins(0U,4U);/*if enable TX output to check IRDA encode data waveform--PTD4 */ configure_flexio_pins(0U,5U); /*if enable RX output to check IRDA decode waveform--PTD5 */ configure_flexio_pins(0U,6U); /*IRDA RX pin -- PTD6 */ configure_flexio_pins(0U,7U); /*IRDA TX pin -- PTD7 */ configure_cmp_pins(0U); /*CMP out as Flexio trigger source if enabled*/ }
void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTC_IDX); CLOCK_SYS_EnablePortClock(PORTE_IDX); #if FSL_FEATURE_SIM_OPT_HAS_RTC_CLOCK_OUT_SELECTION configure_rtc_pins(0); #endif if(PMC_HAL_GetAckIsolation(PMC_BASE_PTR) != 0) { PMC_HAL_ClearAckIsolation(PMC_BASE_PTR); } /* Init board clock */ BOARD_ClockInit(); setup_uart_pins(kPortMuxAlt2); #if (CLOCK_INIT_CONFIG == CLOCK_VLPR) CLOCK_SYS_SetLpuartSrc(BOARD_DEBUG_UART_INSTANCE, kClockLpuartSrcMcgIrClk); #else CLOCK_SYS_SetLpuartSrc(BOARD_DEBUG_UART_INSTANCE, kClockLpuartSrcIrc48M); #endif DbgConsole_Init(BOARD_DEBUG_UART_INSTANCE, BOARD_LOW_POWER_UART_BAUD, kDebugConsoleLPUART); }
void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTB_IDX); #if FSL_FEATURE_SIM_OPT_HAS_RTC_CLOCK_OUT_SELECTION configure_rtc_pins(0); #endif if(PMC_HAL_GetAckIsolation(PMC_BASE_PTR) != 0) { PMC_HAL_ClearAckIsolation(PMC_BASE_PTR); } /* Disable debug pins in release target */ #if defined (NDEBUG) setup_debug_pins(kPortPinDisabled); #endif /* Init board clock */ BOARD_ClockInit(); setup_uart_pins(kPortMuxAlt2); // Select different clock source for LPSCI. */ #if (CLOCK_INIT_CONFIG == CLOCK_VLPR) CLOCK_SYS_SetLpsciSrc(BOARD_DEBUG_UART_INSTANCE, kClockLpsciSrcMcgIrClk); #else CLOCK_SYS_SetLpsciSrc(BOARD_DEBUG_UART_INSTANCE, kClockLpsciSrcFll); #endif DbgConsole_Init(BOARD_DEBUG_UART_INSTANCE, BOARD_LOW_POWER_UART_BAUD, kDebugConsoleLPSCI); }
void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTE_IDX); /* Init board clock */ BOARD_ClockInit(); dbg_uart_init(); }
void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTB_IDX); /* Init board clock */ BOARD_ClockInit(); configure_uart_pins(0); }
void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTE_IDX); /* Init board clock */ BOARD_ClockInit(); configure_uart_pins(BOARD_DEBUG_UART_INSTANCE); }
void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTB_IDX); CLOCK_SYS_EnablePortClock(PORTC_IDX); configure_i2c_pins(BOARD_I2C_COMM_INSTANCE); /* Init board clock */ BOARD_ClockInit(); dbg_uart_init(); }
void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTD_IDX); CLOCK_SYS_EnablePortClock(PORTE_IDX); /* Init board clock */ BOARD_ClockInit(); dbg_uart_init(); // Configure SPI pins configure_spi_pins(1U); }
void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTB_IDX); configure_tpm_pins(0); /* Init board clock */ BOARD_ClockInit(); /* Select the clock source for the TPM counter */ CLOCK_SYS_SetTpmSrc(BOARD_TPM_INSTANCE, kClockTpmSrcIrc48M); dbg_uart_init(); }
void hardware_init(void) { /* Enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTC_IDX); CLOCK_SYS_EnablePortClock(PORTD_IDX); /* Enable I2C pins */ configure_i2c_pins(0); /* Init board clock */ BOARD_ClockInit(); dbg_uart_init(); }
void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTB_IDX); CLOCK_SYS_EnablePortClock(PORTC_IDX); CLOCK_SYS_EnablePortClock(PORTD_IDX); CLOCK_SYS_EnablePortClock(PORTE_IDX); /* Init board clock */ BOARD_ClockInit(); dbg_uart_init(); GPIO_DRV_Init(switchPins, ledPins); }
void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTB_IDX); CLOCK_SYS_EnablePortClock(PORTC_IDX); CLOCK_SYS_EnablePortClock(PORTD_IDX); CLOCK_SYS_EnablePortClock(PORTE_IDX); configure_ftm_pins(FTM0_IDX); /* Init board clock */ BOARD_ClockInit(); dbg_uart_init(); }
void hardware_init(void) { uint8_t i; /* enable clock for PORTs */ for (i = 0; i < PORT_INSTANCE_COUNT; i++) { CLOCK_SYS_EnablePortClock(i); } #if (SD_CARD_APP) #if ((defined TWR_K64F120M) || (defined FRDM_K64F) || (defined TWR_K60D100M) || (defined TWR_K21F120M) || (defined TWR_K65F180M)) /* configure detect pin as gpio (alt1) */ uint32_t port = GPIO_EXTRACT_PORT(sdhcCdPin[0].pinName); uint32_t pin = GPIO_EXTRACT_PIN(sdhcCdPin[0].pinName); PORT_Type * portBase = g_portBase[port]; PORT_HAL_SetMuxMode(portBase, pin, kPortMuxAsGpio); configure_sdhc_pins(BOARD_SDHC_INSTANCE); #endif #endif /* Init board clock */ BOARD_ClockInit(); dbg_uart_init(); }
/*FUNCTION********************************************************************** * * Function Name : GPIO_DRV_OutputPinInit * Description : Initialize one GPIO output pin used by board. * *END**************************************************************************/ void GPIO_DRV_OutputPinInit(const gpio_output_pin_user_config_t *outputPin) { /* Get actual port and pin number.*/ uint32_t port = GPIO_EXTRACT_PORT(outputPin->pinName); uint32_t pin = GPIO_EXTRACT_PIN(outputPin->pinName); GPIO_Type * gpioBase = g_gpioBase[port]; PORT_Type * portBase = g_portBase[port]; /* Un-gate port clock*/ CLOCK_SYS_EnablePortClock(port); /* Set current pin as gpio.*/ PORT_HAL_SetMuxMode(portBase, pin, kPortMuxAsGpio); /* Set current pin as digital output.*/ GPIO_HAL_SetPinDir(gpioBase, pin, kGpioDigitalOutput); /* Configure GPIO output features. */ GPIO_HAL_WritePinOutput(gpioBase, pin, outputPin->config.outputLogic); #if FSL_FEATURE_PORT_HAS_SLEW_RATE PORT_HAL_SetSlewRateMode(portBase, pin, outputPin->config.slewRate); #endif #if FSL_FEATURE_PORT_HAS_DRIVE_STRENGTH PORT_HAL_SetDriveStrengthMode(portBase, pin, outputPin->config.driveStrength); #endif #if FSL_FEATURE_PORT_HAS_OPEN_DRAIN PORT_HAL_SetOpenDrainCmd(portBase, pin, outputPin->config.isOpenDrainEnabled); #endif }
void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTB_IDX); CLOCK_SYS_EnablePortClock(PORTC_IDX); /* Init board clock */ BOARD_ClockInit(); // Change clock mode, core clock = 48MHz, bus clock = 24MHz. CLOCK_HAL_SetFeeMode(MCG, kMcgOscselRtc, 0U, kMcgDmx32Fine, kMcgDcoRangeSelMid, fllStableDelay); CLOCK_SYS_SetOutDiv(0U, 0U, 0U, 1U); configure_lpuart_pins(BOARD_DEBUG_UART_INSTANCE); }
void hardware_init(void) { uint8_t i; /* enable clock for PORTs */ for (i = 0; i < HW_PORT_INSTANCE_COUNT; i++) { CLOCK_SYS_EnablePortClock(i); } /* Setup board clock source. */ g_xtal0ClkFreq = 50000000U; // g_xtalRtcClkFreq = 32768U; for (i = 0; i < HW_PORT_INSTANCE_COUNT; i++) { configure_gpio_pins(i); } configure_i2c_pins(0);//FXO8700 & L3G4200d // configure_adc_pins_for_quadcopter(); configure_remote_control_pins_for_quadcopter() ; configure_sensors_interrupt_pins_for_quadcopter(); configure_ftm_pins_for_quadcopter(); configure_uart_pins(BOARD_DEBUG_UART_INSTANCE); }
/*FUNCTION********************************************************************** * * Function Name : GPIO_DRV_InputPinInit * Description : Initialize one GPIO input pin used by board. * *END**************************************************************************/ void GPIO_DRV_InputPinInit(const gpio_input_pin_user_config_t *inputPin) { /* Get actual port and pin number.*/ uint32_t port = GPIO_EXTRACT_PORT(inputPin->pinName); uint32_t pin = GPIO_EXTRACT_PIN(inputPin->pinName); uint32_t gpioBaseAddr = g_gpioBaseAddr[port]; uint32_t portBaseAddr = g_portBaseAddr[port]; /* Un-gate port clock*/ CLOCK_SYS_EnablePortClock(port); /* Set current pin as digital input.*/ GPIO_HAL_SetPinDir(gpioBaseAddr, pin, kGpioDigitalInput); /* Configure GPIO input features. */ PORT_HAL_SetPullCmd(portBaseAddr, pin, inputPin->config.isPullEnable); PORT_HAL_SetPullMode(portBaseAddr, pin, inputPin->config.pullSelect); PORT_HAL_SetPassiveFilterCmd(portBaseAddr, pin, inputPin->config.isPassiveFilterEnabled); #if FSL_FEATURE_PORT_HAS_DIGITAL_FILTER PORT_HAL_SetDigitalFilterCmd(portBaseAddr, pin, inputPin->config.isDigitalFilterEnabled); #endif PORT_HAL_SetPinIntMode(portBaseAddr, pin, inputPin->config.interrupt); /* Configure NVIC */ if ((inputPin->config.interrupt) && (g_portIrqId[port])) { /* Enable GPIO interrupt.*/ INT_SYS_EnableIRQ(g_portIrqId[port]); } }
void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTB_IDX); CLOCK_SYS_EnablePortClock(PORTC_IDX); CLOCK_SYS_EnablePortClock(PORTE_IDX); #ifdef BOARD_XTAL0_CLK_FREQUENCY #endif configure_sdcard_spi_pins(1U); GPIO_DRV_Init(sdcardCardDectionPin, NULL); /* Init board clock */ BOARD_ClockInit(); dbg_uart_init(); }
void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTB_IDX); CLOCK_SYS_EnablePortClock(PORTC_IDX); configure_cmp_pins(0); /* Board don't have pull up resister, so internal resister need to be enabled */ PORT_HAL_SetMuxMode(PORTB,2U,kPortMuxAsGpio); PORT_HAL_SetPullMode(PORTB,2U,kPortPullUp); PORT_HAL_SetPullCmd(PORTB,2U,true); /* Init board clock */ BOARD_ClockInit(); dbg_uart_init(); }
void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTA_IDX); CLOCK_SYS_EnablePortClock(PORTC_IDX); CLOCK_SYS_EnablePortClock(PORTD_IDX); CLOCK_SYS_EnablePortClock(PORTE_IDX); /* Init board clock */ BOARD_ClockInit(); dbg_uart_init(); //Configure flexio clock src and pin mux CLOCK_SYS_SetFlexioSrc(0,(clock_flexio_src_t)1); configure_flexio_pins(0,5); /*FLEXIO pin 5 simulated as UART TX*/ configure_flexio_pins(0,4); /*FLEXIO pin 4 simulated as UART RX*/ //Configure lpuart pin mux configure_lpuart_pins(1); }
void gpio_init(gpio_t *obj, PinName pin) { obj->pin = pin; if (pin == (PinName)NC) return; uint32_t port = pin >> GPIO_PORT_SHIFT; uint32_t port_addrs[] = PORT_BASE_ADDRS; uint32_t pin_num = pin & 0xFF; CLOCK_SYS_EnablePortClock(port); PORT_HAL_SetMuxMode(port_addrs[port], pin_num, kPortMuxAsGpio); }
void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTE_IDX); CLOCK_SYS_EnablePortClock(PORTF_IDX); CLOCK_SYS_EnablePortClock(PORTI_IDX); CLOCK_SYS_EnablePortClock(PORTL_IDX); /* enable XBAR clock */ CLOCK_SYS_EnableXbarClock(0); /* Init board EXTAL 32.768KHz clock */ BOARD_InitRtcOsc(); /* configure MCG mode as FEE, FLL 24MHz 1:1:1 */ CLOCK_SYS_SetConfiguration(&clkFll24MCfg); /* init debug uart */ dbg_uart_init(); configure_xbar_pins(0U); }
void hardware_init(void) { uint16_t i; /* enable clock for PORTs */ for (i = 0; i < PORT_INSTANCE_COUNT; i++) { CLOCK_SYS_EnablePortClock(i); } /* Init board clock */ BOARD_ClockInit(); dbg_uart_init(); }
_WEAK_FUNCTION(void hardware_init(void)) { uint8_t i; /* enable clock for PORTs */ for (i = 0; i < PORT_INSTANCE_COUNT; i++) { CLOCK_SYS_EnablePortClock(i); } /* Init board clock */ BOARD_ClockInit(); /* In case IO sub is turned off, dbg console should be used for printing */ #if !BSPCFG_ENABLE_IO_SUBSYSTEM dbg_uart_init(); #endif }
void hardware_init(void) { int32_t i; /* enable clock for PORTs */ for (i = 0; i < HW_PORT_INSTANCE_COUNT; i++) { CLOCK_SYS_EnablePortClock(i); } /* Setup board clock source. */ g_xtal0ClkFreq = 8000000U; /* init the general pinmux */ for (i = 0; i < HW_PORT_INSTANCE_COUNT; i++) { configure_gpio_pins(i); } }
/*FUNCTION********************************************************************** * * Function Name : GPIO_DRV_InputPinInit * Description : Initialize one GPIO input pin used by board. * *END**************************************************************************/ void GPIO_DRV_InputPinInit(const gpio_input_pin_user_config_t *inputPin) { /* Get actual port and pin number.*/ uint32_t port = GPIO_EXTRACT_PORT(inputPin->pinName); uint32_t pin = GPIO_EXTRACT_PIN(inputPin->pinName); GPIO_Type * gpioBase = g_gpioBase[port]; PORT_Type * portBase = g_portBase[port]; /* Un-gate port clock*/ CLOCK_SYS_EnablePortClock(port); /* Set current pin as gpio.*/ PORT_HAL_SetMuxMode(portBase, pin, kPortMuxAsGpio); /* Set current pin as digital input.*/ GPIO_HAL_SetPinDir(gpioBase, pin, kGpioDigitalInput); /* Configure GPIO input features. */ #if FSL_FEATURE_PORT_HAS_PULL_ENABLE PORT_HAL_SetPullCmd(portBase, pin, inputPin->config.isPullEnable); #endif #if FSL_FEATURE_PORT_HAS_PULL_SELECTION PORT_HAL_SetPullMode(portBase, pin, inputPin->config.pullSelect); #endif #if FSL_FEATURE_PORT_HAS_PASSIVE_FILTER PORT_HAL_SetPassiveFilterCmd(portBase, pin, inputPin->config.isPassiveFilterEnabled); #endif #if FSL_FEATURE_PORT_HAS_DIGITAL_FILTER PORT_HAL_SetDigitalFilterCmd(portBase, pin, inputPin->config.isDigitalFilterEnabled); #endif #if FSL_FEATURE_GPIO_HAS_INTERRUPT_VECTOR PORT_HAL_SetPinIntMode(portBase, pin, inputPin->config.interrupt); /* Configure NVIC */ if ((inputPin->config.interrupt) && (g_portIrqId[port])) { /* Enable GPIO interrupt.*/ INT_SYS_EnableIRQ(g_portIrqId[port]); } #endif }
void hardware_init(void) { /* enable clock for PORTs */ CLOCK_SYS_EnablePortClock(PORTC_IDX); CLOCK_SYS_EnablePortClock(PORTD_IDX); CLOCK_SYS_EnablePortClock(PORTE_IDX); CLOCK_SYS_EnablePortClock(PORTF_IDX); CLOCK_SYS_EnablePortClock(PORTI_IDX); CLOCK_SYS_EnablePortClock(PORTJ_IDX); /* Init board clock */ BOARD_ClockInit(); configure_gpio_pins(PORTC_IDX); configure_gpio_pins(PORTD_IDX); configure_gpio_pins(PORTE_IDX); configure_gpio_pins(PORTF_IDX); configure_gpio_pins(PORTJ_IDX); /* Configure the UART TX/RX pins */ configure_uart_pins(2U); }
/******************************************************************************* * Main function for application. ******************************************************************************/ void lab2_power(void) { demo_power_modes_t testVal = kDemoRun; volatile uint8_t powerMode; uint8_t clockManagerMode = CLOCK_RUN; uint32_t freq = 0; //******************************************************* //* Step 1: Initialize the Clock Manager configurations. //******************************************************* // Create list of supported clock configurations. These are taken from the // board.c file and will be passed into CLOCK_SYS_Init(). clock_manager_user_config_t const *clockConfigs[] = { NULL, &g_defaultClockConfigVlpr, &g_defaultClockConfigRun, &g_defaultClockConfigHsrun, }; //***************************************************** //* Step 2: Configure Clock Manager callback function. //***************************************************** // Clock Manager callback function. clock_manager_callback_user_config_t clockManagerCallbackCfg = { .callback = clockManagerCallback, .callbackType = kClockManagerCallbackBeforeAfter, .callbackData = NULL }; clock_manager_callback_user_config_t *clockCallbacks[] = { &clockManagerCallbackCfg }; //***************************************************** //* Step 3: Initialize the Clock Manager. //***************************************************** // Pass in configuration and callback data to Clock Manager. CLOCK_SYS_Init(clockConfigs, CLOCK_NUMBER_OF_CONFIGURATIONS, clockCallbacks, ARRAY_SIZE(clockCallbacks)); // Set to RUN mode. CLOCK_SYS_UpdateConfiguration(CLOCK_RUN, kClockManagerPolicyForcible); //***************************************************** //* Step 4: Set up supported power mode structures. //***************************************************** const power_manager_user_config_t runConfig = { .mode = kPowerManagerRun, .sleepOnExitValue = false, }; power_manager_user_config_t hsrunConfig = runConfig; hsrunConfig.mode = kPowerManagerHsrun; power_manager_user_config_t waitConfig = runConfig; waitConfig.mode = kPowerManagerWait; power_manager_user_config_t stopConfig = runConfig; stopConfig.mode = kPowerManagerStop; power_manager_user_config_t vlprConfig = runConfig; vlprConfig.mode = kPowerManagerVlpr; power_manager_user_config_t vlpwConfig = runConfig; vlpwConfig.mode = kPowerManagerVlpw; power_manager_user_config_t vlpsConfig = runConfig; vlpsConfig.mode = kPowerManagerVlps; power_manager_user_config_t lls3Config = runConfig; lls3Config.mode = kPowerManagerLls3; power_manager_user_config_t vlls0Config = runConfig; vlls0Config.mode = kPowerManagerVlls0; //*********************************************************** //* Step 5: Configure managed power configurations structure. //*********************************************************** // Create the list of supported modes to pass into the Power Manager. power_manager_user_config_t const *powerConfigs[] = { &runConfig, &hsrunConfig, &waitConfig, &stopConfig, &vlprConfig, &vlpwConfig, &vlpsConfig, &lls3Config, &vlls0Config }; //***************************************************** //* Step 6: Configure Power Manager callback function. //***************************************************** // Initializes callback configuration structure for the Power Manager. power_manager_callback_user_config_t powerManagerCallbackCfg = { .callback = powerManagerCallback, .callbackType = kPowerManagerCallbackBeforeAfter, .callbackData = NULL }; // Initializes array of pointers to power manager callbacks. power_manager_callback_user_config_t *powerCallbacks[] = { &powerManagerCallbackCfg }; //***************************************************** //* Step 7: Initialize the Power Manager. //***************************************************** // Pass power configurations and callback info to Power Manager. POWER_SYS_Init(powerConfigs, sizeof(powerConfigs) / sizeof(power_manager_user_config_t *), powerCallbacks, ARRAY_SIZE(powerCallbacks)); // Initialize system to RUN mode. powerMode = kDemoRun - kDemoMin - 1; POWER_SYS_SetMode(powerMode, kPowerManagerPolicyAgreement); //************************************************************** //* Step 8: Configure the rest of the chip for this application. //************************************************************** // Configure pin mux for UART functionality. configure_uart_pins(BOARD_DEBUG_UART_INSTANCE); // Initializes GPIO driver for LEDs and buttons GPIO_DRV_Init(switchPins, ledPins); // Initialize the debug UART console. DbgConsole_Init(BOARD_DEBUG_UART_INSTANCE, BOARD_LOW_POWER_UART_BAUD, kDebugConsoleUART); // Enable PORTC clock for GPIO/LLWU interrupt. CLOCK_SYS_EnablePortClock(2); // Enables falling edge interrupt for switch SW2. PORT_HAL_SetMuxMode(BOARD_SW_LLWU_BASE, BOARD_SW_LLWU_PIN, kPortMuxAsGpio); PORT_HAL_SetPinIntMode(BOARD_SW_LLWU_BASE, BOARD_SW_LLWU_PIN, kPortIntFallingEdge); // Enable GPIO interrupt. INT_SYS_EnableIRQ(PORTC_IRQn); // Configure the LLWU. LLWU_HAL_ClearExternalPinWakeupFlag(LLWU, BOARD_SW_LLWU_EXT_PIN); LLWU_HAL_SetExternalInputPinMode(LLWU, kLlwuExternalPinFallingEdge, BOARD_SW_LLWU_EXT_PIN); // Enable LLWU interrupt. INT_SYS_EnableIRQ(LLWU_IRQn); // Main loop. while (1) { // Get the system clock frequency and current clock configuration to print out. CLOCK_SYS_GetFreq(kCoreClock, &freq); clockManagerMode = CLOCK_SYS_GetCurrentConfiguration(); PRINTF("\n\r#################### Power Manager Demo ####################\n\n\r"); PRINTF(" Core Clock = %d MHz \n\r", freq / 1000000); PRINTF(" Current Mode = "); switch(clockManagerMode) { case CLOCK_RUN: PRINTF("RUN\n\r"); break; case CLOCK_VLPR: PRINTF("VLPR\n\r"); break; case CLOCK_HSRUN: PRINTF("HSRUN\n\r"); break; } PRINTF("\n\rSelect the desired operation \n\n\r"); PRINTF("Press %c for enter: RUN - Normal RUN mode\n\r", kDemoRun); PRINTF("Press %c for enter: HSRUN - High Speed RUN mode\n\r", kDemoHsRun); PRINTF("Press %c for enter: Wait - Wait mode\n\r", kDemoWait); PRINTF("Press %c for enter: Stop - Stop mode\n\r", kDemoStop); PRINTF("Press %c for enter: VLPR - Very Low Power Run mode\n\r", kDemoVlpr); PRINTF("Press %c for enter: VLPW - Very Low Power Wait mode\n\r", kDemoVlpw); PRINTF("Press %c for enter: VLPS - Very Low Power Stop mode\n\r", kDemoVlps); PRINTF("Press %c for enter: LLS3 - Low Leakage Stop mode\n\r", kDemoLls3); PRINTF("Press %c for enter: VLLS0 - Very Low Leakage Stop mode 0\n\r", kDemoVlls0); //PRINTF("Press %c for enter: VLLS3 - Very Low Leakage Stop mode 3\n\r", kDemoVlls3); PRINTF("\n\rWaiting for key press...\n\r\n\r"); // Wait for user input. testVal = (demo_power_modes_t)GETCHAR(); if ((testVal >= 'a') && (testVal <= 'z')) { testVal -= 'a' - 'A'; } if (testVal > kDemoMin && testVal < kDemoMax) { // Obtain Power Manager readable version of the value passed in. powerMode = testVal - kDemoMin - 1; // Switch to selected mode. switch (testVal) { case kDemoRun: if (POWER_SYS_GetCurrentMode() == kPowerManagerRun) { PRINTF("Run mode already active.\n\r"); break; } // Update the power configuration. POWER_SYS_SetMode(powerMode, kPowerManagerPolicyAgreement); // Update the clock configuration. CLOCK_SYS_UpdateConfiguration(CLOCK_RUN, kClockManagerPolicyAgreement); break; case kDemoHsRun: if (POWER_SYS_GetCurrentMode() == kPowerManagerHsrun) { PRINTF("High Speed Run mode already active.\n\r"); break; } // Update the power configuration. POWER_SYS_SetMode(powerMode, kPowerManagerPolicyAgreement); // Update the clock configuration. CLOCK_SYS_UpdateConfiguration(CLOCK_HSRUN, kClockManagerPolicyAgreement); break; case kDemoWait: if (POWER_SYS_GetCurrentMode() == kPowerManagerVlpr) { PRINTF("Cannot go from VLPR to WAIT directly...\n\r"); break; } if (POWER_SYS_GetCurrentMode() == kPowerManagerHsrun) { PRINTF("Cannot go from HSRUN to WAIT directly...\n\r"); break; } PRINTF("Entering WAIT mode. Press SW2 to wake...\n\r"); // Update the power configuration. POWER_SYS_SetMode(powerMode, kPowerManagerPolicyAgreement); break; case kDemoStop: if (POWER_SYS_GetCurrentMode() == kPowerManagerVlpr) { PRINTF("Cannot go from VLPR to STOP directly...\n\r"); break; } if (POWER_SYS_GetCurrentMode() == kPowerManagerHsrun) { PRINTF("Cannot go from HSRUN to STOP directly...\n\r"); break; } PRINTF("Entering STOP mode. Press SW2 to wake...\n\r"); // Update the power configuration. POWER_SYS_SetMode(powerMode, kPowerManagerPolicyAgreement); // Update the clock configuration. CLOCK_SYS_UpdateConfiguration(clockManagerMode, kClockManagerPolicyAgreement); break; case kDemoVlpr: if (POWER_SYS_GetCurrentMode() == kPowerManagerHsrun) { PRINTF("Cannot go from HSRUN to VLPR directly...\n\r"); break; } if(POWER_SYS_GetCurrentMode() != kPowerManagerVlpr) { // Update the clock configuration PRIOR to entering VLPR. CLOCK_SYS_UpdateConfiguration(CLOCK_VLPR, kClockManagerPolicyAgreement); // Update the power configuration. POWER_SYS_SetMode(powerMode, kPowerManagerPolicyAgreement); } else { PRINTF("Very Low Power Run mode already active.\n\r"); } break; case kDemoVlpw: if (POWER_SYS_GetCurrentMode() == kPowerManagerRun) { PRINTF("Cannot go from RUN to VLPW directly...\n\r"); break; } if (POWER_SYS_GetCurrentMode() == kPowerManagerHsrun) { PRINTF("Cannot go from HSRUN to VLPW directly...\n\r"); break; } PRINTF("Entering VLPW mode. Press SW2 to wake...\n\r"); // Update the power configuration. POWER_SYS_SetMode(powerMode, kPowerManagerPolicyAgreement); break; case kDemoVlps: if (POWER_SYS_GetCurrentMode() == kPowerManagerHsrun) { PRINTF("Cannot go from HSRUN to VLPS directly...\n\r"); break; } PRINTF("Entering VLPS mode. Press SW2 to wake...\n\r"); // Update the power configuration. POWER_SYS_SetMode(powerMode, kPowerManagerPolicyAgreement); // If we entered via RUN mode, restore clock settings. if (POWER_SYS_GetCurrentMode() == kPowerManagerRun) { CLOCK_SYS_UpdateConfiguration(clockManagerMode, kClockManagerPolicyAgreement); } break; case kDemoLls3: if (POWER_SYS_GetCurrentMode() == kPowerManagerHsrun) { PRINTF("Cannot go from HSRUN to LLSx directly...\n\r"); break; } PRINTF("Entering LLS3 mode. Press SW2 to wake...\n\r"); // Update the power configuration. POWER_SYS_SetMode(powerMode, kPowerManagerPolicyAgreement); // Check the mode active mode prior to LLS3 entry. if(POWER_SYS_GetCurrentMode() != kPowerManagerVlpr) { CLOCK_SYS_UpdateConfiguration(clockManagerMode, kClockManagerPolicyAgreement); } break; case kDemoVlls0: if (POWER_SYS_GetCurrentMode() == kPowerManagerHsrun) { PRINTF("Cannot go from HSRUN to VLLSx directly...\n\r"); break; } PRINTF("Press SW2 to wake. VLLSx wake goes through RESET sequence.\n\r"); // Update the power configuration. POWER_SYS_SetMode(powerMode, kPowerManagerPolicyAgreement); break; default: PRINTF("Bad value."); break; } PRINTF("\n\rNext loop\n\r"); } } }