diff --git a/include/libopencm3/stm32/common/rng_common_f24.h b/include/libopencm3/stm32/common/rng_common_v1.h similarity index 93% rename from include/libopencm3/stm32/common/rng_common_f24.h rename to include/libopencm3/stm32/common/rng_common_v1.h index dd7efa89..e0c26a81 100644 --- a/include/libopencm3/stm32/common/rng_common_f24.h +++ b/include/libopencm3/stm32/common/rng_common_v1.h @@ -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 */ diff --git a/include/libopencm3/stm32/f2/rng.h b/include/libopencm3/stm32/f2/rng.h index 6c3def69..09d014d1 100644 --- a/include/libopencm3/stm32/f2/rng.h +++ b/include/libopencm3/stm32/f2/rng.h @@ -18,6 +18,6 @@ #ifndef LIBOPENCM3_RNG_H #define LIBOPENCM3_RNG_H -#include +#include #endif diff --git a/include/libopencm3/stm32/f4/rng.h b/include/libopencm3/stm32/f4/rng.h index 6c3def69..09d014d1 100644 --- a/include/libopencm3/stm32/f4/rng.h +++ b/include/libopencm3/stm32/f4/rng.h @@ -18,6 +18,6 @@ #ifndef LIBOPENCM3_RNG_H #define LIBOPENCM3_RNG_H -#include +#include #endif diff --git a/include/libopencm3/stm32/rng.h b/include/libopencm3/stm32/rng.h index 5821062c..d29650a0 100644 --- a/include/libopencm3/stm32/rng.h +++ b/include/libopencm3/stm32/rng.h @@ -20,7 +20,9 @@ #include #include -#if defined(STM32F4) +#if defined(STM32F2) +# include +#elif defined(STM32F4) # include #else # error "stm32 family not defined." diff --git a/lib/stm32/common/rng_common_v1.c b/lib/stm32/common/rng_common_v1.c new file mode 100644 index 00000000..6808b683 --- /dev/null +++ b/lib/stm32/common/rng_common_v1.c @@ -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 . + */ + +#include + +/**@{*/ + +/** 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; +} + +/**@}*/ diff --git a/lib/stm32/f2/Makefile b/lib/stm32/f2/Makefile index cb989f2f..397e77a0 100644 --- a/lib/stm32/f2/Makefile +++ b/lib/stm32/f2/Makefile @@ -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 diff --git a/lib/stm32/f2/rng.c b/lib/stm32/f2/rng.c new file mode 100644 index 00000000..1b666d88 --- /dev/null +++ b/lib/stm32/f2/rng.c @@ -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 libopencm3 STM32F2xx RNG + +*/ + +/* + * 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 . + */ + +#include diff --git a/lib/stm32/f4/Makefile b/lib/stm32/f4/Makefile index a99413e6..c1d9e1b8 100644 --- a/lib/stm32/f4/Makefile +++ b/lib/stm32/f4/Makefile @@ -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 diff --git a/lib/stm32/f4/rng.c b/lib/stm32/f4/rng.c index 2f781760..9adcd75a 100644 --- a/lib/stm32/f4/rng.c +++ b/lib/stm32/f4/rng.c @@ -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 libopencm3 STM32F4xx RNG - * - * @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 libopencm3 STM32F4xx RNG + +*/ /* * This file is part of the libopencm3 project. @@ -32,21 +29,3 @@ */ #include - -/**@{*/ - -/** 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; -} - -/**@}*/