Ejemplo n.º 1
0
/* This function is called for configuring pinmux for uart module
 * This function only support switching default or gpio or fixed-ALTx mode on fixed pins
 * (Although there are many ALTx-pinmux configuration choices on various pins for the same
 * peripheral module) */
void uart_pinmux_config(unsigned int instance, pinmux_type_t pinmux)
{
    switch(instance)
    {
        case 0:
#if BL_CONFIG_SCUART          
            switch(pinmux)
            {
                case kPinmuxType_Default:
                    PORT_BWR_PCR_MUX(PORTC, LPUART0_RX_GPIO_PIN_NUM, 0);
                    PORT_BWR_PCR_MUX(PORTC, LPUART0_TX_GPIO_PIN_NUM, 0);
                    break;
                case kPinmuxType_GPIO:
                    PORT_BWR_PCR_MUX(PORTC, LPUART0_RX_GPIO_PIN_NUM, LPUART0_RX_GPIO_ALT_MODE); // Set LPUART0_RX pin in GPIO mode
                    GPIO_CLR_PDDR(PTC, 1 << LPUART0_RX_GPIO_PIN_NUM);                        // Set LPUART0_RX pin as an input
                    break;
                case kPinmuxType_Peripheral:
                    PORT_BWR_PCR_MUX(PORTC, LPUART0_RX_GPIO_PIN_NUM, LPUART0_RX_ALT_MODE);   // Set LPUART0_RX pin to LPUART0_RX functionality
                    PORT_BWR_PCR_MUX(PORTC, LPUART0_TX_GPIO_PIN_NUM, LPUART0_TX_ALT_MODE);   // Set LPUART0_TX pin to LPUART0_TX functionality
                    break;
                default:
                    break;
            }
            break;
        case 1:
            switch(pinmux)
            {
                case kPinmuxType_Default:
                    PORT_BWR_PCR_MUX(PORTE, UART1_RX_GPIO_PIN_NUM, 0);
                    PORT_BWR_PCR_MUX(PORTE, UART1_TX_GPIO_PIN_NUM, 0);
                    break;
                case kPinmuxType_GPIO:
                    PORT_BWR_PCR_MUX(PORTE, UART1_RX_GPIO_PIN_NUM, UART1_RX_GPIO_ALT_MODE); // Set UART1_RX pin in GPIO mode
                    GPIO_CLR_PDDR(PTE, 1 << UART1_RX_GPIO_PIN_NUM);                      // Set UART1_RX pin as an input
                    break;
                case kPinmuxType_Peripheral:
                    PORT_BWR_PCR_MUX(PORTE, UART1_RX_GPIO_PIN_NUM, UART1_RX_ALT_MODE);   // Set UART1_RX pin to UART1_RX functionality
                    PORT_BWR_PCR_MUX(PORTE, UART1_TX_GPIO_PIN_NUM, UART1_TX_ALT_MODE);   // Set UART1_TX pin to UART1_TX functionality
                    break;
                default:
                    break;
            }
            break;
#endif // BL_CONFIG_SCUART            
        case 2:
        case 3:
        case 4:
        case 5:
        default:
            break;
    }
}
Ejemplo n.º 2
0
/* This function is called for configuring pinmux for uart module
 * This function only support switching default or gpio or fixed-ALTx mode on fixed pins
 * (Although there are many ALTx-pinmux configuration choices on various pins for the same
 * peripheral module) */
