[PATCH 11 minor addeum] arm/raspberrypi: GPIO - using RTEMS interrupt lock during BSP

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Sep 6 18:33:08 UTC 2016


The interrupt locks are simple interrupt disable/enable or spin locks. So, they always work.

----- Pavel Pisa <pisa at cmp.felk.cvut.cz> schrieb:
> 
> Locking can be used only when RTEMS reaches multitasking state
>   _System_state_Is_up( _System_state_Get() )
> ---
>  c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 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 6c01d62..f7c8c36 100644
> --- a/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c
> +++ b/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c
> @@ -19,6 +19,7 @@
>  #include <bsp/irq-generic.h>
>  #include <bsp/gpio.h>
>  #include <bsp/rpi-gpio.h>
> +#include <rtems/score/sysstate.h>
>  
>  #include <stdlib.h>
>  
> @@ -57,16 +58,21 @@ static rtems_status_code rpi_select_pin_function(
>    /* Calculate the pin function select register address. */
>    volatile uint32_t *pin_addr = (uint32_t *) BCM2835_GPIO_REGS_BASE +
>                                               (pin / 10);
> -  uint32_t reg_old;
>    uint32_t reg_new;
> +  int use_locks;
>    rtems_interrupt_lock_context lock_context;
>  
> -  rtems_interrupt_lock_acquire(&rtems_gpio_bsp_lock, &lock_context);
> -  reg_new = reg_old = *pin_addr;
> +  use_locks = _System_state_Is_up( _System_state_Get() );
> +  if ( use_locks )
> +    rtems_interrupt_lock_acquire(&rtems_gpio_bsp_lock, &lock_context);
> +
> +  reg_new = *pin_addr;
>    reg_new &= ~SELECT_PIN_FUNCTION(RPI_ALT_FUNC_MASK, pin);
>    reg_new |= SELECT_PIN_FUNCTION(type, pin);
>    *pin_addr = reg_new;
> -  rtems_interrupt_lock_release(&rtems_gpio_bsp_lock, &lock_context);
> +
> +  if ( use_locks )
> +    rtems_interrupt_lock_release(&rtems_gpio_bsp_lock, &lock_context);
>  
>    return RTEMS_SUCCESSFUL;
>  }
> -- 
> 1.9.1
> 
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the devel mailing list