Add test in common headers for improper inclusion of such files in application.

(prevents inclusion and also issues warning)
Changes to some source files to remove references to common headers.
Changes to rng.h to make guard symbols the same in f2 and f4.
This commit is contained in:
Ken Sarkies 2013-03-07 18:35:04 +10:30
parent e2022f5884
commit a9a85f080b
23 changed files with 128 additions and 26 deletions

View File

@ -23,8 +23,11 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>. * along with this library. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA CRC.H */ /* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA CRC.H
The order of header inclusion is important. crc.h includes the device
specific memorymap.h header before including this header file.*/
#ifdef LIBOPENCM3_CRC_H
#ifndef LIBOPENCM3_CRC_COMMON_ALL_H #ifndef LIBOPENCM3_CRC_COMMON_ALL_H
#define LIBOPENCM3_CRC_COMMON_ALL_H #define LIBOPENCM3_CRC_COMMON_ALL_H
@ -87,3 +90,7 @@ u32 crc_calculate_block(u32 *datap, int size);
END_DECLS END_DECLS
#endif #endif
#else
#warning "crc_common_all.h should not be included explicitly, only via crc.h"
#endif

View File

@ -25,6 +25,11 @@
/**@{*/ /**@{*/
/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA DAC.H
The order of header inclusion is important. dac.h includes the device
specific memorymap.h header before including this header file.*/
#ifdef LIBOPENCM3_DAC_H
#ifndef LIBOPENCM3_DAC_COMMON_ALL_H #ifndef LIBOPENCM3_DAC_COMMON_ALL_H
#define LIBOPENCM3_DAC_COMMON_ALL_H #define LIBOPENCM3_DAC_COMMON_ALL_H
@ -403,5 +408,9 @@ void dac_software_trigger(data_channel dac_channel);
END_DECLS END_DECLS
#endif #endif
#else
#warning "dac_common_all.h should not be included explicitly, only via dac.h"
#endif
/**@}*/ /**@}*/

View File

@ -27,6 +27,11 @@
/**@{*/ /**@{*/
/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA DMA.H
The order of header inclusion is important. dma.h includes the device
specific memorymap.h header before including this header file.*/
#ifdef LIBOPENCM3_DMA_H
#ifndef LIBOPENCM3_DMA_COMMON_F13_H #ifndef LIBOPENCM3_DMA_COMMON_F13_H
#define LIBOPENCM3_DMA_COMMON_F13_H #define LIBOPENCM3_DMA_COMMON_F13_H
@ -390,5 +395,9 @@ void dma_set_number_of_data(u32 dma, u8 channel, u16 number);
END_DECLS END_DECLS
#endif #endif
#else
#warning "dma_common_f13.h should not be included explicitly, only via dma.h"
#endif
/**@}*/ /**@}*/

View File

@ -24,8 +24,11 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>. * along with this library. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA DMA.H */ /* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA DMA.H
The order of header inclusion is important. dma.h includes the device
specific memorymap.h header before including this header file.*/
#ifdef LIBOPENCM3_DMA_H
#ifndef LIBOPENCM3_DMA_COMMON_F24_H #ifndef LIBOPENCM3_DMA_COMMON_F24_H
#define LIBOPENCM3_DMA_COMMON_F24_H #define LIBOPENCM3_DMA_COMMON_F24_H
@ -605,4 +608,7 @@ void dma_set_number_of_data(u32 dma, u8 stream, u16 number);
END_DECLS END_DECLS
/**@}*/ /**@}*/
#endif #endif
#else
#warning "dma_common_f24.h should not be included explicitly, only via dma.h"
#endif

View File

@ -25,8 +25,11 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>. * along with this library. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA GPIO.H */ /* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA GPIO.H
The order of header inclusion is important. gpio.h includes the device
specific memorymap.h header before including this header file.*/
#if defined (LIBOPENCM3_GPIO_H) || defined (LIBOPENCM3_GPIO_COMMON_F24_H)
#ifndef LIBOPENCM3_GPIO_COMMON_ALL_H #ifndef LIBOPENCM3_GPIO_COMMON_ALL_H
#define LIBOPENCM3_GPIO_COMMON_ALL_H #define LIBOPENCM3_GPIO_COMMON_ALL_H
@ -79,4 +82,7 @@ END_DECLS
/**@}*/ /**@}*/
#endif #endif
#else
#warning "gpio_common_all.h should not be included explicitly, only via gpio.h"
#endif

