/* Function Name : BOARD_InitPins */ void BOARD_InitPins(void) { /* Initialize UART1 pins below */ /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortE); /* Affects PORTE_PCR0 register */ PORT_SetPinMux(PORTE, 0u, kPORT_MuxAlt3); /* Affects PORTE_PCR1 register */ PORT_SetPinMux(PORTE, 1u, kPORT_MuxAlt3); }
/*! * @brief Initialize all pins used in this example */ void BOARD_InitPins(void) { /* Debug uart port mux config */ /* Enable uart port clock */ CLOCK_EnableClock(kCLOCK_PortB); /* Affects PORTB_PCR16 register */ PORT_SetPinMux(PORTB, 16u, kPORT_MuxAlt3); /* Affects PORTB_PCR17 register */ PORT_SetPinMux(PORTB, 17u, kPORT_MuxAlt3); }
void BOARD_InitPins(void) { /* Set EXTAL0/XTAL0 pinmux. */ CLOCK_EnableClock(kCLOCK_PortA); PORT_SetPinMux(PORTA, 18U, kPORT_PinDisabledOrAnalog); PORT_SetPinMux(PORTA, 19U, kPORT_PinDisabledOrAnalog); /* Enable LED port clock */ CLOCK_EnableClock(kCLOCK_PortA); /* Led pin mux Configuration */ PORT_SetPinMux(PORTA, 13U, kPORT_MuxAsGpio); }
/*! * @brief Initialize all pins used in this example */ void BOARD_InitPins(void) { /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortE); /* Affects PORTE_PCR0 register */ PORT_SetPinMux(PORTE, 0U, kPORT_MuxAlt3); /* Affects PORTE_PCR1 register */ PORT_SetPinMux(PORTE, 1U, kPORT_MuxAlt3); CLOCK_EnableClock(kCLOCK_PortB); PORT_SetPinMux(PORTB, 0U, kPORT_PinDisabledOrAnalog); }
void BOARD_InitPins(void) { /* Initialize UART1 pins below */ /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortB); /* Affects PORTB_PCR16 register */ PORT_SetPinMux(PORTB, 16U, kPORT_MuxAlt3); /* Affects PORTB_PCR17 register */ PORT_SetPinMux(PORTB, 17U, kPORT_MuxAlt3); /* Configure LED's */ /* Affects PORTB_PCR22 register */ PORT_SetPinMux(PORTB, 22U, kPORT_MuxAsGpio); }
void BOARD_InitPins(void) { /* Initialize LPUART0 pins below */ /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortA); /* Affects PORTA_PCR1 register */ PORT_SetPinMux(PORTA, 1U, kPORT_MuxAlt2); /* Affects PORTA_PCR2 register */ PORT_SetPinMux(PORTA, 2U, kPORT_MuxAlt2); /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortE); /* PTE31 TPM0 channel 4 -- GREEN LED */ PORT_SetPinMux(PORTE, 31U, kPORT_MuxAlt3); }
void BOARD_InitPins(void) { /* Enable LED port clock */ CLOCK_EnableClock(kCLOCK_PortE); /* Led pin mux Configuration */ PORT_SetPinMux(PORTE, 29U, kPORT_MuxAsGpio); }
void BOARD_InitPins(void) { /* Debug uart port mux config */ /* Enable uart port clock */ CLOCK_EnableClock(kCLOCK_PortE); /* Affects PORTE_PCR0 register */ PORT_SetPinMux(PORTE, 0U, kPORT_MuxAlt3); /* Affects PORTE_PCR1 register */ PORT_SetPinMux(PORTE, 1U, kPORT_MuxAlt3); /* Enable GPIO port clock */ CLOCK_EnableClock(kCLOCK_PortD); /* Led pin mux Configuration */ PORT_SetPinMux(PORTD, 6U, kPORT_MuxAsGpio); }
void LedDriver_InitAllLeds(char isEnabled) { CLOCK_EnableClock(LED_DRIVER_SDB_CLOCK); PORT_SetPinMux(LED_DRIVER_SDB_PORT, LED_DRIVER_SDB_PIN, kPORT_MuxAsGpio); GPIO_PinInit(GPIOA, LED_DRIVER_SDB_PIN, &(gpio_pin_config_t){kGPIO_DigitalOutput, 0}); GPIO_WritePinOutput(LED_DRIVER_SDB_GPIO, LED_DRIVER_SDB_PIN, 1); uint8_t ledDriverAddresses[] = {I2C_ADDRESS_LED_DRIVER_LEFT, I2C_ADDRESS_LED_DRIVER_RIGHT}; for (uint8_t addressId=0; addressId<sizeof(ledDriverAddresses); addressId++) { uint8_t address = ledDriverAddresses[addressId]; LedDriver_WriteRegister(address, LED_DRIVER_REGISTER_FRAME, LED_DRIVER_FRAME_FUNCTION); LedDriver_WriteRegister(address, LED_DRIVER_REGISTER_SHUTDOWN, SHUTDOWN_MODE_NORMAL); LedDriver_WriteRegister(address, LED_DRIVER_REGISTER_FRAME, LED_DRIVER_FRAME_1); uint8_t i; for (i=FRAME_REGISTER_PWM_FIRST; i<=FRAME_REGISTER_PWM_LAST; i++) { LedDriver_WriteRegister(address, i, isEnabled ? 0xFF : 0x00); } for (i=FRAME_REGISTER_LED_CONTROL_FIRST; i<=FRAME_REGISTER_LED_CONTROL_LAST; i++) { LedDriver_WriteRegister(address, i, 0xff); } for (i=FRAME_REGISTER_BLINK_CONTROL_FIRST; i<=FRAME_REGISTER_BLINK_CONTROL_LAST; i++) { LedDriver_WriteRegister(address, i, 0x00); } } }
static OsStatus_t KL25Z_PinMuxDriverSetToGpio (Device_t * dev, uint8_t bitPos) { OsStatus_t ret = kStatusOk; KL25ZPinMuxDevData_t *dat = (KL25ZPinMuxDevData_t *)dev->config->devConfigData; PORT_SetPinMux(dat->port, bitPos, kPORT_MuxAsGpio); return(ret); }
void BOARD_InitPins(void) { /* Initialize UART1 pins below */ /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortB); /* Affects PORTB_PCR16 register */ PORT_SetPinMux(PORTB, 16U, kPORT_MuxAlt3); /* Affects PORTB_PCR17 register */ PORT_SetPinMux(PORTB, 17U, kPORT_MuxAlt3); /* Configure pin for LED. */ PORT_SetPinMux(PORTB, 22U, kPORT_MuxAsGpio); /* PTB22, GPIO.LED_RED */ /* Configure pin for CMP example. */ CLOCK_EnableClock(kCLOCK_PortC); PORT_SetPinMux(PORTC, 7U, kPORT_PinDisabledOrAnalog); /* PTC7, CMP0_IN1, J1-13 on FRDM-K64F. */ }
void BOARD_InitPins(void) { /* Initialize UART1 pins below */ /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortE); /* Affects PORTE_PCR0 register */ PORT_SetPinMux(PORTE, 0U, kPORT_MuxAlt3); /* Affects PORTE_PCR1 register */ PORT_SetPinMux(PORTE, 1U, kPORT_MuxAlt3); /* Configure LED's */ /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortD); PORT_SetPinMux(PORTD, 4U, kPORT_MuxAsGpio); PORT_SetPinMux(PORTD, 6U, kPORT_MuxAsGpio); }
/*! * @brief Initialize all pins used in this example * */ void BOARD_InitPins(void) { /* Initialize UART2 pins below */ /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortE); /* Affects PORTE_PCR22 register */ PORT_SetPinMux(PORTE, 22U, kPORT_MuxAlt4); /* Affects PORTA_PCR23 register */ PORT_SetPinMux(PORTE, 23U, kPORT_MuxAlt4); /* Configure LED's */ /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortA); /* Affects PORTA_PCR13 register */ PORT_SetPinMux(PORTA, 13U, kPORT_MuxAsGpio); }
void BOARD_InitPins(void) { /* Debug uart port mux config */ /* Enable uart port clock */ CLOCK_EnableClock(kCLOCK_PortB); /* Affects PORTB_PCR16 register */ PORT_SetPinMux(PORTB, 16U, kPORT_MuxAlt3); /* Affects PORTB_PCR17 register */ PORT_SetPinMux(PORTB, 17U, kPORT_MuxAlt3); /* Enable SW port clock */ CLOCK_EnableClock(kCLOCK_PortC); /* Affects PORTC_PCR6 register */ port_pin_config_t config = {0}; config.pullSelect = kPORT_PullUp; config.mux = kPORT_MuxAsGpio; PORT_SetPinConfig(PORTC, 6U, &config); }
void BOARD_InitPins(void) { /* Initialize UART1 pins below */ /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortE); /* Affects PORTE_PCR0 register */ PORT_SetPinMux(PORTE, 0u, kPORT_MuxAlt3); /* Affects PORTE_PCR1 register */ PORT_SetPinMux(PORTE, 1u, kPORT_MuxAlt3); /* Enable SW1 port clock */ CLOCK_EnableClock(kCLOCK_PortC); /* Affects PORTC_PCR6 register */ port_pin_config_t config = {0}; config.pullSelect = kPORT_PullUp; config.mux = kPORT_MuxAsGpio; PORT_SetPinConfig(PORTC, 6U, &config); }
void BOARD_InitPins(void) { /* Initialize LPUART0 pins below */ /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortA); /* Affects PORTA_PCR1 register */ PORT_SetPinMux(PORTA, 1U, kPORT_MuxAlt2); /* Affects PORTA_PCR2 register */ PORT_SetPinMux(PORTA, 2U, kPORT_MuxAlt2); /* Configure pin for LED. */ CLOCK_EnableClock(kCLOCK_PortE); PORT_SetPinMux(PORTE, 31U, kPORT_MuxAsGpio); /* PTE31, GPIO.RED_LED */ /* Configure pin for CMP example. */ CLOCK_EnableClock(kCLOCK_PortC); PORT_SetPinMux(PORTC, 6U, kPORT_PinDisabledOrAnalog); /* PTC6, CMP0_IN0, J1-9 on board FRDM KL43Z */ }
/*! * @brief Initialize all pins used in this example * * @param disablePortClockAfterInit disable port clock after pin * initialization or not. */ void BOARD_InitPins(void) { port_pin_config_t config = {0}; /* Initialize UART1 pins below */ /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortB); /* Affects PORTB_PCR16 register */ PORT_SetPinMux(PORTB, 16u, kPORT_MuxAlt3); /* Affects PORTB_PCR17 register */ PORT_SetPinMux(PORTB, 17u, kPORT_MuxAlt3); config.pullSelect = kPORT_PullUp; config.driveStrength = kPORT_HighDriveStrength; config.mux = kPORT_MuxAlt4; /* Initializes SDHC pins below. */ /* Ungates the port clock. */ CLOCK_EnableClock(kCLOCK_PortE); CLOCK_EnableClock(kCLOCK_PortB); /* Affects PORTE_PCR0 register */ PORT_SetPinConfig(PORTE, 0U, &config); /* Affects PORTE_PCR1 register */ PORT_SetPinConfig(PORTE, 1U, &config); /* Affects PORTE_PCR2 register */ PORT_SetPinConfig(PORTE, 2U, &config); /* Affects PORTE_PCR3 register */ PORT_SetPinConfig(PORTE, 3U, &config); /* Affects PORTE_PCR4 register */ PORT_SetPinConfig(PORTE, 4U, &config); /* Affects PORTE_PCR5 register */ PORT_SetPinConfig(PORTE, 5U, &config); /* Card detection pin */ config.driveStrength = 0U; config.mux = kPORT_MuxAsGpio; PORT_SetPinConfig(PORTE, 6U, &config); }
static OsStatus_t KL25Z_PinMuxDriverSetToAlternate(Device_t *dev, uint8_t bitPos, uint32_t alternateFun) { OsStatus_t ret = kStatusOk; KL25ZPinMuxDevData_t *dat = (KL25ZPinMuxDevData_t *)dev->config->devConfigData; port_mux_t ksdkAlt = (port_mux_t)alternateFun; PORT_SetPinMux(dat->port, bitPos, ksdkAlt); return(ret); }
/******************************************************************************* * Code ******************************************************************************/ void BOARD_InitPins(void) { /* Debug uart port mux config */ /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortE); /* Affects PORTE_PCR22 register */ PORT_SetPinMux(PORTE, 22U, kPORT_MuxAlt4); /* Affects PORTA_PCR23 register */ PORT_SetPinMux(PORTE, 23U, kPORT_MuxAlt4); /* Ungate the SW port clock */ CLOCK_EnableClock(kCLOCK_PortA); /* Affects PORTA_PCR5 register */ port_pin_config_t config = {0}; config.pullSelect = kPORT_PullUp; config.mux = kPORT_MuxAsGpio; PORT_SetPinConfig(PORTA, 5U, &config); /* LED PIN_MUX Configuration */ PORT_SetPinMux(PORTA, 13U, kPORT_MuxAsGpio); }
/*! * @brief Initialize all pins used in this example * * @param disablePortClockAfterInit disable port clock after pin * initialization or not. */ void BOARD_InitPins(void) { /* Initialize UART1 pins below */ /* Ungate the port clock */ /* Enable the clock to the PORT module that the LED is on. */ CLOCK_EnableClock(kCLOCK_PortE); CLOCK_EnableClock(kCLOCK_PortB); /* SET USB pins */ /* Affects PORTB_PCR16 register */ PORT_SetPinMux(PORTB, 16u, kPORT_MuxAlt3); /* Affects PORTB_PCR17 register */ PORT_SetPinMux(PORTB, 17u, kPORT_MuxAlt3); /* Led pin mux Configuration */ PORT_SetPinMux(PORTB, 22U, kPORT_MuxAsGpio); PORT_SetPinMux(PORTE, 26U, kPORT_MuxAsGpio); PORT_SetPinMux(PORTB, 21U, kPORT_MuxAsGpio); //debug PORT_SetPinMux(PORTE, 24U, kPORT_MuxAsGpio); /* Initialize LED pins below */ LED_RED_INIT(1U); LED_GREEN_INIT(1U); LED_BLUE_INIT(1U); }
void BOARD_InitPins(void) { /* Declare and initialise for pull up configuration */ port_pin_config_t pinConfig = {0}; pinConfig.pullSelect = kPORT_PullUp; #if defined(FSL_FEATURE_PORT_HAS_OPEN_DRAIN) && FSL_FEATURE_PORT_HAS_OPEN_DRAIN pinConfig.openDrainEnable = kPORT_OpenDrainEnable; #endif /* FSL_FEATURE_PORT_HAS_OPEN_DRAIN */ /* Initialize LPUART0 pins below */ /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortA); /* Affects PORTA_PCR1 register */ PORT_SetPinMux(PORTA, 1u, kPORT_MuxAlt2); /* Affects PORTA_PCR2 register */ PORT_SetPinMux(PORTA, 2u, kPORT_MuxAlt2); /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortB); /* I2C0 pull up resistor setting */ PORT_SetPinConfig(PORTB, 2U, &pinConfig); PORT_SetPinConfig(PORTB, 3U, &pinConfig); /* I2C0 PIN_MUX Configuration */ PORT_SetPinMux(PORTB, 2U, kPORT_MuxAlt2); PORT_SetPinMux(PORTB, 3U, kPORT_MuxAlt2); /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortE); /* I2C1 pull up resistor setting */ PORT_SetPinConfig(PORTE, 0U, &pinConfig); PORT_SetPinConfig(PORTE, 1U, &pinConfig); /* I2C1 PIN_MUX Configuration */ PORT_SetPinMux(PORTE, 0U, kPORT_MuxAlt6); PORT_SetPinMux(PORTE, 1U, kPORT_MuxAlt6); }
/******************************************************************************* * Code ******************************************************************************/ void BOARD_InitPins(void) { /* Declare and initialise for pull up configuration */ port_pin_config_t pinConfig = {0}; pinConfig.pullSelect = kPORT_PullUp; pinConfig.openDrainEnable = kPORT_OpenDrainEnable; /* Initialize UART1 pins below */ /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortE); /* Affects PORTE_PCR0 register */ PORT_SetPinMux(PORTE, 0U, kPORT_MuxAlt3); /* Affects PORTE_PCR1 register */ PORT_SetPinMux(PORTE, 1U, kPORT_MuxAlt3); /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortB); /* I2C0 pull up resistor setting */ PORT_SetPinConfig(PORTB, 2U, &pinConfig); PORT_SetPinConfig(PORTB, 3U, &pinConfig); /* I2C0 PIN_MUX Configuration */ PORT_SetPinMux(PORTB, 2U, kPORT_MuxAlt2); PORT_SetPinMux(PORTB, 3U, kPORT_MuxAlt2); /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortC); /* I2C1 pull up resistor setting */ PORT_SetPinConfig(PORTC, 10U, &pinConfig); PORT_SetPinConfig(PORTC, 11U, &pinConfig); /* I2C1 PIN_MUX Configuration */ PORT_SetPinMux(PORTC, 10U, kPORT_MuxAlt2); PORT_SetPinMux(PORTC, 11U, kPORT_MuxAlt2); }
static OsStatus_t KL25Z_PinMuxDriverSetRowToGpio(Device_t * dev, uint8_t bitOffset, uint8_t len, uint32_t acceptMask) { OsStatus_t ret = kStatusOk; KL25ZPinMuxDevData_t *dat = (KL25ZPinMuxDevData_t *)dev->config->devConfigData; for(uint8_t i = 0; i < len; i++, acceptMask >>= 1) { /* only modify desired pins passed with accept mask */ if(acceptMask & 0x01) { PORT_SetPinMux(dat->port, i + bitOffset, kPORT_MuxAsGpio); } } return(ret); }
void BOARD_InitPins(void) { /* Debug uart port mux config */ /* Enable uart port clock */ CLOCK_EnableClock(kCLOCK_PortE); /* Affects PORTE_PCR0 register */ PORT_SetPinMux(PORTE, 0U, kPORT_MuxAlt3); /* Affects PORTE_PCR1 register */ PORT_SetPinMux(PORTE, 1U, kPORT_MuxAlt3); /* Enable SW port clock */ CLOCK_EnableClock(kCLOCK_PortC); /* Affects PORTC_PCR7 register */ port_pin_config_t config = {0}; config.pullSelect = kPORT_PullUp; config.mux = kPORT_MuxAsGpio; PORT_SetPinConfig(PORTC, 7U, &config); /* Enable GPIO port clock */ CLOCK_EnableClock(kCLOCK_PortD); /* LED PIN_MUX Configuration */ PORT_SetPinMux(PORTD, 6U, kPORT_MuxAsGpio); }
static OsStatus_t KL25Z_PinMuxDriverSetRowToAlternate(Device_t * dev, uint8_t bitOffset, uint8_t len, uint32_t acceptMask, uint32_t alternateFun) { OsStatus_t ret = kStatusOk; KL25ZPinMuxDevData_t *dat = (KL25ZPinMuxDevData_t *)dev->config->devConfigData; for(uint8_t i = 0; i < len; i++, acceptMask >>= 1) { /* only modify desired pins passed with accept mask */ if(acceptMask & 0x01) { port_mux_t ksdkAlt = (port_mux_t)alternateFun; PORT_SetPinMux(dat->port, i + bitOffset, ksdkAlt); } } return(ret); }
void modem_init() { const gpio_pin_config_t OUTTRUE = {kGPIO_DigitalOutput, true}; const gpio_pin_config_t IN = {kGPIO_DigitalInput, false}; // initialize BOARD_CELL pins CLOCK_EnableClock(BOARD_CELL_UART_PORT_CLOCK); PORT_SetPinMux(BOARD_CELL_UART_PORT, BOARD_CELL_UART_TX_PIN, BOARD_CELL_UART_TX_ALT); PORT_SetPinMux(BOARD_CELL_UART_PORT, BOARD_CELL_UART_RX_PIN, BOARD_CELL_UART_RX_ALT); CLOCK_EnableClock(BOARD_CELL_PIN_PORT_CLOCK); PORT_SetPinMux(BOARD_CELL_PIN_PORT, BOARD_CELL_STATUS_PIN, kPORT_MuxAsGpio); GPIO_PinInit(BOARD_CELL_PIN_GPIO, BOARD_CELL_STATUS_PIN, &IN); #if BOARD_CELL_RESET_PIN PORT_SetPinMux(BOARD_CELL_PIN_PORT, BOARD_CELL_RESET_PIN, kPORT_MuxAsGpio); GPIO_PinInit(BOARD_CELL_PIN_GPIO, BOARD_CELL_RESET_PIN, &OUTTRUE); #endif PORT_SetPinMux(BOARD_CELL_PIN_PORT, BOARD_CELL_PWRKEY_PIN, kPORT_MuxAsGpio); GPIO_PinInit(BOARD_CELL_PIN_GPIO, BOARD_CELL_PWRKEY_PIN, &OUTTRUE); // the ring identifier is optional, only use if a pin and port exists #if BOARD_CELL_RI_PIN PORT_SetPinMux(BOARD_CELL_PIN_PORT, BOARD_CELL_RI_PIN, kPORT_MuxAsGpio); GPIO_PinInit(BOARD_CELL_PIN_GPIO, BOARD_CELL_RI_PIN, &IN); #endif #if BOARD_CELL_PWR_DOMAIN const gpio_pin_config_t OUTFALSE = {kGPIO_DigitalOutput, false}; CLOCK_EnableClock(BOARD_CELL_PWR_EN_CLOCK); PORT_SetPinMux(BOARD_CELL_PWR_EN_PORT, BOARD_CELL_PWR_EN_PIN, kPORT_MuxAsGpio); GPIO_PinInit(BOARD_CELL_PWR_EN_GPIO, BOARD_CELL_PWR_EN_PIN, &OUTFALSE); #endif // configure uart driver connected to the SIM800H lpuart_config_t lpuart_config; LPUART_GetDefaultConfig(&lpuart_config); lpuart_config.baudRate_Bps = 115200; lpuart_config.parityMode = kLPUART_ParityDisabled; lpuart_config.stopBitCount = kLPUART_OneStopBit; LPUART_Init(BOARD_CELL_UART, &lpuart_config, BOARD_CELL_PORT_CLOCK_FREQ); LPUART_EnableRx(BOARD_CELL_UART, true); LPUART_EnableTx(BOARD_CELL_UART, true); LPUART_EnableInterrupts(BOARD_CELL_UART, kLPUART_RxDataRegFullInterruptEnable); EnableIRQ(BOARD_CELL_UART_IRQ); }
static void hw_uart_init(void) { register uint16_t sbr, brfa; uint8_t temp; #ifdef FREESCALE_KSDK_BM PORT_SetPinMux(UART_TX_PORT, UART_TX_PIN, UART_TX_MUX); CLOCK_SetLpuartClock(1); /* MCGPLLCLK */ DbgConsole_Init((uint32_t)UART_PORT, UART_BAUD, DEBUG_CONSOLE_DEVICE_TYPE_LPUART, SYS_CLK_HZ); #else /* Enable UART core clock */ /* Note: Remember to update me if UART_PORT changes */ SIM->SCGC1 |= SIM_SCGC1_UART4_MASK; /* Configure UART TX pin */ UART_TX_PORT->PCR[UART_TX_PIN] = PORT_PCR_MUX(UART_TX_MUX); /* Disable transmitter and receiver while we change settings. */ UART_PORT->C2 &= ~(UART_C2_TE_MASK | UART_C2_RE_MASK ); /* Configure the UART for 8-bit mode, no parity */ UART_PORT->C1 = 0; /* Calculate baud settings */ sbr = (uint16_t)((BUS_CLK_KHZ * 1000)/(UART_BAUD * 16)); temp = UART_PORT->BDH & ~(UART_BDH_SBR(0x1F)); UART_PORT->BDH = temp | UART_BDH_SBR(((sbr & 0x1F00) >> 8)); UART_PORT->BDL = (uint8_t)(sbr & UART_BDL_SBR_MASK); /* Determine if a fractional divider is needed to get closer to the baud rate */ brfa = (((BUS_CLK_KHZ * 32000)/(UART_BAUD * 16)) - (sbr * 32)); temp = UART_PORT->C4 & ~(UART_C4_BRFA(0x1F)); UART_PORT->C4 = temp | UART_C4_BRFA(brfa); /* Enable receiver and transmitter */ UART_PORT->C2 |= (UART_C2_TE_MASK | UART_C2_RE_MASK); #endif }
/******************************************************************************* * Code ******************************************************************************/ void BOARD_InitPins(void) { /* Initialize LPUART4 pins below */ /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortC); /* Affects PORTC_PCR14 register */ PORT_SetPinMux(PORTC, 14U, kPORT_MuxAlt3); /* Affects PORTC_PCR15 register */ PORT_SetPinMux(PORTC, 15U, kPORT_MuxAlt3); CLOCK_EnableClock(kCLOCK_PortB); /* FlexIO-I2C SDA pin */ /* Affects PORTB_PCR10 register */ PORT_SetPinMux(PORTB, 10U, kPORT_MuxAlt7); /* FlexIO-I2C SCL pin */ /* Affects PORTB_PCR11 register */ PORT_SetPinMux(PORTB, 11U, kPORT_MuxAlt7); CLOCK_EnableClock(kCLOCK_PortA); /* Affects PORTA_PCR1 register */ PORT_SetPinMux(PORTA, 1U, kPORT_MuxAlt4); /* Affects PORTA_PCR2 register */ PORT_SetPinMux(PORTA, 2U, kPORT_MuxAlt4); }
/******************************************************************************* * Code ******************************************************************************/ void k64f_init_eth_hardware(void) { port_pin_config_t configENET = {0}; /* Disable MPU. */ MPU->CESR &= ~MPU_CESR_VLD_MASK; CLOCK_EnableClock(kCLOCK_PortC); /* Affects PORTC_PCR16 register */ PORT_SetPinMux(PORTC, 16u, kPORT_MuxAlt4); /* Affects PORTC_PCR17 register */ PORT_SetPinMux(PORTC, 17u, kPORT_MuxAlt4); /* Affects PORTC_PCR18 register */ PORT_SetPinMux(PORTC, 18u, kPORT_MuxAlt4); /* Affects PORTC_PCR19 register */ PORT_SetPinMux(PORTC, 19u, kPORT_MuxAlt4); /* Affects PORTB_PCR1 register */ PORT_SetPinMux(PORTB, 1u, kPORT_MuxAlt4); configENET.openDrainEnable = kPORT_OpenDrainEnable; configENET.mux = kPORT_MuxAlt4; configENET.pullSelect = kPORT_PullUp; /* Ungate the port clock */ CLOCK_EnableClock(kCLOCK_PortA); /* Affects PORTB_PCR0 register */ PORT_SetPinConfig(PORTB, 0u, &configENET); /* Affects PORTA_PCR13 register */ PORT_SetPinMux(PORTA, 13u, kPORT_MuxAlt4); /* Affects PORTA_PCR12 register */ PORT_SetPinMux(PORTA, 12u, kPORT_MuxAlt4); /* Affects PORTA_PCR14 register */ PORT_SetPinMux(PORTA, 14u, kPORT_MuxAlt4); /* Affects PORTA_PCR5 register */ PORT_SetPinMux(PORTA, 5u, kPORT_MuxAlt4); /* Affects PORTA_PCR16 register */ PORT_SetPinMux(PORTA, 16u, kPORT_MuxAlt4); /* Affects PORTA_PCR17 register */ PORT_SetPinMux(PORTA, 17u, kPORT_MuxAlt4); /* Affects PORTA_PCR15 register */ PORT_SetPinMux(PORTA, 15u, kPORT_MuxAlt4); /* Affects PORTA_PCR28 register */ PORT_SetPinMux(PORTA, 28u, kPORT_MuxAlt4); /* Select the Ethernet timestamp clock source */ CLOCK_SetEnetTime0Clock(0x2); }
void NMI_Handler(void) { /* Change NMI Pin MUX */ CLOCK_EnableClock(kCLOCK_PortB); PORT_SetPinMux(PORTB, 18, kPORT_MuxAlt2); }