Exemple #1
0
void configure_i2c_pins(uint32_t instance)
{
  switch(instance) {
    case I2C0_IDX:                          /* I2C0 */
      /* PORTB_PCR2 */
      PORT_HAL_SetMuxMode(PORTB,2u,kPortMuxAlt2);
      PORT_HAL_SetPassiveFilterCmd(PORTB,2u,false);
      PORT_HAL_SetPullMode(PORTB,2u,kPortPullUp);
      PORT_HAL_SetPullCmd(PORTB,2u,true);
      /* PORTB_PCR1 */
      PORT_HAL_SetMuxMode(PORTB,1u,kPortMuxAlt2);
      PORT_HAL_SetPassiveFilterCmd(PORTB,1u,false);
      PORT_HAL_SetPullMode(PORTB,1u,kPortPullUp);
      PORT_HAL_SetPullCmd(PORTB,1u,true);
      break;
    case I2C1_IDX:                          /* I2C1 */
      /* PORTC_PCR1 */
      PORT_HAL_SetMuxMode(PORTC,1u,kPortMuxAlt2);
      PORT_HAL_SetPassiveFilterCmd(PORTC,1u,false);
      /* PORTC_PCR2 */
      PORT_HAL_SetMuxMode(PORTC,2u,kPortMuxAlt2);
      PORT_HAL_SetPassiveFilterCmd(PORTC,2u,false);
      break;
    default:
      break;
  }
}
Exemple #2
0
// Connected TWR_MEM
void configure_sdcard_spi_pins(uint32_t instance)
{
  /* SPI1_CS0 */
  PORT_HAL_SetMuxMode(PORTB,10u,kPortMuxAlt2);
  PORT_HAL_SetPullMode(PORTB,10u,kPortPullUp);
  PORT_HAL_SetPullCmd(PORTB,10u,true);

  /* SPI1_SCK */
  PORT_HAL_SetMuxMode(PORTB,11u,kPortMuxAlt2);

  /* SPI1_SOUT */
  PORT_HAL_SetMuxMode(PORTB,16u,kPortMuxAlt2);
  PORT_HAL_SetPullMode(PORTB,16u,kPortPullUp);
  PORT_HAL_SetPullCmd(PORTB,16u,true);

  /* SPI1_SIN */
  PORT_HAL_SetMuxMode(PORTB,17u,kPortMuxAlt2);
  PORT_HAL_SetPullMode(PORTB,17u,kPortPullUp);
  PORT_HAL_SetPullCmd(PORTB,17u,true);

  /* Pin_Card_detection*/
  PORT_HAL_SetMuxMode(PORTB,20u,kPortMuxAsGpio);

  /* Pin_Card_write_protection*/
  PORT_HAL_SetMuxMode(PORTA,17u,kPortMuxAsGpio);
  PORT_HAL_SetPullMode(PORTA,17u,kPortPullUp);
  PORT_HAL_SetPullCmd(PORTA,17u,true);
}
void configure_gpio_pins(uint32_t instance)
{
  switch(instance) {    
    case HW_PORTA:                      /* HW_PORTA */
      /* Affects PORTA_PCR4 register */
      PORT_HAL_SetPassiveFilterCmd(PORTA_BASE,4u,false);
      PORT_HAL_SetMuxMode(PORTA_BASE,4u,kPortMuxAsGpio);
      PORT_HAL_SetPullMode(PORTA_BASE,4u,kPortPullUp);
      PORT_HAL_SetPullCmd(PORTA_BASE,4u,true);
      break;
    case HW_PORTB:                      /* HW_PORTB */
      /* Affects PORTB_PCR21 register */
      PORT_HAL_SetDriveStrengthMode(PORTB_BASE,21u,kPortLowDriveStrength);  
      PORT_HAL_SetMuxMode(PORTB_BASE,21u,kPortMuxAsGpio);
      PORT_HAL_SetSlewRateMode(PORTB_BASE,21u,kPortSlowSlewRate);
      /* Affects PORTB_PCR22 register */
      PORT_HAL_SetDriveStrengthMode(PORTB_BASE,22u,kPortLowDriveStrength);  
      PORT_HAL_SetMuxMode(PORTB_BASE,22u,kPortMuxAsGpio);
      PORT_HAL_SetSlewRateMode(PORTB_BASE,22u,kPortSlowSlewRate);
      break;
    case HW_PORTC:                      /* HW_PORTC */
      /* Affects PORTC_PCR0 register */
      PORT_HAL_SetMuxMode(PORTC_BASE,0u,kPortMuxAsGpio);
      /* Affects PORTC_PCR6 register */
      PORT_HAL_SetPassiveFilterCmd(PORTC_BASE,6u,false);
      PORT_HAL_SetMuxMode(PORTC_BASE,6u,kPortMuxAsGpio);
      PORT_HAL_SetPullMode(PORTC_BASE,6u,kPortPullUp);
      PORT_HAL_SetPullCmd(PORTC_BASE,6u,true);
      /* Affects PORTC_PCR8 register */
      PORT_HAL_SetMuxMode(PORTC_BASE,8u,kPortMuxAsGpio);
      /* Affects PORTC_PCR9 register */
      PORT_HAL_SetMuxMode(PORTC_BASE,9u,kPortMuxAsGpio);
      /* Affects PORTC_PCR12 register */
      PORT_HAL_SetMuxMode(PORTC_BASE,12u,kPortMuxAsGpio);
      /* Affects PORTC_PCR13 register */
      PORT_HAL_SetMuxMode(PORTC_BASE,13u,kPortMuxAsGpio);
      /* Affects PORTC_PCR16 register */
      PORT_HAL_SetMuxMode(PORTC_BASE,16u,kPortMuxAsGpio);
      PORT_HAL_SetMuxMode(PORTC_BASE,10u,kPortMuxAsGpio);
      PORT_HAL_SetMuxMode(PORTC_BASE,2u,kPortMuxAsGpio);
      break;
    case HW_PORTE:                      /* HW_PORTE */
      /* Affects PORTE_PCR6 register */
      PORT_HAL_SetMuxMode(PORTE_BASE,6u,kPortMuxAsGpio);
      /* Affects PORTE_PCR26 register */
      PORT_HAL_SetDriveStrengthMode(PORTE_BASE,26u,kPortLowDriveStrength);  
      PORT_HAL_SetMuxMode(PORTE_BASE,26u,kPortMuxAsGpio);
      PORT_HAL_SetSlewRateMode(PORTE_BASE,26u,kPortSlowSlewRate);
      break;
    default:
      break;
  }
}
Exemple #4
0
void configure_enet_pins(uint32_t instance)
{
  /* Affects PORTC_PCR16 register */
  PORT_HAL_SetMuxMode(PORTC_BASE,16u,kPortMuxAlt4);
  /* Affects PORTC_PCR17 register */
  PORT_HAL_SetMuxMode(PORTC_BASE,17u,kPortMuxAlt4);
  /* Affects PORTC_PCR18 register */
  PORT_HAL_SetMuxMode(PORTC_BASE,18u,kPortMuxAlt4);
  /* Affects PORTC_PCR19 register */
  PORT_HAL_SetMuxMode(PORTC_BASE,19u,kPortMuxAlt4);
  /* Affects PORTB_PCR1 register */
  PORT_HAL_SetMuxMode(PORTB_BASE,1u,kPortMuxAlt4);
  /* Affects PORTB_PCR0 register */
  PORT_HAL_SetMuxMode(PORTB_BASE,0u,kPortMuxAlt4);
  PORT_HAL_SetOpenDrainCmd(PORTB_BASE,0u,true);
  PORT_HAL_SetPullMode(PORTB_BASE,0u,kPortPullUp);
  PORT_HAL_SetPullCmd(PORTB_BASE,0u,true);
  /* Affects PORTA_PCR13 register */
  PORT_HAL_SetMuxMode(PORTA_BASE,13u,kPortMuxAlt4);
  /* Affects PORTA_PCR12 register */
  PORT_HAL_SetMuxMode(PORTA_BASE,12u,kPortMuxAlt4);
  /* Affects PORTA_PCR14 register */
  PORT_HAL_SetMuxMode(PORTA_BASE,14u,kPortMuxAlt4);
  /* Affects PORTA_PCR5 register */
  PORT_HAL_SetMuxMode(PORTA_BASE,5u,kPortMuxAlt4);
  /* Affects PORTA_PCR16 register */
  PORT_HAL_SetMuxMode(PORTA_BASE,16u,kPortMuxAlt4);
  /* Affects PORTA_PCR17 register */
  PORT_HAL_SetMuxMode(PORTA_BASE,17u,kPortMuxAlt4);
  /* Affects PORTA_PCR15 register */
  PORT_HAL_SetMuxMode(PORTA_BASE,15u,kPortMuxAlt4);
  /* Affects PORTA_PCR28 register */
  PORT_HAL_SetMuxMode(PORTA_BASE,28u,kPortMuxAlt4);
}
Exemple #5
0
/*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]);
    }
}
Exemple #6
0
void disable_unused_pins(void)
{
  /* Disable debug pins when MCU sleeps */
   setup_debug_pins(kPortPinDisabled);

  /* Disable uart pins */
    setup_uart_pins(kPortMuxAsGpio);

    GPIO_HAL_SetPinDir(GPIOE, 0, kGpioDigitalInput);
    PORT_HAL_SetPullCmd(PORTE, 0, true);
    PORT_HAL_SetPullMode(PORTE, 0, kPortPullUp);

    GPIO_HAL_SetPinDir(GPIOE, 1, kGpioDigitalInput);
    PORT_HAL_SetPullCmd(PORTE, 1, true);
    PORT_HAL_SetPullMode(PORTE, 1, kPortPullUp);

    OSC_HAL_SetExternalRefClkInStopModeCmd(OSC_BASE_PTR, false);
}
Exemple #7
0
void configure_gpio_pins(uint32_t instance)
{
  switch(instance) {
    case PORTA_IDX:                      /* PORTA_IDX */
      /* Affects PORTA_PCR4 register */
      PORT_HAL_SetPassiveFilterCmd(PORTA,4u,false);
      PORT_HAL_SetMuxMode(PORTA,4u,kPortMuxAsGpio);
      PORT_HAL_SetPullMode(PORTA,4u,kPortPullUp);
      PORT_HAL_SetPullCmd(PORTA,4u,true);
      /* Affects PORTA_PCR13 register */
      PORT_HAL_SetDriveStrengthMode(PORTA,13u,kPortLowDriveStrength);
      PORT_HAL_SetMuxMode(PORTA,13u,kPortMuxAsGpio);
      PORT_HAL_SetSlewRateMode(PORTA,13u,kPortSlowSlewRate);
      break;
    case PORTB_IDX:                      /* PORTB_IDX */
      /* Affects PORTB_PCR18 register */
      PORT_HAL_SetDriveStrengthMode(PORTB,18u,kPortLowDriveStrength);
      PORT_HAL_SetMuxMode(PORTB,18u,kPortMuxAsGpio);
      PORT_HAL_SetSlewRateMode(PORTB,18u,kPortSlowSlewRate);
      /* Affects PORTB_PCR19 register */
      PORT_HAL_SetDriveStrengthMode(PORTB,19u,kPortLowDriveStrength);
      PORT_HAL_SetMuxMode(PORTB,19u,kPortMuxAsGpio);
      PORT_HAL_SetSlewRateMode(PORTB,19u,kPortSlowSlewRate);
      break;
    case PORTC_IDX:                      /* PORTC_IDX */
      /* PORTC_PCR1 */
      PORT_HAL_SetMuxMode(PORTC,1u,kPortMuxAsGpio);
      /* Affects PORTC_PCR2 register */
      PORT_HAL_SetPassiveFilterCmd(PORTC,2u,false);
      PORT_HAL_SetMuxMode(PORTC,2u,kPortMuxAsGpio);
      PORT_HAL_SetPullMode(PORTC,2u,kPortPullUp);
      PORT_HAL_SetPullCmd(PORTC,2u,true);
      /* Affects PORTC_PCR3 register */
      PORT_HAL_SetPassiveFilterCmd(PORTC,3u,false);
      PORT_HAL_SetMuxMode(PORTC,3u,kPortMuxAsGpio);
      PORT_HAL_SetPullMode(PORTC,3u,kPortPullUp);
      PORT_HAL_SetPullCmd(PORTC,3u,true);
      break;
    default:
      break;
  }
}
Exemple #8
0
void configure_i2c_pins(uint32_t instance)
{
  switch(instance) {
    case I2C0_IDX:                             /* I2C0 */
#if  defined(DEMO_I2C_ACCELEROMETER)

      /* PORTE_PCR24 */
      PORT_HAL_SetMuxMode(PORTE,24u,kPortMuxAlt5);
      /* PORTE_PCR25 */
      PORT_HAL_SetMuxMode(PORTE,25u,kPortMuxAlt5);
#else
      /* PORTB_PCR0 */
      PORT_HAL_SetMuxMode(PORTB,0u,kPortMuxAlt2);
      /* Enable pull up */
      PORT_HAL_SetPullMode(PORTB,0u,kPortPullUp);
      PORT_HAL_SetPullCmd(PORTB,0u,true);

      /* PORTB_PCR1 */
      PORT_HAL_SetMuxMode(PORTB,1u,kPortMuxAlt2);
      /* Enable pull up */
      PORT_HAL_SetPullMode(PORTB,1u,kPortPullUp);
      PORT_HAL_SetPullCmd(PORTB,1u,true);
#endif
      break;
    case I2C1_IDX:                             /* I2C1 */
      /* PORTE_PCR0 */
      PORT_HAL_SetMuxMode(PORTE,0u,kPortMuxAlt6);
      /* Enable pull up */
      PORT_HAL_SetPullMode(PORTE,0u,kPortPullUp);
      PORT_HAL_SetPullCmd(PORTE,0u,true);

      /* PORTE_PCR1 */
      PORT_HAL_SetMuxMode(PORTE,1u,kPortMuxAlt6);
      /* Enable pull up */
      PORT_HAL_SetPullMode(PORTE,1u,kPortPullUp);
      PORT_HAL_SetPullCmd(PORTE,1u,true);
      break;
    default:
      break;
  }
}
Exemple #9
0
void configure_sdhc_pins(uint32_t instance)
{
  /* Affects PORTE_PCR3 register */
  PORT_HAL_SetMuxMode(PORTE_BASE,3u,kPortMuxAlt4);
  PORT_HAL_SetPullMode(PORTE_BASE,3u,kPortPullUp);
  PORT_HAL_SetPullCmd(PORTE_BASE,3u,true);
  PORT_HAL_SetDriveStrengthMode(PORTE_BASE,3u,kPortHighDriveStrength);
  /* Affects PORTE_PCR1 register */
  PORT_HAL_SetMuxMode(PORTE_BASE,1u,kPortMuxAlt4);
  PORT_HAL_SetPullMode(PORTE_BASE,1u,kPortPullUp);
  PORT_HAL_SetPullCmd(PORTE_BASE,1u,true);
  PORT_HAL_SetDriveStrengthMode(PORTE_BASE,1u,kPortHighDriveStrength);
  /* Affects PORTE_PCR0 register */
  PORT_HAL_SetMuxMode(PORTE_BASE,0u,kPortMuxAlt4);
  PORT_HAL_SetPullMode(PORTE_BASE,0u,kPortPullUp);
  PORT_HAL_SetPullCmd(PORTE_BASE,0u,true);
  PORT_HAL_SetDriveStrengthMode(PORTE_BASE,0u,kPortHighDriveStrength);
  /* Affects PORTE_PCR5 register */
  PORT_HAL_SetMuxMode(PORTE_BASE,5u,kPortMuxAlt4);
  PORT_HAL_SetPullMode(PORTE_BASE,5u,kPortPullUp);
  PORT_HAL_SetPullCmd(PORTE_BASE,5u,true);
  PORT_HAL_SetDriveStrengthMode(PORTE_BASE,5u,kPortHighDriveStrength);
  /* Affects PORTE_PCR4 register */
  PORT_HAL_SetMuxMode(PORTE_BASE,4u,kPortMuxAlt4);
  PORT_HAL_SetPullMode(PORTE_BASE,4u,kPortPullUp);
  PORT_HAL_SetPullCmd(PORTE_BASE,4u,true);
  PORT_HAL_SetDriveStrengthMode(PORTE_BASE,4u,kPortHighDriveStrength);
  /* Affects PORTE_PCR2 register */
  PORT_HAL_SetMuxMode(PORTE_BASE,2u,kPortMuxAlt4);
  PORT_HAL_SetPullMode(PORTE_BASE,2u,kPortPullUp);
  PORT_HAL_SetPullCmd(PORTE_BASE,2u,true);
  PORT_HAL_SetDriveStrengthMode(PORTE_BASE,2u,kPortHighDriveStrength);
}
Exemple #10
0
void configure_i2c_pins(uint32_t instance)
{
  switch(instance) {
    case 0:                          /* I2C0 */
      /* PORTB_PCR2 */
      PORT_HAL_SetMuxMode(PORTB_BASE,2u,kPortMuxAlt2);
      PORT_HAL_SetPullCmd(PORTB_BASE, 2u, true);
      PORT_HAL_SetPullMode(PORTB_BASE, 2u, kPortPullUp);
      PORT_HAL_SetPassiveFilterCmd(PORTB_BASE, 2u, false);
      /* PORTB_PCR3 */
      PORT_HAL_SetMuxMode(PORTB_BASE,3u,kPortMuxAlt2);
      PORT_HAL_SetPullCmd(PORTB_BASE, 3u, true);
      PORT_HAL_SetPullMode(PORTB_BASE, 3u, kPortPullUp);
      PORT_HAL_SetPassiveFilterCmd(PORTB_BASE, 3u, false);

      break;
    case 1:
      /* PORTE_PCR0 */
      PORT_HAL_SetMuxMode(PORTE_BASE,0u,kPortMuxAlt6);
      PORT_HAL_SetPullCmd(PORTE_BASE, 0u, true);
      PORT_HAL_SetPullMode(PORTE_BASE, 0u, kPortPullUp);
      PORT_HAL_SetPassiveFilterCmd(PORTE_BASE, 0u, false);
      /* PORTE_PCR1 */
      PORT_HAL_SetMuxMode(PORTE_BASE,1u,kPortMuxAlt6);
      PORT_HAL_SetPullCmd(PORTE_BASE, 1u, true);
      PORT_HAL_SetPullMode(PORTE_BASE, 1u, kPortPullUp);
      PORT_HAL_SetPassiveFilterCmd(PORTE_BASE, 1u, false);
      break;
    case 2:
      break;
    case 3:
      break;
    case 4:
      break;
    default:
      break;
  }
}
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();
}
/*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
}
Exemple #13
0
void configure_gpio_pins(uint32_t instance)
{
  switch(instance) {
    case GPIOB_IDX:                     /* GPIOB_IDX */
      /* Affects PORTB_PCR2 register */
      PORT_HAL_SetMuxMode(PORTB,2UL,kPortMuxAsGpio);
      PORT_HAL_SetPullMode(PORTB,2UL,kPortPullUp);
      PORT_HAL_SetPullCmd(PORTB,2UL,true);
      break;
    case GPIOC_IDX:                     /* GPIOC_IDX */
      /* Affects PORTC_PCR0 register */
      PORT_HAL_SetMuxMode(PORTC,0UL,kPortMuxAsGpio);
      PORT_HAL_SetSlewRateMode(PORTC,0UL,kPortSlowSlewRate);
      /* Affects PORTC_PCR1 register */
      PORT_HAL_SetMuxMode(PORTC,1UL,kPortMuxAsGpio);
      PORT_HAL_SetSlewRateMode(PORTC,1UL,kPortSlowSlewRate);
      break;
    default:
      break;
  }
}