summaryrefslogtreecommitdiffstats
path: root/bsps/arm/lpc176x/include/bsp/system-clocks.h
blob: 26087ff3e9566d4d9fcf39d4240829bfc8484be1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
 * @file
 *
 * @ingroup lpc176x_clocks
 *
 * @brief System clocks.
 */

/*
 * Copyright (c) 2008, 2009
 * embedded brains GmbH
 * Obere Lagerstr. 30
 * D-82178 Puchheim
 * Germany
 * <rtems@embedded-brains.de>
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rtems.org/license/LICENSE.
 */

#ifndef LIBBSP_ARM_LPC176X_SYSTEM_CLOCKS_H
#define LIBBSP_ARM_LPC176X_SYSTEM_CLOCKS_H

#include <bsp/lpc176x.h>
#include <bsp/timer-defs.h>

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/**
 * @defgroup lpc176x_clock System Clocks
 *
 * @ingroup lpc176x
 *
 * @brief System clocks.
 *
 * @{
 */

/**
 * @brief Initializes the standard timer.
 *
 * This function uses Timer 1.
 */
void lpc176x_timer_initialize( void );

/**
 * @brief Returns current standard timer value in CPU clocks.
 *
 * @return This function uses Timer 1.
 */
static inline unsigned lpc176x_get_timer1( void )
{
  return LPC176X_T1TC;
}

/**
 * @brief Delay for @a us micro seconds.
 *
 * This function uses the standard timer and assumes that the CPU
 * frequency is in whole MHz numbers.  The delay value @a us will be
 * converted to CPU ticks and there is no protection against integer
 * overflows.
 *
 * This function uses Timer 1.
 */
void lpc176x_micro_seconds_delay( unsigned us );

/**
 * @brief Returns the PLL output clock frequency in [Hz].
 *
 * @return Returns zero in case of an unexpected PLL input frequency.
 */
unsigned lpc176x_pllclk( void );

/**
 * @brief Returns the CPU clock frequency in [Hz].
 *
 * @return Returns zero in case of an unexpected PLL input frequency.
 */
unsigned lpc176x_cclk( void );

/** @} */

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* LIBBSP_ARM_LPC176X_SYSTEM_CLOCKS_H */