Ticket #2390: 0001-Fixes-ticket-2390-and-also-updates-the-RPI-implement.patch

File 0001-Fixes-ticket-2390-and-also-updates-the-RPI-implement.patch, 3.5 KB (added by André Marques, on Aug 13, 2015 at 3:11:43 PM)
  • c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c

    From a9586eda4a2a5a450702b58bb180e850ab2016db Mon Sep 17 00:00:00 2001
    From: Andre Marques <andre.lousa.marques@gmail.com>
    Date: Thu, 13 Aug 2015 15:58:25 +0100
    Subject: [PATCH] Fixes ticket #2390, and also updates the RPI implementation.
    
    ---
     c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c |  2 +-
     c/src/lib/libbsp/shared/gpio.c                   | 14 ++++++++++----
     c/src/lib/libbsp/shared/include/gpio.h           | 10 +++++-----
     3 files changed, 16 insertions(+), 10 deletions(-)
    
    diff --git a/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c b/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c
    index bd37e67..a782d11 100644
    a b rtems_status_code rtems_gpio_bsp_clear(uint32_t bank, uint32_t pin) 
    9898  return RTEMS_SUCCESSFUL;
    9999}
    100100
    101 uint8_t rtems_gpio_bsp_get_value(uint32_t bank, uint32_t pin)
     101uint32_t rtems_gpio_bsp_get_value(uint32_t bank, uint32_t pin)
    102102{
    103103  return (BCM2835_REG(BCM2835_GPIO_GPLEV0) & (1 << pin));
    104104}
  • c/src/lib/libbsp/shared/gpio.c

    diff --git a/c/src/lib/libbsp/shared/gpio.c b/c/src/lib/libbsp/shared/gpio.c
    index a87b39f..e409174 100644
    a b rtems_status_code rtems_gpio_clear(uint32_t pin_number) 
    12501250  return sc;
    12511251}
    12521252
    1253 uint8_t rtems_gpio_get_value(uint32_t pin_number)
     1253int rtems_gpio_get_value(uint32_t pin_number)
    12541254{
    12551255  uint32_t bank;
    12561256  uint32_t pin;
    1257   int rv;
     1257  uint32_t rv;
    12581258
    12591259  if ( pin_number < 0 || pin_number >= BSP_GPIO_PIN_COUNT ) {
    12601260    return -1;
    uint8_t rtems_gpio_get_value(uint32_t pin_number) 
    12801280
    12811281  rv = rtems_gpio_bsp_get_value(bank, pin);
    12821282
    1283   if ( gpio_pin_state[pin_number].logic_invert && rv > 0 ) {
     1283  if ( rv == 0xDEADBEEF ) {
     1284    RELEASE_LOCK(gpio_bank_state[bank].lock);
     1285
     1286    return -1;
     1287  }
     1288
     1289  if ( gpio_pin_state[pin_number].logic_invert ) {
    12841290    RELEASE_LOCK(gpio_bank_state[bank].lock);
    12851291
    12861292    return !rv;
    uint8_t rtems_gpio_get_value(uint32_t pin_number) 
    12881294
    12891295  RELEASE_LOCK(gpio_bank_state[bank].lock);
    12901296
    1291   return ( rv > 0 ) ? 1 : rv;
     1297  return rv > 0;
    12921298}
    12931299
    12941300rtems_status_code rtems_gpio_request_pin(
  • c/src/lib/libbsp/shared/include/gpio.h

    diff --git a/c/src/lib/libbsp/shared/include/gpio.h b/c/src/lib/libbsp/shared/include/gpio.h
    index b2deb1e..af6f8c1 100644
    a b extern rtems_status_code rtems_gpio_clear(uint32_t pin_number); 
    444444 *         logical value.
    445445 * @retval -1 Pin number is invalid, or not a digital input pin.
    446446 */
    447 extern uint8_t rtems_gpio_get_value(uint32_t pin_number);
     447extern int rtems_gpio_get_value(uint32_t pin_number);
    448448
    449449/**
    450450 * @brief Requests multiple GPIO pin configurations. If the BSP provides
    extern rtems_status_code rtems_gpio_bsp_clear(uint32_t bank, uint32_t pin); 
    802802 * @param[in] bank GPIO bank number.
    803803 * @param[in] pin GPIO pin number within the given bank.
    804804 *
    805  * @retval The function must return 0 or 1 depending on the pin current
    806  *         logical value.
    807  * @retval -1 Could not read the pin level.
     805 * @retval The function must return 0 if the pin level is a logical low,
     806 *         or non zero if it has a logical high.
     807 * @retval 0xDEADBEEF Could not read the pin level.
    808808 */
    809 extern uint8_t rtems_gpio_bsp_get_value(uint32_t bank, uint32_t pin);
     809extern uint32_t rtems_gpio_bsp_get_value(uint32_t bank, uint32_t pin);
    810810
    811811/**
    812812 * @brief Assigns the digital input function to the given pin.