source: rtems/c/src/lib/libbsp/arm/stm32f4/startup/rcc.c @ 7be19f8

4.115
Last change on this file since 7be19f8 was 7be19f8, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 15, 2012 at 7:15:22 PM

bsp/stm32f4: API changes

  • Property mode set to 100644
File size: 1.3 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.com/license/LICENSE.
13 */
14
15#include <bsp/rcc.h>
16
17#include <rtems.h>
18
19static void rcc_set(
20  stm32f4_rcc_index index,
21  bool set,
22  volatile uint32_t *regs
23)
24{
25  int reg = index >> 5;
26  uint32_t one = 1;
27  uint32_t bit = one << (index & 0x1f);
28  rtems_interrupt_level level;
29  uint32_t val;
30
31  rtems_interrupt_disable(level);
32  val = regs [reg];
33  if (set) {
34    val |= bit;
35  } else {
36    val &= ~bit;
37  }
38  regs [reg] = val;
39  rtems_interrupt_enable(level);
40}
41
42void stm32f4_rcc_reset(stm32f4_rcc_index index)
43{
44  stm32f4_rcc_set_reset(index, true);
45  stm32f4_rcc_set_reset(index, false);
46}
47
48void stm32f4_rcc_set_reset(stm32f4_rcc_index index, bool set)
49{
50  volatile stm32f4_rcc *rcc = STM32F4_RCC;
51
52  rcc_set(index, set, &rcc->ahbrstr [0]);
53}
54
55void stm32f4_rcc_set_clock(stm32f4_rcc_index index, bool set)
56{
57  volatile stm32f4_rcc *rcc = STM32F4_RCC;
58
59  rcc_set(index, set, &rcc->ahbenr [0]);
60}
61
62void stm32f4_rcc_set_low_power_clock(stm32f4_rcc_index index, bool set)
63{
64  volatile stm32f4_rcc *rcc = STM32F4_RCC;
65
66  rcc_set(index, set, &rcc->ahblpenr [0]);
67}
Note: See TracBrowser for help on using the repository browser.