stm32:rng: f4 rng peripheral is common with at least f2

Pull it up as common code immediately. Rename to v1, extract to common
with a doxygen marker stubs, add to F2 makefiles.
This commit is contained in:
Karl Palsson 2017-01-12 22:23:31 +00:00
parent ac45247f60
commit 2476099f29
9 changed files with 97 additions and 39 deletions

View File

@ -25,8 +25,8 @@ specific memorymap.h header before including this header file.*/
/** @cond */
#ifdef LIBOPENCM3_RNG_H
/** @endcond */
#ifndef LIBOPENCM3_RNG_COMMON_F24_H
#define LIBOPENCM3_RNG_COMMON_F24_H
#ifndef LIBOPENCM3_RNG_V1_H
#define LIBOPENCM3_RNG_V1_H
/**@{*/
@ -80,7 +80,7 @@ END_DECLS
#endif
/** @cond */
#else
#warning "rng_common_f24.h should not be included explicitly, only via rng.h"
#warning "rng_common_v1.h should not be included explicitly, only via rng.h"
#endif
/** @endcond */

View File

@ -18,6 +18,6 @@
#ifndef LIBOPENCM3_RNG_H
#define LIBOPENCM3_RNG_H
#include <libopencm3/stm32/common/rng_common_f24.h>
#include <libopencm3/stm32/common/rng_common_v1.h>
#endif

View File

@ -18,6 +18,6 @@
#ifndef LIBOPENCM3_RNG_H
#define LIBOPENCM3_RNG_H
#include <libopencm3/stm32/common/rng_common_f24.h>
#include <libopencm3/stm32/common/rng_common_v1.h>
#endif

View File

@ -20,7 +20,9 @@
#include <libopencm3/cm3/common.h>
#include <libopencm3/stm32/memorymap.h>
#if defined(STM32F4)
#if defined(STM32F2)
# include <libopencm3/stm32/f2/rng.h>
#elif defined(STM32F4)
# include <libopencm3/stm32/f4/rng.h>
#else
# error "stm32 family not defined."

View File

@ -0,0 +1,44 @@
/** @addtogroup rng_file
*
* This library supports the random number generator peripheral (RNG) in the
* STM32F4 series of ARM Cortex Microcontrollers by ST Microelectronics.
*
* LGPL License Terms @ref lgpl_license
*/
/*
* This file is part of the libopencm3 project.
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <libopencm3/stm32/rng.h>
/**@{*/
/** Disable the Random Number Generator peripheral.
*/
void rng_disable(void)
{
RNG_CR &= ~RNG_CR_RNGEN;
}
/** Enable the Random Number Generator peripheral.
*/
void rng_enable(void)
{
RNG_CR |= RNG_CR_RNGEN;
}
/**@}*/

View File

@ -44,6 +44,7 @@ OBJS += crc_common_all.o dac_common_all.o dma_common_f24.o \
timer_common_f24.o usart_common_all.o usart_common_f124.o \
flash_common_f234.o flash_common_f24.o hash_common_f24.o \
crypto_common_f24.o exti_common_all.o rcc_common_all.o
OBJS += rng_common_v1.o
OBJS += usb.o usb_standard.o usb_control.o usb_fx07_common.o \
usb_f107.o usb_f207.o usb_msc.o

31
lib/stm32/f2/rng.c Normal file
View File

@ -0,0 +1,31 @@
/* This file is used for documentation purposes. It does not need
to be compiled. All source code is in the common area.
If there is any device specific code required it can be included here,
in which case this file must be added to the compile list. */
/** @defgroup rng_file RNG
@ingroup STM32F2xx
@brief <b>libopencm3 STM32F2xx RNG</b>
*/
/*
* This file is part of the libopencm3 project.
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <libopencm3/stm32/rng.h>

View File

@ -39,7 +39,7 @@ TGT_CFLAGS += $(DEBUG_FLAGS)
ARFLAGS = rcs
OBJS = adc.o adc_common_v1.o can.o desig.o gpio.o pwr.o rcc.o \
rtc.o crypto.o rng.o
rtc.o crypto.o
OBJS += crc_common_all.o dac_common_all.o dma_common_f24.o \
gpio_common_all.o gpio_common_f0234.o i2c_common_all.o \
@ -49,6 +49,7 @@ OBJS += crc_common_all.o dac_common_all.o dma_common_f24.o \
usart_common_f124.o flash_common_f234.o flash_common_f24.o \
hash_common_f24.o crypto_common_f24.o exti_common_all.o \
rcc_common_all.o
OBJS += rng_common_v1.o
OBJS += usb.o usb_standard.o usb_control.o usb_fx07_common.o \
usb_f107.o usb_f207.o usb_msc.o

View File

@ -1,18 +1,15 @@
/* This file is used for documentation purposes. It does not need
to be compiled. All source code is in the common area.
If there is any device specific code required it can be included here,
in which case this file must be added to the compile list. */
/** @defgroup rng_file RNG
*
* @ingroup STM32F4xx
*
* @brief <b>libopencm3 STM32F4xx RNG</b>
*
* @version 1.0.0
*
* @date 25 March 2015
*
* This library supports the random number generator peripheral (RNG) in the
* STM32F4 series of ARM Cortex Microcontrollers by ST Microelectronics.
*
*LGPL License Terms @ref lgpl_license
*/
@ingroup STM32F4xx
@brief <b>libopencm3 STM32F4xx RNG</b>
*/
/*
* This file is part of the libopencm3 project.
@ -32,21 +29,3 @@
*/
#include <libopencm3/stm32/rng.h>
/**@{*/
/** Disable the Random Number Generator peripheral.
*/
void rng_disable(void)
{
RNG_CR &= ~RNG_CR_RNGEN;
}
/** Enable the Random Number Generator peripheral.
*/
void rng_enable(void)
{
RNG_CR |= RNG_CR_RNGEN;
}
/**@}*/