InES Hardware Abstraction Layer
hal_rcc.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2  * -- _____ ______ _____ -
3  * -- |_ _| | ____|/ ____| -
4  * -- | | _ __ | |__ | (___ Institute of Embedded Systems -
5  * -- | | | '_ \| __| \___ \ Zurich University of -
6  * -- _| |_| | | | |____ ____) | Applied Sciences -
7  * -- |_____|_| |_|______|_____/ 8401 Winterthur, Switzerland -
8  * ------------------------------------------------------------------------- */
18 /* Re-definition guard */
19 #ifndef _HAL_RCC_H
20 #define _HAL_RCC_H
21 
22 
23 /* User includes */
24 #include "hal_common.h"
25 
26 
27 /* -- Type definitions
28  * ------------------------------------------------------------------------- */
29 
34 typedef enum {
35  HAL_RCC_OSC_HSI = 0u,
36  HAL_RCC_OSC_HSE = 16u,
37  HAL_RCC_OSC_PLL = 24u,
38  HAL_RCC_OSC_PLLI2S = 26u,
39  HAL_RCC_OSC_PLLSAI = 28u
41 
42 
47 typedef enum {
48  HAL_RCC_HPRE_1 = 0u,
49  HAL_RCC_HPRE_2 = 8u,
50  HAL_RCC_HPRE_4 = 9u,
51  HAL_RCC_HPRE_8 = 10u,
52  HAL_RCC_HPRE_16 = 11u,
53  HAL_RCC_HPRE_64 = 12u,
54  HAL_RCC_HPRE_128 = 13u,
55  HAL_RCC_HPRE_256 = 14u,
56  HAL_RCC_HPRE_512 = 15u
58 
59 
64 typedef enum {
65  HAL_RCC_PPRE_2 = 4u,
66  HAL_RCC_PPRE_4 = 5u,
67  HAL_RCC_PPRE_8 = 6u,
68  HAL_RCC_PPRE_16 = 7u
70 
71 
76 typedef struct {
77  hal_rcc_osc_t source;
78  uint16_t n_factor;
79  uint8_t p_divider;
80  uint8_t q_divider;
81  uint8_t r_divider;
82  /* Only for main pll */
83  uint8_t m_divider;
85 
86 
91 typedef struct {
92  hal_rcc_osc_t osc;
93  hal_rcc_hpre_t hpre;
94  hal_rcc_ppre_t ppre1;
95  hal_rcc_ppre_t ppre2;
97 
98 
99 /* -- Public function declarations
100  * ------------------------------------------------------------------------- */
101 
105 void hal_rcc_reset(void);
106 
112 void hal_rcc_set_peripheral(hal_peripheral_t peripheral, hal_bool_t status)
113 __attribute__((deprecated("Please use XXX_ENABLE() or XXX_DISABLE().")));
114 
124 
132 
138 
139 
140 #endif
void hal_rcc_setup_pll(hal_rcc_osc_t pll, hal_rcc_pll_init_t init)
Configures the different pll settings. Don't forget to enable the pll after configuration.
void hal_rcc_set_peripheral(hal_peripheral_t peripheral, hal_bool_t status) __attribute__((deprecated("Please use XXX_ENABLE() or XXX_DISABLE().")))
Enables/Disables the defined periphery.
Initialization structure for system clock configuration.
Definition: hal_rcc.h:91
void hal_rcc_setup_clock(hal_rcc_clk_init_t init)
Configure the system clocks.
hal_rcc_ppre_t
Defines available divider for the advanced peripheral buses.
Definition: hal_rcc.h:64
hal_peripheral_t
Defines a peripheral.
Definition: hal_common.h:58
hal_rcc_hpre_t
Defines available divider for the advanced high-performance bus.
Definition: hal_rcc.h:47
Common #defines and typedefs.
hal_rcc_osc_t
Defines the different oscillators of the SoC.
Definition: hal_rcc.h:34
hal_bool_t
Often used TRUE / FALSE type.
Definition: hal_common.h:31
hal_bool_t hal_rcc_set_osc(hal_rcc_osc_t osc, hal_bool_t status)
Enables the defined clock source. If a pll is choosen, make sure the configured source clock is up an...
void hal_rcc_reset(void)
Resets all involved registers.
Initialization structure for pll configuration.
Definition: hal_rcc.h:76