void uart_pinmux_config(unsigned int instance, pinmux_type_t pinmux)
{
    switch(instance)
    {
#if BL_CONFIG_SCUART  
#ifdef TOWER      
        case 2:
           switch(pinmux)
            {
                case kPinmuxType_Default:
                    PORT_BWR_PCR_MUX(PORTE, UART2_RX_GPIO_PIN_NUM, 0);
                    PORT_BWR_PCR_MUX(PORTE, UART2_TX_GPIO_PIN_NUM, 0);
                    break;
                case kPinmuxType_GPIO:
                    PORT_BWR_PCR_MUX(PORTE, UART2_RX_GPIO_PIN_NUM, UART2_RX_GPIO_ALT_MODE); 
                    GPIO_CLR_PDDR(PTE, 1 << UART2_RX_GPIO_PIN_NUM);                      
                    break;
                case kPinmuxType_Peripheral:
                    PORT_BWR_PCR_MUX(PORTE, UART2_RX_GPIO_PIN_NUM, UART2_RX_ALT_MODE);  
                    PORT_BWR_PCR_MUX(PORTE, UART2_TX_GPIO_PIN_NUM, UART2_TX_ALT_MODE);  
                    break;      
                default:
                    break;    
            }
            break;  
#else // defined TOWER           
        case 4:
           switch(pinmux)
            {
                case kPinmuxType_Default:
                    PORT_BWR_PCR_MUX(PORTE, UART4_RX_GPIO_PIN_NUM, 0);
                    PORT_BWR_PCR_MUX(PORTE, UART4_TX_GPIO_PIN_NUM, 0);
                    break;
                case kPinmuxType_GPIO:
                    PORT_BWR_PCR_MUX(PORTE, UART4_RX_GPIO_PIN_NUM, UART4_RX_GPIO_ALT_MODE); 
                    GPIO_CLR_PDDR(PTE, 1 << UART4_RX_GPIO_PIN_NUM);                      
                    break;
                case kPinmuxType_Peripheral:
                    PORT_BWR_PCR_MUX(PORTE, UART4_RX_GPIO_PIN_NUM, UART4_RX_ALT_MODE);  
                    PORT_BWR_PCR_MUX(PORTE, UART4_TX_GPIO_PIN_NUM, UART4_TX_ALT_MODE);  
                    break;      
                default:
                    break;    
            }
            break;  
#endif // defined TOWER           
#endif // BL_CONFIG_SCUART           
        default:
            break;
    }
}
Ejemplo n.º 3
0
bool is_boot_pin_asserted(void)
{
#ifdef BL_TARGET_FLASH
    // Initialize boot pin for GPIO
    PORT_BWR_PCR_MUX(BOOTPIN_PORT, BOOTPIN_PIN, 1);
    // Set boot pin as an input
    GPIO_CLR_PDDR(BOOTPIN_GPIO, 1 << BOOTPIN_PIN);
    // Set boot pin pullup enabled, pullup select, filter enable
    PORT_SET_PCR(BOOTPIN_PORT, BOOTPIN_PIN, PORT_PCR_PE_MASK | PORT_PCR_PS_MASK | PORT_PCR_PFE_MASK);

    unsigned int readCount = 0;

    // Sample the pin a number of times
    for (unsigned int i = 0; i < BOOTPIN_DEBOUNCE_READ_COUNT; i++)
    {
        readCount += (GPIO_RD_PDIR(BOOTPIN_GPIO) >> BOOTPIN_PIN) & 1;
    }

    // boot pin is pulled high so we are measuring lows, make sure most of our measurements
    // registered as low
    return (readCount < (BOOTPIN_DEBOUNCE_READ_COUNT/2));
#else
    // Boot pin for Flash only target
    return false;
#endif
}
/*FUNCTION**********************************************************************
 *
 * Function Name : GPIO_HAL_SetPinDir
 * Description   : Set individual gpio pin to general input or output.
 *
 *END**************************************************************************/
void GPIO_HAL_SetPinDir(GPIO_Type * base, uint32_t pin, gpio_pin_direction_t direction)
{
    assert(pin < 32);

    if (direction == kGpioDigitalOutput)
    {
        GPIO_SET_PDDR(base, 1U << pin);
    }
    else
    {
        GPIO_CLR_PDDR(base, 1U << pin);
    }
}
Ejemplo n.º 5
0
/* This function is called for configurating pinmux for uart module
 * This function only support switching default or gpio or fixed-ALTx mode on fixed pins
 * (Although there are many ALTx-pinmux configuration choices on various pins for the same
 * peripheral module) */
void uart_pinmux_config(unsigned int instance, pinmux_type_t pinmux)
{
    switch(pinmux)
    {
    case kPinmuxType_Default:
        PORT_BWR_PCR_MUX(UART_TX_PORT, UART_TX_PIN, 0);
        PORT_BWR_PCR_MUX(UART_RX_PORT, UART_RX_PIN, 0);
        break;
    case kPinmuxType_GPIO:
        PORT_BWR_PCR_MUX(UART_RX_PORT, UART_RX_PIN, UART_RX_ALT);           // Set UART_RX pin in GPIO mode
        GPIO_CLR_PDDR(UART_RX_GPIO, 1 << UART_RX_PIN);                      // Set UART_RX pin as an input
        break;
    case kPinmuxType_Peripheral:
        PORT_BWR_PCR_MUX(UART_TX_PORT, UART_TX_PIN, UART_TX_ALT);   // Set UART_RX pin to UART_RX functionality
        PORT_BWR_PCR_MUX(UART_RX_PORT, UART_RX_PIN, UART_RX_ALT);   // Set UART_TX pin to UART_TX functionality
        break;
    default:
        break;
    }
}