From 17b2e87ba3ba3cc029a92f275f110e17249d59f7 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Thu, 30 Dec 2010 00:53:52 +0100 Subject: Factor out cm3/common.h and cm3/memorymap.h. --- HACKING | 2 +- examples/other/dogm128/dogm128.h | 2 +- include/cm3/common.h | 39 +++++++++++++++++++++++++++ include/cm3/memorymap.h | 58 ++++++++++++++++++++++++++++++++++++++++ include/libopenstm32.h | 2 +- include/libopenstm32/adc.h | 2 +- include/libopenstm32/bkp.h | 2 +- include/libopenstm32/can.h | 2 +- include/libopenstm32/common.h | 39 --------------------------- include/libopenstm32/crc.h | 2 +- include/libopenstm32/dma.h | 2 +- include/libopenstm32/ethernet.h | 2 +- include/libopenstm32/exti.h | 2 +- include/libopenstm32/flash.h | 2 +- include/libopenstm32/gpio.h | 2 +- include/libopenstm32/i2c.h | 2 +- include/libopenstm32/iwdg.h | 2 +- include/libopenstm32/memorymap.h | 35 +----------------------- include/libopenstm32/nvic.h | 2 +- include/libopenstm32/pwr.h | 2 +- include/libopenstm32/rcc.h | 2 +- include/libopenstm32/rtc.h | 2 +- include/libopenstm32/scb.h | 2 +- include/libopenstm32/spi.h | 2 +- include/libopenstm32/systick.h | 2 +- include/libopenstm32/timer.h | 2 +- include/libopenstm32/usart.h | 2 +- include/libopenstm32/usb.h | 2 +- include/libopenstm32/wwdg.h | 2 +- include/usb/usbstd.h | 2 +- lib/usb/usb_f103.c | 2 +- 31 files changed, 125 insertions(+), 100 deletions(-) create mode 100644 include/cm3/common.h create mode 100644 include/cm3/memorymap.h delete mode 100644 include/libopenstm32/common.h diff --git a/HACKING b/HACKING index 70f34fd..755b338 100644 --- a/HACKING +++ b/HACKING @@ -34,7 +34,7 @@ Development guidelines - All subsystem-specific function names should be prefixed with the subsystem name. For example, gpio_set_mode() or rcc_osc_on(). - - Please consistently use the short form types from , + - Please consistently use the short form types from , e.g. u8, u16, u32, and so on. - Variables that are used to store register values read from registers or diff --git a/examples/other/dogm128/dogm128.h b/examples/other/dogm128/dogm128.h index 4411852..5be924f 100644 --- a/examples/other/dogm128/dogm128.h +++ b/examples/other/dogm128/dogm128.h @@ -20,7 +20,7 @@ #ifndef DOGM128_H #define DOGM128_H -#include +#include #include #include diff --git a/include/cm3/common.h b/include/cm3/common.h new file mode 100644 index 0000000..dac67a8 --- /dev/null +++ b/include/cm3/common.h @@ -0,0 +1,39 @@ +/* + * This file is part of the libopenstm32 project. + * + * Copyright (C) 2009 Uwe Hermann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 this program. If not, see . + */ + +#ifndef CM3_COMMON_H +#define CM3_COMMON_H + +#include +#include + +/* Type definitions for shorter and nicer code */ +typedef int8_t s8; +typedef int16_t s16; +typedef int32_t s32; +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; + +/* Generic memory-mapped I/O accessor functions */ +#define MMIO8(addr) (*(volatile u8 *)(addr)) +#define MMIO16(addr) (*(volatile u16 *)(addr)) +#define MMIO32(addr) (*(volatile u32 *)(addr)) + +#endif diff --git a/include/cm3/memorymap.h b/include/cm3/memorymap.h new file mode 100644 index 0000000..ce0a85c --- /dev/null +++ b/include/cm3/memorymap.h @@ -0,0 +1,58 @@ +/* + * This file is part of the libopenstm32 project. + * + * Copyright (C) 2009 Uwe Hermann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 this program. If not, see . + */ + +#ifndef CM3_MEMORYMAP_H +#define CM3_MEMORYMAP_H + +/* --- ARM Cortex-M3 specific definitions ---------------------------------- */ + +/* Private peripheral bus - Internal */ +#define PPBI_BASE 0xE0000000 +#define ITM_BASE (PPBI_BASE + 0x0000) +#define DWT_BASE (PPBI_BASE + 0x1000) +#define FPB_BASE (PPBI_BASE + 0x2000) +/* PPBI_BASE + 0x3000 (0xE000 3000 - 0xE000 DFFF): Reserved */ +#define SCS_BASE (PPBI_BASE + 0xE000) +/* PPBI_BASE + 0xF000 (0xE000 F000 - 0xE003 FFFF): Reserved */ + +/* --- ITM: Instrumentation Trace Macrocell --- */ +/* TODO */ + +/* --- DWT: Data Watchpoint and Trace unit --- */ +/* TODO */ + +/* --- FPB: Flash Patch and Breakpoint unit --- */ +/* TODO */ + +/* --- SCS: System Control Space --- */ + +/* ITR: Interrupt Type Register */ +#define ITR_BASE (SCS_BASE + 0x0000) +/* SYS_TICK: System Timer */ +#define SYS_TICK_BASE (SCS_BASE + 0x0010) +/* NVIC: Nested Vector Interrupt Controller */ +#define NVIC_BASE (SCS_BASE + 0x0100) +/* SCB: System Control Block */ +#define SCB_BASE (SCS_BASE + 0x0D00) +/* STE: Software Trigger Interrupt Register */ +#define STIR_BASE (SCS_BASE + 0x0F00) +/* ID: ID space */ +#define ID_BASE (SCS_BASE + 0x0FD0) + +#endif diff --git a/include/libopenstm32.h b/include/libopenstm32.h index 2893cb5..a618590 100644 --- a/include/libopenstm32.h +++ b/include/libopenstm32.h @@ -21,7 +21,7 @@ #define LIBOPENSTM32_LIBOPENSTM32_H #include -#include +#include #include #include #include diff --git a/include/libopenstm32/adc.h b/include/libopenstm32/adc.h index 2497780..95d21b8 100644 --- a/include/libopenstm32/adc.h +++ b/include/libopenstm32/adc.h @@ -21,7 +21,7 @@ #define LIBOPENSTM32_ADC_H #include -#include +#include /* --- Convenience macros -------------------------------------------------- */ diff --git a/include/libopenstm32/bkp.h b/include/libopenstm32/bkp.h index 6d21a6b..10b9e70 100644 --- a/include/libopenstm32/bkp.h +++ b/include/libopenstm32/bkp.h @@ -21,7 +21,7 @@ #define LIBOPENSTM32_BKP_H #include -#include +#include /* --- BKP registers ------------------------------------------------------- */ diff --git a/include/libopenstm32/can.h b/include/libopenstm32/can.h index e00574b..74e7380 100644 --- a/include/libopenstm32/can.h +++ b/include/libopenstm32/can.h @@ -21,7 +21,7 @@ #define LIBOPENSTM32_CAN_H #include -#include +#include /* --- Convenience macros -------------------------------------------------- */ diff --git a/include/libopenstm32/common.h b/include/libopenstm32/common.h deleted file mode 100644 index 81b2f52..0000000 --- a/include/libopenstm32/common.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of the libopenstm32 project. - * - * Copyright (C) 2009 Uwe Hermann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 this program. If not, see . - */ - -#ifndef LIBOPENSTM32_COMMON_H -#define LIBOPENSTM32_COMMON_H - -#include -#include - -/* Type definitions for shorter and nicer code */ -typedef int8_t s8; -typedef int16_t s16; -typedef int32_t s32; -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; - -/* Generic memory-mapped I/O accessor functions */ -#define MMIO8(addr) (*(volatile u8 *)(addr)) -#define MMIO16(addr) (*(volatile u16 *)(addr)) -#define MMIO32(addr) (*(volatile u32 *)(addr)) - -#endif diff --git a/include/libopenstm32/crc.h b/include/libopenstm32/crc.h index c92d36e..f642a18 100644 --- a/include/libopenstm32/crc.h +++ b/include/libopenstm32/crc.h @@ -21,7 +21,7 @@ #define LIBOPENSTM32_CRC_H #include -#include +#include /* --- CRC registers ------------------------------------------------------- */ diff --git a/include/libopenstm32/dma.h b/include/libopenstm32/dma.h index 389019f..92a0918 100644 --- a/include/libopenstm32/dma.h +++ b/include/libopenstm32/dma.h @@ -21,7 +21,7 @@ #define LIBOPENSTM32_DMA_H #include -#include +#include /* --- Convenience macros -------------------------------------------------- */ diff --git a/include/libopenstm32/ethernet.h b/include/libopenstm32/ethernet.h index f611ce5..92791df 100644 --- a/include/libopenstm32/ethernet.h +++ b/include/libopenstm32/ethernet.h @@ -21,7 +21,7 @@ #define LIBOPENSTM32_ETHERNET_H #include -#include +#include /* Ethernet MAC registers */ #define ETH_MACCR MMIO32(ETHERNET_BASE + 0x00) diff --git a/include/libopenstm32/exti.h b/include/libopenstm32/exti.h index 6d0bc3a..db84cac 100644 --- a/include/libopenstm32/exti.h +++ b/include/libopenstm32/exti.h @@ -21,7 +21,7 @@ #define LIBOPENSTM32_EXTI_H #include -#include +#include /* --- EXTI registers ------------------------------------------------------ */ diff --git a/include/libopenstm32/flash.h b/include/libopenstm32/flash.h index 5f667a6..66dac33 100644 --- a/include/libopenstm32/flash.h +++ b/include/libopenstm32/flash.h @@ -29,7 +29,7 @@ #define LIBOPENSTM32_FLASH_H #include -#include +#include /* --- FLASH registers ----------------------------------------------------- */ diff --git a/include/libopenstm32/gpio.h b/include/libopenstm32/gpio.h index f1864a8..e0ef4a8 100644 --- a/include/libopenstm32/gpio.h +++ b/include/libopenstm32/gpio.h @@ -21,7 +21,7 @@ #define LIBOPENSTM32_GPIO_H #include -#include +#include /* --- Convenience macros -------------------------------------------------- */ diff --git a/include/libopenstm32/i2c.h b/include/libopenstm32/i2c.h index 85fdeb1..e9722e5 100644 --- a/include/libopenstm32/i2c.h +++ b/include/libopenstm32/i2c.h @@ -21,7 +21,7 @@ #define LIBOPENSTM32_I2C_H #include -#include +#include /* --- Convenience macros -------------------------------------------------- */ diff --git a/include/libopenstm32/iwdg.h b/include/libopenstm32/iwdg.h index 3931369..3435aea 100644 --- a/include/libopenstm32/iwdg.h +++ b/include/libopenstm32/iwdg.h @@ -21,7 +21,7 @@ #define LIBOPENSTM32_IWDG_H #include -#include +#include /* --- IWDG registers ------------------------------------------------------ */ diff --git a/include/libopenstm32/memorymap.h b/include/libopenstm32/memorymap.h index a9c7fef..9aa1e97 100644 --- a/include/libopenstm32/memorymap.h +++ b/include/libopenstm32/memorymap.h @@ -20,40 +20,7 @@ #ifndef LIBOPENSTM32_MEMORYMAP_H #define LIBOPENSTM32_MEMORYMAP_H -/* --- ARM Cortex-M3 specific definitions ---------------------------------- */ - -/* Private peripheral bus - Internal */ -#define PPBI_BASE 0xE0000000 -#define ITM_BASE (PPBI_BASE + 0x0000) -#define DWT_BASE (PPBI_BASE + 0x1000) -#define FPB_BASE (PPBI_BASE + 0x2000) -/* PPBI_BASE + 0x3000 (0xE000 3000 - 0xE000 DFFF): Reserved */ -#define SCS_BASE (PPBI_BASE + 0xE000) -/* PPBI_BASE + 0xF000 (0xE000 F000 - 0xE003 FFFF): Reserved */ - -/* --- ITM: Instrumentation Trace Macrocell --- */ -/* TODO */ - -/* --- DWT: Data Watchpoint and Trace unit --- */ -/* TODO */ - -/* --- FPB: Flash Patch and Breakpoint unit --- */ -/* TODO */ - -/* --- SCS: System Control Space --- */ - -/* ITR: Interrupt Type Register */ -#define ITR_BASE (SCS_BASE + 0x0000) -/* SYS_TICK: System Timer */ -#define SYS_TICK_BASE (SCS_BASE + 0x0010) -/* NVIC: Nested Vector Interrupt Controller */ -#define NVIC_BASE (SCS_BASE + 0x0100) -/* SCB: System Control Block */ -#define SCB_BASE (SCS_BASE + 0x0D00) -/* STE: Software Trigger Interrupt Register */ -#define STIR_BASE (SCS_BASE + 0x0F00) -/* ID: ID space */ -#define ID_BASE (SCS_BASE + 0x0FD0) +#include /* --- STM32 specific peripheral definitions ------------------------------- */ diff --git a/include/libopenstm32/nvic.h b/include/libopenstm32/nvic.h index 198f9d0..a0ccb98 100644 --- a/include/libopenstm32/nvic.h +++ b/include/libopenstm32/nvic.h @@ -21,7 +21,7 @@ #define LIBOPENSTM32_NVIC_H #include -#include +#include /* --- NVIC Registers ------------------------------------------------------ */ diff --git a/include/libopenstm32/pwr.h b/include/libopenstm32/pwr.h index 5a4842c..ba5a5b6 100644 --- a/include/libopenstm32/pwr.h +++ b/include/libopenstm32/pwr.h @@ -21,7 +21,7 @@ #define LIBOPENSTM32_PWR_H #include -#include +#include /* --- PWR registers ------------------------------------------------------- */ diff --git a/include/libopenstm32/rcc.h b/include/libopenstm32/rcc.h index c108dd8..cc0244d 100644 --- a/include/libopenstm32/rcc.h +++ b/include/libopenstm32/rcc.h @@ -22,7 +22,7 @@ #define LIBOPENSTM32_RCC_H #include -#include +#include /* Note: Regs/bits marked (**) only exist in "connectivity line" STM32s. */ /* Note: Regs/bits marked (XX) do NOT exist in "connectivity line" STM32s. */ diff --git a/include/libopenstm32/rtc.h b/include/libopenstm32/rtc.h index c7e89da..76fc16e 100644 --- a/include/libopenstm32/rtc.h +++ b/include/libopenstm32/rtc.h @@ -21,7 +21,7 @@ #define LIBOPENSTM32_RTC_H #include -#include +#include #include /* --- RTC registers ------------------------------------------------------- */ diff --git a/include/libopenstm32/scb.h b/include/libopenstm32/scb.h index b2b9bee..ef6eb8a 100644 --- a/include/libopenstm32/scb.h +++ b/include/libopenstm32/scb.h @@ -22,7 +22,7 @@ #define LIBOPENSTM32_SCB_H #include -#include +#include /* --- SCB: Registers ------------------------------------------------------ */ diff --git a/include/libopenstm32/spi.h b/include/libopenstm32/spi.h index 08da073..71026d1 100644 --- a/include/libopenstm32/spi.h +++ b/include/libopenstm32/spi.h @@ -21,7 +21,7 @@ #define LIBOPENSTM32_SPI_H #include -#include +#include /* Registers can be accessed as 16bit or 32bit values. */ diff --git a/include/libopenstm32/systick.h b/include/libopenstm32/systick.h index a45f744..420c57c 100644 --- a/include/libopenstm32/systick.h +++ b/include/libopenstm32/systick.h @@ -21,7 +21,7 @@ #define LIBOPENSTM32_SYSTICK_H #include -#include +#include /* --- SYSTICK registers --------------------------------------------------- */ diff --git a/include/libopenstm32/timer.h b/include/libopenstm32/timer.h index 73a4993..5a21b02 100644 --- a/include/libopenstm32/timer.h +++ b/include/libopenstm32/timer.h @@ -21,7 +21,7 @@ #define LIBOPENSTM32_TIMER_H #include -#include +#include /* --- Convenience macros -------------------------------------------------- */ diff --git a/include/libopenstm32/usart.h b/include/libopenstm32/usart.h index 3f93d1b..eb82018 100644 --- a/include/libopenstm32/usart.h +++ b/include/libopenstm32/usart.h @@ -21,7 +21,7 @@ #define LIBOPENSTM32_USART_H #include -#include +#include /* --- Convenience macros -------------------------------------------------- */ diff --git a/include/libopenstm32/usb.h b/include/libopenstm32/usb.h index b982746..00815d8 100644 --- a/include/libopenstm32/usb.h +++ b/include/libopenstm32/usb.h @@ -21,7 +21,7 @@ #define LIBOPENSTM32_USB_H #include -#include +#include #include /* --- USB base addresses -------------------------------------------------- */ diff --git a/include/libopenstm32/wwdg.h b/include/libopenstm32/wwdg.h index 367fc47..87d8006 100644 --- a/include/libopenstm32/wwdg.h +++ b/include/libopenstm32/wwdg.h @@ -21,7 +21,7 @@ #define LIBOPENSTM32_WWDG_H #include -#include +#include /* --- WWDG registers ------------------------------------------------------ */ diff --git a/include/usb/usbstd.h b/include/usb/usbstd.h index a055a43..51e9c8b 100644 --- a/include/usb/usbstd.h +++ b/include/usb/usbstd.h @@ -21,7 +21,7 @@ #define __USBSTD_H #include -#include /* TODO: Move elsewhere? */ +#include /* * This file contains structure definitions for the USB control structures diff --git a/lib/usb/usb_f103.c b/lib/usb/usb_f103.c index b5a2f55..14ec14b 100644 --- a/lib/usb/usb_f103.c +++ b/lib/usb/usb_f103.c @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -#include +#include #include #include #include -- cgit v1.2.3