View File

@ -24,8 +24,11 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>. * along with this library. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA GPIO.H */ /* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA GPIO.H
The order of header inclusion is important. gpio.h includes the device
specific memorymap.h header before including this header file.*/
#ifdef LIBOPENCM3_GPIO_H
#ifndef LIBOPENCM3_GPIO_COMMON_F24_H #ifndef LIBOPENCM3_GPIO_COMMON_F24_H
#define LIBOPENCM3_GPIO_COMMON_F24_H #define LIBOPENCM3_GPIO_COMMON_F24_H
@ -287,4 +290,7 @@ void gpio_set_af(u32 gpioport, u8 alt_func_num, u16 gpios);
END_DECLS END_DECLS
/**@}*/ /**@}*/
#endif #endif
#else
#warning "gpio_common_f24.h should not be included explicitly, only via gpio.h"
#endif

View File

@ -23,8 +23,11 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>. * along with this library. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA I2C.H */ /* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA I2C.H
The order of header inclusion is important. i2c.h includes the device
specific memorymap.h header before including this header file.*/
#if defined (LIBOPENCM3_I2C_H) || defined (LIBOPENCM3_I2C_COMMON_F24_H)
#ifndef LIBOPENCM3_I2C_COMMON_ALL_H #ifndef LIBOPENCM3_I2C_COMMON_ALL_H
#define LIBOPENCM3_I2C_COMMON_ALL_H #define LIBOPENCM3_I2C_COMMON_ALL_H
@ -382,6 +385,9 @@ void i2c_clear_dma_last_transfer(u32 i2c);
END_DECLS END_DECLS
#endif
#else
#warning "i2c_common_all.h should not be included explicitly, only via i2c.h"
#endif #endif
/**@}*/ /**@}*/

View File

@ -23,8 +23,11 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>. * along with this library. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA I2C.H */ /* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA I2C.H
The order of header inclusion is important. i2c.h includes the device
specific memorymap.h header before including this header file.*/
#ifdef LIBOPENCM3_I2C_H
#ifndef LIBOPENCM3_I2C_COMMON_F24_H #ifndef LIBOPENCM3_I2C_COMMON_F24_H
#define LIBOPENCM3_I2C_COMMON_F24_H #define LIBOPENCM3_I2C_COMMON_F24_H
@ -37,3 +40,6 @@
/**@}*/ /**@}*/
#endif #endif
#else
#warning "i2c_common_f24.h should not be included explicitly, only via i2c.h"
#endif

View File

@ -22,8 +22,11 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>. * along with this library. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA IWDG.H */ /* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA IWDG.H
The order of header inclusion is important. iwdg.h includes the device
specific memorymap.h header before including this header file.*/
#ifdef LIBOPENCM3_IWDG_H
#ifndef LIBOPENCM3_IWDG_COMMON_ALL_H #ifndef LIBOPENCM3_IWDG_COMMON_ALL_H
#define LIBOPENCM3_IWDG_COMMON_ALL_H #define LIBOPENCM3_IWDG_COMMON_ALL_H
@ -108,6 +111,9 @@ void iwdg_reset(void);
END_DECLS END_DECLS
#endif
#else
#warning "iwdg_common_all.h should not be included explicitly, only via iwdg.h"
#endif #endif
/**@}*/ /**@}*/

View File

