2020-02-15 22:09:55 +01:00
|
|
|
/* Reflow Oven Controller
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
|
|
|
|
*
|
|
|
|
* This file is part of the Reflow Oven Controller Project.
|
|
|
|
*
|
|
|
|
* The reflow oven controller is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* GDSII-Converter is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with the reflow oven controller project.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-02-03 19:19:31 +01:00
|
|
|
#ifndef __CLOCK_ENABLE_MANAGER_H__
|
|
|
|
#define __CLOCK_ENABLE_MANAGER_H__
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2020-02-12 21:00:35 +01:00
|
|
|
#include <stm-periph/stm32-gpio-macros.h>
|
2020-02-03 19:19:31 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The RCC Enable Manager uses static memory with a fixed maximum
|
|
|
|
*/
|
|
|
|
#define RCC_ENABLE_MANAGER_STATIC 1U
|
|
|
|
|
|
|
|
#if RCC_ENABLE_MANAGER_STATIC
|
2020-02-03 19:40:59 +01:00
|
|
|
#define RCC_ENABLE_MANAGER_COUNT 30U
|
2020-02-03 19:19:31 +01:00
|
|
|
#else
|
|
|
|
#error "RCC Enable Manager not yet implemented with dynamic memory"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Enable Clock for peripheral by setting the corresponding bit (@p bit_no) to one
|
|
|
|
*
|
|
|
|
* This function also keeps a enable count on each bit that is set, in order to allow nested enables/disables
|
|
|
|
*
|
|
|
|
* If there is no more space to track a new register bit in memory (either due to the static limit or due to no remaining heap space),
|
|
|
|
* the function still enables the peripheral clock but does not track it and returns -1
|
|
|
|
*
|
|
|
|
* @param rcc_enable_register
|
|
|
|
* @param bit_no
|
|
|
|
*
|
|
|
|
* @return 0 if successful
|
|
|
|
*/
|
2020-02-03 19:40:59 +01:00
|
|
|
int rcc_manager_enable_clock(volatile uint32_t *rcc_enable_register, uint8_t bit_no);
|
2020-02-03 19:19:31 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Disable clock for peripheral and decrement the enaböe-counter of that bit.
|
|
|
|
*
|
|
|
|
* If there is no bit entry in the counting table yet, teh peripheral clock is not disabled and error code
|
|
|
|
* -1 is returned.
|
|
|
|
*
|
|
|
|
* If the count reaches zero, the element is removed from the list to make room for new ones
|
|
|
|
*
|
|
|
|
* @param rcc_enable_register Register to disable the bit in
|
|
|
|
* @param bit_no Bit number (0 to 31) of the bit to disable
|
|
|
|
* @return 0 if successful
|
|
|
|
*/
|
2020-02-03 19:40:59 +01:00
|
|
|
int rcc_manager_disable_clock(volatile uint32_t *rcc_enable_register, uint8_t bit_no);
|
2020-02-03 19:19:31 +01:00
|
|
|
|
|
|
|
#endif /* __CLOCK_ENABLE_MANAGER_H__ */
|