source: rtems/c/src/lib/libbsp/arm/stm32f4/startup/rcc.c @ 78c9fe8

5
Last change on this file since 78c9fe8 was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 * Copyright (c) 2012 Sebastian Huber.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Obere Lagerstr. 30
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#include <bsp/rcc.h>
16#include <bsp/stm32f4.h>
17
18#include <rtems.h>
19
20static void rcc_set(
21  stm32f4_rcc_index index,
22  bool set,
23  volatile uint32_t *regs
24)
25{
26  int reg = index >> 5;
27  uint32_t one = 1;
28  uint32_t bit = one << (index & 0x1f);
29  rtems_interrupt_level level;
30  uint32_t val;
31
32  rtems_interrupt_disable(level);
33  val = regs [reg];
34  if (set) {
35    val |= bit;
36  } else {
37    val &= ~bit;
38  }
39  regs [reg] = val;
40  rtems_interrupt_enable(level);
41}
42
43void stm32f4_rcc_reset(stm32f4_rcc_index index)
44{
45  stm32f4_rcc_set_reset(index, true);
46  stm32f4_rcc_set_reset(index, false);
47}
48
49void stm32f4_rcc_set_reset(stm32f4_rcc_index index, bool set)
50{
51  volatile stm32f4_rcc *rcc = STM32F4_RCC;
52
53#ifdef STM32F4_FAMILY_F4XXXX
54  rcc_set(index, set, &rcc->ahbrstr [0]);
55#endif/* STM32F4_FAMILY_F4XXXX */
56#ifdef STM32F4_FAMILY_F10XXX
57  /* The first register is missing for the reset-block */
58  rcc_set(index, set, &rcc->cir);
59#endif /* STM32F4_FAMILY_F10XXX */
60}
61
62void stm32f4_rcc_set_clock(stm32f4_rcc_index index, bool set)
63{
64  volatile stm32f4_rcc *rcc = STM32F4_RCC;
65
66  rcc_set(index, set, &rcc->ahbenr [0]);
67}
68
69#ifdef STM32F4_FAMILY_F4XXXX
70void stm32f4_rcc_set_low_power_clock(stm32f4_rcc_index index, bool set)
71{
72  volatile stm32f4_rcc *rcc = STM32F4_RCC;
73
74  rcc_set(index, set, &rcc->ahblpenr [0]);
75}
76#endif /* STM32F4_FAMILY_F4XXXX */
Note: See TracBrowser for help on using the repository browser.