├── README
└── stm32f4
├── README
├── libmaple
├── .cproject
├── .dir-locals.el
├── .gdbinit
├── .gitignore
├── .project
├── LICENSE
├── Makefile
├── README
├── build-targets.mk
├── contrib
│ └── automake
│ │ ├── Makefile.am
│ │ └── configure.ac
├── examples
│ ├── blinky.cpp
│ ├── debug-dtrrts.cpp
│ ├── freertos-blinky.cpp
│ ├── fsmc-stress-test.cpp
│ ├── mini-exti-test.cpp
│ ├── qa-slave-shield.cpp
│ ├── spi_master.cpp
│ ├── test-bkp.cpp
│ ├── test-dac.cpp
│ ├── test-fsmc.cpp
│ ├── test-print.cpp
│ ├── test-ring-buffer-insertion.cpp
│ ├── test-serial-flush.cpp
│ ├── test-serialusb.cpp
│ ├── test-servo.cpp
│ ├── test-session.cpp
│ ├── test-spi-roundtrip.cpp
│ ├── test-systick.cpp
│ ├── test-timers.cpp
│ ├── test-usart-dma.cpp
│ ├── vga-leaf.cpp
│ └── vga-scope.cpp
├── libMaple.vcproj
├── libMaple.vcproj.ALA.ich.user
├── libmaple
│ ├── adc.c
│ ├── adc.h
│ ├── bitband.h
│ ├── bkp.c
│ ├── bkp.h
│ ├── dac.c
│ ├── dac.h
│ ├── delay.h
│ ├── dma.c
│ ├── dma.h
│ ├── exc.S
│ ├── exti.c
│ ├── exti.h
│ ├── flash.c
│ ├── flash.h
│ ├── fsmc.c
│ ├── fsmc.h
│ ├── gpio.c
│ ├── gpio.h
│ ├── gpioF1.c
│ ├── gpioF1.h
│ ├── gpioF2.c
│ ├── gpioF2.h
│ ├── i2c.c
│ ├── i2c.h
│ ├── iwdg.c
│ ├── iwdg.h
│ ├── libmaple.h
│ ├── libmaple_types.h
│ ├── nvic.c
│ ├── nvic.h
│ ├── pwr.c
│ ├── pwr.h
│ ├── rcc.c
│ ├── rcc.h
│ ├── rccF1.c
│ ├── rccF1.h
│ ├── rccF2.c
│ ├── rccF2.h
│ ├── ring_buffer.h
│ ├── rules.mk
│ ├── scb.h
│ ├── spi.c
│ ├── spi.h
│ ├── stm32.h
│ ├── syscalls.c
│ ├── systick.c
│ ├── systick.h
│ ├── timer.c
│ ├── timer.h
│ ├── usart.c
│ ├── usart.h
│ ├── usb
│ │ ├── README
│ │ ├── descriptors.c
│ │ ├── descriptors.h
│ │ ├── usb.c
│ │ ├── usb.h
│ │ ├── usb_callbacks.c
│ │ ├── usb_callbacks.h
│ │ ├── usb_config.h
│ │ ├── usb_hardware.c
│ │ ├── usb_hardware.h
│ │ └── usb_lib
│ │ │ ├── usb_core.c
│ │ │ ├── usb_core.h
│ │ │ ├── usb_def.h
│ │ │ ├── usb_init.c
│ │ │ ├── usb_init.h
│ │ │ ├── usb_int.c
│ │ │ ├── usb_int.h
│ │ │ ├── usb_lib.h
│ │ │ ├── usb_mem.c
│ │ │ ├── usb_mem.h
│ │ │ ├── usb_regs.c
│ │ │ ├── usb_regs.h
│ │ │ └── usb_type.h
│ ├── util.c
│ └── util.h
├── libraries
│ ├── FreeRTOS
│ │ ├── MapleFreeRTOS.cpp
│ │ ├── MapleFreeRTOS.h
│ │ ├── keywords.txt
│ │ ├── rules.mk
│ │ └── utility
│ │ │ ├── FreeRTOS.h
│ │ │ ├── FreeRTOSConfig.h
│ │ │ ├── StackMacros.h
│ │ │ ├── croutine.c
│ │ │ ├── croutine.h
│ │ │ ├── heap_2.c
│ │ │ ├── list.c
│ │ │ ├── list.h
│ │ │ ├── mpu_wrappers.h
│ │ │ ├── port.c
│ │ │ ├── portable.h
│ │ │ ├── portmacro.h
│ │ │ ├── projdefs.h
│ │ │ ├── queue.c
│ │ │ ├── queue.h
│ │ │ ├── semphr.h
│ │ │ ├── task.h
│ │ │ ├── tasks.c
│ │ │ ├── timers.c
│ │ │ └── timers.h
│ ├── LiquidCrystal
│ │ ├── LiquidCrystal.cpp
│ │ ├── LiquidCrystal.h
│ │ └── rules.mk
│ ├── Servo
│ │ ├── Servo.cpp
│ │ ├── Servo.h
│ │ └── rules.mk
│ ├── Wire
│ │ ├── README
│ │ ├── Wire.cpp
│ │ ├── Wire.h
│ │ ├── WireOrg.cpp
│ │ ├── WireOrg.h
│ │ └── rules.mk
│ └── mapleSDfat
│ │ ├── Document1.txt
│ │ ├── FatStructs.h
│ │ ├── Sd2Card.cpp
│ │ ├── Sd2Card.h
│ │ ├── Sd2PinMap.h
│ │ ├── SdFat.h
│ │ ├── SdFatUtil.h
│ │ ├── SdFatWorks.h
│ │ ├── SdFatmainpage.h
│ │ ├── SdFile.cpp
│ │ ├── SdInfo.h
│ │ ├── SdVolume.cpp
│ │ ├── examples
│ │ ├── Arduino Examples
│ │ │ ├── SdFatAnalogLogger
│ │ │ │ └── SdFatAnalogLogger.pde
│ │ │ ├── SdFatAppend
│ │ │ │ └── SdFatAppend.pde
│ │ │ ├── SdFatBench
│ │ │ │ └── SdFatBench.pde
│ │ │ ├── SdFatCopy
│ │ │ │ └── SdFatCopy.pde
│ │ │ ├── SdFatGPSLogger_v3
│ │ │ │ └── SdFatGPSLogger_v3.pde
│ │ │ ├── SdFatGPS_CSVSensorLogger
│ │ │ │ └── SdFatGPS_CSVSensorLogger.pde
│ │ │ ├── SdFatInfo
│ │ │ │ └── SdFatInfo.pde
│ │ │ ├── SdFatLs
│ │ │ │ └── SdFatLs.pde
│ │ │ ├── SdFatMakeDir
│ │ │ │ └── SdFatMakeDir.pde
│ │ │ ├── SdFatPrint
│ │ │ │ └── SdFatPrint.pde
│ │ │ ├── SdFatRawWrite
│ │ │ │ └── SdFatRawWrite.pde
│ │ │ ├── SdFatRead
│ │ │ │ └── SdFatRead.c
│ │ │ ├── SdFatRemove
│ │ │ │ └── SdFatRemove.pde
│ │ │ ├── SdFatRewrite
│ │ │ │ └── SdFatRewrite.pde
│ │ │ ├── SdFatRmDir
│ │ │ │ └── SdFatRmDir.pde
│ │ │ ├── SdFatTail
│ │ │ │ └── SdFatTail.pde
│ │ │ ├── SdFatTimestamp
│ │ │ │ └── SdFatTimestamp.pde
│ │ │ ├── SdFatTruncate
│ │ │ │ └── SdFatTruncate.pde
│ │ │ └── SdFatWrite
│ │ │ │ └── SdFatWrite.pde
│ │ ├── FileSys
│ │ │ └── FileSys.pde
│ │ └── clean.bat
│ │ └── rules.mk
├── main.cpp.example
├── notes
│ ├── dac.txt
│ ├── dma.txt
│ ├── exti.txt
│ ├── fsmc.txt
│ ├── pin-definitions.txt
│ ├── portable.txt
│ ├── timers.txt
│ ├── usb.txt
│ └── vga.txt
├── support
│ ├── gdb
│ │ ├── gpio
│ │ │ └── gpio.gdb
│ │ └── i2c
│ │ │ └── test.gdb
│ ├── ld
│ │ ├── aeroquad32
│ │ │ ├── flash.ld
│ │ │ ├── jtag.ld
│ │ │ └── ram.ld
│ │ ├── aeroquad32mini
│ │ │ ├── flash.ld
│ │ │ ├── jtag.ld
│ │ │ └── ram.ld
│ │ ├── common.inc
│ │ ├── discovery_f4
│ │ │ ├── flash.ld
│ │ │ ├── jtag.ld
│ │ │ └── ram.ld
│ │ ├── libcs3_stm32_high_density.a
│ │ ├── libcs3_stm32_src
│ │ │ ├── Makefile
│ │ │ ├── start.S
│ │ │ ├── start_c.c
│ │ │ ├── stm32_isrs.S
│ │ │ └── stm32_vector_table.S
│ │ ├── libcs4_stm32_high_density.a
│ │ ├── libcs4_stm32_src
│ │ │ ├── Makefile
│ │ │ ├── libcs4_stm32_high_density.a
│ │ │ ├── start.S
│ │ │ ├── start_c.c
│ │ │ ├── stm32_isrs.S
│ │ │ └── stm32_vector_table.S
│ │ ├── maple
│ │ │ ├── flash.ld
│ │ │ ├── jtag.ld
│ │ │ └── ram.ld
│ │ ├── maple_RET6
│ │ │ ├── flash.ld
│ │ │ ├── jtag.ld
│ │ │ └── ram.ld
│ │ ├── maple_mini
│ │ │ ├── flash.ld
│ │ │ ├── jtag.ld
│ │ │ └── ram.ld
│ │ ├── maple_native
│ │ │ ├── flash.ld
│ │ │ ├── jtag.ld
│ │ │ └── ram.ld
│ │ └── names.inc
│ ├── make
│ │ ├── build-rules.mk
│ │ ├── build-templates.mk
│ │ └── target-config.mk
│ ├── openocd
│ │ ├── debug_0.3.cfg
│ │ ├── debug_0.4.cfg
│ │ ├── flash_0.3.cfg
│ │ └── flash_0.4.cfg
│ ├── scripts
│ │ ├── 45-maple.rules
│ │ ├── copy-to-ide
│ │ ├── openocd-wrapper.sh
│ │ └── reset.py
│ └── stm32loader.py
└── wirish
│ ├── HardwareTimer.cpp
│ ├── HardwareTimer.h
│ ├── Print.cpp
│ ├── Print.h
│ ├── WProgram.h
│ ├── bit_constants.h
│ ├── bits.h
│ ├── boards.cpp
│ ├── boards.h
│ ├── boards
│ ├── aeroquad32.cpp
│ ├── aeroquad32.h
│ ├── aeroquad32mini.cpp
│ ├── aeroquad32mini.h
│ ├── discovery_f4.cpp
│ ├── discovery_f4.h
│ ├── maple.cpp
│ ├── maple.h
│ ├── maple_RET6.cpp
│ ├── maple_RET6.h
│ ├── maple_mini.cpp
│ ├── maple_mini.h
│ ├── maple_native.cpp
│ └── maple_native.h
│ ├── comm
│ ├── HardwareSPI.cpp
│ ├── HardwareSPI.h
│ ├── HardwareSerial.cpp
│ └── HardwareSerial.h
│ ├── cxxabi-compat.cpp
│ ├── ext_interrupts.cpp
│ ├── ext_interrupts.h
│ ├── io.h
│ ├── main.cxx
│ ├── pwm.cpp
│ ├── pwm.h
│ ├── rules.mk
│ ├── usb_serial.cpp
│ ├── usb_serial.h
│ ├── wirish.h
│ ├── wirish_analog.cpp
│ ├── wirish_debug.h
│ ├── wirish_digital.cpp
│ ├── wirish_math.cpp
│ ├── wirish_math.h
│ ├── wirish_shift.cpp
│ ├── wirish_time.cpp
│ ├── wirish_time.h
│ └── wirish_types.h
└── maple-bootloader
├── .gitignore
├── FlashV2.bat
├── Makefile
├── README
├── common.h
├── config.h
├── config.h.old
├── dfu.c
├── dfu.h
├── flash
├── debug.cfg
├── flash.cfg
├── openocd.cfg
├── stm32.cfg
└── stm32loader.py
├── hardware.c
├── hardware.h
├── main.c
├── stm32_lib
├── c_only_md_RAM.ld
├── c_only_md_flash128k_ram20k.ld
├── c_only_md_flash512k_ram64k.ld
├── c_only_startup.s
├── c_only_startup_user.s
├── cortexm3_macro.h
├── cortexm3_macro.s
├── stm32f10x.h
├── stm32f10x_type.h
└── stm32f2xx.h
├── usb.c
├── usb.h
├── usb_callbacks.c
├── usb_descriptor.c
├── usb_descriptor.h
└── usb_lib
├── usb_conf.h
├── usb_core.c
├── usb_core.h
├── usb_def.h
├── usb_init.c
├── usb_init.h
├── usb_int.c
├── usb_int.h
├── usb_lib.h
├── usb_mem.c
├── usb_mem.h
├── usb_regs.c
├── usb_regs.h
└── usb_type.h
/README:
--------------------------------------------------------------------------------
1 | openstm32sw README
2 |
3 | The aim is to provide both Open Source software and hardware for STM32.
4 | This is the software repository.
5 |
6 | This repository grew from a discussion thread on LeafLabs Maple forum:
7 | http://forums.leaflabs.com/topic.php?id=1303
8 |
9 | It was triggered by ala42 who had released a first cut at libmaple for STM32F4:
10 | http://forums.leaflabs.com/topic.php?id=1268&page=2#post-7828
11 |
12 | We are aiming to maintain compatibility with LeafLabs Maple software API
13 |
14 | LeafLabs announced that they are collaborating with Wiring
15 | http://leaflabs.com/2011/11/were-teaming-up-with-wiring/
16 |
17 | Hence openstm32 should have some compatibility with the Wiring Framework.
18 |
19 |
20 | sub-directories:
21 |
22 | stm32f4 - ala42's stm32f4 fork of libmaple and maple bootloader
--------------------------------------------------------------------------------
/stm32f4/README:
--------------------------------------------------------------------------------
1 | README for openstm32sw/stm32f4
2 |
3 | This was inspired by ala42 releasing an STM32F4 fork of libmaple
4 | http://ala42.cdfreaks.com/AeroQuad/maple_0.0.12_F4AQ_mod_ala42_20120123.zip
5 |
6 | The post is at
7 | http://forums.leaflabs.com/topic.php?id=1268&page=2#post-7828
8 |
9 |
10 | This repository grew from a discussion thread on LeafLabs Maple forum:
11 | http://forums.leaflabs.com/topic.php?id=1303
12 |
13 | Thanks to ala42 for sharing.
--------------------------------------------------------------------------------
/stm32f4/libmaple/.dir-locals.el:
--------------------------------------------------------------------------------
1 | ((c-mode . ((c-basic-offset . 4)
2 | (indent-tabs-mode . nil)
3 | (tab-width . 50))) ; display tabs badly on purpose
4 | (c++-mode . ((c-basic-offset . 4)
5 | (indent-tabs-mode . nil)
6 | (tab-width . 50)))) ; display tabs badly on purpose
--------------------------------------------------------------------------------
/stm32f4/libmaple/.gdbinit:
--------------------------------------------------------------------------------
1 | target remote localhost:3333
2 | symbol-file build/maple.elf
3 | source test.gdb
4 | delete breakpoints
5 | ##break main.cpp:setup()
6 | ##monitor reset halt
7 | #display/i $pc
8 | # display/x *0xe000ed2c
9 | # display/x *0xE000ED28
10 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 | doxygen/
3 | main.cpp
4 | libmaple.layout
5 | tags
6 | TAGS
7 | *~
8 | *.swp
9 | arm
10 | cscope*
11 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | libmaple
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 | ?name?
14 |
15 |
16 |
17 | org.eclipse.cdt.make.core.append_environment
18 | true
19 |
20 |
21 | org.eclipse.cdt.make.core.autoBuildTarget
22 | all
23 |
24 |
25 | org.eclipse.cdt.make.core.buildArguments
26 |
27 |
28 |
29 | org.eclipse.cdt.make.core.buildCommand
30 | cs-make
31 |
32 |
33 | org.eclipse.cdt.make.core.cleanBuildTarget
34 | clean
35 |
36 |
37 | org.eclipse.cdt.make.core.contents
38 | org.eclipse.cdt.make.core.activeConfigSettings
39 |
40 |
41 | org.eclipse.cdt.make.core.enableAutoBuild
42 | false
43 |
44 |
45 | org.eclipse.cdt.make.core.enableCleanBuild
46 | true
47 |
48 |
49 | org.eclipse.cdt.make.core.enableFullBuild
50 | true
51 |
52 |
53 | org.eclipse.cdt.make.core.fullBuildTarget
54 | library
55 |
56 |
57 | org.eclipse.cdt.make.core.stopOnError
58 | true
59 |
60 |
61 | org.eclipse.cdt.make.core.useDefaultBuildCmd
62 | false
63 |
64 |
65 |
66 |
67 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
68 | full,incremental,
69 |
70 |
71 |
72 |
73 |
74 | org.eclipse.cdt.core.cnature
75 | org.eclipse.cdt.core.ccnature
76 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
77 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
78 |
79 |
80 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/build-targets.mk:
--------------------------------------------------------------------------------
1 | # main project target
2 | $(BUILD_PATH)/main.o: main.cpp
3 | $(SILENT_CXX) $(CXX) $(CFLAGS) $(CXXFLAGS) $(LIBMAPLE_INCLUDES) $(WIRISH_INCLUDES) -o $@ -c $<
4 |
5 | $(BUILD_PATH)/libmaple.a: $(BUILDDIRS) $(TGT_BIN)
6 | - rm -f $@
7 | $(AR) crv $(BUILD_PATH)/libmaple.a $(TGT_BIN)
8 |
9 | library: $(BUILD_PATH)/libmaple.a
10 |
11 | .PHONY: library
12 |
13 | $(BUILD_PATH)/$(BOARD).elf: $(BUILDDIRS) $(TGT_BIN) $(BUILD_PATH)/main.o
14 | $(SILENT_LD) $(CXX) $(LDFLAGS) -o $@ $(TGT_BIN) $(BUILD_PATH)/main.o -Wl,-Map,$(BUILD_PATH)/$(BOARD).map
15 |
16 | $(BUILD_PATH)/$(BOARD).bin: $(BUILD_PATH)/$(BOARD).elf
17 | $(SILENT_OBJCOPY) $(OBJCOPY) -v -Obinary $(BUILD_PATH)/$(BOARD).elf $@ 1>/dev/null
18 | $(SILENT_DISAS) $(DISAS) -d $(BUILD_PATH)/$(BOARD).elf > $(BUILD_PATH)/$(BOARD).disas
19 | @echo " "
20 | @echo "Object file sizes:"
21 | @find $(BUILD_PATH) -iname *.o | xargs $(SIZE) -t > $(BUILD_PATH)/$(BOARD).sizes
22 | @cat $(BUILD_PATH)/$(BOARD).sizes
23 | @echo " "
24 | @echo "Final Size:"
25 | @$(SIZE) $<
26 | @echo $(MEMORY_TARGET) > $(BUILD_PATH)/build-type
27 |
28 | $(BUILDDIRS):
29 | @mkdir -p $@
30 |
31 | MSG_INFO:
32 | @echo "================================================================================"
33 | @echo ""
34 | @echo " Build info:"
35 | @echo " BOARD: " $(BOARD)
36 | @echo " MCU: " $(MCU)
37 | @echo " MEMORY_TARGET: " $(MEMORY_TARGET)
38 | @echo ""
39 | @echo " See 'make help' for all possible targets"
40 | @echo ""
41 | @echo "================================================================================"
42 | @echo
43 |
44 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/contrib/automake/configure.ac:
--------------------------------------------------------------------------------
1 | AC_INIT(libmaple, 0.11+git)
2 | AM_INIT_AUTOMAKE(foreign subdir-objects color-tests)
3 | AC_CONFIG_HEADERS([config.h])
4 | AC_CONFIG_FILES(Makefile)
5 | AM_PROG_AS
6 | AC_PROG_CXX
7 | AM_PROG_LIBTOOL
8 | AC_OUTPUT
9 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/examples/blinky.cpp:
--------------------------------------------------------------------------------
1 | // Blinks the built-in LED
2 |
3 | #include "wirish.h"
4 |
5 | void setup() {
6 | pinMode(BOARD_LED_PIN, OUTPUT);
7 | }
8 |
9 | int toggle = 1;
10 |
11 | void loop() {
12 | // You could just use toggleLED() instead, but this illustrates
13 | // the use of digitalWrite():
14 | digitalWrite(BOARD_LED_PIN, toggle);
15 | toggle ^= 1;
16 | delay(100);
17 | }
18 |
19 | // Force init to be called *first*, i.e. before static object allocation.
20 | // Otherwise, statically allocated objects that need libmaple may fail.
21 | __attribute__((constructor)) void premain() {
22 | init();
23 | }
24 |
25 | int main(void) {
26 | setup();
27 |
28 | while (true) {
29 | loop();
30 | }
31 | return 0;
32 | }
33 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/examples/debug-dtrrts.cpp:
--------------------------------------------------------------------------------
1 | // Test sketch for figuring out DTR/RTS behavior on different platforms.
2 |
3 | #include "wirish.h"
4 | #include "usb.h"
5 |
6 | void setup() {
7 | /* Set up the LED to blink */
8 | pinMode(BOARD_LED_PIN, OUTPUT);
9 |
10 | /* Send a message out USART2 */
11 | Serial2.begin(9600);
12 | Serial2.println("Debugging DTR/RTS...");
13 |
14 | }
15 |
16 | void loop() {
17 | toggleLED();
18 | delay(100);
19 |
20 | Serial2.print("DTR: ");
21 | Serial2.print(usbGetDTR(), DEC);
22 | Serial2.print("\tRTS: ");
23 | Serial2.println(usbGetRTS(), DEC);
24 | }
25 |
26 | // Force init to be called *first*, i.e. before static object allocation.
27 | // Otherwise, statically allocated objects that need libmaple may fail.
28 | __attribute__((constructor)) void premain() {
29 | init();
30 | }
31 |
32 | int main(void) {
33 | setup();
34 |
35 | while (1) {
36 | loop();
37 | }
38 | return 0;
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/examples/freertos-blinky.cpp:
--------------------------------------------------------------------------------
1 | #include "wirish.h"
2 | #include "libraries/FreeRTOS/MapleFreeRTOS.h"
3 |
4 | static void vLEDFlashTask(void *pvParameters) {
5 | for (;;) {
6 | vTaskDelay(1000);
7 | digitalWrite(BOARD_LED_PIN, HIGH);
8 | vTaskDelay(50);
9 | digitalWrite(BOARD_LED_PIN, LOW);
10 | }
11 | }
12 |
13 | void setup() {
14 | // initialize the digital pin as an output:
15 | pinMode(BOARD_LED_PIN, OUTPUT);
16 |
17 | xTaskCreate(vLEDFlashTask,
18 | (signed portCHAR *)"Task1",
19 | configMINIMAL_STACK_SIZE,
20 | NULL,
21 | tskIDLE_PRIORITY + 2,
22 | NULL);
23 | vTaskStartScheduler();
24 | }
25 |
26 | void loop() {
27 | // Insert background code here
28 | }
29 |
30 | // Force init to be called *first*, i.e. before static object allocation.
31 | // Otherwise, statically allocated objects that need libmaple may fail.
32 | __attribute__((constructor)) void premain() {
33 | init();
34 | }
35 |
36 | int main(void) {
37 | setup();
38 |
39 | while (true) {
40 | loop();
41 | }
42 | return 0;
43 | }
44 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/examples/qa-slave-shield.cpp:
--------------------------------------------------------------------------------
1 | // Slave mode for Quality Assurance test
2 |
3 | #include "wirish.h"
4 |
5 | #define INTER_TOGGLE_DELAY_NORMAL 5
6 | #define INTER_TOGGLE_DELAY_SLOW 80
7 |
8 | void interToggleDelay(void);
9 |
10 | void setup() {
11 | pinMode(BOARD_LED_PIN, OUTPUT);
12 | pinMode(BOARD_BUTTON_PIN, INPUT);
13 |
14 | // All unused pins start out low.
15 | for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) {
16 | if (boardUsesPin(i))
17 | continue;
18 | pinMode(i, OUTPUT);
19 | digitalWrite(i, LOW);
20 | }
21 | SerialUSB.println("OK, starting...");
22 | }
23 |
24 | void loop() {
25 | toggleLED();
26 | delay(100);
27 | toggleLED();
28 |
29 | for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) {
30 | if (boardUsesPin(i))
31 | continue;
32 |
33 | // Bring just this pin high.
34 | digitalWrite(i, HIGH);
35 | // Give the master time to detect if any other pins also went high.
36 | interToggleDelay();
37 | // Bring this pin back low again; all pins should now be low.
38 | digitalWrite(i, LOW);
39 | // Give the master time to detect if any pins are still high.
40 | interToggleDelay();
41 | }
42 | }
43 |
44 | void interToggleDelay(void) {
45 | if (digitalRead(BOARD_BUTTON_PIN)) { // don't pay the debouncing time
46 | delay(INTER_TOGGLE_DELAY_SLOW);
47 | } else {
48 | delay(INTER_TOGGLE_DELAY_NORMAL);
49 | }
50 | }
51 |
52 | // Force init to be called *first*, i.e. before static object allocation.
53 | // Otherwise, statically allocated objects that need libmaple may fail.
54 | __attribute__((constructor)) void premain() {
55 | init();
56 | }
57 |
58 | int main(void) {
59 | setup();
60 |
61 | while (true) {
62 | loop();
63 | }
64 | return 0;
65 | }
66 |
67 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/examples/spi_master.cpp:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 LeafLabs LLC.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | /**
28 | * @brief Sample main.cpp file. Sends "Hello world!" out SPI1.
29 | *
30 | * SPI1 is set up to be a master transmitter at 4.5MHz, little
31 | * endianness, and SPI mode 0.
32 | *
33 | * Pin 10 is used as slave select.
34 | */
35 |
36 | #include "wirish.h"
37 |
38 | #define NSS 10
39 |
40 | byte buf[] = "Hello world!";
41 |
42 | HardwareSPI spi1(1);
43 |
44 | void setup() {
45 | /* Set up chip select as output */
46 | pinMode(NSS, OUTPUT);
47 |
48 | /* NSS is usually active LOW, so initialize it HIGH */
49 | digitalWrite(NSS, HIGH);
50 |
51 | /* Initialize SPI */
52 | spi1.begin(SPI_4_5MHZ, LSBFIRST, 0);
53 | }
54 |
55 | void loop() {
56 | /* Send message */
57 | digitalWrite(NSS, LOW);
58 | spi1.write(buf, sizeof buf);
59 | digitalWrite(NSS, HIGH);
60 | delay(1000);
61 | }
62 |
63 | // Force init to be called *first*, i.e. before static object allocation.
64 | // Otherwise, statically allocated objects that need libmaple may fail.
65 | __attribute__((constructor)) void premain() {
66 | init();
67 | }
68 |
69 | int main(void) {
70 | setup();
71 |
72 | while (true) {
73 | loop();
74 | }
75 | return 0;
76 | }
77 |
78 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/examples/test-bkp.cpp:
--------------------------------------------------------------------------------
1 | #include // for snprintf()
2 |
3 | #include "wirish.h"
4 | #include "bkp.h"
5 | #include "iwdg.h"
6 |
7 | void print_bkp_contents();
8 | void write_to_bkp(uint16 val);
9 |
10 | #define comm Serial2
11 |
12 | void setup() {
13 | pinMode(BOARD_BUTTON_PIN, INPUT);
14 |
15 | comm.begin(9600);
16 | comm.println("*** Beginning BKP test");
17 |
18 | comm.println("Init...");
19 | bkp_init();
20 | comm.println("Done.");
21 |
22 | print_bkp_contents();
23 | write_to_bkp(10);
24 | print_bkp_contents();
25 |
26 | comm.println("Enabling backup writes.");
27 | bkp_enable_writes();
28 | write_to_bkp(20);
29 | print_bkp_contents();
30 |
31 | comm.println("Disabling backup writes.");
32 | bkp_disable_writes();
33 | write_to_bkp(30);
34 | print_bkp_contents();
35 |
36 | comm.println("Done testing backup registers; press button to enable "
37 | "independent watchdog (in order to cause a reset).");
38 | waitForButtonPress(0);
39 | iwdg_init(IWDG_PRE_4, 1);
40 | comm.println();
41 | }
42 |
43 | void loop() {
44 | }
45 |
46 | void print_bkp_contents() {
47 | comm.println("Backup data register contents:");
48 | char buf[100];
49 | for (int i = 1; i <= BKP_NR_DATA_REGS; i++) {
50 | snprintf(buf, sizeof buf, "DR%d: %d ", i, bkp_read(i));
51 | comm.print(buf);
52 | if (i % 5 == 0) comm.println();
53 | }
54 | comm.println();
55 | }
56 |
57 | void write_to_bkp(uint16 val) {
58 | comm.print("Attempting to write ");
59 | comm.print(val);
60 | comm.println(" to backup registers...");
61 | for (int i = 1; i <= BKP_NR_DATA_REGS; i++) {
62 | bkp_write(i, val);
63 | }
64 | comm.println("Done.");
65 | }
66 |
67 | __attribute__((constructor)) void premain() {
68 | init();
69 | }
70 |
71 | int main(void) {
72 | init();
73 | setup();
74 |
75 | while (1) {
76 | loop();
77 | }
78 | return 0;
79 | }
80 |
81 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/examples/test-dac.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Simple DAC test.
3 | *
4 | * Author: Marti Bolivar
5 | *
6 | * This file is released into the public domain.
7 | */
8 |
9 | #include "wirish.h"
10 | #include "dac.h"
11 |
12 | uint16 count = 0;
13 |
14 | void setup() {
15 | pinMode(BOARD_LED_PIN, OUTPUT);
16 | digitalWrite(BOARD_LED_PIN, HIGH);
17 |
18 | Serial1.begin(9600);
19 | Serial1.println("**** Beginning DAC test");
20 |
21 | Serial1.print("Init... ");
22 | dac_init(DAC, DAC_CH1 | DAC_CH2);
23 | Serial1.println("Done.");
24 | }
25 |
26 | void loop() {
27 | toggleLED();
28 | delay(100);
29 |
30 | count += 100;
31 | if (count > 4095) {
32 | count = 0;
33 | }
34 |
35 | dac_write_channel(DAC, 1, 4095 - count);
36 | dac_write_channel(DAC, 2, count);
37 | }
38 |
39 | __attribute__((constructor)) void premain() {
40 | init();
41 | }
42 |
43 | int main(void) {
44 | setup();
45 |
46 | while (true) {
47 | loop();
48 | }
49 | return 0;
50 | }
51 |
52 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/examples/test-serial-flush.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Tests the "flush" Serial function.
3 | */
4 |
5 | #include "wirish.h"
6 |
7 | void setup() {
8 | Serial1.begin(9600);
9 | Serial1.println("Hello world!");
10 | }
11 |
12 | void loop() {
13 | Serial1.println("Waiting for multiple input...");
14 | while (Serial1.available() < 5)
15 | ;
16 | Serial1.println(Serial1.read());
17 | Serial1.println(Serial1.read());
18 | Serial1.flush();
19 |
20 | if (Serial1.available()) {
21 | Serial1.println("FAIL! Still had junk in the buffer...");
22 | }
23 | }
24 |
25 | // Force init to be called *first*, i.e. before static object allocation.
26 | // Otherwise, statically allocated objects that need libmaple may fail.
27 | __attribute__((constructor)) void premain() {
28 | init();
29 | }
30 |
31 | int main(void) {
32 | setup();
33 |
34 | while (true) {
35 | loop();
36 | }
37 | return 0;
38 | }
39 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/examples/test-systick.cpp:
--------------------------------------------------------------------------------
1 | // Tests the SysTick enable/disable functions
2 |
3 | #include "wirish.h"
4 | #include "systick.h"
5 |
6 | void setup() {
7 | pinMode(BOARD_LED_PIN, OUTPUT);
8 | pinMode(BOARD_BUTTON_PIN, INPUT);
9 | }
10 |
11 | bool disable = true;
12 | long time = 0;
13 |
14 | void loop() {
15 | volatile int i = 0;
16 | toggleLED();
17 |
18 | // An artificial delay
19 | for(i = 0; i < 150000; i++)
20 | ;
21 |
22 | if (isButtonPressed()) {
23 | if (disable) {
24 | systick_disable();
25 | SerialUSB.println("Disabling SysTick");
26 | } else {
27 | SerialUSB.println("Re-enabling SysTick");
28 | systick_enable();
29 | }
30 | disable = !disable;
31 | }
32 |
33 | SerialUSB.println(millis());
34 | }
35 |
36 | // Force init to be called *first*, i.e. before static object allocation.
37 | // Otherwise, statically allocated object that need libmaple may fail.
38 | __attribute__((constructor)) void premain() {
39 | init();
40 | }
41 |
42 | int main(void) {
43 | setup();
44 |
45 | while (true) {
46 | loop();
47 | }
48 | return 0;
49 | }
50 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libMaple.vcproj.ALA.ich.user:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
35 |
36 |
39 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libmaple/delay.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file delay.h
3 | * @brief Delay implementation
4 | */
5 |
6 | #include "libmaple_types.h"
7 | #include "stm32.h"
8 |
9 | #ifndef _DELAY_H_
10 | #define _DELAY_H_
11 |
12 | /**
13 | * @brief Delay the given number of microseconds.
14 | *
15 | * @param us Number of microseconds to delay.
16 | */
17 | static inline void delay_us(uint32 us) {
18 | us *= STM32_DELAY_US_MULT;
19 |
20 | /* fudge for function call overhead */
21 | //us--;
22 | asm volatile(" mov r0, %[us] \n\t"
23 | "1: subs r0, #1 \n\t"
24 | " bhi 1b \n\t"
25 | :
26 | : [us] "r" (us)
27 | : "r0");
28 | }
29 |
30 | static inline void delay_ns100(uint32 us) {
31 | us *= STM32_DELAY_US_MULT;
32 | us /= 10;
33 |
34 | /* fudge for function call overhead */
35 | //us--;
36 | asm volatile(" mov r0, %[us] \n\t"
37 | "1: subs r0, #1 \n\t"
38 | " bhi 1b \n\t"
39 | :
40 | : [us] "r" (us)
41 | : "r0");
42 | }
43 | #endif
44 |
45 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libmaple/flash.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 Perry Hung.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | /**
28 | * @file flash.c
29 | * @brief Flash management functions
30 | */
31 |
32 | #include "libmaple.h"
33 | #include "flash.h"
34 | #include "bitband.h"
35 |
36 | /**
37 | * @brief Turn on the hardware prefetcher.
38 | */
39 | void flash_enable_prefetch(void) {
40 | *bb_perip(&FLASH_BASE->ACR, FLASH_ACR_PRFTBE_BIT) = 1;
41 | }
42 |
43 | /**
44 | * @brief Set flash wait states
45 | *
46 | * See ST PM0042, section 3.1 for restrictions on the acceptable value
47 | * of wait_states for a given SYSCLK configuration.
48 | *
49 | * @param wait_states number of wait states (one of
50 | * FLASH_WAIT_STATE_0, FLASH_WAIT_STATE_1,
51 | * FLASH_WAIT_STATE_2).
52 | */
53 | void flash_set_latency(uint32 wait_states) {
54 | uint32 val = FLASH_BASE->ACR;
55 |
56 | val &= ~FLASH_ACR_LATENCY;
57 | val |= wait_states;
58 |
59 | FLASH_BASE->ACR = val;
60 | }
61 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libmaple/gpio.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 Perry Hung.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | /**
28 | * @file gpio.c
29 | * @brief GPIO initialization routine
30 | */
31 |
32 | #ifdef STM32F2
33 | #include "gpioF2.c"
34 | #else
35 | #include "gpioF1.c"
36 | #endif
37 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libmaple/gpio.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 Perry Hung.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | /**
28 | * @file gpio.h
29 | *
30 | * @brief General purpose I/O (GPIO) and Alternate Function I/O
31 | * (AFIO) prototypes, defines, and inlined access functions.
32 | */
33 |
34 | #ifdef STM32F2
35 | #include "gpioF2.h"
36 | #else
37 | #include "gpioF1.h"
38 | #endif
39 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libmaple/iwdg.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 Michael Hope.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | /**
28 | * @file iwdg.c
29 | * @brief Independent watchdog (IWDG) support
30 | */
31 |
32 | #include "iwdg.h"
33 |
34 | /**
35 | * @brief Initialise and start the watchdog
36 | *
37 | * The prescaler and reload set the timeout. For example, a prescaler
38 | * of IWDG_PRE_32 divides the 40 kHz clock by 32 and gives roughly 1
39 | * ms per reload.
40 | *
41 | * @param prescaler Prescaler for the 40 kHz IWDG clock.
42 | * @param reload Independent watchdog counter reload value.
43 | */
44 | void iwdg_init(iwdg_prescaler prescaler, uint16 reload) {
45 | IWDG_BASE->KR = IWDG_KR_UNLOCK;
46 | IWDG_BASE->PR = prescaler;
47 | IWDG_BASE->RLR = reload;
48 |
49 | /* Start things off */
50 | IWDG_BASE->KR = IWDG_KR_START;
51 | iwdg_feed();
52 | }
53 |
54 | /**
55 | * @brief Reset the IWDG counter.
56 | *
57 | * Calling this function will cause the IWDG counter to be reset to
58 | * its reload value.
59 | */
60 | void iwdg_feed(void) {
61 | IWDG_BASE->KR = IWDG_KR_FEED;
62 | }
63 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libmaple/libmaple.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 Perry Hung.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | /**
28 | * @file libmaple.h
29 | * @brief General include file for libmaple
30 | */
31 |
32 | #ifndef _LIBMAPLE_H_
33 | #define _LIBMAPLE_H_
34 |
35 | #include "libmaple_types.h"
36 | #include "stm32.h"
37 | #include "util.h"
38 | #include "delay.h"
39 |
40 | /*
41 | * Where to put usercode, based on space reserved for bootloader.
42 | *
43 | * FIXME this has no business being here
44 | */
45 | #if defined(MCU_STM32F103VE) || defined(MCU_STM32F205VE) || defined(MCU_STM32F406VG)
46 | /* e.g., Aeroquad32 */
47 | #define USER_ADDR_ROM 0x08010000 /* ala42 */
48 | #define USER_ADDR_RAM 0x20000C00
49 | #define STACK_TOP 0x20000800
50 | #else
51 | #define USER_ADDR_ROM 0x08005000
52 | #define USER_ADDR_RAM 0x20000C00
53 | #define STACK_TOP 0x20000800
54 | #endif
55 | #endif
56 |
57 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libmaple/libmaple_types.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 Perry Hung.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | /**
28 | * @file libmaple_types.h
29 | *
30 | * @brief libmaple types
31 | */
32 |
33 | #ifndef _LIBMAPLE_TYPES_H_
34 | #define _LIBMAPLE_TYPES_H_
35 |
36 | typedef unsigned char uint8;
37 | typedef unsigned short uint16;
38 | typedef unsigned int uint32;
39 | typedef unsigned long long uint64;
40 |
41 | typedef signed char int8;
42 | typedef short int16;
43 | typedef int int32;
44 | typedef long long int64;
45 |
46 | typedef void (*voidFuncPtr)(void);
47 |
48 | #define __io volatile
49 | #define __attr_flash __attribute__((section (".USER_FLASH")))
50 |
51 | #ifndef NULL
52 | #define NULL 0
53 | #endif
54 |
55 | #endif
56 |
57 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libmaple/pwr.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2011 LeafLabs, LLC.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | /**
28 | * @file pwr.c
29 | * @brief Power control (PWR) support.
30 | */
31 |
32 | #include "pwr.h"
33 | #include "rcc.h"
34 |
35 | /**
36 | * Enables the power interface clock, and resets the power device.
37 | */
38 | void pwr_init(void) {
39 | rcc_clk_enable(RCC_PWR);
40 | rcc_reset_dev(RCC_PWR);
41 | }
42 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libmaple/pwr.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 LeafLabs, LLC.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | /**
28 | * @file pwr.h
29 | * @brief Power control (PWR) defines.
30 | */
31 |
32 | #include "libmaple.h"
33 |
34 | #ifdef __cplusplus
35 | extern "C" {
36 | #endif
37 |
38 | /** Power interface register map. */
39 | typedef struct pwr_reg_map {
40 | __io uint32 CR; /**< Control register */
41 | __io uint32 CSR; /**< Control and status register */
42 | } pwr_reg_map;
43 |
44 | /** Power peripheral register map base pointer. */
45 | #define PWR_BASE ((struct pwr_reg_map*)0x40007000)
46 |
47 | /*
48 | * Register bit definitions
49 | */
50 |
51 | /* Control register */
52 |
53 | /** Disable backup domain write protection bit */
54 | #define PWR_CR_DBP 8
55 | /** Power voltage detector enable bit */
56 | #define PWR_CR_PVDE 4
57 | /** Clear standby flag bit */
58 | #define PWR_CR_CSBF 3
59 | /** Clear wakeup flag bit */
60 | #define PWR_CR_CWUF 2
61 | /** Power down deepsleep bit */
62 | #define PWR_CR_PDDS 1
63 | /** Low-power deepsleep bit */
64 | #define PWR_CR_LPDS 0
65 |
66 | /* Control and status register */
67 |
68 | /** Enable wakeup pin bit */
69 | #define PWR_CSR_EWUP 8
70 | /** PVD output bit */
71 | #define PWR_CSR_PVDO 2
72 | /** Standby flag bit */
73 | #define PWR_CSR_SBF 1
74 | /** Wakeup flag bit */
75 | #define PWR_CSR_WUF 0
76 |
77 | /*
78 | * Convenience functions
79 | */
80 |
81 | void pwr_init(void);
82 |
83 | #ifdef __cplusplus
84 | }
85 | #endif
86 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libmaple/rcc.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 Perry Hung.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | /**
28 | * @file rcc.c
29 | * @brief Implements pretty much only the basic clock setup on the
30 | * stm32, clock enable/disable and peripheral reset commands.
31 | */
32 |
33 | #ifdef STM32F2
34 | #include "rccF2.c"
35 | #else
36 | #include "rccF1.c"
37 | #endif
38 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libmaple/rcc.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 Perry Hung.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | /**
28 | * @file rcc.h
29 | * @brief reset and clock control definitions and prototypes
30 | */
31 |
32 | #ifdef STM32F2
33 | #include "rccF2.h"
34 | #else
35 | #include "rccF1.h"
36 | #endif
37 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libmaple/rules.mk:
--------------------------------------------------------------------------------
1 | # Standard things
2 | sp := $(sp).x
3 | dirstack_$(sp) := $(d)
4 | d := $(dir)
5 | BUILDDIRS += $(BUILD_PATH)/$(d)
6 | BUILDDIRS += $(BUILD_PATH)/$(d)/usb
7 | BUILDDIRS += $(BUILD_PATH)/$(d)/usb/usb_lib
8 |
9 | LIBMAPLE_INCLUDES := -I$(LIBMAPLE_PATH) -I$(LIBMAPLE_PATH)/usb -I$(LIBMAPLE_PATH)/usb/usb_lib
10 |
11 | # Local flags
12 | CFLAGS_$(d) = -I$(d) $(LIBMAPLE_INCLUDES) -Wall -Werror
13 |
14 | # Local rules and targets
15 | # bkp.c
16 |
17 | cSRCS_$(d) := adc.c \
18 | dac.c \
19 | dma.c \
20 | exti.c \
21 | flash.c \
22 | fsmc.c \
23 | gpio.c \
24 | iwdg.c \
25 | nvic.c \
26 | pwr.c \
27 | i2c.c \
28 | rcc.c \
29 | spi.c \
30 | syscalls.c \
31 | systick.c \
32 | timer.c \
33 | usart.c \
34 | util.c \
35 | usb/descriptors.c \
36 | usb/usb.c \
37 | usb/usb_callbacks.c \
38 | usb/usb_hardware.c \
39 | usb/usb_lib/usb_core.c \
40 | usb/usb_lib/usb_init.c \
41 | usb/usb_lib/usb_int.c \
42 | usb/usb_lib/usb_mem.c \
43 | usb/usb_lib/usb_regs.c
44 |
45 | ifneq ($(MCU_FAMILY), STM32F2)
46 | cSRCS_$(d) += bkp.c
47 | endif
48 |
49 | sSRCS_$(d) := exc.S
50 |
51 | cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%)
52 | sFILES_$(d) := $(sSRCS_$(d):%=$(d)/%)
53 |
54 | OBJS_$(d) := $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) $(sFILES_$(d):%.S=$(BUILD_PATH)/%.o)
55 | DEPS_$(d) := $(OBJS_$(d):%.o=%.d)
56 |
57 | $(OBJS_$(d)): TGT_CFLAGS := $(CFLAGS_$(d))
58 | $(OBJS_$(d)): TGT_ASFLAGS :=
59 |
60 | TGT_BIN += $(OBJS_$(d))
61 |
62 | # Standard things
63 | -include $(DEPS_$(d))
64 | d := $(dirstack_$(sp))
65 | sp := $(basename $(sp))
66 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libmaple/usb/usb.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 LeafLabs LLC.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in
15 | * all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | #ifndef _USB_H_
28 | #define _USB_H_
29 |
30 | #include "usb_lib.h"
31 | #include "libmaple.h"
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | typedef enum {
38 | RESUME_EXTERNAL,
39 | RESUME_INTERNAL,
40 | RESUME_LATER,
41 | RESUME_WAIT,
42 | RESUME_START,
43 | RESUME_ON,
44 | RESUME_OFF,
45 | RESUME_ESOF
46 | } RESUME_STATE;
47 |
48 | typedef enum {
49 | UNCONNECTED,
50 | ATTACHED,
51 | POWERED,
52 | SUSPENDED,
53 | ADDRESSED,
54 | CONFIGURED
55 | } DEVICE_STATE;
56 |
57 | extern volatile uint32 bDeviceState;
58 |
59 | void setupUSB(void);
60 | void disableUSB(void);
61 | void usbSuspend(void);
62 | void usbResumeInit(void);
63 | void usbResume(RESUME_STATE);
64 |
65 | RESULT usbPowerOn(void);
66 | RESULT usbPowerOff(void);
67 |
68 | void usbDsbISR(void);
69 | void usbEnbISR(void);
70 |
71 | /* overloaded ISR routine, this is the main usb ISR */
72 | void __irq_usb_lp_can_rx0(void);
73 | void usbWaitReset(void);
74 |
75 | /* blocking functions for send/receive */
76 | void usbBlockingSendByte(char ch);
77 | uint32 usbSendBytes(const uint8* sendBuf,uint32 len);
78 | uint32 usbBytesAvailable(void);
79 | uint32 usbReceiveBytes(uint8* recvBuf, uint32 len);
80 | uint8 usbGetDTR(void);
81 | uint8 usbGetRTS(void);
82 | uint8 usbIsConnected(void);
83 | uint8 usbIsConfigured(void);
84 | uint16 usbGetPending(void);
85 |
86 | void usbSendHello(void);
87 |
88 | #ifdef __cplusplus
89 | } // extern "C"
90 | #endif
91 |
92 | #endif // _USB_H_
93 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libmaple/usb/usb_callbacks.h:
--------------------------------------------------------------------------------
1 | /* insert license */
2 |
3 | #ifndef __USB_CALLBACKS
4 | #define __USB_CALLBACKS
5 |
6 | #include "libmaple.h"
7 | #include "usb_lib.h"
8 | #include "usb_config.h"
9 |
10 | #define SET_LINE_CODING 0x20
11 | #define GET_LINE_CODING 0x21
12 | #define SET_COMM_FEATURE 0x02
13 | #define SET_CONTROL_LINE_STATE 0x22
14 | #define CONTROL_LINE_DTR (0x01)
15 | #define CONTROL_LINE_RTS (0x02)
16 |
17 | #if defined(__cplusplus)
18 | extern "C" {
19 | #endif
20 |
21 | typedef struct {
22 | uint32 bitrate;
23 | uint8 format;
24 | uint8 paritytype;
25 | uint8 datatype;
26 | } USB_Line_Coding;
27 |
28 | typedef enum {
29 | DTR_UNSET,
30 | DTR_HIGH,
31 | DTR_NEGEDGE,
32 | DTR_LOW
33 | } RESET_STATE;
34 |
35 | extern RESET_STATE reset_state; /* tracks DTR/RTS */
36 | extern uint8 line_dtr_rts;
37 | extern volatile uint32 countTx;
38 | extern uint8 vcomBufferRx[VCOM_RX_BUFLEN]; /* no reason this has to be VCOM_RX_EPSIZE, could be bigger */
39 | extern volatile uint32 recvBufIn; /* the FIFO in index to the recvbuffer */
40 | extern volatile uint32 recvBufOut; /* the FIFO out index to the recvbuffer */
41 | extern volatile uint32 maxNewBytes;
42 | extern volatile uint32 newBytes;
43 |
44 | void vcomDataTxCb(void);
45 | void vcomDataRxCb(void);
46 | void vcomManagementCb(void);
47 |
48 | uint8* vcomGetSetLineCoding(uint16 length);
49 | void vcomSetLineSate(void);
50 |
51 | void usbInit(void);
52 | /* internal functions (as per the usb_core pProperty structure) */
53 | void usbInit(void);
54 | void usbReset(void);
55 | void usbStatusIn(void);
56 | void usbStatusOut(void);
57 |
58 | RESULT usbDataSetup(uint8 request);
59 | RESULT usbNoDataSetup(uint8 request);
60 | RESULT usbGetInterfaceSetting(uint8,uint8);
61 |
62 | uint8* usbGetDeviceDescriptor(uint16 length);
63 | uint8* usbGetConfigDescriptor(uint16 length);
64 | uint8* usbGetStringDescriptor(uint16 length);
65 |
66 | /* internal callbacks to respond to standard requests */
67 | void usbSetConfiguration(void);
68 | void usbSetDeviceAddress(void);
69 |
70 | #if defined(__cplusplus)
71 | }
72 | #endif
73 |
74 |
75 | #endif
76 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libmaple/usb/usb_lib/usb_init.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
2 | * File Name : usb_init.h
3 | * Author : MCD Application Team
4 | * Version : V2.2.1
5 | * Date : 09/22/2008
6 | * Description : Initialization routines & global variables
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 |
16 | /* Define to prevent recursive inclusion -------------------------------------*/
17 | #ifndef __USB_INIT_H
18 | #define __USB_INIT_H
19 |
20 | #if defined(__cplusplus)
21 | extern "C" {
22 | #endif
23 |
24 | /* Includes ------------------------------------------------------------------*/
25 | /* Exported types ------------------------------------------------------------*/
26 | /* Exported constants --------------------------------------------------------*/
27 | /* Exported macro ------------------------------------------------------------*/
28 | /* Exported functions ------------------------------------------------------- */
29 | void USB_Init(void);
30 |
31 | /* External variables --------------------------------------------------------*/
32 | /* The number of current endpoint, it will be used to specify an endpoint */
33 | extern u8 EPindex;
34 | /* The number of current device, it is an index to the Device_Table */
35 | /*extern u8 Device_no; */
36 | /* Points to the DEVICE_INFO structure of current device */
37 | /* The purpose of this register is to speed up the execution */
38 | extern DEVICE_INFO* pInformation;
39 | /* Points to the DEVICE_PROP structure of current device */
40 | /* The purpose of this register is to speed up the execution */
41 | extern DEVICE_PROP* pProperty;
42 | /* Temporary save the state of Rx & Tx status. */
43 | /* Whenever the Rx or Tx state is changed, its value is saved */
44 | /* in this variable first and will be set to the EPRB or EPRA */
45 | /* at the end of interrupt process */
46 | extern USER_STANDARD_REQUESTS *pUser_Standard_Requests;
47 |
48 | extern u16 SaveState ;
49 | extern u16 wInterrupt_Mask;
50 |
51 | #if defined(__cplusplus)
52 | }
53 | #endif
54 |
55 | #endif /* __USB_INIT_H */
56 |
57 | /******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
58 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libmaple/usb/usb_lib/usb_int.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
2 | * File Name : usb_int.h
3 | * Author : MCD Application Team
4 | * Version : V2.2.1
5 | * Date : 09/22/2008
6 | * Description : Endpoint CTR (Low and High) interrupt's service routines
7 | * prototypes
8 | ********************************************************************************
9 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
10 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
11 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
12 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
13 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
14 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
15 | *******************************************************************************/
16 |
17 | /* Define to prevent recursive inclusion -------------------------------------*/
18 | #ifndef __USB_INT_H
19 | #define __USB_INT_H
20 |
21 | /* Includes ------------------------------------------------------------------*/
22 | /* Exported types ------------------------------------------------------------*/
23 | /* Exported constants --------------------------------------------------------*/
24 | /* Exported macro ------------------------------------------------------------*/
25 | /* Exported functions ------------------------------------------------------- */
26 | #if defined(__cplusplus)
27 | extern "C" {
28 | #endif
29 |
30 | void CTR_LP(void);
31 | void CTR_HP(void);
32 |
33 | /* External variables --------------------------------------------------------*/
34 |
35 | #if defined(__cplusplus)
36 | }
37 | #endif
38 |
39 | #endif /* __USB_INT_H */
40 |
41 | /******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
42 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libmaple/usb/usb_lib/usb_lib.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
2 | * File Name : usb_lib.h
3 | * Author : MCD Application Team
4 | * Version : V2.2.1
5 | * Date : 09/22/2008
6 | * Description : USB library include files
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 |
16 | /* Define to prevent recursive inclusion -------------------------------------*/
17 | #ifndef __USB_LIB_H
18 | #define __USB_LIB_H
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "usb_type.h"
22 | #include "usb_regs.h"
23 | #include "usb_def.h"
24 | #include "usb_core.h"
25 | #include "usb_init.h"
26 | #include "usb_mem.h"
27 | #include "usb_int.h"
28 |
29 | /* Exported types ------------------------------------------------------------*/
30 | /* Exported constants --------------------------------------------------------*/
31 | /* Exported macro ------------------------------------------------------------*/
32 | /* Exported functions ------------------------------------------------------- */
33 | /* External variables --------------------------------------------------------*/
34 |
35 | #endif /* __USB_LIB_H */
36 |
37 | /******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
38 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libmaple/usb/usb_lib/usb_mem.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
2 | * File Name : usb_mem.h
3 | * Author : MCD Application Team
4 | * Version : V2.2.1
5 | * Date : 09/22/2008
6 | * Description : Utility prototypes functions for memory/PMA transfers
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 |
16 | /* Define to prevent recursive inclusion -------------------------------------*/
17 | #ifndef __USB_MEM_H
18 | #define __USB_MEM_H
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | /* Exported types ------------------------------------------------------------*/
22 | /* Exported constants --------------------------------------------------------*/
23 | /* Exported macro ------------------------------------------------------------*/
24 | /* Exported functions ------------------------------------------------------- */
25 | #if defined(__cplusplus)
26 | extern "C" {
27 | #endif
28 |
29 | void UserToPMABufferCopy(const u8 *pbUsrBuf, u16 wPMABufAddr, u16 wNBytes);
30 | void PMAToUserBufferCopy(u8 *pbUsrBuf, u16 wPMABufAddr, u16 wNBytes);
31 |
32 | #if defined(__cplusplus)
33 | }
34 | #endif
35 |
36 | /* External variables --------------------------------------------------------*/
37 |
38 | #endif /*__USB_MEM_H*/
39 |
40 | /******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
41 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/FreeRTOS/MapleFreeRTOS.cpp:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2011 LeafLabs, LLC.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | #include "MapleFreeRTOS.h"
28 |
29 | extern "C" {
30 |
31 | void vApplicationStackOverflowHook(xTaskHandle *pxTask,
32 | signed char *pcTaskName) {
33 | /* This function will get called if a task overflows its stack.
34 | * If the parameters are corrupt then inspect pxCurrentTCB to find
35 | * which was the offending task. */
36 |
37 | (void) pxTask;
38 | (void) pcTaskName;
39 |
40 | while (1)
41 | ;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/FreeRTOS/MapleFreeRTOS.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2011 LeafLabs, LLC.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | #ifndef __MAPLE_FREERTOS_H__
28 | #define __MAPLE_FREERTOS_H__
29 |
30 | #include "wirish.h"
31 |
32 | extern "C" {
33 | #define GCC_ARMCM3
34 | #include "utility/FreeRTOS.h"
35 | #include "utility/task.h"
36 | #include "utility/queue.h"
37 | #include "utility/semphr.h"
38 | }
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/FreeRTOS/keywords.txt:
--------------------------------------------------------------------------------
1 | #######################################
2 | # Syntax Coloring Map For CoOS
3 | #######################################
4 |
5 | #######################################
6 | # Datatypes (KEYWORD1)
7 | #######################################
8 |
9 | #######################################
10 | # Methods and Functions (KEYWORD2)
11 | #######################################
12 | vTaskDelay KEYWORD2
13 | vTaskDelayUntil KEYWORD2
14 | xTaskCreate KEYWORD2
15 | vTaskSuspend KEYWORD2
16 | vTaskDelete KEYWORD2
17 | vTaskPrioritySet KEYWORD2
18 | uxTaskPriorityGet KEYWORD2
19 | vTaskStartScheduler KEYWORD2
20 | vApplicationIdleHook KEYWORD2
21 |
22 | #######################################
23 | # Constants (LITERAL1)
24 | #######################################
25 | configUSE_IDLE_HOOK LITERAL1
26 | configMINIMAL_STACK_SIZE LITERAL1
27 | tskIDLE_PRIORITY LITERAL1
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/FreeRTOS/rules.mk:
--------------------------------------------------------------------------------
1 | # Standard things
2 | sp := $(sp).x
3 | dirstack_$(sp) := $(d)
4 | d := $(dir)
5 | BUILDDIRS += $(BUILD_PATH)/$(d)
6 | BUILDDIRS += $(BUILD_PATH)/$(d)/utility
7 |
8 | # Local flags
9 | CXXFLAGS_$(d) := $(WIRISH_INCLUDES) $(LIBMAPLE_INCLUDES)
10 | CFLAGS_$(d) := $(WIRISH_INCLUDES) $(LIBMAPLE_INCLUDES)
11 |
12 | # Local rules and targets
13 | cSRCS_$(d) := utility/croutine.c \
14 | utility/heap_2.c \
15 | utility/list.c \
16 | utility/port.c \
17 | utility/queue.c \
18 | utility/timers.c \
19 | utility/tasks.c \
20 |
21 | cppSRCS_$(d) := MapleFreeRTOS.cpp
22 |
23 | cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%)
24 | cppFILES_$(d) := $(cppSRCS_$(d):%=$(d)/%)
25 |
26 | OBJS_$(d) := $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) \
27 | $(cppFILES_$(d):%.cpp=$(BUILD_PATH)/%.o)
28 | DEPS_$(d) := $(OBJS_$(d):%.o=%.d)
29 |
30 | $(OBJS_$(d)): TGT_CXXFLAGS := $(CXXFLAGS_$(d))
31 | $(OBJS_$(d)): TGT_CFLAGS := $(CFLAGS_$(d))
32 |
33 | TGT_BIN += $(OBJS_$(d))
34 |
35 | # Standard things
36 | -include $(DEPS_$(d))
37 | d := $(dirstack_$(sp))
38 | sp := $(basename $(sp))
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/LiquidCrystal/rules.mk:
--------------------------------------------------------------------------------
1 | # Standard things
2 | sp := $(sp).x
3 | dirstack_$(sp) := $(d)
4 | d := $(dir)
5 | BUILDDIRS += $(BUILD_PATH)/$(d)
6 |
7 | # Local flags
8 | CFLAGS_$(d) := $(WIRISH_INCLUDES) $(LIBMAPLE_INCLUDES)
9 |
10 | # Local rules and targets
11 | cSRCS_$(d) :=
12 |
13 | cppSRCS_$(d) := LiquidCrystal.cpp
14 |
15 | cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%)
16 | cppFILES_$(d) := $(cppSRCS_$(d):%=$(d)/%)
17 |
18 | OBJS_$(d) := $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) \
19 | $(cppFILES_$(d):%.cpp=$(BUILD_PATH)/%.o)
20 | DEPS_$(d) := $(OBJS_$(d):%.o=%.d)
21 |
22 | $(OBJS_$(d)): TGT_CFLAGS := $(CFLAGS_$(d))
23 |
24 | TGT_BIN += $(OBJS_$(d))
25 |
26 | # Standard things
27 | -include $(DEPS_$(d))
28 | d := $(dirstack_$(sp))
29 | sp := $(basename $(sp))
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/Servo/rules.mk:
--------------------------------------------------------------------------------
1 | # Standard things
2 | sp := $(sp).x
3 | dirstack_$(sp) := $(d)
4 | d := $(dir)
5 | BUILDDIRS += $(BUILD_PATH)/$(d)
6 |
7 | # Local flags
8 | CXXFLAGS_$(d) := $(WIRISH_INCLUDES) $(LIBMAPLE_INCLUDES)
9 |
10 | # Local rules and targets
11 | cSRCS_$(d) :=
12 |
13 | cppSRCS_$(d) := Servo.cpp
14 |
15 | cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%)
16 | cppFILES_$(d) := $(cppSRCS_$(d):%=$(d)/%)
17 |
18 | OBJS_$(d) := $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) \
19 | $(cppFILES_$(d):%.cpp=$(BUILD_PATH)/%.o)
20 | DEPS_$(d) := $(OBJS_$(d):%.o=%.d)
21 |
22 | $(OBJS_$(d)): TGT_CXXFLAGS := $(CXXFLAGS_$(d))
23 |
24 | TGT_BIN += $(OBJS_$(d))
25 |
26 | # Standard things
27 | -include $(DEPS_$(d))
28 | d := $(dirstack_$(sp))
29 | sp := $(basename $(sp))
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/Wire/README:
--------------------------------------------------------------------------------
1 | Wirish soft (bit-banged) implementation of the Wire I2C library.
2 |
3 | This implementation is synchronous, and thus supports only a subset of
4 | the full Wire interface. An asynchronous hardware version implemented
5 | with DMA is expected for Maple IDE release 0.1.0.
6 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/Wire/rules.mk:
--------------------------------------------------------------------------------
1 | # Standard things
2 | sp := $(sp).x
3 | dirstack_$(sp) := $(d)
4 | d := $(dir)
5 | BUILDDIRS += $(BUILD_PATH)/$(d)
6 |
7 | # Local flags
8 | CFLAGS_$(d) := $(WIRISH_INCLUDES) $(LIBMAPLE_INCLUDES)
9 |
10 | # Local rules and targets
11 | cSRCS_$(d) :=
12 |
13 | cppSRCS_$(d) := Wire.cpp
14 |
15 | cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%)
16 | cppFILES_$(d) := $(cppSRCS_$(d):%=$(d)/%)
17 |
18 | OBJS_$(d) := $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) \
19 | $(cppFILES_$(d):%.cpp=$(BUILD_PATH)/%.o)
20 | DEPS_$(d) := $(OBJS_$(d):%.o=%.d)
21 |
22 | $(OBJS_$(d)): TGT_CFLAGS := $(CFLAGS_$(d))
23 |
24 | TGT_BIN += $(OBJS_$(d))
25 |
26 | # Standard things
27 | -include $(DEPS_$(d))
28 | d := $(dirstack_$(sp))
29 | sp := $(basename $(sp))
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/mapleSDfat/Document1.txt:
--------------------------------------------------------------------------------
1 | EB 3C 90
2 | 4D 53 44 4F 53 35 2E 30
3 | 0 2
4 | 40
5 | 8 0
6 | 2 fat count
7 | 0 2
8 | 0 0 F8 F0 0 3F 0 FF 0 3F 0 0 0
9 | C1 FF 3B 0 80 0 29 4D C5 39 80 4E 4F 20 4E 41
10 | 4D 45 20 20 20 20 46 41 54 31 36 20 20 20 33 C9
11 | 8E D1 BC F0 7B 8E D9 B8 0 20 8E C0 FC BD 0 7C
12 | 38 4E 24 7D 24 8B C1 99 E8 3C 1 72 1C 83 EB 3A
13 | 66 A1 1C 7C 26 66 3B 7 26 8A 57 FC 75 6 80 CA
14 | 2 88 56 2 80 C3 10 73 EB 33 C9 8A 46 10 98 F7
15 | 66 16 3 46 1C 13 56 1E 3 46 E 13 D1 8B 76 11
16 | 60 89 46 FC 89 56 FE B8 20 0 F7 E6 8B 5E B 3
17 | C3 48 F7 F3 1 46 FC 11 4E FE 61 BF 0 0 E8 E6
18 | 0 72 39 26 38 2D 74 17 60 B1 B BE A1 7D F3 A6
19 | 61 74 32 4E 74 9 83 C7 20 3B FB 72 E6 EB DC A0
20 | FB 7D B4 7D 8B F0 AC 98 40 74 C 48 74 13 B4 E
21 | BB 7 0 CD 10 EB EF A0 FD 7D EB E6 A0 FC 7D EB
22 | E1 CD 16 CD 19 26 8B 55 1A 52 B0 1 BB 0 0 E8
23 | 3B 0 72 E8 5B 8A 56 24 BE B 7C 8B FC C7 46 F0
24 | 3D 7D C7 46 F4 29 7D 8C D9 89 4E F2 89 4E F6 C6
25 | 6 96 7D CB EA 3 0 0 20 F B6 C8 66 8B 46 F8
26 | 66 3 46 1C 66 8B D0 66 C1 EA 10 EB 5E F B6 C8
27 | 4A 4A 8A 46 D 32 E4 F7 E2 3 46 FC 13 56 FE EB
28 | 4A 52 50 6 53 6A 1 6A 10 91 8B 46 18 96 92 33
29 | D2 F7 F6 91 F7 F6 42 87 CA F7 76 1A 8A F2 8A E8
30 | C0 CC 2 A CC B8 1 2 80 7E 2 E 75 4 B4 42
31 | 8B F4 8A 56 24 CD 13 61 61 72 B 40 75 1 42 3
32 | 5E B 49 75 6 F8 C3 41 BB 0 0 60 66 6A 0 EB
33 | B0 4E 54 4C 44 52 20 20 20 20 20 20 D A 52 65
34 | 6D 6F 76 65 20 64 69 73 6B 73 20 6F 72 20 6F 74
35 | 68 65 72 20 6D 65 64 69 61 2E FF D A 44 69 73
36 | 6B 20 65 72 72 6F 72 FF D A 50 72 65 73 73 20
37 | 61 6E 79 20 6B 65 79 20 74 6F 20 72 65 73 74 61
38 | 72 74 D A 0 0 0 0 0 0 0 AC CB D8 55 AA
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/mapleSDfat/SdFatUtil.h:
--------------------------------------------------------------------------------
1 | /* Arduino SdFat Library
2 | * Copyright (C) 2008 by William Greiman
3 | *
4 | * This file is part of the Arduino SdFat Library
5 | *
6 | * This Library is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This Library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 |
16 | * You should have received a copy of the GNU General Public License
17 | * along with the Arduino SdFat Library. If not, see
18 | * .
19 | */
20 | #ifndef SdFatUtil_h
21 | #define SdFatUtil_h
22 | /**
23 | * \file
24 | * Useful utility functions.
25 | */
26 | #include
27 | //#include
28 | /** Store and print a string in flash memory.*/
29 | #define PgmPrint(x) SerialPrint_P(PSTR(x))
30 | /** Store and print a string in flash memory followed by a CR/LF.*/
31 | #define PgmPrintln(x) SerialPrintln_P(PSTR(x))
32 | /** Defined so doxygen works for function definitions. */
33 | #define NOINLINE __attribute__((noinline))
34 | //------------------------------------------------------------------------------
35 | /** Return the number of bytes currently free in RAM. */
36 | static int FreeRam(void) {
37 | extern int __bss_end;
38 | extern int* __brkval;
39 | int free_memory;
40 | if (reinterpret_cast(__brkval) == 0) {
41 | // if no heap use from end of bss section
42 | free_memory = reinterpret_cast(&free_memory)
43 | - reinterpret_cast(&__bss_end);
44 | } else {
45 | // use from top of stack to heap
46 | free_memory = reinterpret_cast(&free_memory)
47 | - reinterpret_cast(__brkval);
48 | }
49 | return free_memory;
50 | }
51 | #endif // #define SdFatUtil_h
52 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/mapleSDfat/examples/Arduino Examples/SdFatAppend/SdFatAppend.pde:
--------------------------------------------------------------------------------
1 | /*
2 | * Append Example
3 | *
4 | * This sketch shows how to use open for append and the Arduino Print class
5 | * with SdFat.
6 | */
7 | #include
8 | #include // use functions to print strings from flash memory
9 |
10 | Sd2Card card;
11 | SdVolume volume;
12 | SdFile root;
13 | SdFile file;
14 |
15 | // store error strings in flash to save RAM
16 | #define error(s) error_P(PSTR(s))
17 |
18 | void error_P(const char* str) {
19 | PgmPrint("error: ");
20 | SerialPrintln_P(str);
21 | if (card.errorCode()) {
22 | PgmPrint("SD error: ");
23 | Serial.print(card.errorCode(), HEX);
24 | Serial.print(',');
25 | Serial.println(card.errorData(), HEX);
26 | }
27 | while(1);
28 | }
29 |
30 | void setup(void) {
31 | Serial.begin(9600);
32 | Serial.println();
33 | PgmPrintln("Type any character to start");
34 | while (!Serial.available());
35 |
36 | // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
37 | // breadboards. use SPI_FULL_SPEED for better performance.
38 | if (!card.init(SPI_HALF_SPEED)) error("card.init failed");
39 |
40 | // initialize a FAT volume
41 | if (!volume.init(&card)) error("volume.init failed");
42 |
43 | // open the root directory
44 | if (!root.openRoot(&volume)) error("openRoot failed");
45 |
46 | char name[] = "APPEND.TXT";
47 | PgmPrint("Appending to: ");
48 | Serial.println(name);
49 |
50 | // clear write error
51 | file.writeError = false;
52 |
53 | for (uint8_t i = 0; i < 100; i++) {
54 | // O_CREAT - create the file if it does not exist
55 | // O_APPEND - seek to the end of the file prior to each write
56 | // O_WRITE - open for write
57 | if (!file.open(&root, name, O_CREAT | O_APPEND | O_WRITE)) {
58 | error("open failed");
59 | }
60 | // print 100 lines to file
61 | for (uint8_t j = 0; j < 100; j++) {
62 | file.print("line ");
63 | file.print(j, DEC);
64 | file.print(" of pass ");
65 | file.print(i, DEC);
66 | file.print(" millis = ");
67 | file.println(millis());
68 | }
69 | if (file.writeError) error("write failed");
70 | if (!file.close()) error("close failed");
71 | if (i > 0 && i%25 == 0)Serial.println();
72 | Serial.print('.');
73 | }
74 | Serial.println();
75 | Serial.println("Done");
76 | }
77 | void loop(void){}
78 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/mapleSDfat/examples/Arduino Examples/SdFatCopy/SdFatCopy.pde:
--------------------------------------------------------------------------------
1 | /*
2 | * Copy Example - only runs on chips with 2K or more RAM
3 | *
4 | * This sketch copies the file APPEND.TXT, created by the
5 | * SdFatAppend.pde example, to the file ACOPY.TXT.
6 | */
7 | #include
8 | #include // use functions to print strings from flash memory
9 |
10 | Sd2Card card;
11 | SdVolume volume;
12 | SdFile root;
13 | SdFile from; // read file
14 | SdFile copy; // write file
15 |
16 | // large buffer to test for bugs. 512 bytes runs much faster.
17 | char buf[600];
18 |
19 | // store error strings in flash to save RAM
20 | #define error(s) error_P(PSTR(s))
21 |
22 | void error_P(const char* str) {
23 | PgmPrint("error: ");
24 | SerialPrintln_P(str);
25 | if (card.errorCode()) {
26 | PgmPrint("SD error: ");
27 | Serial.print(card.errorCode(), HEX);
28 | Serial.print(',');
29 | Serial.println(card.errorData(), HEX);
30 | }
31 | while(1);
32 | }
33 |
34 | void setup(void) {
35 | Serial.begin(9600);
36 | Serial.println();
37 | PgmPrintln("Type any character to start");
38 | while (!Serial.available());
39 |
40 | PgmPrint("FreeRam: ");
41 | Serial.println(FreeRam());
42 |
43 | // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
44 | // breadboards. use SPI_FULL_SPEED for better performance.
45 | if (!card.init(SPI_HALF_SPEED)) error("card.init failed");
46 |
47 | // initialize a FAT volume
48 | if (!volume.init(&card)) error("volume.init failed");
49 |
50 | // open the root directory
51 | if (!root.openRoot(&volume)) error("openRoot failed");
52 |
53 | strcpy_P(buf, PSTR("APPEND.TXT"));
54 | // open for read
55 | if (!from.open(&root, buf, O_READ)) {
56 | PgmPrint("Can't open ");
57 | Serial.println(buf);
58 | PgmPrintln("Run the append example to create the file.");
59 | error("from.open failed");
60 | }
61 | strcpy_P(buf, PSTR("ACOPY.TXT"));
62 | // create if needed, truncate to zero length, open for write
63 | if (!copy.open(&root, buf, O_CREAT | O_TRUNC | O_WRITE)) {
64 | error("copy.open failed");
65 | }
66 | // count for printing periods
67 | uint16_t p = 0;
68 | int16_t n;
69 | while ((n = from.read(buf, sizeof(buf))) > 0) {
70 | if (copy.write(buf, n) != n) error("write failed");
71 | // print progress periods
72 | if (!(p++ % 25)) Serial.print('.');
73 | if (!(p % 500)) Serial.println();
74 | }
75 | Serial.println();
76 | if (n != 0) error ("read");
77 | // force write of directory entry and last data
78 | if (!copy.close()) error("copy.close failed");
79 | PgmPrintln("Copy done.");
80 | }
81 |
82 | void loop(void) {}
83 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/mapleSDfat/examples/Arduino Examples/SdFatLs/SdFatLs.pde:
--------------------------------------------------------------------------------
1 | /*
2 | * This sketch will list all files in the root directory and
3 | * then do a recursive list of all directories on the SD card.
4 | *
5 | */
6 |
7 | #include
8 | #include
9 |
10 | Sd2Card card;
11 | SdVolume volume;
12 | SdFile root;
13 |
14 | // store error strings in flash to save RAM
15 | #define error(s) error_P(PSTR(s))
16 |
17 | void error_P(const char* str) {
18 | PgmPrint("error: ");
19 | SerialPrintln_P(str);
20 | if (card.errorCode()) {
21 | PgmPrint("SD error: ");
22 | Serial.print(card.errorCode(), HEX);
23 | Serial.print(',');
24 | Serial.println(card.errorData(), HEX);
25 | }
26 | while(1);
27 | }
28 |
29 | void setup() {
30 | Serial.begin(9600);
31 | PgmPrintln("Type any character to start");
32 | while (!Serial.available());
33 |
34 | PgmPrint("Free RAM: ");
35 | Serial.println(FreeRam());
36 |
37 | // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
38 | // breadboards. use SPI_FULL_SPEED for better performance.
39 | if (!card.init(SPI_HALF_SPEED)) error("card.init failed!");
40 |
41 | // initialize a FAT volume
42 | if (!volume.init(&card)) error("vol.init failed!");
43 |
44 | PgmPrint("Volume is FAT");
45 | Serial.println(volume.fatType(),DEC);
46 | Serial.println();
47 |
48 | if (!root.openRoot(&volume)) error("openRoot failed");
49 |
50 | // list file in root with date and size
51 | PgmPrintln("Files found in root:");
52 | root.ls(LS_DATE | LS_SIZE);
53 | Serial.println();
54 |
55 | // Recursive list of all directories
56 | PgmPrintln("Files found in all dirs:");
57 | root.ls(LS_R);
58 |
59 | Serial.println();
60 | PgmPrintln("Done");
61 | }
62 |
63 | void loop() { }
64 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/mapleSDfat/examples/Arduino Examples/SdFatPrint/SdFatPrint.pde:
--------------------------------------------------------------------------------
1 | /*
2 | * Print Example
3 | *
4 | * This sketch shows how to use the Arduino Print class with SdFat.
5 | */
6 | #include
7 | #include // use functions to print strings from flash memory
8 |
9 | Sd2Card card;
10 | SdVolume volume;
11 | SdFile root;
12 | SdFile file;
13 |
14 | // store error strings in flash to save RAM
15 | #define error(s) error_P(PSTR(s))
16 |
17 | void error_P(const char* str) {
18 | PgmPrint("error: ");
19 | SerialPrintln_P(str);
20 | if (card.errorCode()) {
21 | PgmPrint("SD error: ");
22 | Serial.print(card.errorCode(), HEX);
23 | Serial.print(',');
24 | Serial.println(card.errorData(), HEX);
25 | }
26 | while(1);
27 | }
28 |
29 | void setup(void) {
30 | Serial.begin(9600);
31 | Serial.println();
32 | PgmPrintln("Type any character to start");
33 | while (!Serial.available());
34 |
35 | // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
36 | // breadboards. use SPI_FULL_SPEED for better performance.
37 | if (!card.init(SPI_HALF_SPEED)) error("card.init failed");
38 |
39 | // initialize a FAT volume
40 | if (!volume.init(&card)) error("volume.init failed");
41 |
42 | // open the root directory
43 | if (!root.openRoot(&volume)) error("openRoot failed");
44 |
45 | // create a new file
46 | char name[] = "PRINT00.TXT";
47 | for (uint8_t i = 0; i < 100; i++) {
48 | name[5] = i/10 + '0';
49 | name[6] = i%10 + '0';
50 | // only create new file for write
51 | if (file.open(&root, name, O_CREAT | O_EXCL | O_WRITE)) break;
52 | }
53 | if (!file.isOpen()) error ("file.create");
54 | PgmPrintln("Printing to: ");
55 | Serial.println(name);
56 |
57 | // clear print error
58 | file.writeError = 0;
59 |
60 | // print 100 line to file
61 | for (uint8_t i = 0; i < 100; i++) {
62 | file.print("line ");
63 | file.print(i, DEC);
64 | file.print(" millis = ");
65 | file.println(millis());
66 | }
67 | // force write of all data to the SD card
68 | if (file.writeError || !file.sync()) error ("print or sync");
69 | PgmPrintln("Done");
70 | }
71 | void loop(void){}
72 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/mapleSDfat/examples/Arduino Examples/SdFatRead/SdFatRead.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This sketch reads and prints the file
3 | * PRINT00.TXT created by SdFatPrint.pde or
4 | * WRITE00.TXT created by SdFatWrite.pde
5 | */
6 | #include
7 | #include
8 |
9 | Sd2Card card;
10 | SdVolume volume;
11 | SdFile root;
12 | SdFile file;
13 |
14 | // store error strings in flash to save RAM
15 | #define error(s) error_P(PSTR(s))
16 |
17 | void error_P(const char* str) {
18 | PgmPrint("error: ");
19 | SerialPrintln_P(str);
20 | if (card.errorCode()) {
21 | PgmPrint("SD error: ");
22 | Serial.print(card.errorCode(), HEX);
23 | Serial.print(',');
24 | Serial.println(card.errorData(), HEX);
25 | }
26 | while(1);
27 | }
28 |
29 | void setup(void) {
30 | Serial.begin(9600);
31 | Serial.println();
32 | Serial.println("type any character to start");
33 | while (!Serial.available());
34 | Serial.println();
35 |
36 | // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
37 | // breadboards. use SPI_FULL_SPEED for better performance.
38 | if (!card.init(SPI_HALF_SPEED)) error("card.init failed");
39 |
40 | // initialize a FAT volume
41 | if (!volume.init(&card)) error("volume.init failed");
42 |
43 | // open the root directory
44 | if (!root.openRoot(&volume)) error("openRoot failed");
45 |
46 | // open a file
47 | if (file.open(&root, "PRINT00.TXT", O_READ)) {
48 | Serial.println("Opened PRINT00.TXT");
49 | }
50 | else if (file.open(&root, "WRITE00.TXT", O_READ)) {
51 | Serial.println("Opened WRITE00.TXT");
52 | }
53 | else{
54 | error("file.open failed");
55 | }
56 | Serial.println();
57 |
58 | // copy file to serial port
59 | int16_t n;
60 | uint8_t buf[7];// nothing special about 7, just a lucky number.
61 | while ((n = file.read(buf, sizeof(buf))) > 0) {
62 | for (uint8_t i = 0; i < n; i++) Serial.print(buf[i]);
63 | }
64 | /* easier way
65 | int16_t c;
66 | while ((c = file.read()) > 0) Serial.print((char)c);
67 | */
68 | Serial.println("\nDone");
69 | }
70 |
71 | void loop(void) {}
72 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/mapleSDfat/examples/Arduino Examples/SdFatRemove/SdFatRemove.pde:
--------------------------------------------------------------------------------
1 | /*
2 | * Remove Example
3 | *
4 | * This sketch shows how to use remove() to delete
5 | * the file created by the SdFatAppend.pde example.
6 | */
7 | #include
8 | #include // use functions to print strings from flash memory
9 |
10 | Sd2Card card;
11 | SdVolume volume;
12 | SdFile root;
13 | SdFile file;
14 |
15 | // store error strings in flash to save RAM
16 | #define error(s) error_P(PSTR(s))
17 |
18 | void error_P(const char* str) {
19 | PgmPrint("error: ");
20 | SerialPrintln_P(str);
21 | if (card.errorCode()) {
22 | PgmPrint("SD error: ");
23 | Serial.print(card.errorCode(), HEX);
24 | Serial.print(',');
25 | Serial.println(card.errorData(), HEX);
26 | }
27 | while(1);
28 | }
29 |
30 | void setup(void) {
31 | Serial.begin(9600);
32 | Serial.println();
33 | PgmPrintln("Type any character to start");
34 | while (!Serial.available());
35 |
36 | // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
37 | // breadboards. use SPI_FULL_SPEED for better performance.
38 | if (!card.init(SPI_HALF_SPEED)) error("card.init failed");
39 |
40 | // initialize a FAT volume
41 | if (!volume.init(&card)) error("volume.init failed");
42 |
43 | // open the root directory
44 | if (!root.openRoot(&volume)) error("openRoot failed");
45 |
46 | char name[] = "APPEND.TXT";
47 | if (!file.open(&root, name, O_WRITE)) {
48 | PgmPrint("Can't open ");
49 | Serial.println(name);
50 | PgmPrintln("Run the append example to create the file.");
51 | error("file.open failed");
52 | }
53 | if (!file.remove()) error("file.remove failed");
54 | Serial.print(name);
55 | PgmPrintln(" deleted.");
56 | }
57 |
58 | void loop(void) {}
59 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/mapleSDfat/examples/Arduino Examples/SdFatRewrite/SdFatRewrite.pde:
--------------------------------------------------------------------------------
1 | /*
2 | * Rewrite Example
3 | *
4 | * This sketch shows how to rewrite part of a line in the middle
5 | * of the file created by the SdFatAppend.pde example.
6 | *
7 | * Check around line 30 of pass 50 of APPEND.TXT after running this sketch.
8 | */
9 | #include
10 | #include // use functions to print strings from flash memory
11 |
12 | Sd2Card card;
13 | SdVolume volume;
14 | SdFile root;
15 | SdFile file;
16 |
17 | // store error strings in flash to save RAM
18 | #define error(s) error_P(PSTR(s))
19 |
20 | void error_P(const char* str) {
21 | PgmPrint("error: ");
22 | SerialPrintln_P(str);
23 | if (card.errorCode()) {
24 | PgmPrint("SD error: ");
25 | Serial.print(card.errorCode(), HEX);
26 | Serial.print(',');
27 | Serial.println(card.errorData(), HEX);
28 | }
29 | while(1);
30 | }
31 |
32 | void setup(void) {
33 | Serial.begin(9600);
34 | Serial.println();
35 | PgmPrintln("Type any character to start");
36 | while (!Serial.available());
37 |
38 | // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
39 | // breadboards. use SPI_FULL_SPEED for better performance.
40 | if (!card.init(SPI_HALF_SPEED)) error("card.init failed");
41 |
42 | // initialize a FAT volume
43 | if (!volume.init(&card)) error("volume.init failed");
44 |
45 | // open the root directory
46 | if (!root.openRoot(&volume)) error("openRoot failed");
47 |
48 | char name[] = "APPEND.TXT";
49 | // open for read and write
50 | if (!file.open(&root, name, O_RDWR)) {
51 | PgmPrint("Can't open ");
52 | Serial.println(name);
53 | PgmPrintln("Run the append example to create the file.");
54 | error("file.open failed");
55 | }
56 | // seek to middle of file
57 | if (!file.seekSet(file.fileSize()/2)) error("file.seekSet failed");
58 | // find end of line
59 | int16_t c;
60 | while ((c = file.read()) > 0 && c != '\n');
61 | if (c < 0) error("file.read failed");
62 | // clear write error flag
63 | file.writeError = false;
64 | // rewrite the begining of the line at the current position
65 | file.write("**rewrite**");
66 | if (file.writeError) error("file.write failed");
67 | if (!file.close()) error("file.close failed");
68 | Serial.print(name);
69 | PgmPrintln(" rewrite done.");
70 | }
71 |
72 | void loop(void) {}
73 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/mapleSDfat/examples/Arduino Examples/SdFatTruncate/SdFatTruncate.pde:
--------------------------------------------------------------------------------
1 | /*
2 | * Truncate Example
3 | *
4 | * This sketch shows how to use truncate() to remove the last
5 | * half of the file created by the SdFatAppend.pde example.
6 | */
7 | #include
8 | #include // use functions to print strings from flash memory
9 |
10 | Sd2Card card;
11 | SdVolume volume;
12 | SdFile root;
13 | SdFile file;
14 |
15 | // store error strings in flash to save RAM
16 | #define error(s) error_P(PSTR(s))
17 |
18 | void error_P(const char* str) {
19 | PgmPrint("error: ");
20 | SerialPrintln_P(str);
21 | if (card.errorCode()) {
22 | PgmPrint("SD error: ");
23 | Serial.print(card.errorCode(), HEX);
24 | Serial.print(',');
25 | Serial.println(card.errorData(), HEX);
26 | }
27 | while(1);
28 | }
29 |
30 | void setup(void) {
31 | Serial.begin(9600);
32 | Serial.println();
33 | PgmPrintln("Type any character to start");
34 | while (!Serial.available());
35 |
36 | // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
37 | // breadboards. use SPI_FULL_SPEED for better performance.
38 | if (!card.init(SPI_HALF_SPEED)) error("card.init failed");
39 |
40 | // initialize a FAT volume
41 | if (!volume.init(&card)) error("volume.init failed");
42 |
43 | // open the root directory
44 | if (!root.openRoot(&volume)) error("openRoot failed");
45 |
46 | char name[] = "APPEND.TXT";
47 | // open for read and write
48 | if (!file.open(&root, name, O_RDWR)) {
49 | PgmPrint("Can't open ");
50 | Serial.println(name);
51 | PgmPrintln("Run the append example to create the file.");
52 | error("file.open failed");
53 | }
54 | // seek to middle of file
55 | if (!file.seekSet(file.fileSize()/2)) error("file.seekSet failed");
56 | // find end of line
57 | int16_t c;
58 | while ((c = file.read()) > 0 && c != '\n');
59 | if (c < 0) error("file.read failed");
60 | // truncate at current position
61 | if (!file.truncate(file.curPosition())) error("file.truncate failed");
62 | Serial.print(name);
63 | PgmPrintln(" truncated.");
64 | }
65 |
66 | void loop(void) {}
67 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/mapleSDfat/examples/Arduino Examples/SdFatWrite/SdFatWrite.pde:
--------------------------------------------------------------------------------
1 | /*
2 | * Write Example
3 | *
4 | * This sketch creates a new file and writes 100 lines to the file.
5 | * No error checks on write in this example.
6 | */
7 |
8 | #include
9 | #include
10 |
11 | Sd2Card card;
12 | SdVolume volume;
13 | SdFile root;
14 | SdFile file;
15 |
16 | // store error strings in flash to save RAM
17 | #define error(s) error_P(PSTR(s))
18 |
19 | void error_P(const char* str) {
20 | PgmPrint("error: ");
21 | SerialPrintln_P(str);
22 | if (card.errorCode()) {
23 | PgmPrint("SD error: ");
24 | Serial.print(card.errorCode(), HEX);
25 | Serial.print(',');
26 | Serial.println(card.errorData(), HEX);
27 | }
28 | while(1);
29 | }
30 | /*
31 | * Write CR LF to a file
32 | */
33 | void writeCRLF(SdFile& f) {
34 | f.write((uint8_t*)"\r\n", 2);
35 | }
36 | /*
37 | * Write an unsigned number to a file
38 | */
39 | void writeNumber(SdFile& f, uint32_t n) {
40 | uint8_t buf[10];
41 | uint8_t i = 0;
42 | do {
43 | i++;
44 | buf[sizeof(buf) - i] = n%10 + '0';
45 | n /= 10;
46 | } while (n);
47 | f.write(&buf[sizeof(buf) - i], i);
48 | }
49 | /*
50 | * Write a string to a file
51 | */
52 | void writeString(SdFile& f, char *str) {
53 | uint8_t n;
54 | for (n = 0; str[n]; n++);
55 | f.write((uint8_t *)str, n);
56 | }
57 |
58 | void setup(void) {
59 | Serial.begin(9600);
60 | Serial.println();
61 | Serial.println("Type any character to start");
62 | while (!Serial.available());
63 |
64 | // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
65 | // breadboards. use SPI_FULL_SPEED for better performance.
66 | if (!card.init(SPI_HALF_SPEED)) error("card.init failed");
67 |
68 | // initialize a FAT volume
69 | if (!volume.init(&card)) error("volume.init failed");
70 |
71 | // open the root directory
72 | if (!root.openRoot(&volume)) error("openRoot failed");
73 |
74 | // create a new file
75 | char name[] = "WRITE00.TXT";
76 | for (uint8_t i = 0; i < 100; i++) {
77 | name[5] = i/10 + '0';
78 | name[6] = i%10 + '0';
79 | if (file.open(&root, name, O_CREAT | O_EXCL | O_WRITE)) break;
80 | }
81 | if (!file.isOpen()) error ("file.create");
82 | Serial.print("Writing to: ");
83 | Serial.println(name);
84 |
85 | // write 100 line to file
86 | for (uint8_t i = 0; i < 100; i++) {
87 | writeString(file, "line ");
88 | writeNumber(file, i);
89 | writeString(file, " millis = ");
90 | writeNumber(file, millis());
91 | writeCRLF(file);
92 | }
93 | // close file and force write of all data to the SD card
94 | file.close();
95 | Serial.println("Done");
96 | }
97 |
98 | void loop(void) {}
99 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/mapleSDfat/examples/FileSys/FileSys.pde:
--------------------------------------------------------------------------------
1 | /*
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | */
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | HardwareSPI spi(1);
15 | Sd2Card card;
16 | SdVolume volume;
17 | SdFile root;
18 | SdFile file;
19 |
20 | void setup()
21 | {
22 | SerialUSB.begin();
23 | spi.begin(SPI_281_250KHZ, MSBFIRST, 0);
24 | SerialUSB.println("type any char to start");
25 | while (!SerialUSB.available());
26 | SerialUSB.println();
27 |
28 | if (!card.init(&spi))
29 | SerialUSB.println("card.init failed");
30 | else
31 | SerialUSB.println("card.init passed");
32 | // spi.end();
33 |
34 | // spi.begin(SPI_1_125MHZ, MSBFIRST, 0);
35 |
36 | delay(100);
37 |
38 | // initialize a FAT volume
39 | if (!volume.init(&card))
40 | SerialUSB.println("volume.init failed");
41 | else
42 | SerialUSB.println("volume.init passed");
43 |
44 |
45 | // open the root directory
46 | if (!root.openRoot(&volume))
47 | SerialUSB.println("openRoot failed");
48 | else
49 | SerialUSB.println("openRoot passed");
50 |
51 | // open a file
52 | if (file.open(&root, "output2.csv", O_READ))
53 | {
54 | SerialUSB.println("Opened PRINT00.TXT");
55 | }
56 | else if (file.open(&root, "WRITE00.TXT", O_READ))
57 | {
58 | SerialUSB.println("Opened WRITE00.TXT");
59 | }
60 | else
61 | {
62 | SerialUSB.println("file.open failed");
63 | }
64 | SerialUSB.println();
65 |
66 | int16_t n;
67 | uint8_t buf[7];// nothing special about 7, just a lucky number.
68 | while ((n = file.read(buf, sizeof(buf))) > 0)
69 | {
70 | for (uint8_t i = 0; i < n; i++)
71 | SerialUSB.print(buf[i]);
72 | }
73 | /* easier way
74 | int16_t c;
75 | while ((c = file.read()) > 0) Serial.print((char)c);
76 | */
77 | SerialUSB.println("\nDone");
78 | spi.end();
79 |
80 | }
81 |
82 | void loop()
83 | {
84 | }
85 |
86 |
87 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/mapleSDfat/examples/clean.bat:
--------------------------------------------------------------------------------
1 | rm -r */applet
2 | pause
--------------------------------------------------------------------------------
/stm32f4/libmaple/libraries/mapleSDfat/rules.mk:
--------------------------------------------------------------------------------
1 | # Standard things
2 | sp := $(sp).x
3 | dirstack_$(sp) := $(d)
4 | d := $(dir)
5 | BUILDDIRS += $(BUILD_PATH)/$(d)
6 |
7 | # Local flags
8 | CFLAGS_$(d) := $(WIRISH_INCLUDES) $(LIBMAPLE_INCLUDES)
9 |
10 | # Local rules and targets
11 | cSRCS_$(d) :=
12 |
13 | cppSRCS_$(d) := Sd2Card.cpp SdFile.cpp SdVolume.cpp
14 |
15 | cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%)
16 | cppFILES_$(d) := $(cppSRCS_$(d):%=$(d)/%)
17 |
18 | OBJS_$(d) := $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) \
19 | $(cppFILES_$(d):%.cpp=$(BUILD_PATH)/%.o)
20 | DEPS_$(d) := $(OBJS_$(d):%.o=%.d)
21 |
22 | $(OBJS_$(d)): TGT_CFLAGS := $(CFLAGS_$(d))
23 |
24 | TGT_BIN += $(OBJS_$(d))
25 |
26 | # Standard things
27 | -include $(DEPS_$(d))
28 | d := $(dirstack_$(sp))
29 | sp := $(basename $(sp))
--------------------------------------------------------------------------------
/stm32f4/libmaple/main.cpp.example:
--------------------------------------------------------------------------------
1 | // Sample main.cpp file. Blinks the built-in LED, sends a message out
2 | // USART2, and turns on PWM on pin 2.
3 |
4 | #include "wirish.h"
5 |
6 | #define PWM_PIN 2
7 |
8 | void setup() {
9 | /* Set up the LED to blink */
10 | pinMode(BOARD_LED_PIN, OUTPUT);
11 |
12 | /* Turn on PWM on pin PWM_PIN */
13 | pinMode(PWM_PIN, PWM);
14 | pwmWrite(PWM_PIN, 0x8000);
15 |
16 | /* Send a message out USART2 */
17 | Serial2.begin(9600);
18 | Serial2.println("Hello world!");
19 |
20 | /* Send a message out the usb virtual serial port */
21 | SerialUSB.println("Hello!");
22 | }
23 |
24 | void loop() {
25 | toggleLED();
26 | delay(100);
27 | }
28 |
29 | // Force init to be called *first*, i.e. before static object allocation.
30 | // Otherwise, statically allocated objects that need libmaple may fail.
31 | __attribute__((constructor)) void premain() {
32 | init();
33 | }
34 |
35 | int main(void) {
36 | setup();
37 |
38 | while (true) {
39 | loop();
40 | }
41 |
42 | return 0;
43 | }
44 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/notes/dac.txt:
--------------------------------------------------------------------------------
1 | DAC
2 | -------------------------------------------------------------------------------
3 |
4 | There is an ST application note for the DACs; it provides a lot of
5 | context but doesn't help setup the peripheral very much.
6 |
7 | For the first code iteration we'll just use 12-bit right-aligned
8 | single writes, or DAC_DHR12Rx.
9 |
10 | Once data is loaded into the digital registers, there are a number of
11 | possible triggers to start conversion to analog output: external
12 | interrupts, software control, and timer events. We'll just use
13 | software triggering for now.
14 |
15 | There is (obviously) DMA support for DAC output.
16 |
17 | There are noise (via LFSR) output and triangle wave output features
18 | with variable amplitude.
19 |
20 | There are eleven modes to trigger output to both channels at the same
21 | time, as follows:
22 |
23 | - Independent trigger:
24 | (1) No wave generation
25 | (2) Same LFSR
26 | (3) Different LFSR
27 | (4) Same triangle
28 | (5) Different triangle
29 | - (6) Simultaneous software start
30 | - Simultaneous trigger:
31 | (7) Without wave generation
32 | (8) Same LFSR
33 | (9) Different LFSR
34 | (10) Same triangle
35 | (11) Different triangle
36 |
37 | Buffering is enabled by default.
38 |
39 | Triangle Wave HOWTO
40 | -------------------------------------------------------------------------------
41 |
42 | In order to generate a full-amplitude triangle wave:
43 |
44 | - Make the following settings in DAC_BASE->CR, for the DAC channel you
45 | want: set MAMP to 1011 (amplitude 4095), WAVE to 10 (triangle),
46 | TSEL to 111 (software trigger), TEN to 1 (trigger enabled), and
47 | EN to 1 (chanel enabled).
48 |
49 | - Set dac->DHR12Rx to 0 (where x is your channel). This gets added
50 | to the triangle wave value at each trigger step.
51 |
52 | - Now, forever: set DAC_SWTRIGR_SWTRIGx in dac->SWTRIGR, and wait
53 | for it to get cleared by hardware.
54 |
55 | You can do something similar for noise (by setting WAVE to 01
56 | instead). You can also cause the waves to advance due to timer events
57 | or external line 9, by making appropriate settings to TSEL.
58 |
59 | TODO
60 | -------------------------------------------------------------------------------
61 |
62 | - Sine wave demo (using timer interrupts?)
63 | - Wirish implementation
64 | - Official docs
65 | - Higher performance modes?
66 | - Signal quality testing
67 | - DMA output
68 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/notes/exti.txt:
--------------------------------------------------------------------------------
1 | External interrupt notes.
2 |
3 | To generate the interrupt, the interrupt line should be configured
4 | and enabled. This is done by programming the two trigger registers
5 | with the desired edge detection and by enabling the interrupt
6 | request by writing a '1' to the corresponding bit in the interrupt
7 | mask register. When the selected edge occurs on the external
8 | interrupt line, an interrupt request is generated. The pending bit
9 | corresponding to the interrupt line is also set. This request is
10 | reset by writing a '1' in the pending register.
11 |
12 | Hardware interrupt selection:
13 |
14 | To configure the 20 lines as interrupt sources, use the following
15 | procedure:
16 |
17 | 1) Configure AFIO_EXTICR[y] to select the source input for EXTIx
18 | external interrupt
19 | 2) Configure the mask bits of the 20 interrupt lines (EXTI_IMR)
20 | 3) Configure the trigger selection bits of the interrupt lines
21 | (EXTI_RTSR and EXTI_FTSR)
22 | 4) Configure the enable and mask bits that control the NVIC_IRQ
23 | channel mapped to the External Interrupt Controller (EXTI) so
24 | that an inerrupt coming from one of the 20 lines can be
25 | correctly acknowledged.
26 |
27 | AFIO clock must be on.
28 |
29 | RM0008, page 107: "PD0, PD1 cannot be used for external
30 | interrupt/event generation on 36, 48, 64-bin packages."
31 |
32 | The 16 EXTI interrupts are mapped to 7 interrupt handlers.
33 |
34 | EXTI Lines to Interrupt Mapping:
35 | EXTI0 -> EXTI0
36 | EXTI1 -> EXTI1
37 | EXTI2 -> EXTI2
38 | EXTI3 -> EXTI3
39 | EXTI4 -> EXTI4
40 | EXTI[5-9] -> EXT9_5
41 | EXTI[10-15] -> EXT15_10
42 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/notes/fsmc.txt:
--------------------------------------------------------------------------------
1 |
2 | FSMC notes (for maple native and other "high density" STM32 devices)
3 | -------------------------------------------------------------------------------
4 |
5 | There is an application note for all this which is helpful; see the ST website.
6 |
7 | SRAM chip details
8 | IS62WV51216BLL
9 | 512k x 16
10 | 19 address input
11 | 16 data inputs
12 | t_wc (write cycle) = 55ns
13 | t_rc (write cycle) = 55ns
14 | t_pwe1 (write enable low pulse) = 40ns
15 | t_aa (address access) = 55ns
16 |
17 |
18 | The FSMC nomenclature is very confusing. There are three separate
19 | "banks" (which I will call "peripheral banks") each specialized for
20 | different types of external memory (NOR flash, NAND flash, SRAM,
21 | etc). We use the one for "PSRAM" with our SRAM chip; it's bank #1. The
22 | SRAM peripheral bank is further split into 4 "banks" (which I will
23 | call "channels") to support multiple external devices with chip select
24 | pins. I think what's going on is that there are 4 hardware peripherals
25 | and many sections of RAM; the docs are confusing about what's a "block
26 | of memeory" and what's an "FSMC block".
27 |
28 | Anyways, this all takes place on the AHB memory bus.
29 |
30 | I'm going to use not-extended mode 1 for read/write.
31 |
32 | Steps from application note:
33 |
34 | - enable bank3: BCR3_MBKEN = '1'
35 | - memory type is SRAM: BCR3_MTYP = '00'
36 | - databuse weidth is 16bits: BCR3_MWID = '01'
37 | - memory is nonmultiplexed: BCR3_MEXEN is reset (= '0')
38 | - everything else is cleared
39 |
40 | But not true! Actually write enable needs to be set.
41 |
42 | Using the application note, which is based around a very similar chip (with
43 | faster timing), I calculated an ADDSET (address setup) value of 0x0 and a
44 | DATAST (data setup) value of 0x3.
45 |
46 | Using channel1, NOR/PSRAM1 memory starts at 0x60000000.
47 |
48 | Have to turn on the RCC clock for all those GPIO pins, but don't need to use
49 | any interrupts.
50 |
51 | Not-super-helpful-link:
52 | http://www.keil.com/support/man/docs/mcbstm32e/mcbstm32e_to_xmemory.htm
53 |
54 | Note the possible confusion with address spaces, bitwidths, rollovers, etc.
55 |
56 |
57 | TODO
58 | -------------------------------------------------------------------------------
59 | - more rigorous testing: throughput, latency, bounds checking, bitwidth, data
60 | resiliance, etc.
61 | - update .ld scripts to transparently make use of this external memory
62 | - test/demo using a seperate external SRAM chip or screen
63 | - write up documentation
64 |
65 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/notes/portable.txt:
--------------------------------------------------------------------------------
1 | libmaple was previously very restricted to LeafLabs boards. However,
2 | the contents of libmaple proper are now fairly portable across medium-
3 | and high-density STM32F1xx chips (though there are some caveats). The
4 | current design is expected to accomodate new chips straightforwardly
5 | and well into the future.
6 |
7 | The library's configuration is based around the files wirish/boards.h
8 | (and .cpp), wirish/boards/*, and libmaple/stm32.h, as well as some
9 | #defines it expects the environment to handle during compilation.
10 |
11 | If you want to use libmaple proper, you must define one of
12 | STM32_MEDIUM_DENSITY or STM32_HIGH_DENSITY during compilation.
13 | Defining one of these allows libmaple to decide what processor
14 | features to expose to you (e.g., definitions related to ADC3 aren't
15 | compiled in when STM32_MEDIUM_DENSITY is defined). There's no support
16 | for low-density chips. XL-density is planned but not done (we don't
17 | have one to test on); patches (and samples) are welcome! See:
18 |
19 | http://leaflabs.com/docs/libmaple/contributing.html
20 |
21 | There are some other useful #defines the environment can provide when
22 | compiling libmaple. They aren't as crucial, though. See the Makefile
23 | for more information.
24 |
25 | If you want to use Wirish, you'll need to define a BOARD_foo
26 | (e.g. BOARD_maple, BOARD_maple_mini, etc.). This determines which
27 | board files get loaded from wirish/boards/. See /wirish/boards.h and
28 | /wirish/boards.cpp for more details. See /wirish/boards/maple.h and
29 | /wirish/boards/maple.cpp for well-commented examples on how to add a
30 | new board configuration.
31 |
32 | The code in libmaple/usb/ is not very portable at all right now;
33 | expect this to change in the future.
34 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/notes/vga.txt:
--------------------------------------------------------------------------------
1 |
2 | Notes on GPIO Writing
3 | ------------------------------------------------------------------------------
4 | Classic digitalWrite() gives ~500ns pulse time (2MHz)
5 |
6 | gpio_write_bit() is about 360ns (2.78MHz)
7 |
8 | Writing to GPIO?_BASE is about 60ns (16.6MHz -> 18MHz)
9 |
10 | PWM write 0x0001 is about 14ns (72MHz) with prescaler as 0 (!)
11 |
12 | VGA Timing
13 | ------------------------------------------------------------------------------
14 | 1/25.125MHz = 39.72ns (640x480 pixel clock)
15 |
16 | Crude 640x480 directions:
17 | From www.epanorama.net/documents/pc/vga_timing.html
18 | 480 lines
19 | 31.77 us horizontal line length -> 2287.44 clock cycles -> 2287
20 | 3.77 us sync period -> 271 clocks -> 271
21 | 1.89 us front porch? -> 136 clocks -> 136
22 | 25.17 us video -> 1812.24 clocks -> 1812
23 |
24 | So...
25 | 2287 reload
26 | 271 1: Hsync high
27 | 407 2: Video on
28 | 2219 3: Video off
29 | 2287 4: Hsync low
30 |
31 | Vertically, it's
32 | 480 lines active video
33 | 11 lines front porch
34 | 2 lines Vsync (low)
35 | 31 lines back porch
36 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/gdb/gpio/gpio.gdb:
--------------------------------------------------------------------------------
1 | set print pretty on
2 |
3 | print "GPIOA registers:"
4 | p/x *GPIOA->regs
5 | print "GPIOB registers:"
6 | p/x *GPIOB->regs
7 | print "GPIOC registers:"
8 | p/x *GPIOC->regs
9 | print "GPIOD registers:"
10 | p/x *GPIOD->regs
11 | print "AFIO registers:"
12 | p/x *(struct afio_reg_map*)0x40010000
13 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/gdb/i2c/test.gdb:
--------------------------------------------------------------------------------
1 | define i2c_sr1_flags
2 | set $s = $arg0
3 | printf "SR1: "
4 |
5 | if (($s & (1 << 15)))
6 | printf "SMBALERT "
7 | end
8 |
9 | if (($s & (1 << 14)))
10 | printf "TIMEOUT "
11 | end
12 |
13 | if (($s & (1 << 12)))
14 | printf "PECERR "
15 | end
16 |
17 | if (($s & (1 << 11)))
18 | printf "OVR "
19 | end
20 |
21 | if (($s & (1 << 10)))
22 | printf "AF "
23 | end
24 |
25 | if (($s & (1 << 9)))
26 | printf "ARLO "
27 | end
28 |
29 | if (($s & (1 << 8)))
30 | printf "BERR "
31 | end
32 |
33 | if (($s & (1 << 7)))
34 | printf "TXE "
35 | end
36 |
37 | if (($s & (1 << 6)))
38 | printf "RXNE "
39 | end
40 |
41 | if (($s & (1 << 4)))
42 | printf "STOPF "
43 | end
44 |
45 | if (($s & (1 << 3)))
46 | printf "ADD10 "
47 | end
48 |
49 | if (($s & (1 << 2)))
50 | printf "BTF "
51 | end
52 |
53 | if (($s & (1 << 1)))
54 | printf "ADDR "
55 | end
56 |
57 | if (($s & (1 << 0)))
58 | printf "SB "
59 | end
60 | end
61 |
62 | define i2c_sr2_flags
63 | set $s = $arg0
64 | printf "SR2: "
65 |
66 | if (($s & (1 << 7)))
67 | printf "DUALF "
68 | end
69 |
70 | if (($s & (1 << 6)))
71 | printf "SMBHOST "
72 | end
73 |
74 | if (($s & (1 << 5)))
75 | printf "SMBDEFAULT "
76 | end
77 |
78 | if (($s & (1 << 4)))
79 | printf "GENCALL "
80 | end
81 |
82 |
83 | if (($s & (1 << 2)))
84 | printf "TRA "
85 | end
86 |
87 | if (($s & (1 << 1)))
88 | printf "BUSY "
89 | end
90 |
91 | if (($s & (1 << 0)))
92 | printf "MSL "
93 | end
94 |
95 | end
96 |
97 | define pbc
98 | set $c = crumbs
99 | while ($c->event)
100 | if ($c->event != 0)
101 | printf "Event: %d ", $c->event
102 | if ($c->event == 1)
103 | i2c_sr1_flags $c->sr1
104 | printf "\t"
105 | i2c_sr2_flags $c->sr2
106 | end
107 | printf "\n"
108 | end
109 | set $c = $c + 1
110 | end
111 |
112 |
113 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/aeroquad32/flash.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * aeroquad32 (STM32F103VET6, high density) linker script for
3 | * Flash builds.
4 | */
5 |
6 | MEMORY
7 | {
8 | ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K
9 | /* rom (rx) : ORIGIN = 0x08005000, LENGTH = 492K */ /* ala42 */
10 | rom (rx) : ORIGIN = 0x08010000, LENGTH = 448K /* ala42 */
11 | }
12 |
13 | GROUP(libcs3_stm32_high_density.a)
14 |
15 | REGION_ALIAS("REGION_TEXT", rom);
16 | REGION_ALIAS("REGION_DATA", ram);
17 | REGION_ALIAS("REGION_BSS", ram);
18 | REGION_ALIAS("REGION_RODATA", rom);
19 |
20 | _FLASH_BUILD = 1;
21 | INCLUDE common.inc
22 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/aeroquad32/jtag.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * aeroquad32 (STM32F103VET6, high density) linker script for
3 | * JTAG (bare metal, no bootloader) builds.
4 | */
5 |
6 | MEMORY
7 | {
8 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
9 | rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K
10 | }
11 |
12 | GROUP(libcs3_stm32_high_density.a)
13 |
14 | REGION_ALIAS("REGION_TEXT", rom);
15 | REGION_ALIAS("REGION_DATA", ram);
16 | REGION_ALIAS("REGION_BSS", ram);
17 | REGION_ALIAS("REGION_RODATA", rom);
18 |
19 | _FLASH_BUILD = 1;
20 | INCLUDE common.inc
21 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/aeroquad32/ram.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * aeroquad32 (STM32F103VET6, high density) linker script for
3 | * RAM builds.
4 | */
5 |
6 | MEMORY
7 | {
8 | ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K
9 | /* rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K ala42 */
10 | rom (rx) : ORIGIN = 0x08010000, LENGTH = 0K /* ala42 */
11 | }
12 |
13 | GROUP(libcs3_stm32_high_density.a)
14 |
15 | REGION_ALIAS("REGION_TEXT", ram);
16 | REGION_ALIAS("REGION_DATA", ram);
17 | REGION_ALIAS("REGION_BSS", ram);
18 | REGION_ALIAS("REGION_RODATA", ram);
19 |
20 | INCLUDE common.inc
21 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/aeroquad32mini/flash.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * Maple Mini (STM32F103CBT6, medium density) linker script for Flash builds.
3 | */
4 |
5 | /*
6 | * Define memory spaces.
7 | */
8 | MEMORY
9 | {
10 | ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K
11 | rom (rx) : ORIGIN = 0x08005000, LENGTH = 108K
12 | }
13 |
14 | /*
15 | * Use medium density device vector table
16 | */
17 | GROUP(libcs3_stm32_med_density.a)
18 |
19 | REGION_ALIAS("REGION_TEXT", rom);
20 | REGION_ALIAS("REGION_DATA", ram);
21 | REGION_ALIAS("REGION_BSS", ram);
22 | REGION_ALIAS("REGION_RODATA", rom);
23 |
24 | /*
25 | * Define the rest of the sections
26 | */
27 | _FLASH_BUILD = 1;
28 | INCLUDE common.inc
29 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/aeroquad32mini/jtag.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * Maple Mini (STM32F103CBT6, medium density) linker script for JTAG
3 | * (bare metal, no bootloader) builds.
4 | */
5 |
6 | /*
7 | * Define memory spaces.
8 | */
9 | MEMORY
10 | {
11 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
12 | rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
13 | }
14 |
15 | /*
16 | * Use medium density device vector table
17 | */
18 | GROUP(libcs3_stm32_med_density.a)
19 |
20 | REGION_ALIAS("REGION_TEXT", rom);
21 | REGION_ALIAS("REGION_DATA", ram);
22 | REGION_ALIAS("REGION_BSS", ram);
23 | REGION_ALIAS("REGION_RODATA", rom);
24 |
25 | /*
26 | * Define the rest of the sections
27 | */
28 | _FLASH_BUILD = 1;
29 | INCLUDE common.inc
30 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/aeroquad32mini/ram.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * Maple Mini (STM32F103CBT6, medium density) linker script for RAM builds.
3 | */
4 |
5 | /*
6 | * Define memory spaces.
7 | */
8 | MEMORY
9 | {
10 | ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K
11 | rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K
12 | }
13 |
14 | /*
15 | * Use medium density device vector table
16 | */
17 | GROUP(libcs3_stm32_med_density.a)
18 |
19 | REGION_ALIAS("REGION_TEXT", ram);
20 | REGION_ALIAS("REGION_DATA", ram);
21 | REGION_ALIAS("REGION_BSS", ram);
22 | REGION_ALIAS("REGION_RODATA", ram);
23 |
24 | /*
25 | * Define the rest of the sections
26 | */
27 | INCLUDE common.inc
28 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/discovery_f4/flash.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * aeroquad32 (STM32F103VET6, high density) linker script for
3 | * Flash builds.
4 | */
5 |
6 | MEMORY
7 | {
8 | ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K
9 | /* rom (rx) : ORIGIN = 0x08005000, LENGTH = 492K */ /* ala42 */
10 | rom (rx) : ORIGIN = 0x08010000, LENGTH = 448K /* ala42 */
11 | }
12 |
13 | GROUP(libcs4_stm32_high_density.a)
14 |
15 | REGION_ALIAS("REGION_TEXT", rom);
16 | REGION_ALIAS("REGION_DATA", ram);
17 | REGION_ALIAS("REGION_BSS", ram);
18 | REGION_ALIAS("REGION_RODATA", rom);
19 |
20 | _FLASH_BUILD = 1;
21 | INCLUDE common.inc
22 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/discovery_f4/jtag.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * aeroquad32 (STM32F103VET6, high density) linker script for
3 | * JTAG (bare metal, no bootloader) builds.
4 | */
5 |
6 | MEMORY
7 | {
8 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
9 | rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K
10 | }
11 |
12 | GROUP(libcs3_stm32_high_density.a)
13 |
14 | REGION_ALIAS("REGION_TEXT", rom);
15 | REGION_ALIAS("REGION_DATA", ram);
16 | REGION_ALIAS("REGION_BSS", ram);
17 | REGION_ALIAS("REGION_RODATA", rom);
18 |
19 | _FLASH_BUILD = 1;
20 | INCLUDE common.inc
21 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/discovery_f4/ram.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * aeroquad32 (STM32F103VET6, high density) linker script for
3 | * RAM builds.
4 | */
5 |
6 | MEMORY
7 | {
8 | ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K
9 | /* rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K ala42 */
10 | rom (rx) : ORIGIN = 0x08010000, LENGTH = 0K /* ala42 */
11 | }
12 |
13 | GROUP(libcs3_stm32_high_density.a)
14 |
15 | REGION_ALIAS("REGION_TEXT", ram);
16 | REGION_ALIAS("REGION_DATA", ram);
17 | REGION_ALIAS("REGION_BSS", ram);
18 | REGION_ALIAS("REGION_RODATA", ram);
19 |
20 | INCLUDE common.inc
21 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/libcs3_stm32_high_density.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbulmer/openstm32sw/d70fe3fd9266ffc8602b8cd8d5190f90992194af/stm32f4/libmaple/support/ld/libcs3_stm32_high_density.a
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/libcs3_stm32_src/Makefile:
--------------------------------------------------------------------------------
1 | # setup environment
2 |
3 | TARGET_ARCH = -mcpu=cortex-m3 -mthumb
4 |
5 | CC = arm-none-eabi-gcc
6 | CFLAGS =
7 |
8 | AS = $(CC) -x assembler-with-cpp -c $(TARGET_ARCH)
9 | ASFLAGS =
10 |
11 | AR = arm-none-eabi-ar
12 | ARFLAGS = cr
13 |
14 | LIB_OBJS = stm32_vector_table.o stm32_isrs.o start.o start_c.o
15 |
16 | help:
17 | @echo "Targets:"
18 | @echo "\t medium-density: Target medium density chips (e.g. Maple)"
19 | @echo "\t high-density: Target high density chips (e.g. Maple-native)"
20 |
21 | .PHONY: help medium high
22 |
23 | medium-density: $(LIB_OBJS)
24 | $(AR) $(ARFLAGS) libcs3_stm32_med_density.a $(LIB_OBJS)
25 | rm -f $(LIB_OBJS)
26 |
27 | high-density: CFLAGS := -DSTM32_HIGH_DENSITY
28 | high-density: $(LIB_OBJS)
29 | $(AR) $(ARFLAGS) libcs3_stm32_high_density.a $(LIB_OBJS)
30 | rm -f $(LIB_OBJS)
31 |
32 | # clean
33 | .PHONY: clean
34 | clean:
35 | -rm -f $(LIB_OBJS) *.a
36 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/libcs3_stm32_src/start.S:
--------------------------------------------------------------------------------
1 | /*
2 | * The authors hereby grant permission to use, copy, modify, distribute,
3 | * and license this software and its documentation for any purpose, provided
4 | * that existing copyright notices are retained in all copies and that this
5 | * notice is included verbatim in any distributions. No written agreement,
6 | * license, or royalty fee is required for any of the authorized uses.
7 | * Modifications to this software may be copyrighted by their authors
8 | * and need not follow the licensing terms described here, provided that
9 | * the new terms are clearly indicated on the first page of each file where
10 | * they apply.
11 | */
12 |
13 | .text
14 | .code 16
15 | .thumb_func
16 |
17 | .globl _start
18 | .type _start, %function
19 | _start:
20 | .fnstart
21 | ldr r1,=__cs3_stack
22 | mov sp,r1
23 | ldr r1,=__cs3_start_c
24 | bx r1
25 | .pool
26 | .cantunwind
27 | .fnend
28 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/libcs3_stm32_src/start_c.c:
--------------------------------------------------------------------------------
1 | /* CS3 start_c routine.
2 | *
3 | * Copyright (c) 2006, 2007 CodeSourcery Inc
4 | *
5 | * The authors hereby grant permission to use, copy, modify, distribute,
6 | * and license this software and its documentation for any purpose, provided
7 | * that existing copyright notices are retained in all copies and that this
8 | * notice is included verbatim in any distributions. No written agreement,
9 | * license, or royalty fee is required for any of the authorized uses.
10 | * Modifications to this software may be copyrighted by their authors
11 | * and need not follow the licensing terms described here, provided that
12 | * the new terms are clearly indicated on the first page of each file where
13 | * they apply.
14 | */
15 |
16 | #include "cs3.h"
17 |
18 | extern void __libc_init_array (void);
19 |
20 | extern int main (int, char **, char **);
21 |
22 | extern void exit (int) __attribute__ ((noreturn, weak));
23 |
24 | void __attribute ((noreturn))
25 | __cs3_start_c (void)
26 | {
27 | unsigned regions = __cs3_region_num;
28 | const struct __cs3_region *rptr = __cs3_regions;
29 | int exit_code;
30 |
31 | /* Initialize memory */
32 | for (regions = __cs3_region_num, rptr = __cs3_regions; regions--; rptr++)
33 | {
34 | long long *src = (long long *)rptr->init;
35 | long long *dst = (long long *)rptr->data;
36 | unsigned limit = rptr->init_size;
37 | unsigned count;
38 |
39 | if (src != dst)
40 | for (count = 0; count != limit; count += sizeof (long long))
41 | *dst++ = *src++;
42 | else
43 | dst = (long long *)((char *)dst + limit);
44 | limit = rptr->zero_size;
45 | for (count = 0; count != limit; count += sizeof (long long))
46 | *dst++ = 0;
47 | }
48 |
49 | /* Run initializers. */
50 | __libc_init_array ();
51 |
52 | exit_code = main (0, NULL, NULL);
53 | if (exit)
54 | exit (exit_code);
55 | /* If exit is NULL, make sure we don't return. */
56 | for (;;)
57 | continue;
58 | }
59 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/libcs3_stm32_src/stm32_vector_table.S:
--------------------------------------------------------------------------------
1 | /* STM32 vector table */
2 |
3 | .section ".stm32.interrupt_vector"
4 |
5 | .globl __cs3_stm32_vector_table
6 | .type __cs3_stm32_vector_table, %object
7 |
8 | __cs3_stm32_vector_table:
9 | /* CM3 core interrupts */
10 | .long __cs3_stack
11 | .long __cs3_reset
12 | .long __exc_nmi
13 | .long __exc_hardfault
14 | .long __exc_memmanage
15 | .long __exc_busfault
16 | .long __exc_usagefault
17 | .long __stm32reservedexception7
18 | .long __stm32reservedexception8
19 | .long __stm32reservedexception9
20 | .long __stm32reservedexception10
21 | .long __exc_svc
22 | .long __exc_debug_monitor
23 | .long __stm32reservedexception13
24 | .long __exc_pendsv
25 | .long __exc_systick
26 | /* Peripheral interrupts */
27 | .long __irq_wwdg
28 | .long __irq_pvd
29 | .long __irq_tamper
30 | .long __irq_rtc
31 | .long __irq_flash
32 | .long __irq_rcc
33 | .long __irq_exti0
34 | .long __irq_exti1
35 | .long __irq_exti2
36 | .long __irq_exti3
37 | .long __irq_exti4
38 | .long __irq_dma1_channel1
39 | .long __irq_dma1_channel2
40 | .long __irq_dma1_channel3
41 | .long __irq_dma1_channel4
42 | .long __irq_dma1_channel5
43 | .long __irq_dma1_channel6
44 | .long __irq_dma1_channel7
45 | .long __irq_adc
46 | .long __irq_usb_hp_can_tx
47 | .long __irq_usb_lp_can_rx0
48 | .long __irq_can_rx1
49 | .long __irq_can_sce
50 | .long __irq_exti9_5
51 | .long __irq_tim1_brk
52 | .long __irq_tim1_up
53 | .long __irq_tim1_trg_com
54 | .long __irq_tim1_cc
55 | .long __irq_tim2
56 | .long __irq_tim3
57 | .long __irq_tim4
58 | .long __irq_i2c1_ev
59 | .long __irq_i2c1_er
60 | .long __irq_i2c2_ev
61 | .long __irq_i2c2_er
62 | .long __irq_spi1
63 | .long __irq_spi2
64 | .long __irq_usart1
65 | .long __irq_usart2
66 | .long __irq_usart3
67 | .long __irq_exti15_10
68 | .long __irq_rtcalarm
69 | .long __irq_usbwakeup
70 | #if defined (STM32_HIGH_DENSITY)
71 | .long __irq_tim8_brk
72 | .long __irq_tim8_up
73 | .long __irq_tim8_trg_com
74 | .long __irq_tim8_cc
75 | .long __irq_adc3
76 | .long __irq_fsmc
77 | .long __irq_sdio
78 | .long __irq_tim5
79 | .long __irq_spi3
80 | .long __irq_uart4
81 | .long __irq_uart5
82 | .long __irq_tim6
83 | .long __irq_tim7
84 | .long __irq_dma2_channel1
85 | .long __irq_dma2_channel2
86 | .long __irq_dma2_channel3
87 | .long __irq_dma2_channel4_5
88 | #endif /* STM32_HIGH_DENSITY */
89 |
90 | .size __cs3_stm32_vector_table, . - __cs3_stm32_vector_table
91 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/libcs4_stm32_high_density.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbulmer/openstm32sw/d70fe3fd9266ffc8602b8cd8d5190f90992194af/stm32f4/libmaple/support/ld/libcs4_stm32_high_density.a
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/libcs4_stm32_src/Makefile:
--------------------------------------------------------------------------------
1 | # setup environment
2 |
3 | TARGET_ARCH = -mcpu=cortex-m4 -mthumb
4 |
5 | CC = arm-none-eabi-gcc
6 | CFLAGS = -g3 -gdwarf-2
7 |
8 | AS = $(CC) -x assembler-with-cpp -c $(TARGET_ARCH)
9 | ASFLAGS = -g3 -gdwarf-2
10 |
11 | AR = arm-none-eabi-ar
12 | ARFLAGS = cr
13 |
14 | LIB_OBJS = stm32_vector_table.o stm32_isrs.o start.o start_c.o
15 |
16 | help:
17 | @echo "Targets:"
18 | @echo "\t medium-density: Target medium density chips (e.g. Maple)"
19 | @echo "\t high-density: Target high density chips (e.g. Maple-native)"
20 |
21 | .PHONY: help medium high
22 |
23 | medium-density: $(LIB_OBJS)
24 | $(AR) $(ARFLAGS) libcs3_stm32_med_density.a $(LIB_OBJS)
25 | rm -f $(LIB_OBJS)
26 |
27 | high-density: CFLAGS := -DSTM32_HIGH_DENSITY
28 | high-density: $(LIB_OBJS)
29 | $(AR) $(ARFLAGS) libcs4_stm32_high_density.a $(LIB_OBJS)
30 | rm -f $(LIB_OBJS)
31 |
32 | # clean
33 | .PHONY: clean
34 | clean:
35 | -rm -f $(LIB_OBJS) *.a
36 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/libcs4_stm32_src/libcs4_stm32_high_density.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbulmer/openstm32sw/d70fe3fd9266ffc8602b8cd8d5190f90992194af/stm32f4/libmaple/support/ld/libcs4_stm32_src/libcs4_stm32_high_density.a
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/libcs4_stm32_src/start.S:
--------------------------------------------------------------------------------
1 | /*
2 | * The authors hereby grant permission to use, copy, modify, distribute,
3 | * and license this software and its documentation for any purpose, provided
4 | * that existing copyright notices are retained in all copies and that this
5 | * notice is included verbatim in any distributions. No written agreement,
6 | * license, or royalty fee is required for any of the authorized uses.
7 | * Modifications to this software may be copyrighted by their authors
8 | * and need not follow the licensing terms described here, provided that
9 | * the new terms are clearly indicated on the first page of each file where
10 | * they apply.
11 | */
12 |
13 | .text
14 | .code 16
15 | .thumb_func
16 |
17 | .globl _start
18 | .type _start, %function
19 | _start:
20 | .fnstart
21 |
22 |
23 | //;FPU settings
24 | ldr r0, =0xe000ed88 //; enable cp10,cp11
25 | ldr r1,[r0]
26 | ldr r2, =0xf00000
27 | orr r1,r1,r2
28 | str r1,[r0]
29 |
30 |
31 |
32 | ldr r1,=__cs3_stack
33 | mov sp,r1
34 | ldr r1,=__cs3_start_c
35 | bx r1
36 | .pool
37 | .cantunwind
38 | .fnend
39 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/libcs4_stm32_src/start_c.c:
--------------------------------------------------------------------------------
1 | /* CS3 start_c routine.
2 | *
3 | * Copyright (c) 2006, 2007 CodeSourcery Inc
4 | *
5 | * The authors hereby grant permission to use, copy, modify, distribute,
6 | * and license this software and its documentation for any purpose, provided
7 | * that existing copyright notices are retained in all copies and that this
8 | * notice is included verbatim in any distributions. No written agreement,
9 | * license, or royalty fee is required for any of the authorized uses.
10 | * Modifications to this software may be copyrighted by their authors
11 | * and need not follow the licensing terms described here, provided that
12 | * the new terms are clearly indicated on the first page of each file where
13 | * they apply.
14 | */
15 |
16 | #include "cs3.h"
17 |
18 | extern void __libc_init_array (void);
19 |
20 | extern int main (int, char **, char **);
21 |
22 | extern void exit (int) __attribute__ ((noreturn, weak));
23 |
24 | void __attribute ((noreturn))
25 | __cs3_start_c (void)
26 | {
27 | unsigned regions = __cs3_region_num;
28 | const struct __cs3_region *rptr = __cs3_regions;
29 | int exit_code;
30 |
31 | /* Initialize memory */
32 | for (regions = __cs3_region_num, rptr = __cs3_regions; regions--; rptr++)
33 | {
34 | long long *src = (long long *)rptr->init;
35 | long long *dst = (long long *)rptr->data;
36 | unsigned limit = rptr->init_size;
37 | unsigned count;
38 |
39 | if (src != dst)
40 | for (count = 0; count != limit; count += sizeof (long long))
41 | *dst++ = *src++;
42 | else
43 | dst = (long long *)((char *)dst + limit);
44 | limit = rptr->zero_size;
45 | for (count = 0; count != limit; count += sizeof (long long))
46 | *dst++ = 0;
47 | }
48 |
49 | /* Run initializers. */
50 | __libc_init_array ();
51 |
52 | exit_code = main (0, NULL, NULL);
53 | if (exit)
54 | exit (exit_code);
55 | /* If exit is NULL, make sure we don't return. */
56 | for (;;)
57 | continue;
58 | }
59 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/maple/flash.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * Maple (STM32F103RBT6, medium density) linker script for Flash builds.
3 | */
4 |
5 | /*
6 | * Define memory spaces.
7 | */
8 | MEMORY
9 | {
10 | ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K
11 | rom (rx) : ORIGIN = 0x08005000, LENGTH = 108K
12 | }
13 |
14 | /*
15 | * Use medium density device vector table
16 | */
17 | GROUP(libcs3_stm32_med_density.a)
18 |
19 | REGION_ALIAS("REGION_TEXT", rom);
20 | REGION_ALIAS("REGION_DATA", ram);
21 | REGION_ALIAS("REGION_BSS", ram);
22 | REGION_ALIAS("REGION_RODATA", rom);
23 |
24 | /*
25 | * Define the rest of the sections
26 | */
27 | _FLASH_BUILD = 1;
28 |
29 | INCLUDE common.inc
30 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/maple/jtag.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * Maple (STM32F103RBT6, medium density) linker script for JTAG (bare
3 | * metal, no bootloader) builds.
4 | */
5 |
6 | /*
7 | * Define memory spaces.
8 | */
9 | MEMORY
10 | {
11 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
12 | rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
13 | }
14 |
15 | /*
16 | * Use medium density device vector table
17 | */
18 | GROUP(libcs3_stm32_med_density.a)
19 |
20 | REGION_ALIAS("REGION_TEXT", rom);
21 | REGION_ALIAS("REGION_DATA", ram);
22 | REGION_ALIAS("REGION_BSS", ram);
23 | REGION_ALIAS("REGION_RODATA", rom);
24 |
25 | /*
26 | * Define the rest of the sections
27 | */
28 | _FLASH_BUILD = 1;
29 | INCLUDE common.inc
30 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/maple/ram.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * Maple (STM32F103RBT6, medium density) linker script for RAM builds.
3 | */
4 |
5 | /*
6 | * Define memory spaces.
7 | */
8 | MEMORY
9 | {
10 | ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K
11 | rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K
12 | }
13 |
14 | /*
15 | * Use medium density device vector table
16 | */
17 | GROUP(libcs3_stm32_med_density.a)
18 |
19 | REGION_ALIAS("REGION_TEXT", ram);
20 | REGION_ALIAS("REGION_DATA", ram);
21 | REGION_ALIAS("REGION_BSS", ram);
22 | REGION_ALIAS("REGION_RODATA", ram);
23 |
24 | /*
25 | * Define the rest of the sections
26 | */
27 | INCLUDE common.inc
28 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/maple_RET6/flash.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * Maple RET6 Edition (STM32F103RET6, high density) linker script for
3 | * Flash builds.
4 | */
5 |
6 | MEMORY
7 | {
8 | ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K
9 | rom (rx) : ORIGIN = 0x08005000, LENGTH = 492K
10 | }
11 |
12 | GROUP(libcs3_stm32_high_density.a)
13 |
14 | REGION_ALIAS("REGION_TEXT", rom);
15 | REGION_ALIAS("REGION_DATA", ram);
16 | REGION_ALIAS("REGION_BSS", ram);
17 | REGION_ALIAS("REGION_RODATA", rom);
18 |
19 | _FLASH_BUILD = 1;
20 | INCLUDE common.inc
21 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/maple_RET6/jtag.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * Maple RET6 Edition (STM32F103RET6, high density) linker script for
3 | * JTAG (bare metal, no bootloader) builds.
4 | */
5 |
6 | MEMORY
7 | {
8 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
9 | rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K
10 | }
11 |
12 | GROUP(libcs3_stm32_high_density.a)
13 |
14 | REGION_ALIAS("REGION_TEXT", rom);
15 | REGION_ALIAS("REGION_DATA", ram);
16 | REGION_ALIAS("REGION_BSS", ram);
17 | REGION_ALIAS("REGION_RODATA", rom);
18 |
19 | _FLASH_BUILD = 1;
20 | INCLUDE common.inc
21 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/maple_RET6/ram.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * Maple RET6 Edition (STM32F103RET6, high density) linker script for
3 | * RAM builds.
4 | */
5 |
6 | MEMORY
7 | {
8 | ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K
9 | rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K
10 | }
11 |
12 | GROUP(libcs3_stm32_high_density.a)
13 |
14 | REGION_ALIAS("REGION_TEXT", ram);
15 | REGION_ALIAS("REGION_DATA", ram);
16 | REGION_ALIAS("REGION_BSS", ram);
17 | REGION_ALIAS("REGION_RODATA", ram);
18 |
19 | INCLUDE common.inc
20 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/maple_mini/flash.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * Maple Mini (STM32F103CBT6, medium density) linker script for Flash builds.
3 | */
4 |
5 | /*
6 | * Define memory spaces.
7 | */
8 | MEMORY
9 | {
10 | ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K
11 | rom (rx) : ORIGIN = 0x08005000, LENGTH = 108K
12 | }
13 |
14 | /*
15 | * Use medium density device vector table
16 | */
17 | GROUP(libcs3_stm32_med_density.a)
18 |
19 | REGION_ALIAS("REGION_TEXT", rom);
20 | REGION_ALIAS("REGION_DATA", ram);
21 | REGION_ALIAS("REGION_BSS", ram);
22 | REGION_ALIAS("REGION_RODATA", rom);
23 |
24 | /*
25 | * Define the rest of the sections
26 | */
27 | _FLASH_BUILD = 1;
28 | INCLUDE common.inc
29 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/maple_mini/jtag.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * Maple Mini (STM32F103CBT6, medium density) linker script for JTAG
3 | * (bare metal, no bootloader) builds.
4 | */
5 |
6 | /*
7 | * Define memory spaces.
8 | */
9 | MEMORY
10 | {
11 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
12 | rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
13 | }
14 |
15 | /*
16 | * Use medium density device vector table
17 | */
18 | GROUP(libcs3_stm32_med_density.a)
19 |
20 | REGION_ALIAS("REGION_TEXT", rom);
21 | REGION_ALIAS("REGION_DATA", ram);
22 | REGION_ALIAS("REGION_BSS", ram);
23 | REGION_ALIAS("REGION_RODATA", rom);
24 |
25 | /*
26 | * Define the rest of the sections
27 | */
28 | _FLASH_BUILD = 1;
29 | INCLUDE common.inc
30 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/maple_mini/ram.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * Maple Mini (STM32F103CBT6, medium density) linker script for RAM builds.
3 | */
4 |
5 | /*
6 | * Define memory spaces.
7 | */
8 | MEMORY
9 | {
10 | ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K
11 | rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K
12 | }
13 |
14 | /*
15 | * Use medium density device vector table
16 | */
17 | GROUP(libcs3_stm32_med_density.a)
18 |
19 | REGION_ALIAS("REGION_TEXT", ram);
20 | REGION_ALIAS("REGION_DATA", ram);
21 | REGION_ALIAS("REGION_BSS", ram);
22 | REGION_ALIAS("REGION_RODATA", ram);
23 |
24 | /*
25 | * Define the rest of the sections
26 | */
27 | INCLUDE common.inc
28 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/maple_native/flash.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * Maple Native (STM32F103ZET6, high density) linker script for Flash builds.
3 | */
4 |
5 | MEMORY
6 | {
7 | ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K
8 | rom (rx) : ORIGIN = 0x08005000, LENGTH = 492K
9 | }
10 |
11 | /*
12 | * Use high density device vector table
13 | */
14 | GROUP(libcs3_stm32_high_density.a)
15 |
16 | REGION_ALIAS("REGION_TEXT", rom);
17 | REGION_ALIAS("REGION_DATA", ram);
18 | REGION_ALIAS("REGION_BSS", ram);
19 | REGION_ALIAS("REGION_RODATA", rom);
20 |
21 | /* Specify heap boundary addresses on the external SRAM chip */
22 | _lm_heap_start = 0x60000000;
23 | _lm_heap_end = 0x60100000;
24 |
25 | _FLASH_BUILD = 1;
26 | INCLUDE common.inc
27 |
28 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/maple_native/jtag.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * Maple Native (STM32F103ZET6, high density) linker script for JTAG
3 | * (bare metal, no bootloader) builds.
4 | */
5 |
6 | MEMORY
7 | {
8 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
9 | rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K
10 | }
11 |
12 | /*
13 | * Use high density device vector table
14 | */
15 | GROUP(libcs3_stm32_high_density.a)
16 |
17 | REGION_ALIAS("REGION_TEXT", rom);
18 | REGION_ALIAS("REGION_DATA", ram);
19 | REGION_ALIAS("REGION_BSS", ram);
20 | REGION_ALIAS("REGION_RODATA", rom);
21 |
22 | /* Specify heap boundary addresses on the external SRAM chip */
23 | _lm_heap_start = 0x60000000;
24 | _lm_heap_end = 0x60100000;
25 |
26 | _FLASH_BUILD = 1;
27 | INCLUDE common.inc
28 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/maple_native/ram.ld:
--------------------------------------------------------------------------------
1 | /*
2 | * Maple Native (STM32F103ZET6, high density) linker script for RAM builds.
3 | */
4 |
5 | MEMORY
6 | {
7 | ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K
8 | rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K
9 | }
10 |
11 | /*
12 | * Use high density device vector table
13 | */
14 | GROUP(libcs3_stm32_high_density.a)
15 |
16 | REGION_ALIAS("REGION_TEXT", ram);
17 | REGION_ALIAS("REGION_DATA", ram);
18 | REGION_ALIAS("REGION_BSS", ram);
19 | REGION_ALIAS("REGION_RODATA", ram);
20 |
21 | /* Specify heap boundary addresses on the external SRAM chip */
22 | _lm_heap_start = 0x60000000;
23 | _lm_heap_end = 0x60100000;
24 |
25 | INCLUDE common.inc
26 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/ld/names.inc:
--------------------------------------------------------------------------------
1 | EXTERN(__cs3_stack)
2 | EXTERN(__cs3_reset)
3 | EXTERN(__exc_nmi)
4 | EXTERN(__exc_hardfault)
5 | EXTERN(__exc_memmanage)
6 | EXTERN(__exc_busfault)
7 | EXTERN(__exc_usagefault)
8 | EXTERN(__stm32reservedexception7)
9 | EXTERN(__stm32reservedexception8)
10 | EXTERN(__stm32reservedexception9)
11 | EXTERN(__stm32reservedexception10)
12 | EXTERN(__exc_svc)
13 | EXTERN(__exc_debug_monitor)
14 | EXTERN(__stm32reservedexception13)
15 | EXTERN(__exc_pendsv)
16 | EXTERN(__exc_systick)
17 |
18 | EXTERN(__irq_wwdg)
19 | EXTERN(__irq_pvd)
20 | EXTERN(__irq_tamper)
21 | EXTERN(__irq_rtc)
22 | EXTERN(__irq_flash)
23 | EXTERN(__irq_rcc)
24 | EXTERN(__irq_exti0)
25 | EXTERN(__irq_exti1)
26 | EXTERN(__irq_exti2)
27 | EXTERN(__irq_exti3)
28 | EXTERN(__irq_exti4)
29 | EXTERN(__irq_dma1_channel1)
30 | EXTERN(__irq_dma1_channel2)
31 | EXTERN(__irq_dma1_channel3)
32 | EXTERN(__irq_dma1_channel4)
33 | EXTERN(__irq_dma1_channel5)
34 | EXTERN(__irq_dma1_channel6)
35 | EXTERN(__irq_dma1_channel7)
36 | EXTERN(__irq_adc)
37 | EXTERN(__irq_usb_hp_can_tx)
38 | EXTERN(__irq_usb_lp_can_rx0)
39 | EXTERN(__irq_can_rx1)
40 | EXTERN(__irq_can_sce)
41 | EXTERN(__irq_exti9_5)
42 | EXTERN(__irq_tim1_brk)
43 | EXTERN(__irq_tim1_up)
44 | EXTERN(__irq_tim1_trg_com)
45 | EXTERN(__irq_tim1_cc)
46 | EXTERN(__irq_tim2)
47 | EXTERN(__irq_tim3)
48 | EXTERN(__irq_tim4)
49 | EXTERN(__irq_i2c1_ev)
50 | EXTERN(__irq_i2c1_er)
51 | EXTERN(__irq_i2c2_ev)
52 | EXTERN(__irq_i2c2_er)
53 | EXTERN(__irq_spi1)
54 | EXTERN(__irq_spi2)
55 | EXTERN(__irq_usart1)
56 | EXTERN(__irq_usart2)
57 | EXTERN(__irq_usart3)
58 | EXTERN(__irq_exti15_10)
59 | EXTERN(__irq_rtcalarm)
60 | EXTERN(__irq_usbwakeup)
61 |
62 | EXTERN(__irq_tim8_brk)
63 | EXTERN(__irq_tim8_up)
64 | EXTERN(__irq_tim8_trg_com)
65 | EXTERN(__irq_tim8_cc)
66 | EXTERN(__irq_adc3)
67 | EXTERN(__irq_fsmc)
68 | EXTERN(__irq_sdio)
69 | EXTERN(__irq_tim5)
70 | EXTERN(__irq_spi3)
71 | EXTERN(__irq_uart4)
72 | EXTERN(__irq_uart5)
73 | EXTERN(__irq_tim6)
74 | EXTERN(__irq_tim7)
75 | EXTERN(__irq_dma2_channel1)
76 | EXTERN(__irq_dma2_channel2)
77 | EXTERN(__irq_dma2_channel3)
78 | EXTERN(__irq_dma2_channel4_5)
79 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/make/build-rules.mk:
--------------------------------------------------------------------------------
1 | # Useful tools
2 | CC := arm-none-eabi-gcc
3 | CXX := arm-none-eabi-g++
4 | LD := arm-none-eabi-ld -v
5 | AR := arm-none-eabi-ar
6 | AS := arm-none-eabi-gcc
7 | OBJCOPY := arm-none-eabi-objcopy
8 | DISAS := arm-none-eabi-objdump
9 | OBJDUMP := arm-none-eabi-objdump
10 | SIZE := arm-none-eabi-size
11 | DFU := dfu-util
12 | OPENOCD_WRAPPER := support/scripts/openocd-wrapper.sh
13 |
14 | # Suppress annoying output unless V is set
15 | ifndef V
16 | SILENT_CC = @echo ' [CC] ' $(@:$(BUILD_PATH)/%.o=%.c);
17 | SILENT_AS = @echo ' [AS] ' $(@:$(BUILD_PATH)/%.o=%.S);
18 | SILENT_CXX = @echo ' [CXX] ' $(@:$(BUILD_PATH)/%.o=%.cpp);
19 | SILENT_LD = @echo ' [LD] ' $(@F);
20 | SILENT_AR = @echo ' [AR] '
21 | SILENT_OBJCOPY = @echo ' [OBJCOPY] ' $(@F);
22 | SILENT_DISAS = @echo ' [DISAS] ' $(@:$(BUILD_PATH)/%.bin=%).disas;
23 | SILENT_OBJDUMP = @echo ' [OBJDUMP] ' $(OBJDUMP);
24 | endif
25 |
26 | BUILDDIRS :=
27 | TGT_BIN :=
28 |
29 | CFLAGS = $(GLOBAL_CFLAGS) $(TGT_CFLAGS)
30 | CXXFLAGS = $(GLOBAL_CXXFLAGS) $(TGT_CXXFLAGS)
31 | ASFLAGS = $(GLOBAL_ASFLAGS) $(TGT_ASFLAGS)
32 |
33 | ifdef IDE_VS
34 | VS_TRIM_ERRORS = 2>&1 | sed -e 's/\(\w\+\):\([0-9]\+\):/\1(\2):/'
35 | else
36 | VS_TRIM_ERRORS =
37 | endif
38 |
39 | # General directory independent build rules, generate dependency information
40 | #$(SILENT_CC) $(CC) $(CFLAGS) -MMD -MP -MF $(@:%.o=%.d) -MT $@ -o $@ -c $<
41 | $(BUILD_PATH)/%.o: %.c
42 | $(SILENT_CC) $(CC) $(CFLAGS) -MMD -MP -MF $(@:%.o=%.d) -MT $@ -o $@ -c $(abspath $<) $(VS_TRIM_ERRORS)
43 |
44 | #$(SILENT_CXX) $(CXX) $(CFLAGS) $(CXXFLAGS) -MMD -MP -MF $(@:%.o=%.d) -MT $@ -o $@ -c $<
45 | $(BUILD_PATH)/%.o: %.cpp
46 | $(SILENT_CXX) $(CXX) $(CFLAGS) $(CXXFLAGS) -MMD -MP -MF $(@:%.o=%.d) -MT $@ -o $@ -c $(abspath $<) $(VS_TRIM_ERRORS)
47 |
48 | #$(SILENT_AS) $(AS) $(ASFLAGS) -MMD -MP -MF $(@:%.o=%.d) -MT $@ -o $@ -c $<
49 | $(BUILD_PATH)/%.o: %.S
50 | $(SILENT_AS) $(AS) $(ASFLAGS) -MMD -MP -MF $(@:%.o=%.d) -MT $@ -o $@ -c $(abspath $<) $(VS_TRIM_ERRORS)
51 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/make/build-templates.mk:
--------------------------------------------------------------------------------
1 | define LIBMAPLE_MODULE_template
2 | dir := $(1)
3 | LIBMAPLE_INCLUDES += -I$$(dir)
4 | include $$(dir)/rules.mk
5 | endef
6 |
7 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/make/target-config.mk:
--------------------------------------------------------------------------------
1 | # Board-specific configuration values. Flash and SRAM sizes in bytes.
2 |
3 | ifeq ($(BOARD), maple)
4 | MCU := STM32F103RB
5 | PRODUCT_ID := 0003
6 | ERROR_LED_PORT := GPIOA
7 | ERROR_LED_PIN := 5
8 | DENSITY := STM32_MEDIUM_DENSITY
9 | FLASH_SIZE := 131072
10 | SRAM_SIZE := 20480
11 | endif
12 |
13 | ifeq ($(BOARD), maple_native)
14 | MCU := STM32F103ZE
15 | PRODUCT_ID := 0003
16 | ERROR_LED_PORT := GPIOC
17 | ERROR_LED_PIN := 15
18 | DENSITY := STM32_HIGH_DENSITY
19 | FLASH_SIZE := 524288
20 | SRAM_SIZE := 65536
21 | endif
22 |
23 | ifeq ($(BOARD), maple_mini)
24 | MCU := STM32F103CB
25 | PRODUCT_ID := 0003
26 | ERROR_LED_PORT := GPIOC
27 | ERROR_LED_PIN := 1
28 | DENSITY := STM32_MEDIUM_DENSITY
29 | FLASH_SIZE := 131072
30 | SRAM_SIZE := 20480
31 | endif
32 |
33 | ifeq ($(BOARD), maple_RET6)
34 | MCU := STM32F103RE
35 | PRODUCT_ID := 0003
36 | ERROR_LED_PORT := GPIOA
37 | ERROR_LED_PIN := 5
38 | DENSITY := STM32_HIGH_DENSITY
39 | FLASH_SIZE := 524288
40 | SRAM_SIZE := 65536
41 | endif
42 |
43 | ifeq ($(BOARD), aeroquad32)
44 | MCU := STM32F103VE
45 | PRODUCT_ID := 0003
46 | ERROR_LED_PORT := GPIOE
47 | ERROR_LED_PIN := 5
48 | DENSITY := STM32_HIGH_DENSITY
49 | FLASH_SIZE := 524288
50 | SRAM_SIZE := 65536
51 | MCU_FAMILY := STM32F1
52 | endif
53 |
54 | ifeq ($(BOARD), aeroquad32mini)
55 | MCU := STM32F103CB
56 | PRODUCT_ID := 0003
57 | ERROR_LED_PORT := GPIOB
58 | ERROR_LED_PIN := 1
59 | DENSITY := STM32_MEDIUM_DENSITY
60 | FLASH_SIZE := 131072
61 | SRAM_SIZE := 20480
62 | endif
63 |
64 | ifeq ($(BOARD), discovery_f4)
65 | MCU := STM32F406VG
66 | PRODUCT_ID := 0003
67 | ERROR_LED_PORT := GPIOD
68 | ERROR_LED_PIN := 14
69 | DENSITY := STM32_HIGH_DENSITY
70 | FLASH_SIZE := 524288
71 | SRAM_SIZE := 65536
72 | MCU_FAMILY := STM32F2
73 | endif
74 |
75 |
76 | # Memory target-specific configuration values
77 |
78 | ifeq ($(MEMORY_TARGET), ram)
79 | LDSCRIPT := $(BOARD)/ram.ld
80 | VECT_BASE_ADDR := VECT_TAB_RAM
81 | endif
82 | ifeq ($(MEMORY_TARGET), flash)
83 | LDSCRIPT := $(BOARD)/flash.ld
84 | VECT_BASE_ADDR := VECT_TAB_FLASH
85 | endif
86 | ifeq ($(MEMORY_TARGET), jtag)
87 | LDSCRIPT := $(BOARD)/jtag.ld
88 | VECT_BASE_ADDR := VECT_TAB_BASE
89 | endif
90 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/openocd/debug_0.3.cfg:
--------------------------------------------------------------------------------
1 | # script for stm32
2 |
3 | interface ft2232
4 | ft2232_device_desc "Olimex OpenOCD JTAG"
5 | ft2232_layout olimex-jtag
6 | ft2232_vid_pid 0x15ba 0x0003
7 |
8 | if { [info exists CHIPNAME] } {
9 | set _CHIPNAME $CHIPNAME
10 | } else {
11 | set _CHIPNAME stm32
12 | }
13 |
14 | if { [info exists ENDIAN] } {
15 | set _ENDIAN $ENDIAN
16 | } else {
17 | set _ENDIAN little
18 | }
19 |
20 | # jtag speed speed should be <= F_CPU/6. F_CPU after reset is 8MHz, so ufse F_JTAG = 1MHz
21 | jtag_khz 1000
22 |
23 | jtag_nsrst_delay 100
24 | jtag_ntrst_delay 100
25 |
26 | #use combined on interfaces or targets that can't set TRST/SRST separately
27 | reset_config trst_and_srst
28 |
29 | #jtag scan chain
30 | if { [info exists CPUTAPID ] } {
31 | set _CPUTAPID $CPUTAPID
32 | } else {
33 | # See STM Document RM0008
34 | # Section 30.6.3
35 | set _CPUTAPID 0x3ba00477
36 | }
37 |
38 | jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
39 |
40 | if { [info exists BSTAPID ] } {
41 | # FIXME this never gets used to override defaults...
42 | set _BSTAPID $BSTAPID
43 | } else {
44 | # See STM Document RM0008
45 | # Section 29.6.2
46 | # Low density devices, Rev A
47 | set _BSTAPID1 0x06412041
48 | # Medium density devices, Rev A
49 | set _BSTAPID2 0x06410041
50 | # Medium density devices, Rev B and Rev Z
51 | set _BSTAPID3 0x16410041
52 | # High density devices, Rev A
53 | set _BSTAPID4 0x06414041
54 | # Connectivity line devices, Rev A and Rev Z
55 | set _BSTAPID5 0x06418041
56 | }
57 | jtag newtap $_CHIPNAME bs -irlen 5 -expected-id $_BSTAPID1 \
58 | -expected-id $_BSTAPID2 -expected-id $_BSTAPID3 \
59 | -expected-id $_BSTAPID4 -expected-id $_BSTAPID5
60 |
61 |
62 | set _TARGETNAME $_CHIPNAME.cpu
63 | target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
64 |
65 | $_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x20000000 -work-area-size 0x5000 -work-area-backup 0
66 |
67 | flash bank stm32x 0x08000000 0x00020000 0 0 $_TARGETNAME
68 |
69 | proc nopforever {} {
70 | puts "Resetting the chip..."
71 | reset run
72 | }
73 |
74 | init
75 | nopforever
76 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/openocd/debug_0.4.cfg:
--------------------------------------------------------------------------------
1 | # script for stm32
2 |
3 | interface ft2232
4 | ft2232_device_desc "Olimex OpenOCD JTAG"
5 | ft2232_layout olimex-jtag
6 | ft2232_vid_pid 0x15ba 0x0003
7 |
8 | if { [info exists CHIPNAME] } {
9 | set _CHIPNAME $CHIPNAME
10 | } else {
11 | set _CHIPNAME stm32
12 | }
13 |
14 | if { [info exists ENDIAN] } {
15 | set _ENDIAN $ENDIAN
16 | } else {
17 | set _ENDIAN little
18 | }
19 |
20 | # jtag speed speed should be <= F_CPU/6. F_CPU after reset is 8MHz, so ufse F_JTAG = 1MHz
21 | jtag_khz 1000
22 |
23 | jtag_nsrst_delay 100
24 | jtag_ntrst_delay 100
25 |
26 | #use combined on interfaces or targets that can't set TRST/SRST separately
27 | reset_config srst_only
28 |
29 | #jtag scan chain
30 | if { [info exists CPUTAPID ] } {
31 | set _CPUTAPID $CPUTAPID
32 | } else {
33 | # See STM Document RM0008
34 | # Section 30.6.3
35 | set _CPUTAPID 0x3ba00477
36 | }
37 |
38 | jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
39 |
40 | if { [info exists BSTAPID ] } {
41 | # FIXME this never gets used to override defaults...
42 | set _BSTAPID $BSTAPID
43 | } else {
44 | # See STM Document RM0008
45 | # Section 29.6.2
46 | # Low density devices, Rev A
47 | set _BSTAPID1 0x06412041
48 | # Medium density devices, Rev A
49 | set _BSTAPID2 0x06410041
50 | # Medium density devices, Rev B and Rev Z
51 | set _BSTAPID3 0x16410041
52 | # High density devices, Rev A
53 | set _BSTAPID4 0x06414041
54 | # Connectivity line devices, Rev A and Rev Z
55 | set _BSTAPID5 0x06418041
56 | }
57 | jtag newtap $_CHIPNAME bs -irlen 5 -expected-id $_BSTAPID1 \
58 | -expected-id $_BSTAPID2 -expected-id $_BSTAPID3 \
59 | -expected-id $_BSTAPID4 -expected-id $_BSTAPID5
60 |
61 |
62 | set _TARGETNAME $_CHIPNAME.cpu
63 | target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
64 |
65 | $_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x20000000 -work-area-size 0x5000 -work-area-backup 0
66 |
67 | flash bank bank0 stm32x 0x08000000 0x00020000 0 0 $_TARGETNAME
68 |
69 | proc nopforever {} {
70 | puts "Resetting the chip... Halting for debugger."
71 | reset halt
72 | }
73 |
74 | init
75 | nopforever
76 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/openocd/flash_0.3.cfg:
--------------------------------------------------------------------------------
1 | # script for stm32
2 |
3 | interface ft2232
4 | ft2232_device_desc "Olimex OpenOCD JTAG"
5 | ft2232_layout olimex-jtag
6 | ft2232_vid_pid 0x15ba 0x0003
7 |
8 | if { [info exists CHIPNAME] } {
9 | set _CHIPNAME $CHIPNAME
10 | } else {
11 | set _CHIPNAME stm32
12 | }
13 |
14 | if { [info exists ENDIAN] } {
15 | set _ENDIAN $ENDIAN
16 | } else {
17 | set _ENDIAN little
18 | }
19 |
20 | # jtag speed speed should be <= F_CPU/6. F_CPU after reset is 8MHz, so ufse F_JTAG = 1MHz
21 | jtag_khz 1000
22 |
23 | jtag_nsrst_delay 100
24 | jtag_ntrst_delay 100
25 |
26 | #use combined on interfaces or targets that can't set TRST/SRST separately
27 | reset_config trst_and_srst
28 |
29 | #jtag scan chain
30 | if { [info exists CPUTAPID ] } {
31 | set _CPUTAPID $CPUTAPID
32 | } else {
33 | # See STM Document RM0008
34 | # Section 30.6.3
35 | set _CPUTAPID 0x3ba00477
36 | }
37 |
38 | jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
39 |
40 | if { [info exists BSTAPID ] } {
41 | # FIXME this never gets used to override defaults...
42 | set _BSTAPID $BSTAPID
43 | } else {
44 | # See STM Document RM0008
45 | # Section 29.6.2
46 | # Low density devices, Rev A
47 | set _BSTAPID1 0x06412041
48 | # Medium density devices, Rev A
49 | set _BSTAPID2 0x06410041
50 | # Medium density devices, Rev B and Rev Z
51 | set _BSTAPID3 0x16410041
52 | # High density devices, Rev A
53 | set _BSTAPID4 0x06414041
54 | # Connectivity line devices, Rev A and Rev Z
55 | set _BSTAPID5 0x06418041
56 | }
57 | jtag newtap $_CHIPNAME bs -irlen 5 -expected-id $_BSTAPID1 \
58 | -expected-id $_BSTAPID2 -expected-id $_BSTAPID3 \
59 | -expected-id $_BSTAPID4 -expected-id $_BSTAPID5
60 |
61 |
62 | set _TARGETNAME $_CHIPNAME.cpu
63 | target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
64 |
65 | $_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x20000000 -work-area-size 0x5000 -work-area-backup 0
66 | # TODO: native
67 | #$_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x20000000 -work-area-size 0x10000 -work-area-backup 0
68 |
69 | flash bank stm32x 0x08000000 0x00020000 0 0 $_TARGETNAME
70 |
71 | proc flash_chip {} {
72 | echo "Halting..."
73 | halt
74 | echo "Erasing..."
75 | flash erase_address 0x08000000 0x20000
76 | # TODO: native
77 | #flash erase_address 0x08000000 0x80000
78 | echo "Flashing image..."
79 | flash write_bank 0 build/maple.bin 0
80 | echo "Verifying image..."
81 | verify_image build/maple.bin 0x08000000 bin
82 | echo "Checksum verified, resetting chip"
83 | reset run
84 | echo "Daemon shutdown"
85 | shutdown
86 | }
87 |
88 | init
89 | flash_chip
90 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/openocd/flash_0.4.cfg:
--------------------------------------------------------------------------------
1 | # script for stm32
2 |
3 | interface ft2232
4 | ft2232_device_desc "Olimex OpenOCD JTAG"
5 | ft2232_layout olimex-jtag
6 | ft2232_vid_pid 0x15ba 0x0003
7 |
8 | if { [info exists CHIPNAME] } {
9 | set _CHIPNAME $CHIPNAME
10 | } else {
11 | set _CHIPNAME stm32
12 | }
13 |
14 | if { [info exists ENDIAN] } {
15 | set _ENDIAN $ENDIAN
16 | } else {
17 | set _ENDIAN little
18 | }
19 |
20 | # jtag speed speed should be <= F_CPU/6. F_CPU after reset is 8MHz, so ufse F_JTAG = 1MHz
21 | jtag_khz 1000
22 |
23 | jtag_nsrst_delay 100
24 | jtag_ntrst_delay 100
25 |
26 | #use combined on interfaces or targets that can't set TRST/SRST separately
27 | reset_config srst_only
28 |
29 | #jtag scan chain
30 | if { [info exists CPUTAPID ] } {
31 | set _CPUTAPID $CPUTAPID
32 | } else {
33 | # See STM Document RM0008
34 | # Section 30.6.3
35 | set _CPUTAPID 0x3ba00477
36 | }
37 |
38 | jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
39 |
40 | if { [info exists BSTAPID ] } {
41 | # FIXME this never gets used to override defaults...
42 | set _BSTAPID $BSTAPID
43 | } else {
44 | # See STM Document RM0008
45 | # Section 29.6.2
46 | # Low density devices, Rev A
47 | set _BSTAPID1 0x06412041
48 | # Medium density devices, Rev A
49 | set _BSTAPID2 0x06410041
50 | # Medium density devices, Rev B and Rev Z
51 | set _BSTAPID3 0x16410041
52 | # High density devices, Rev A
53 | set _BSTAPID4 0x06414041
54 | # Connectivity line devices, Rev A and Rev Z
55 | set _BSTAPID5 0x06418041
56 | }
57 | jtag newtap $_CHIPNAME bs -irlen 5 -expected-id $_BSTAPID1 \
58 | -expected-id $_BSTAPID2 -expected-id $_BSTAPID3 \
59 | -expected-id $_BSTAPID4 -expected-id $_BSTAPID5
60 |
61 |
62 | set _TARGETNAME $_CHIPNAME.cpu
63 | target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
64 |
65 | $_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x20000000 -work-area-size 0x5000 -work-area-backup 0
66 | # TODO: native
67 | #$_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x20000000 -work-area-size 0x10000 -work-area-backup 0
68 |
69 | flash bank bank0 stm32x 0x08000000 0x00020000 0 0 $_TARGETNAME
70 |
71 | proc flash_chip {} {
72 | echo "Halting..."
73 | reset halt
74 |
75 | echo "Unlocking flash..."
76 | flash protect 0 0 last off
77 |
78 | echo "Erasing..."
79 | flash erase_address 0x08000000 0x20000
80 |
81 | echo "Flashing image..."
82 | flash write_bank 0 build/maple.bin 0
83 |
84 | echo "Verifying image..."
85 | verify_image build/maple.bin 0x08000000 bin
86 |
87 | echo "Checksum verified, resetting chip"
88 | reset run
89 |
90 | echo "Daemon shutdown"
91 | shutdown
92 | }
93 |
94 | init
95 | flash_chip
96 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/scripts/45-maple.rules:
--------------------------------------------------------------------------------
1 | ATTRS{idProduct}=="1001", ATTRS{idVendor}=="0110", MODE="664", GROUP="plugdev"
2 | ATTRS{idProduct}=="1002", ATTRS{idVendor}=="0110", MODE="664", GROUP="plugdev"
3 | ATTRS{idProduct}=="0003", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="plugdev" SYMLINK+="maple"
4 | ATTRS{idProduct}=="0004", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="plugdev" SYMLINK+="maple"
5 |
6 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/scripts/copy-to-ide:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # This hack copies libmaple's source, linker scripts, and support
4 | # libraries into the Maple IDE repository (which is expected as its
5 | # first argument).
6 |
7 | DEST=$1
8 |
9 | DEST_CORES=$DEST/hardware/leaflabs/cores/maple
10 | DEST_LIBS=$DEST/libraries
11 |
12 | LMAPLE_SRC="LICENSE
13 | ./libmaple/*.h
14 | ./libmaple/*.c
15 | ./libmaple/*.S
16 | ./libmaple/usb/*.h
17 | ./libmaple/usb/*.c
18 | ./libmaple/usb/usb_lib/*.h
19 | ./libmaple/usb/usb_lib/*.c
20 | ./wirish/*.h
21 | ./wirish/main.cxx
22 | ./wirish/*.cpp
23 | ./wirish/comm/*.cpp
24 | ./wirish/comm/*.h
25 | ./wirish/boards/*.h
26 | ./wirish/boards/*.cpp
27 | ./support/ld/common.inc
28 | ./support/ld/libcs3_stm32_high_density.a
29 | ./support/ld/libcs3_stm32_med_density.a
30 | ./support/ld/maple
31 | ./support/ld/maple_mini
32 | ./support/ld/maple_native
33 | ./support/ld/maple_RET6
34 | ./support/ld/names.inc"
35 |
36 | echo "First make sure DEST exists: $DEST"
37 | if !(test -d $DEST)
38 | then
39 | echo "Nope! Make sure you're doing this right?"
40 | exit -1
41 | fi
42 |
43 | # source
44 | echo Copying libmaple source
45 | rm -rf $DEST_CORES/*.c $DEST_CORES/*.cpp $DEST_CORES/*.h $DEST_CORES/*.cxx $DEST_CORES/*.S
46 | rm -rf $DEST_CORES/*.inc $DEST_CORES/*.a $DEST_CORES/maple $DEST_CORES/maple_*
47 | cp -R $LMAPLE_SRC $DEST_CORES
48 |
49 | echo Copying over libraries
50 | cp -R libraries/* $DEST_LIBS
51 |
52 | # libmaple version
53 | echo Creating libmaple-version.txt
54 | git show-ref HEAD | cut -c 1-10 > $DEST/libmaple-version.txt
55 |
56 | echo Done.
57 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/support/scripts/openocd-wrapper.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # Helper to decide which openocd script to use. We only support 0.3.x and 0.4.x.
4 |
5 | if [ $# -ne 1 ]
6 | then
7 | echo "Usage: `basename $0` {flash|debug}"
8 | exit 1
9 | fi
10 |
11 | OPENOCD_VERSION=`openocd -v 2>&1 | head -n1 | \
12 | awk '{print $4}' | sed 's/\([0-9]*\.[0-9]*\)\.[0-9]*/\1/'`
13 |
14 | CFG_FILE=$1_${OPENOCD_VERSION}.cfg
15 |
16 | openocd -f support/openocd/$CFG_FILE
17 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/wirish/Print.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Print.h - Base class that provides print() and println()
3 | * Copyright (c) 2008 David A. Mellis. All right reserved.
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public License
7 | * as published by the Free Software Foundation; either version 2.1 of
8 | * the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18 | * 02110-1301 USA.
19 | *
20 | * Modified 12 April 2011 by Marti Bolivar
21 | */
22 |
23 | #ifndef _PRINT_H_
24 | #define _PRINT_H_
25 |
26 | #include "libmaple_types.h"
27 |
28 | enum {
29 | BYTE = 0,
30 | BIN = 2,
31 | OCT = 8,
32 | DEC = 10,
33 | HEX = 16
34 | };
35 |
36 | class Print {
37 | public:
38 | virtual void write(uint8 ch) = 0;
39 | virtual void write(const char *str);
40 | virtual void write(const void *buf, uint32 len);
41 | void print(char);
42 | void print(const char[]);
43 | void print(uint8, int=DEC);
44 | void print(int, int=DEC);
45 | void print(unsigned int, int=DEC);
46 | void print(long, int=DEC);
47 | void print(unsigned long, int=DEC);
48 | void print(long long, int=DEC);
49 | void print(unsigned long long, int=DEC);
50 | void print(double, int=2);
51 | void println(void);
52 | void println(char);
53 | void println(const char[]);
54 | void println(uint8, int=DEC);
55 | void println(int, int=DEC);
56 | void println(unsigned int, int=DEC);
57 | void println(long, int=DEC);
58 | void println(unsigned long, int=DEC);
59 | void println(long long, int=DEC);
60 | void println(unsigned long long, int=DEC);
61 | void println(double, int=2);
62 | private:
63 | void printNumber(unsigned long long, uint8);
64 | void printFloat(double, uint8);
65 | };
66 |
67 | #endif
68 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/wirish/WProgram.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 LeafLabs LLC.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | #include "wirish.h"
28 |
29 | void setup();
30 | void loop();
31 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/wirish/bits.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 LeafLabs, LLC.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | /* Note: Use of this header file is deprecated. Use bit_constants.h
28 | instead. */
29 |
30 | #include "bit_constants.h"
31 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/wirish/cxxabi-compat.cpp:
--------------------------------------------------------------------------------
1 | /* We compile with nodefaultlibs, so we need to provide an error
2 | * handler for an empty pure virtual function */
3 | extern "C" void __cxa_pure_virtual(void) {
4 | while(1)
5 | ;
6 | }
7 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/wirish/main.cxx:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 LeafLabs LLC.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | // Force init to be called *first*, i.e. before static object allocation.
28 | // Otherwise, statically allocated objects that need libmaple may fail.
29 | __attribute__(( constructor )) void premain() {
30 | init();
31 | }
32 |
33 | int main(void) {
34 | setup();
35 |
36 | while (1) {
37 | loop();
38 | }
39 | return 0;
40 | }
41 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/wirish/pwm.cpp:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 Perry Hung.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | /**
28 | * @brief Arduino-style PWM implementation.
29 | */
30 |
31 | #include "libmaple_types.h"
32 | #include "timer.h"
33 |
34 | #include "boards.h"
35 | #include "pwm.h"
36 |
37 | void pwmWrite(uint8 pin, uint16 duty_cycle) {
38 | timer_dev *dev = PIN_MAP[pin].timer_device;
39 | if (pin >= BOARD_NR_GPIO_PINS || dev == NULL || dev->type == TIMER_BASIC) {
40 | return;
41 | }
42 |
43 | timer_set_compare(dev, PIN_MAP[pin].timer_channel, duty_cycle);
44 | }
45 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/wirish/pwm.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 Perry Hung.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | /**
28 | * @file pwm.h
29 | *
30 | * @brief Arduino-compatible PWM interface.
31 | */
32 |
33 | #ifndef _PWM_H_
34 | #define _PWM_H_
35 |
36 | /**
37 | * As a convenience, analogWrite is an alias of pwmWrite to ease
38 | * porting Arduino code. However, period and duty will have to be
39 | * recalibrated.
40 | */
41 | #define analogWrite pwmWrite
42 |
43 | /**
44 | * Set the PWM duty on the given pin.
45 | *
46 | * User code is expected to determine and honor the maximum value
47 | * (based on the configured period).
48 | *
49 | * @param pin PWM output pin
50 | * @param duty_cycle Duty cycle to set.
51 | */
52 | void pwmWrite(uint8 pin, uint16 duty_cycle);
53 |
54 | #endif
55 |
56 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/wirish/rules.mk:
--------------------------------------------------------------------------------
1 | # Standard things
2 | sp := $(sp).x
3 | dirstack_$(sp) := $(d)
4 | d := $(dir)
5 | BUILDDIRS += $(BUILD_PATH)/$(d)
6 | BUILDDIRS += $(BUILD_PATH)/$(d)/comm
7 | BUILDDIRS += $(BUILD_PATH)/$(d)/boards
8 |
9 | WIRISH_INCLUDES := -I$(d) -I$(d)/comm -I$(d)/boards
10 |
11 | # Local flags
12 | CFLAGS_$(d) := $(WIRISH_INCLUDES) $(LIBMAPLE_INCLUDES)
13 |
14 | # Local rules and targets
15 | cSRCS_$(d) :=
16 |
17 | cppSRCS_$(d) := wirish_math.cpp \
18 | Print.cpp \
19 | boards.cpp \
20 | boards/maple.cpp \
21 | boards/maple_mini.cpp \
22 | boards/maple_native.cpp \
23 | boards/maple_RET6.cpp \
24 | boards/aeroquad32.cpp \
25 | boards/aeroquad32mini.cpp \
26 | boards/discovery_f4.cpp \
27 | comm/HardwareSerial.cpp \
28 | comm/HardwareSPI.cpp \
29 | HardwareTimer.cpp \
30 | usb_serial.cpp \
31 | cxxabi-compat.cpp \
32 | wirish_shift.cpp \
33 | wirish_analog.cpp \
34 | wirish_time.cpp \
35 | pwm.cpp \
36 | ext_interrupts.cpp \
37 | wirish_digital.cpp
38 |
39 | cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%)
40 | cppFILES_$(d) := $(cppSRCS_$(d):%=$(d)/%)
41 |
42 | OBJS_$(d) := $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) \
43 | $(cppFILES_$(d):%.cpp=$(BUILD_PATH)/%.o)
44 | DEPS_$(d) := $(OBJS_$(d):%.o=%.d)
45 |
46 | $(OBJS_$(d)): TGT_CFLAGS := $(CFLAGS_$(d))
47 |
48 | TGT_BIN += $(OBJS_$(d))
49 |
50 | # Standard things
51 | -include $(DEPS_$(d))
52 | d := $(dirstack_$(sp))
53 | sp := $(basename $(sp))
54 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/wirish/usb_serial.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 Perry Hung.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | /**
28 | * @brief Wirish virtual serial port
29 | */
30 |
31 | #ifndef _USB_SERIAL_H_
32 | #define _USB_SERIAL_H_
33 |
34 | #include "Print.h"
35 |
36 | /**
37 | * @brief Virtual serial terminal.
38 | */
39 | class USBSerial : public Print {
40 | public:
41 | USBSerial(void);
42 |
43 | void begin(void);
44 | void begin(int);
45 | void end(void);
46 |
47 | uint32 available(void);
48 |
49 | uint32 read(void *buf, uint32 len);
50 | uint8 read(void);
51 |
52 | void write(uint8);
53 | void write(const char *str);
54 | void write(const void*, uint32);
55 |
56 | uint8 getRTS();
57 | uint8 getDTR();
58 | uint8 isConnected();
59 | uint8 pending();
60 | };
61 |
62 | extern USBSerial SerialUSB;
63 |
64 | #endif
65 |
66 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/wirish/wirish.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 Perry Hung.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | /**
28 | * @brief Main include file for the Wirish core.
29 | *
30 | * Includes various Arduino wiring macros and bit defines
31 | */
32 |
33 | #ifndef _WIRISH_H_
34 | #define _WIRISH_H_
35 |
36 | #include "libmaple.h"
37 |
38 | #include "wirish_types.h"
39 | #include "boards.h"
40 | #include "io.h"
41 | #include "bits.h"
42 | #include "pwm.h"
43 | #include "ext_interrupts.h"
44 | #include "wirish_debug.h"
45 | #include "wirish_math.h"
46 | #include "wirish_time.h"
47 | #include "HardwareSPI.h"
48 | #include "HardwareSerial.h"
49 | #include "HardwareTimer.h"
50 | #include "usb_serial.h"
51 |
52 | /* Arduino wiring macros and bit defines */
53 | #define HIGH 0x1
54 | #define LOW 0x0
55 |
56 | #define true 0x1
57 | #define false 0x0
58 |
59 | #define LSBFIRST 0
60 | #define MSBFIRST 1
61 |
62 | #define lowByte(w) ((w) & 0xFF)
63 | #define highByte(w) (((w) >> 8) & 0xFF)
64 | #define bitRead(value, bit) (((value) >> (bit)) & 0x01)
65 | #define bitSet(value, bit) ((value) |= (1UL << (bit)))
66 | #define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
67 | #define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : \
68 | bitClear(value, bit))
69 | #define bit(b) (1UL << (b))
70 |
71 | typedef uint8 boolean;
72 | typedef uint8 byte;
73 |
74 | #endif
75 |
76 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/wirish/wirish_analog.cpp:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 Perry Hung.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | /**
28 | * @brief Arduino-compatible ADC implementation.
29 | */
30 |
31 | #include "libmaple.h"
32 | #include "wirish.h"
33 | #include "io.h"
34 |
35 | /* Assumes that the ADC has been initialized and that the pin is set
36 | * to INPUT_ANALOG */
37 | uint16 analogRead(uint8 pin) {
38 | const adc_dev *dev = PIN_MAP[pin].adc_device;
39 | if (dev == NULL) {
40 | return 0;
41 | }
42 |
43 | return adc_read(dev, PIN_MAP[pin].adc_channel);
44 | }
45 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/wirish/wirish_debug.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2011 LeafLabs, LLC.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | /**
28 | * @file wirish_debug.h
29 | * @brief High level debug port configuration
30 | */
31 |
32 | /**
33 | * @brief Disable the JTAG and Serial Wire (SW) debug ports.
34 | *
35 | * You can call this function in order to use the JTAG and SW debug
36 | * pins as ordinary GPIOs.
37 | *
38 | * @see enableDebugPorts()
39 | */
40 | static inline void disableDebugPorts(void) {
41 | afio_cfg_debug_ports(AFIO_DEBUG_NONE);
42 | }
43 |
44 | /**
45 | * @brief Enable the JTAG and Serial Wire (SW) debug ports.
46 | *
47 | * After you call this function, the JTAG and SW debug pins will no
48 | * longer be usable as GPIOs.
49 | *
50 | * @see disableDebugPorts()
51 | */
52 | static inline void enableDebugPorts(void) {
53 | afio_cfg_debug_ports(AFIO_DEBUG_FULL_SWJ);
54 | }
55 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/wirish/wirish_math.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Modified by LeafLabs, LLC.
3 | *
4 | * Part of the Wiring project - http://wiring.org.co Copyright (c)
5 | * 2004-06 Hernando Barragan Modified 13 August 2006, David A. Mellis
6 | * for Arduino - http://www.arduino.cc/
7 | *
8 | * This library is free software; you can redistribute it and/or
9 | * modify it under the terms of the GNU Lesser General Public License
10 | * as published by the Free Software Foundation; either version 2.1 of
11 | * the License, or (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful, but
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | * Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public
19 | * License along with this library; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 | * USA
22 | */
23 |
24 | #include
25 | #include "math.h"
26 |
27 | void randomSeed(unsigned int seed) {
28 | if (seed != 0) {
29 | srand(seed);
30 | }
31 | }
32 |
33 | long random(long howbig) {
34 | if (howbig == 0) {
35 | return 0;
36 | }
37 |
38 | return rand() % howbig;
39 | }
40 |
41 | long random(long howsmall, long howbig) {
42 | if (howsmall >= howbig) {
43 | return howsmall;
44 | }
45 |
46 | long diff = howbig - howsmall;
47 | return random(diff) + howsmall;
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/wirish/wirish_shift.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * wiring_shift.c - shiftOut() function
3 | * Part of Arduino - http://www.arduino.cc/
4 | *
5 | * Copyright (c) 2005-2006 David A. Mellis
6 | *
7 | * This library is free software; you can redistribute it and/or
8 | * modify it under the terms of the GNU Lesser General Public License
9 | * as published by the Free Software Foundation; either version 2.1 of
10 | * the License, or (at your option) any later version.
11 | *
12 | * This library is distributed in the hope that it will be useful, but
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public
18 | * License along with this library; if not, write to the Free Software
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 | * USA
21 | *
22 | * $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
23 | */
24 |
25 | #include "wirish.h"
26 |
27 | void shiftOut(uint8 dataPin, uint8 clockPin, uint8 bitOrder, uint8 val) {
28 | int i;
29 |
30 | for (i = 0; i < 8; i++) {
31 | if (bitOrder == LSBFIRST) {
32 | digitalWrite(dataPin, !!(val & (1 << i)));
33 | } else {
34 | digitalWrite(dataPin, !!(val & (1 << (7 - i))));
35 | }
36 |
37 | digitalWrite(clockPin, HIGH);
38 | digitalWrite(clockPin, LOW);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/wirish/wirish_time.cpp:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 Perry Hung.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | /**
28 | * @brief Delay implementation.
29 | */
30 |
31 | #include "libmaple.h"
32 | #include "systick.h"
33 | #include "wirish_time.h"
34 | #include "delay.h"
35 |
36 | void delay(unsigned long ms) {
37 | uint32 i;
38 | for (i = 0; i < ms; i++) {
39 | delayMicroseconds(1000);
40 | }
41 | }
42 |
43 | void delayMicroseconds(uint32 us) {
44 | delay_us(us);
45 | }
46 |
--------------------------------------------------------------------------------
/stm32f4/libmaple/wirish/wirish_types.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2011 LeafLabs, LLC.
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use, copy,
10 | * modify, merge, publish, distribute, sublicense, and/or sell copies
11 | * of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *****************************************************************************/
26 |
27 | /**
28 | * @file wirish_types.h
29 | * @author Marti Bolivar
30 | * @brief Wirish library type definitions.
31 | */
32 |
33 | #include "libmaple_types.h"
34 | #include "gpio.h"
35 | #include "timer.h"
36 | #include "adc.h"
37 |
38 | #ifndef _WIRISH_TYPES_H_
39 | #define _WIRISH_TYPES_H_
40 |
41 | /**
42 | * Invalid stm32_pin_info adc_channel value.
43 | * @see stm32_pin_info
44 | */
45 | #define ADCx 0xFF
46 |
47 | /**
48 | * @brief Stores STM32-specific information related to a given Maple pin.
49 | * @see PIN_MAP
50 | */
51 | typedef struct stm32_pin_info {
52 | gpio_dev *gpio_device; /**< Maple pin's GPIO device */
53 | timer_dev *timer_device; /**< Pin's timer device, if any. */
54 | const adc_dev *adc_device; /**< ADC device, if any. */
55 | uint8 gpio_bit; /**< Pin's GPIO port bit. */
56 | uint8 timer_channel; /**< Timer channel, or 0 if none. */
57 | uint8 adc_channel; /**< Pin ADC channel, or ADCx if none. */
58 | uint8 filler;
59 | } stm32_pin_info;
60 |
61 | /**
62 | * Variable attribute, instructs the linker to place the marked
63 | * variable in Flash instead of RAM. */
64 | #define __FLASH__ __attr_flash
65 |
66 | #endif
67 |
--------------------------------------------------------------------------------
/stm32f4/maple-bootloader/.gitignore:
--------------------------------------------------------------------------------
1 | .dep
2 | TAGS
3 | tags
4 | cscope.out
5 | build
6 |
--------------------------------------------------------------------------------
/stm32f4/maple-bootloader/FlashV2.bat:
--------------------------------------------------------------------------------
1 | set flasher="%ProgramFiles%\STMicroelectronics\STM32 ST-LINK Utility\ST-LINK Utility\ST-LINK_CLI.exe"
2 | set binary=build\maple_boot.bin
3 |
4 | %flasher% -c SWD -P %binary% 0x08000000 -V
5 | pause
--------------------------------------------------------------------------------
/stm32f4/maple-bootloader/README:
--------------------------------------------------------------------------------
1 |
2 | FILES -------------------------------------------------------------------------
3 |
4 | stm32lib/*
5 | - all the (possibly consolidated) stm32 lib and usb example code
6 |
7 | usb.c
8 | - USB-specific hardware setup. Interrupts, clocks, etc. handling USB when
9 | not "Attached". some low-level callbacks (low power mode, init, reset,
10 | resume, etc).
11 |
12 | usb_callbacks.c
13 | - aka endpoints: handling data transfer when "Configured". calls out to
14 | application specific callbacks (eg DFU or serial shit)
15 |
16 | usb_descriptor.c
17 | - aka application descriptor; big static struct and callbacks for sending
18 | the descriptor.
19 |
20 | main.c
21 | - main loop and calling any hardware init stuff. timing hacks for EEPROM
22 | writes not to block usb interrupts. logic to handle 2 second timeout then
23 | jump to user code.
24 |
25 | hardware.c
26 | - init routines to setup clocks, interrupts, also destructor functions.
27 | does not include USB stuff. EEPROM read/write functions.
28 |
29 | dfu.c
30 | - mostly the giant FSM case switch, also some USB endpoint callbacks
31 |
32 |
33 | TODO --------------------------------------------------------------------------
34 |
35 | * tap reset then quickly tap The Button leaves the board in dfu wait loop
36 | forever instead of just 2 seconds
37 |
38 | * use sizeof() for usb application descriptor
39 |
--------------------------------------------------------------------------------
/stm32f4/maple-bootloader/common.h:
--------------------------------------------------------------------------------
1 | /* *****************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 LeafLabs LLC.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | * ****************************************************************************/
24 |
25 | /**
26 | * @file common.h
27 | *
28 | * @brief toplevel include for bootloader source files
29 | *
30 | *
31 | */
32 |
33 | #ifndef __COMMON_H
34 | #define __COMMON_H
35 |
36 | #include "config.h"
37 | #include "hardware.h"
38 | #include "stm32f10x_type.h"
39 | #include "cortexm3_macro.h"
40 | #include "usb.h"
41 |
42 | typedef void (*FuncPtr)(void);
43 |
44 | #endif
45 |
--------------------------------------------------------------------------------
/stm32f4/maple-bootloader/config.h.old:
--------------------------------------------------------------------------------
1 | /* *****************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 LeafLabs LLC.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | * ****************************************************************************/
24 |
25 | /**
26 | * @file config.h
27 | *
28 | * @brief bootloader settings and macro defines
29 | *
30 | *
31 | */
32 |
33 | #ifndef __CONFIG_H
34 | #define __CONFIG_H
35 |
36 | #include "common.h"
37 |
38 | #define FLASH_PAGE_SIZE 0x800 /* 2KB pages for high density devices */
39 |
40 | /* On the Native, LED is PC15 */
41 | #define LED_BANK GPIOC
42 | #define LED 15
43 | #define LED_BANK_CR GPIO_CRH(LED_BANK)
44 | #define LED_CR_MASK 0x0FFFFFFF
45 | #define LED_CR_OUTPUT 0x10000000
46 | #define RCC_APB2ENR_LED 0x00000010 /* enable PC */
47 |
48 | /* Speed controls for strobing the LED pin */
49 | #define BLINK_FAST 0x50000
50 | #define BLINK_SLOW 0x100000
51 |
52 | /* On the Native, BUT is PG15 */
53 | #define BUTTON_BANK GPIOG
54 | #define BUTTON 15
55 | #define BUT_BANK_CR GPIO_CRH(BUTTON_BANK)
56 | #define BUT_CR_MASK 0x0FFFFFFF
57 | #define BUT_CR_OUTPUT 0x40000000
58 | #define RCC_APB2ENR_BUT 0x00000100 /* enable PG */
59 |
60 | #define STARTUP_BLINKS 5
61 | #define BOOTLOADER_WAIT 6
62 |
63 | #define USER_CODE_RAM ((u32)0x20000C00)
64 | #define USER_CODE_FLASH ((u32)0x08005000)
65 |
66 | #define VEND_ID0 0xAF
67 | #define VEND_ID1 0x1E
68 | #define PROD_ID0 0x03
69 | #define PROD_ID1 0x00
70 |
71 | #endif
72 |
--------------------------------------------------------------------------------
/stm32f4/maple-bootloader/flash/debug.cfg:
--------------------------------------------------------------------------------
1 | # script for stm32
2 |
3 | interface ft2232
4 | ft2232_device_desc "Olimex OpenOCD JTAG"
5 | ft2232_layout olimex-jtag
6 | ft2232_vid_pid 0x15ba 0x0003
7 |
8 | if { [info exists CHIPNAME] } {
9 | set _CHIPNAME $CHIPNAME
10 | } else {
11 | set _CHIPNAME stm32
12 | }
13 |
14 | if { [info exists ENDIAN] } {
15 | set _ENDIAN $ENDIAN
16 | } else {
17 | set _ENDIAN little
18 | }
19 |
20 | # jtag speed
21 | jtag_khz 600
22 |
23 | #use combined on interfaces or targets that can't set TRST/SRST separately
24 | reset_config trst_and_srst
25 |
26 | #jtag scan chain
27 | if { [info exists CPUTAPID ] } {
28 | set _CPUTAPID $CPUTAPID
29 | } else {
30 | # See STM Document RM0008
31 | # Section 26.6.3
32 | set _CPUTAPID 0x3ba00477
33 | }
34 | jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
35 |
36 | if { [info exists BSTAPID ] } {
37 | set _BSTAPID $BSTAPID
38 | } else {
39 | # See STM Document RM0008
40 | # Section 26.6.2
41 | # Medium Density RevA
42 | set _BSTAPID 0x06410041
43 | # Rev B and Rev Z
44 | set _BSTAPID 0x16410041
45 | # High Density Devices, Rev A
46 | #set _BSTAPID 0x06414041
47 | }
48 | jtag newtap $_CHIPNAME bs -irlen 5 -ircapture 0x1 -irmask 0x1 -expected-id $_BSTAPID
49 |
50 | set _TARGETNAME [format "%s.cpu" $_CHIPNAME]
51 | target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
52 |
53 | $_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x20000000 -work-area-size 0x5000 -work-area-backup 0
54 | #$_TARGETNAME configure -event halted halt_handle
55 |
56 | #flash bank stm32x 0 0 0 0 0
57 |
58 |
59 | #target create cortex_m3 -endian little
60 | #run_and_halt_time 0 30
61 |
62 | #working_area 0 0x20000000 0x4000 nobackup
63 |
64 | flash bank stm32x 0x08000000 0x00010000 0 0 0
65 |
66 | # For more information about the configuration files, take a look at:
67 | # openocd.texi
68 |
69 | #script flash.script
70 |
71 | proc halt_handle {} {
72 | resume
73 | }
74 |
75 | proc flash_test {} {
76 | puts "Entering DEBUG wait"
77 | sleep 100
78 | # reset run
79 | # sleep 500
80 | }
81 |
82 | init
83 | flash_test
84 |
--------------------------------------------------------------------------------
/stm32f4/maple-bootloader/flash/flash.cfg:
--------------------------------------------------------------------------------
1 | # script for stm32
2 |
3 | interface ft2232
4 | ft2232_device_desc "Olimex OpenOCD JTAG"
5 | ft2232_layout olimex-jtag
6 | ft2232_vid_pid 0x15ba 0x0003
7 |
8 | if { [info exists CHIPNAME] } {
9 | set _CHIPNAME $CHIPNAME
10 | } else {
11 | set _CHIPNAME stm32
12 | }
13 |
14 | if { [info exists ENDIAN] } {
15 | set _ENDIAN $ENDIAN
16 | } else {
17 | set _ENDIAN little
18 | }
19 |
20 | # jtag speed
21 | jtag_khz 600
22 |
23 | #use combined on interfaces or targets that can't set TRST/SRST separately
24 | reset_config trst_and_srst
25 |
26 | #jtag scan chain
27 | if { [info exists CPUTAPID ] } {
28 | set _CPUTAPID $CPUTAPID
29 | } else {
30 | # See STM Document RM0008
31 | # Section 26.6.3
32 | set _CPUTAPID 0x3ba00477
33 | }
34 | jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
35 |
36 | if { [info exists BSTAPID ] } {
37 | set _BSTAPID $BSTAPID
38 | } else {
39 | # See STM Document RM0008
40 | # Section 26.6.2
41 | # Medium Density RevA
42 | set _BSTAPID 0x06410041
43 | # Rev B and Rev Z
44 | set _BSTAPID 0x16410041
45 | # High Density Devices, Rev A
46 | #set _BSTAPID 0x06414041
47 | }
48 | jtag newtap $_CHIPNAME bs -irlen 5 -ircapture 0x1 -irmask 0x1 -expected-id $_BSTAPID
49 |
50 | set _TARGETNAME [format "%s.cpu" $_CHIPNAME]
51 | target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
52 |
53 | $_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x20000000 -work-area-size 0x5000 -work-area-backup 0
54 | #$_TARGETNAME configure -event halted halt_handle
55 |
56 | #flash bank stm32x 0 0 0 0 0
57 |
58 |
59 | #target create cortex_m3 -endian little
60 | #run_and_halt_time 0 30
61 |
62 | #working_area 0 0x20000000 0x4000 nobackup
63 |
64 | flash bank stm32x 0x08000000 0x00010000 0 0 0
65 |
66 | # For more information about the configuration files, take a look at:
67 | # openocd.texi
68 |
69 | #script flash.script
70 |
71 | proc halt_handle {} {
72 | resume
73 | }
74 |
75 | proc flash_test {} {
76 | puts "Trying to flash"
77 | sleep 100
78 | halt
79 | sleep 300
80 | stm32x mass_erase 0
81 | sleep 20
82 | flash write_bank 0 tmpflash.bin 0
83 | sleep 50
84 | # reset run
85 | # sleep 500
86 | reset run
87 | shutdown
88 | }
89 |
90 | init
91 | flash_test
92 |
--------------------------------------------------------------------------------
/stm32f4/maple-bootloader/flash/openocd.cfg:
--------------------------------------------------------------------------------
1 | # script for stm32
2 |
3 | interface ft2232
4 | ft2232_device_desc "Olimex OpenOCD JTAG"
5 | ft2232_layout olimex-jtag
6 | ft2232_vid_pid 0x15ba 0x0003
7 |
8 | if { [info exists CHIPNAME] } {
9 | set _CHIPNAME $CHIPNAME
10 | } else {
11 | set _CHIPNAME stm32
12 | }
13 |
14 | if { [info exists ENDIAN] } {
15 | set _ENDIAN $ENDIAN
16 | } else {
17 | set _ENDIAN little
18 | }
19 |
20 | # jtag speed
21 | jtag_khz 500
22 |
23 | jtag_nsrst_delay 200
24 | jtag_ntrst_delay 200
25 |
26 | #use combined on interfaces or targets that can't set TRST/SRST separately
27 | reset_config trst_and_srst
28 |
29 | #jtag scan chain
30 | if { [info exists CPUTAPID ] } {
31 | set _CPUTAPID $CPUTAPID
32 | } else {
33 | # See STM Document RM0008
34 | # Section 26.6.3
35 | set _CPUTAPID 0x3ba00477
36 | }
37 |
38 | jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
39 |
40 | if { [info exists BSTAPID ] } {
41 | set _BSTAPID $BSTAPID
42 | } else {
43 | # See STM Document RM0008
44 | # Section 26.6.2
45 | # Medium Density RevA
46 | set _BSTAPID 0x06410041
47 | # Rev B and Rev Z
48 | set _BSTAPID 0x16410041
49 | # High Density Devices, Rev A
50 | #set _BSTAPID 0x06414041
51 | }
52 |
53 | jtag newtap $_CHIPNAME bs -irlen 5 -ircapture 0x1 -irmask 0x1 -expected-id $_BSTAPID
54 |
55 | set _TARGETNAME [format "%s.cpu" $_CHIPNAME]
56 | target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
57 |
58 | $_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x20000000 -work-area-size 0x5000 -work-area-backup 0
59 |
60 | flash bank stm32x 0x08000000 0x00010000 0 0 0
61 |
62 | init
63 |
64 | halt
65 | sleep 1000
66 | stm32x unlock 0
67 | flash erase_sector 0 0 0
68 | sleep 1000
69 | flash write_bank 0 tmpflash.bin 0
70 | sleep 3000
71 | reset
72 | sleep 3000
73 | shutdown
74 |
--------------------------------------------------------------------------------
/stm32f4/maple-bootloader/flash/stm32.cfg:
--------------------------------------------------------------------------------
1 | # script for stm32
2 |
3 | interface ft2232
4 | ft2232_device_desc "Olimex OpenOCD JTAG"
5 | ft2232_layout olimex-jtag
6 | ft2232_vid_pid 0x15ba 0x0003
7 |
8 | if { [info exists CHIPNAME] } {
9 | set _CHIPNAME $CHIPNAME
10 | } else {
11 | set _CHIPNAME stm32
12 | }
13 |
14 | if { [info exists ENDIAN] } {
15 | set _ENDIAN $ENDIAN
16 | } else {
17 | set _ENDIAN little
18 | }
19 |
20 | # jtag speed
21 | jtag_khz 500
22 |
23 | jtag_nsrst_delay 100
24 | jtag_ntrst_delay 100
25 |
26 | #use combined on interfaces or targets that can't set TRST/SRST separately
27 | reset_config trst_and_srst
28 |
29 | #jtag scan chain
30 | if { [info exists CPUTAPID ] } {
31 | set _CPUTAPID $CPUTAPID
32 | } else {
33 | # See STM Document RM0008
34 | # Section 26.6.3
35 | set _CPUTAPID 0x3ba00477
36 | }
37 | jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
38 |
39 | if { [info exists BSTAPID ] } {
40 | set _BSTAPID $BSTAPID
41 | } else {
42 | # See STM Document RM0008
43 | # Section 26.6.2
44 | # Medium Density RevA
45 | set _BSTAPID 0x06410041
46 | # Rev B and Rev Z
47 | set _BSTAPID 0x16410041
48 | # High Density Devices, Rev A
49 | #set _BSTAPID 0x06414041
50 | }
51 | jtag newtap $_CHIPNAME bs -irlen 5 -ircapture 0x1 -irmask 0x1 -expected-id $_BSTAPID
52 |
53 | set _TARGETNAME [format "%s.cpu" $_CHIPNAME]
54 | target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
55 |
56 | $_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x20000000 -work-area-size 16384 -work-area-backup 0
57 |
58 | #flash bank stm32x 0 0 0 0 0
59 |
60 |
61 | target create cortex_m3 -endian little
62 | #run_and_halt_time 0 30
63 |
64 | #working_area 0 0x20000000 0x4000 nobackup
65 |
66 | #flash bank stm32x 0x08000000 0x00010000 0 0 0
67 | reset
68 | sleep 3000
69 | shutdown
70 | # For more information about the configuration files, take a look at:
71 | # openocd.texi
72 |
73 |
--------------------------------------------------------------------------------
/stm32f4/maple-bootloader/stm32_lib/cortexm3_macro.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
2 | * File Name : cortexm3_macro.h
3 | * Author : MCD Application Team
4 | * Version : V2.0.3
5 | * Date : 09/22/2008
6 | * Description : Header file for cortexm3_macro.s.
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 |
16 | /* Define to prevent recursive inclusion -------------------------------------*/
17 | #ifndef __CORTEXM3_MACRO_H
18 | #define __CORTEXM3_MACRO_H
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "stm32f10x_type.h"
22 |
23 | /* Exported types ------------------------------------------------------------*/
24 | /* Exported constants --------------------------------------------------------*/
25 | /* Exported macro ------------------------------------------------------------*/
26 | /* Exported functions ------------------------------------------------------- */
27 | void __WFI(void);
28 | void __WFE(void);
29 | void __SEV(void);
30 | void __ISB(void);
31 | void __DSB(void);
32 | void __DMB(void);
33 | void __SVC(void);
34 | u32 __MRS_CONTROL(void);
35 | void __MSR_CONTROL(u32 Control);
36 | u32 __MRS_PSP(void);
37 | void __MSR_PSP(u32 TopOfProcessStack);
38 | u32 __MRS_MSP(void);
39 | void __MSR_MSP(u32 TopOfMainStack);
40 | void __RESETPRIMASK(void);
41 | void __SETPRIMASK(void);
42 | u32 __READ_PRIMASK(void);
43 | void __RESETFAULTMASK(void);
44 | void __SETFAULTMASK(void);
45 | u32 __READ_FAULTMASK(void);
46 | void __BASEPRICONFIG(u32 NewPriority);
47 | u32 __GetBASEPRI(void);
48 | u16 __REV_HalfWord(u16 Data);
49 | u32 __REV_Word(u32 Data);
50 |
51 | #endif /* __CORTEXM3_MACRO_H */
52 |
53 | /******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
54 |
--------------------------------------------------------------------------------
/stm32f4/maple-bootloader/stm32_lib/stm32f2xx.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbulmer/openstm32sw/d70fe3fd9266ffc8602b8cd8d5190f90992194af/stm32f4/maple-bootloader/stm32_lib/stm32f2xx.h
--------------------------------------------------------------------------------
/stm32f4/maple-bootloader/usb_callbacks.c:
--------------------------------------------------------------------------------
1 | /* *****************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 LeafLabs LLC.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | * ****************************************************************************/
24 |
25 | /**
26 | * @file usb_callbacks.c
27 | *
28 | * @brief aka endpoints: handling data transfer when "Configured". calls out to
29 | * application specific callbacks (eg DFU)
30 | *
31 | */
32 |
--------------------------------------------------------------------------------
/stm32f4/maple-bootloader/usb_descriptor.h:
--------------------------------------------------------------------------------
1 | /* *****************************************************************************
2 | * The MIT License
3 | *
4 | * Copyright (c) 2010 LeafLabs LLC.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | * ****************************************************************************/
24 |
25 | #ifndef __MAPLE_USB_DESC_H
26 | #define __MAPLE_USB_DESC_H
27 |
28 | #include "common.h"
29 | #include "usb_lib.h"
30 | #include "usb.h"
31 |
32 | #define NUM_ALT_SETTINGS 2
33 | #define STR_DESC_LEN 6
34 |
35 | extern ONE_DESCRIPTOR usbDeviceDescriptorDFU;
36 | extern ONE_DESCRIPTOR usbConfigDescriptorDFU;
37 | extern ONE_DESCRIPTOR usbStringDescriptor[6];
38 | extern ONE_DESCRIPTOR usbFunctionalDescriptor;
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/stm32f4/maple-bootloader/usb_lib/usb_init.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
2 | * File Name : usb_init.h
3 | * Author : MCD Application Team
4 | * Version : V2.2.1
5 | * Date : 09/22/2008
6 | * Description : Initialization routines & global variables
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 |
16 | /* Define to prevent recursive inclusion -------------------------------------*/
17 | #ifndef __USB_INIT_H
18 | #define __USB_INIT_H
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | /* Exported types ------------------------------------------------------------*/
22 | /* Exported constants --------------------------------------------------------*/
23 | /* Exported macro ------------------------------------------------------------*/
24 | /* Exported functions ------------------------------------------------------- */
25 | void USB_Init(void);
26 |
27 | /* External variables --------------------------------------------------------*/
28 | /* The number of current endpoint, it will be used to specify an endpoint */
29 | extern volatile u8 EPindex;
30 | /* The number of current device, it is an index to the Device_Table */
31 | /*extern u8 Device_no; */
32 | /* Points to the DEVICE_INFO structure of current device */
33 | /* The purpose of this register is to speed up the execution */
34 | extern volatile DEVICE_INFO* pInformation;
35 | /* Points to the DEVICE_PROP structure of current device */
36 | /* The purpose of this register is to speed up the execution */
37 | extern volatile DEVICE_PROP* pProperty;
38 | /* Temporary save the state of Rx & Tx status. */
39 | /* Whenever the Rx or Tx state is changed, its value is saved */
40 | /* in this variable first and will be set to the EPRB or EPRA */
41 | /* at the end of interrupt process */
42 | extern volatile USER_STANDARD_REQUESTS *pUser_Standard_Requests;
43 |
44 | extern volatile u16 SaveState ;
45 | extern volatile u16 wInterrupt_Mask;
46 |
47 | #endif /* __USB_INIT_H */
48 |
49 | /******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
50 |
--------------------------------------------------------------------------------
/stm32f4/maple-bootloader/usb_lib/usb_int.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
2 | * File Name : usb_int.h
3 | * Author : MCD Application Team
4 | * Version : V2.2.1
5 | * Date : 09/22/2008
6 | * Description : Endpoint CTR (Low and High) interrupt's service routines
7 | * prototypes
8 | ********************************************************************************
9 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
10 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
11 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
12 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
13 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
14 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
15 | *******************************************************************************/
16 |
17 | /* Define to prevent recursive inclusion -------------------------------------*/
18 | #ifndef __USB_INT_H
19 | #define __USB_INT_H
20 |
21 | /* Includes ------------------------------------------------------------------*/
22 | /* Exported types ------------------------------------------------------------*/
23 | /* Exported constants --------------------------------------------------------*/
24 | /* Exported macro ------------------------------------------------------------*/
25 | /* Exported functions ------------------------------------------------------- */
26 | void CTR_LP(void);
27 | void CTR_HP(void);
28 |
29 | /* External variables --------------------------------------------------------*/
30 |
31 | #endif /* __USB_INT_H */
32 |
33 | /******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
34 |
--------------------------------------------------------------------------------
/stm32f4/maple-bootloader/usb_lib/usb_lib.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
2 | * File Name : usb_lib.h
3 | * Author : MCD Application Team
4 | * Version : V2.2.1
5 | * Date : 09/22/2008
6 | * Description : USB library include files
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 |
16 | /* Define to prevent recursive inclusion -------------------------------------*/
17 | #ifndef __USB_LIB_H
18 | #define __USB_LIB_H
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "usb_type.h"
22 | #include "usb_regs.h"
23 | #include "usb_def.h"
24 | #include "usb_core.h"
25 | #include "usb_init.h"
26 | #include "usb_mem.h"
27 | #include "usb_int.h"
28 |
29 | /* Exported types ------------------------------------------------------------*/
30 | /* Exported constants --------------------------------------------------------*/
31 | /* Exported macro ------------------------------------------------------------*/
32 | /* Exported functions ------------------------------------------------------- */
33 | /* External variables --------------------------------------------------------*/
34 |
35 | #endif /* __USB_LIB_H */
36 |
37 | /******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
38 |
--------------------------------------------------------------------------------
/stm32f4/maple-bootloader/usb_lib/usb_mem.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
2 | * File Name : usb_mem.h
3 | * Author : MCD Application Team
4 | * Version : V2.2.1
5 | * Date : 09/22/2008
6 | * Description : Utility prototypes functions for memory/PMA transfers
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 |
16 | /* Define to prevent recursive inclusion -------------------------------------*/
17 | #ifndef __USB_MEM_H
18 | #define __USB_MEM_H
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | /* Exported types ------------------------------------------------------------*/
22 | /* Exported constants --------------------------------------------------------*/
23 | /* Exported macro ------------------------------------------------------------*/
24 | /* Exported functions ------------------------------------------------------- */
25 | void UserToPMABufferCopy(u8 *pbUsrBuf, u16 wPMABufAddr, u16 wNBytes);
26 | void PMAToUserBufferCopy(u8 *pbUsrBuf, u16 wPMABufAddr, u16 wNBytes);
27 |
28 | /* External variables --------------------------------------------------------*/
29 |
30 | #endif /*__USB_MEM_H*/
31 |
32 | /******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
33 |
--------------------------------------------------------------------------------