@ -23,8 +23,11 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>. * along with this library. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA PWR.H */ /* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA PWR.H
The order of header inclusion is important. pwr.h includes the device
specific memorymap.h header before including this header file.*/
#ifdef LIBOPENCM3_PWR_H
#ifndef LIBOPENCM3_PWR_COMMON_ALL_H #ifndef LIBOPENCM3_PWR_COMMON_ALL_H
#define LIBOPENCM3_PWR_COMMON_ALL_H #define LIBOPENCM3_PWR_COMMON_ALL_H
@ -121,3 +124,7 @@ END_DECLS
/**@}*/ /**@}*/
#endif #endif
#else
#warning "pwr_common_all.h should not be included explicitly, only via pwr.h"
#endif

View File

@ -16,6 +16,11 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>. * along with this library. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA RNG.H
The order of header inclusion is important. rng.h includes the device
specific memorymap.h header before including this header file.*/
#ifdef LIBOPENCM3_RNG_H
#ifndef LIBOPENCM3_RNG_COMMON_F24_H #ifndef LIBOPENCM3_RNG_COMMON_F24_H
#define LIBOPENCM3_RNG_COMMON_F24_H #define LIBOPENCM3_RNG_COMMON_F24_H
@ -59,3 +64,7 @@
#define RNG_SR_SEIS (1 << 6) #define RNG_SR_SEIS (1 << 6)
#endif #endif
#else
#warning "rng_common_f24.h should not be included explicitly, only via rng.h"
#endif

View File

@ -22,8 +22,6 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>. * along with this library. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA RTC.H */
/* /*
* This covers the "version 2" RTC peripheral. This is completely different * This covers the "version 2" RTC peripheral. This is completely different
* to the v1 RTC periph on the F1 series devices. It has BCD counters, with * to the v1 RTC periph on the F1 series devices. It has BCD counters, with
@ -32,6 +30,11 @@
* only support a subset. * only support a subset.
*/ */
/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA RTC.H
The order of header inclusion is important. rtc.h includes the device
specific memorymap.h header before including this header file.*/
#ifdef LIBOPENCM3_RTC_H
#ifndef LIBOPENCM3_RTC2_H #ifndef LIBOPENCM3_RTC2_H
#define LIBOPENCM3_RTC2_H #define LIBOPENCM3_RTC2_H
@ -316,4 +319,8 @@ END_DECLS
/**@}*/ /**@}*/
#endif /* RTC2_H */ #endif /* RTC2_H */
#else
#warning "rtc_common_bcd.h should not be included explicitly, only via rtc.h"
#endif

View File

@ -23,8 +23,11 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>. * along with this library. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA SPI.H */ /* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA SPI.H
The order of header inclusion is important. spi.h includes the device
specific memorymap.h header before including this header file.*/
#if defined (LIBOPENCM3_SPI_H) || defined (LIBOPENCM3_SPI_COMMON_F24_H)
#ifndef LIBOPENCM3_SPI_COMMON_ALL_H #ifndef LIBOPENCM3_SPI_COMMON_ALL_H
#define LIBOPENCM3_SPI_COMMON_ALL_H #define LIBOPENCM3_SPI_COMMON_ALL_H
@ -402,3 +405,7 @@ END_DECLS
/**@}*/ /**@}*/
#endif #endif
#else
#warning "spi_common_all.h should not be included explicitly, only via spi.h"
#endif

View File

@ -22,8 +22,11 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>. * along with this library. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA SPI.H */ /* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA SPI.H
The order of header inclusion is important. spi.h includes the device
specific memorymap.h header before including this header file.*/
#ifdef LIBOPENCM3_SPI_H
#ifndef LIBOPENCM3_SPI_COMMON_F24_H #ifndef LIBOPENCM3_SPI_COMMON_F24_H
#define LIBOPENCM3_SPI_COMMON_F24_H #define LIBOPENCM3_SPI_COMMON_F24_H
@ -49,6 +52,9 @@
/* TIFRFE: TI frame format error */ /* TIFRFE: TI frame format error */
#define SPI_SR_TIFRFE (1 << 8) #define SPI_SR_TIFRFE (1 << 8)
#endif
#else
#warning "spi_common_f24.h should not be included explicitly, only via spi.h"
#endif #endif
/**@}*/ /**@}*/

View File

