cpu/stm32_common: added periph clk en/dis functions

pr/gpio
Hauke Petersen 7 years ago
parent 546aacd2ce
commit 462d156821

@ -0,0 +1,39 @@
/*
* Copyright (C) 2016 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup cpu_cortexm_common
* @{
*
* @file
* @brief Shared CPU specific function for the STM32 CPU family
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*
* @}
*/
#include "periph_cpu_common.h"
void periph_clk_en(uint8_t bus, uint32_t mask)
{
if (bus == APB1) {
RCC->APB1ENR |= mask;
} else {
RCC->APB2ENR |= mask;
}
}
void periph_clk_dis(uint8_t bus, uint32_t mask)
{
if (bus == APB1) {
RCC->APB1ENR &= ~(mask);
} else {
RCC->APB2ENR &= ~(mask);
}
}

@ -43,10 +43,26 @@ extern "C" {
* @brief Available peripheral buses
*/
enum {
APB1,
APB2
APB1, /**< APB1 bus */
APB2 /**< APB2 bus */
};
/**
* @brief Enable the given peripheral clock
*
* @param[in] bus bus the peripheral is connected to
* @param[in] mask bit in the RCC enable register
*/
void periph_clk_en(uint8_t bus, uint32_t mask);
/**
* @brief Disable the given peripheral clock
*
* @param[in] bus bus the peripheral is connected to
* @param[in] mask bit in the RCC enable register
*/
void periph_clk_dis(uint8_t bus, uint32_t mask);
#ifdef __cplusplus
}
#endif

Loading…
Cancel
Save