diff options
-rw-r--r-- | Makefile | 22 | ||||
-rw-r--r-- | libmaple/board_maple.h | 82 | ||||
-rw-r--r-- | libmaple/libmaple.h | 58 |
3 files changed, 65 insertions, 97 deletions
@@ -3,6 +3,20 @@ BOARD ?= maple MEMORY_TARGET ?= flash +# USB ID for DFU upload +VENDOR_ID := 1EAF +PRODUCT_ID := 0003 + +# Guess the MCU based on the BOARD (can be overridden ) +ifeq ($(BOARD), maple) + MCU := STM32F103RB + PRODUCT_ID := 0003 +endif +ifeq ($(BOARD), maple-native) + MCU := STM32F103ZE + PRODUCT_ID := 0003 +endif + # Useful paths SRCROOT := $(dir) BUILD_PATH = build @@ -11,8 +25,8 @@ LIBMAPLE_PATH := libmaple # Useful variables GLOBAL_CFLAGS := -Os -g -mcpu=cortex-m3 -mthumb -march=armv7-m -nostdlib \ -ffunction-sections -fdata-sections -Wl,--gc-sections \ - -DBOARD_$(BOARD) -GLOBAL_CXXFLAGS := -fno-rtti -fno-exceptions -Wall -DBOARD_$(BOARD) + -DBOARD_$(BOARD) -DMCU_$(MCU) +GLOBAL_CXXFLAGS := -fno-rtti -fno-exceptions -Wall -DBOARD_$(BOARD) -DMCU_$(MCU) LDDIR := support/ld @@ -24,10 +38,6 @@ LDFLAGS = -T$(LDDIR)/$(LDSCRIPT) -L$(LDDIR) \ include support/make/build-rules.mk include support/make/build-templates.mk -# Maple USB id -VENDOR_ID := 1EAF -PRODUCT_ID := 0003 - # Some target specific things ifeq ($(MEMORY_TARGET), ram) VECT_BASE_ADDR := VECT_TAB_RAM diff --git a/libmaple/board_maple.h b/libmaple/board_maple.h deleted file mode 100644 index 3cbf638..0000000 --- a/libmaple/board_maple.h +++ /dev/null @@ -1,82 +0,0 @@ -/* ***************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Bryan Newbold. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * ****************************************************************************/ - -// Board-specific settings file, included from libmaple.h based on the BOARD -// environment variable. - -// See ../notes/portability.txt for more information - -#ifndef _BOARD_MAPLE_H_ -#define _BOARD_MAPLE_H_ - -// ------------------------------------------------------------------------ -// Some settings probably need to be changed for every board - -// Number of GPIO ports (GPIOA, GPIOB, etc), definately used -#define NR_GPIO_PORTS 4 - -// Number of timer devices ports, definately used -#define NR_TIMERS 4 - -// Total number of GPIO pins -#define NR_MAPLE_PINS 39 - -// Number of ADC pins. Not actually used? -#define NR_ANALOG_PINS 29 - -// USB Identifier numbers -// Descriptor strings must be modified by hand in usb/descriptors.c for now -#define VCOM_ID_VENDOR 0x1EAF -#define VCOM_ID_PRODUCT 0x0004 -#define USB_CONFIG_MAX_POWER (100 >> 1) -#define RESET_DELAY (100) - -// Where to put usercode (based on space reserved for bootloader) -#define USER_ADDR_ROM 0x08005000 -#define USER_ADDR_RAM 0x20000C00 -#define STACK_TOP 0x20000800 - -// Debug port settings (from ASSERT) -#define ERROR_LED_PORT GPIOA_BASE -#define ERROR_LED_PIN 5 -#define ERROR_USART_NUM 2 -#define ERROR_USART_BAUD 9600 -#define ERROR_TX_PIN 2 -#define ERROR_TX_PORT GPIOA_BASE - -// ------------------------------------------------------------------------ -// Some settings are probably stable across the entire STM32 line - -// Just in case, most boards have at least some memory -#ifndef RAMSIZE -# define RAMSIZE (caddr_t)0x50000 -#endif - -#define BITBAND_SRAM_REF 0x20000000 -#define BITBAND_SRAM_BASE 0x22000000 -#define BITBAND_PERI_REF 0x40000000 -#define BITBAND_PERI_BASE 0x42000000 - -#endif - diff --git a/libmaple/libmaple.h b/libmaple/libmaple.h index cf5802c..ce0d630 100644 --- a/libmaple/libmaple.h +++ b/libmaple/libmaple.h @@ -36,18 +36,58 @@ // General configuration #define MAPLE_DEBUG 0 -#ifdef BOARD_maple - #include "board_maple.h" -#endif -/* -#ifdef BOARD_maple-native - #include "board_maple_native.h" +// MCU-specific configuration +#ifdef MCU_STM32F103RB // eg, LeafLabs Maple + + // Number of GPIO ports (GPIOA, GPIOB, etc), definately used + #define NR_GPIO_PORTS 4 + + // Number of timer devices ports, definately used + #define NR_TIMERS 4 + + // Total number of GPIO pins + #define NR_MAPLE_PINS 39 + + // Number of ADC pins. Not actually used? + #define NR_ANALOG_PINS 29 + + // USB Identifier numbers + // Descriptor strings must be modified by hand in usb/descriptors.c for now + #define VCOM_ID_VENDOR 0x1EAF + #define VCOM_ID_PRODUCT 0x0004 + #define USB_CONFIG_MAX_POWER (100 >> 1) + #define RESET_DELAY (100) + + // Where to put usercode (based on space reserved for bootloader) + #define USER_ADDR_ROM 0x08005000 + #define USER_ADDR_RAM 0x20000C00 + #define STACK_TOP 0x20000800 + + // Debug port settings (from ASSERT) + #define ERROR_LED_PORT GPIOA_BASE + #define ERROR_LED_PIN 5 + #define ERROR_USART_NUM 2 + #define ERROR_USART_BAUD 9600 + #define ERROR_TX_PIN 2 + #define ERROR_TX_PORT GPIOA_BASE + + // Just in case, most boards have at least some memory + #ifndef RAMSIZE + # define RAMSIZE (caddr_t)0x50000 + #endif + + // Bitbanded Memory sections + #define BITBAND_SRAM_REF 0x20000000 + #define BITBAND_SRAM_BASE 0x22000000 + #define BITBAND_PERI_REF 0x40000000 + #define BITBAND_PERI_BASE 0x42000000 #endif -#ifdef BOARD_maple-mini - #include "board_maple_mini.h" +// Make sure MCU-specific settings were defined +#ifndef NR_GPIO_PORTS +#error Error: No MCU type specified. Add something like -DMCU_STM32F103RB \ + to your compiler arguments (probably in a Makefile). #endif -*/ // Requires board configuration info #include "util.h" |