1 /*
2 * Copyright 2021 MindMotion Microelectronics Co., Ltd.
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8
9 #include "hal_common.h"
10 #include "hal_rcc.h"
11
RCC_EnableAHB1Periphs(uint32_t ahb1_periphs,bool enable)12 void RCC_EnableAHB1Periphs(uint32_t ahb1_periphs, bool enable)
13 {
14 (enable) ? (RCC->AHB1ENR |= ahb1_periphs) : (RCC->AHB1ENR &= ~ahb1_periphs);
15 }
16
RCC_EnableAHB2Periphs(uint32_t ahb2_periphs,bool enable)17 void RCC_EnableAHB2Periphs(uint32_t ahb2_periphs, bool enable)
18 {
19 (enable) ? (RCC->AHB2ENR |= ahb2_periphs) : (RCC->AHB2ENR &= ~ahb2_periphs);
20 }
21
RCC_EnableAHB3Periphs(uint32_t ahb3_periphs,bool enable)22 void RCC_EnableAHB3Periphs(uint32_t ahb3_periphs, bool enable)
23 {
24 (enable) ? (RCC->AHB3ENR |= ahb3_periphs) : (RCC->AHB3ENR &= ~ahb3_periphs);
25 }
26
RCC_EnableAPB1Periphs(uint32_t apb1_periphs,bool enable)27 void RCC_EnableAPB1Periphs(uint32_t apb1_periphs, bool enable)
28 {
29 (enable) ? (RCC->APB1ENR |= apb1_periphs) : (RCC->APB1ENR &= ~apb1_periphs);
30 }
31
RCC_EnableAPB2Periphs(uint32_t apb2_periphs,bool enable)32 void RCC_EnableAPB2Periphs(uint32_t apb2_periphs, bool enable)
33 {
34 (enable) ? (RCC->APB2ENR |= apb2_periphs) : (RCC->APB2ENR &= ~apb2_periphs);
35 }
36
RCC_ResetAHB1Periphs(uint32_t ahb1_periphs)37 void RCC_ResetAHB1Periphs(uint32_t ahb1_periphs)
38 {
39 RCC->AHB1RSTR |= ahb1_periphs;
40 RCC->AHB1RSTR &= ~ahb1_periphs;
41 }
42
RCC_ResetAHB2Periphs(uint32_t ahb2_periphs)43 void RCC_ResetAHB2Periphs(uint32_t ahb2_periphs)
44 {
45 RCC->AHB2RSTR |= ahb2_periphs;
46 RCC->AHB2RSTR &= ~ahb2_periphs;
47 }
48
RCC_ResetAHB3Periphs(uint32_t ahb3_periphs)49 void RCC_ResetAHB3Periphs(uint32_t ahb3_periphs)
50 {
51 RCC->AHB3RSTR |= ahb3_periphs;
52 RCC->AHB3RSTR &= ~ahb3_periphs;
53 }
54
RCC_ResetAPB1Periphs(uint32_t apb1_periphs)55 void RCC_ResetAPB1Periphs(uint32_t apb1_periphs)
56 {
57 RCC->APB1RSTR |= apb1_periphs;
58 RCC->APB1RSTR &= ~apb1_periphs;
59 }
60
RCC_ResetAPB2Periphs(uint32_t apb2_periphs)61 void RCC_ResetAPB2Periphs(uint32_t apb2_periphs)
62 {
63 RCC->APB2RSTR |= apb2_periphs;
64 RCC->APB2RSTR &= ~apb2_periphs;
65 }
66
RCC_MCOConf(RCC_MCO_Type source)67 void RCC_MCOConf(RCC_MCO_Type source)
68 {
69 RCC->CFGR = (RCC->CFGR & ~RCC_CFGR_MCO_MASK) | RCC_CFGR_MCO(source);
70 }
71
72 /* EOF. */
73