Ejemplo n.º 1
0
//*****************************************************************************
// Turns on the alternate function for the given pins
//*****************************************************************************
bool gpio_config_alternate_function(uint32_t baseAddr, uint8_t pins) {
    GPIOA_Type  *gpioPort;

    // Verify the address
    if(!verifyBaseAddr(baseAddr)) {
        return false;
    }

    // Set the alternate function on selected pins
    gpioPort = (GPIOA_Type *) baseAddr;
    gpioPort->AFSEL |=pins;

    return true;
}
Ejemplo n.º 2
0
//*****************************************************************************
// Enables a pin as an analog input for the provided pins
//*****************************************************************************
bool gpio_config_analog_enable(uint32_t baseAddr, uint8_t pins) {
    GPIOA_Type  *gpioPort;

    // Verify the address
    if(!verifyBaseAddr(baseAddr)) {
        return false;
    }

    // Set the AMSEL on selected pins
    gpioPort = (GPIOA_Type *) baseAddr;
    gpioPort->AMSEL |= pins;

    return true;
}
Ejemplo n.º 3
0
//*****************************************************************************
// Opens the drain for specified pins
//*****************************************************************************
bool gpio_config_open_drain(uint32_t baseAddr, uint32_t pins) {
    GPIOA_Type  *gpioPort;

    // Verify that the base address is a valid GPIO base address
    // using the verifyBaseAddr function provided above
    if(!verifyBaseAddr(baseAddr))
        return false;

    // Type Cast the base address to a GPIOA_Type pointer
    gpioPort = (GPIOA_Type *)baseAddr;

    // Set the pins as outputs
    gpioPort->ODR |= pins;

    return true;
}
Ejemplo n.º 4
0
//*****************************************************************************
// Setting a pins as a digital enable requires writing to DEN register
//
// Paramters
//    pins  -   A bit mask indicating which pins should be configured as digital
//              pins.  Modify only the bits where the bitmask is equal to 1.
//
// Use section 10.5 of the TM4C123 data sheet to determine the bits to set in
// the DEN register.
//
//*****************************************************************************
bool  gpio_config_digital_enable(uint32_t baseAddr, uint8_t pins)
{
    GPIOA_Type  *gpioPort;

    // Verify that the base address is a valid GPIO base address
    // using the verifyBaseAddr function provided above
    if(!verifyBaseAddr(baseAddr))
        return false;

    // Type Cast the base address to a GPIOA_Type pointer
    gpioPort = (GPIOA_Type *) baseAddr;

    // Turn on the digital enable
    gpioPort->DEN |=pins;

    return true;
}
Ejemplo n.º 5
0
//*****************************************************************************
// Enabling a pull-up resistor requires setting the PDR regsiter
//
// Paramters
//    baseAddr - Base address of GPIO port that is being enabled.
//    pins  -   A bit mask indicating which pins should be configured with a
//              pull-down resistor
//*****************************************************************************
bool  gpio_config_enable_pulldown(uint32_t baseAddr, uint8_t pins)
{
    GPIOA_Type  *gpioPort;

    // Verify that the base address is a valid GPIO base address
    // using the verifyBaseAddr function provided above
    if(!verifyBaseAddr(baseAddr)) {
        return false;
    }

    // Type Cast the base address to a GPIOA_Type pointer
    gpioPort = (GPIOA_Type *) baseAddr;

    // Enable the pull-down resistors
    gpioPort->PDR |=pins;

    return true;
}
Ejemplo n.º 6
0
//*****************************************************************************
// Setting a GPIO pin as an output requires setting the DIR register
//
// Paramters
//    pins  -   A bit mask indicating which pins should be configured as output
//              pins.  Modify only the bits where the bitmask is equal to 1.
//
// Use section 10.5 of the TM4C123 data sheet to determine the bits to set in
// the DIR register.
//
//*****************************************************************************
bool  gpio_config_enable_input(uint32_t baseAddr, uint8_t pins)

{
    GPIOA_Type  *gpioPort;

    // Verify that the base address is a valid GPIO base address
    // using the verifyBaseAddr function provided above
    if(!verifyBaseAddr(baseAddr)) {
        return false;
    }

    // Type Cast the base address to a GPIOA_Type pointer
    gpioPort = (GPIOA_Type *) baseAddr;

    // Set the pins as inputs
    gpioPort->DIR &=~pins;

    return true;
}
Ejemplo n.º 7
0
bool  gpio_config_open_drain(uint32_t gpioBase, uint8_t pins)
{
  
  GPIOA_Type  *gpioPort;

  // Verify that the base address is a valid GPIO base address
  // using the verifyBaseAddr function provided above
  if( verifyBaseAddr(gpioBase) == false)
    {
      return false;
    }
    
  // Type Cast the base address to a GPIOA_Type pointer
  gpioPort = (GPIOA_Type *)gpioBase;

  // Configure pins as open-drain
  gpioPort->ODR |= pins;
    
  return true;

}
Ejemplo n.º 8
0
//*****************************************************************************
bool  gpio_config_analog_enable(uint32_t baseAddr, uint8_t pins)
{
  GPIOA_Type  *gpioPort;

  // ADD CODE
  // Verify that the base address is a valid GPIO base address
  // using the verifyBaseAddr function provided above
  if( verifyBaseAddr(baseAddr) == false)
    {
      return false;
    }
    
  // ADD CODE
  // Type Cast the base address to a GPIOA_Type pointer
  gpioPort = (GPIOA_Type *)baseAddr;

  // ADD CODE
  // Enable analog pins
  gpioPort->AMSEL |= pins;
  return true;
}
Ejemplo n.º 9
0
//*****************************************************************************
bool  gpio_config_port_control(uint32_t baseAddr, uint32_t pins)
{
  GPIOA_Type  *gpioPort;

  // ADD CODE
  // Verify that the base address is a valid GPIO base address
  // using the verifyBaseAddr function provided above
  if( verifyBaseAddr(baseAddr) == false)
    {
      return false;
    }
    
  // ADD CODE
  // Type Cast the base address to a GPIOA_Type pointer
  gpioPort = (GPIOA_Type *)baseAddr;

  // ADD CODE
  // Set the port control register
  gpioPort->PCTL |= pins;
    
  return true;
}