source: rtems/c/src/lib/libbsp/arm/lpc176x/irq/irq.c @ 19260fb

4.115
Last change on this file since 19260fb was 19260fb, checked in by Martin Boretto <martin.boretto@…>, on 06/09/14 at 14:27:18

bsp/lpc176x: New BSP

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup bsp_interrupt
5 *
6 * @brief LPC176X interrupt support.
7 */
8
9/*
10 * Copyright (c) 2008-2012 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.com/license/LICENSE.
21 */
22
23#include <rtems/score/armv4.h>
24#include <rtems/score/armv7m.h>
25
26#include <bsp.h>
27#include <bsp/irq.h>
28#include <bsp/irq-generic.h>
29#include <bsp/lpc176x.h>
30#include <bsp/linker-symbols.h>
31
32/**
33 * @brief Checks if the current interrupt vector lenght is valid or not.
34 *
35 * @param  vector The current interrupt vector lenght .
36 * @return  TRUE if valid.
37 *          FALSE otherwise.
38 */
39static inline bool lpc176x_irq_is_valid( const rtems_vector_number vector )
40{
41  return vector <= BSP_INTERRUPT_VECTOR_MAX;
42}
43
44void lpc176x_irq_set_priority(
45  const rtems_vector_number vector,
46  unsigned                  priority
47)
48{
49  if ( lpc176x_irq_is_valid( vector ) ) {
50    if ( priority > LPC176X_IRQ_PRIORITY_VALUE_MAX ) {
51      priority = LPC176X_IRQ_PRIORITY_VALUE_MAX;
52    }
53
54    /* else implies that the priority is unlocked. Also,
55       there is nothing to do. */
56
57    _ARMV7M_NVIC_Set_priority( (int) vector, (int) ( priority << 3u ) );
58  }
59
60  /* else implies that the rtems vector number is invalid. Also,
61     there is nothing to do. */
62}
63
64unsigned lpc176x_irq_get_priority( const rtems_vector_number vector )
65{
66  unsigned priority;
67
68  if ( lpc176x_irq_is_valid( vector ) ) {
69    priority = (unsigned) ( _ARMV7M_NVIC_Get_priority( (int) vector ) >> 3u );
70  } else {
71    priority = LPC176X_IRQ_PRIORITY_VALUE_MIN - 1u;
72  }
73
74  return priority;
75}
Note: See TracBrowser for help on using the repository browser.