@ -25,8 +25,11 @@
/**@{*/ /**@{*/
/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA SPI.H */ /* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA USART.H
The order of header inclusion is important. usart.h includes the device
specific memorymap.h header before including this header file.*/
#if defined (LIBOPENCM3_USART_H) || defined (LIBOPENCM3_USART_COMMON_F24_H)
#ifndef LIBOPENCM3_USART_COMMON_ALL_H #ifndef LIBOPENCM3_USART_COMMON_ALL_H
#define LIBOPENCM3_USART_COMMON_ALL_H #define LIBOPENCM3_USART_COMMON_ALL_H
@ -370,6 +373,9 @@ bool usart_get_interrupt_source(u32 usart, u32 flag);
END_DECLS END_DECLS
#endif
#else
#warning "usart_common_all.h should not be included explicitly, only via usart.h"
#endif #endif
/**@}*/ /**@}*/

View File

@ -24,8 +24,11 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>. * along with this library. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA SPI.H */ /* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA USART.H
The order of header inclusion is important. usart.h includes the device
specific memorymap.h header before including this header file.*/
#ifdef LIBOPENCM3_USART_H
#ifndef LIBOPENCM3_USART_COMMON_F24_H #ifndef LIBOPENCM3_USART_COMMON_F24_H
#define LIBOPENCM3_USART_COMMON_F24_H #define LIBOPENCM3_USART_COMMON_F24_H
@ -69,3 +72,7 @@
#define USART_CR3_ONEBIT (1 << 11) #define USART_CR3_ONEBIT (1 << 11)
#endif #endif
#else
#warning "usart_common_f24.h should not be included explicitly, only via usart.h"
#endif

View File

@ -15,8 +15,8 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>. * along with this library. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef LIBOPENCM3_RNG_F2_H #ifndef LIBOPENCM3_RNG_H
#define LIBOPENCM3_RNG_F2_H #define LIBOPENCM3_RNG_H
#include <libopencm3/stm32/memorymap.h> #include <libopencm3/stm32/memorymap.h>
#include <libopencm3/stm32/common/rng_common_f24.h> #include <libopencm3/stm32/common/rng_common_f24.h>

View File

@ -15,8 +15,8 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>. * along with this library. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef LIBOPENCM3_RNG_F4_H #ifndef LIBOPENCM3_RNG_H
#define LIBOPENCM3_RNG_F4_H #define LIBOPENCM3_RNG_H
#include <libopencm3/stm32/memorymap.h> #include <libopencm3/stm32/memorymap.h>
#include <libopencm3/stm32/common/rng_common_f24.h> #include <libopencm3/stm32/common/rng_common_f24.h>

View File

@ -68,7 +68,6 @@ Example 2: Digital input on port C12 with pullup
/**@{*/ /**@{*/
#include <libopencm3/stm32/common/gpio_common_all.h>
#include <libopencm3/stm32/gpio.h> #include <libopencm3/stm32/gpio.h>
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/

View File

@ -73,7 +73,6 @@ LGPL License Terms @ref lgpl_license
*/ */
#include <libopencm3/stm32/gpio.h> #include <libopencm3/stm32/gpio.h>
#include <libopencm3/stm32/common/gpio_common_all.h>
/**@{*/ /**@{*/

View File

@ -29,5 +29,3 @@ LGPL License Terms @ref lgpl_license
*/ */
#include <libopencm3/stm32/gpio.h> #include <libopencm3/stm32/gpio.h>
#include <libopencm3/stm32/common/gpio_common_f24.h>

View File

@ -29,5 +29,3 @@ LGPL License Terms @ref lgpl_license
*/ */
#include <libopencm3/stm32/gpio.h> #include <libopencm3/stm32/gpio.h>
#include <libopencm3/stm32/common/gpio_common_f24.h>

View File

@ -29,5 +29,3 @@ LGPL License Terms @ref lgpl_license
*/ */
#include <libopencm3/stm32/gpio.h> #include <libopencm3/stm32/gpio.h>
#include <libopencm3/stm32/common/gpio_common_all.h>