Merge remote-tracking branch 'rogerclarkmelbourne/master'

This commit is contained in:
Josh Stewart 2018-07-19 22:14:30 +10:00
commit 737ec5e126
738 changed files with 49632 additions and 39018 deletions

5
.gitignore vendored
View File

@ -6,4 +6,7 @@ other/maple-bootloader/cscope.out
other/maple-bootloader/build other/maple-bootloader/build
other/maple-bootloader/*~ other/maple-bootloader/*~
*.o *.o
tools/src/stm32flash_serial/src/parsers/parsers.a *.bak
*.1
platform.local.txt
boards.local.txt

View File

@ -1,46 +1,43 @@
Arduino STM32 Arduino STM32
============= =============
##Notice
## Notice
This software is experimental and a work in progress. This software is experimental and a work in progress.
Under no circumstances should these files be used in relation to any critical system(s). Under no circumstances should these files be used in relation to any critical system(s).
Use of these files is at your own risk. Use of these files is at your own risk.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
##Summary: ## Summary:
This repo contains, the "Hardware" files to support STM32 based boards on Arduino version 1.6.13 or 1.6.12 (some older versions may also work) including [LeafLabs Maple, and Maple mini](http://www.leaflabs.com/about-maple/), and other generic STM32F103 boards This repo contains the "Hardware" files to support STM32 based boards on Arduino version 1.8.x (some older versions may also work) including [LeafLabs Maple, and Maple mini](http://www.leaflabs.com/about-maple/), and other generic STM32F103 boards.
***PRIMARY SUPPORT FORUM: http://www.stm32duino.com/*** ***PRIMARY SUPPORT FORUM: http://www.stm32duino.com/***
##Background & Support: ***We are also on Gitter https://gitter.im/stm32duino/Lobby/***
* Based on https://github.com/bobc/maple-asp, which is in turn based on LibMaple by Leaflabs [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/stm32duino/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
## Background & Support:
* Based on https://github.com/bobc/maple-asp, which is in turn based on LibMaple by Leaflabs
* **Please read the wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki) for full details** * **Please read the wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki) for full details**
* See also my blog: http://www.rogerclark.net/stm32f103-and-maple-maple-mini-with-arduino-1-5-x-ide/ * See also my blog: http://www.rogerclark.net/stm32f103-and-maple-maple-mini-with-arduino-1-5-x-ide/
* **NEW: Main support site for using STM32 boards with the Arduino IDE: http://www.stm32duino.com/** * **NEW: Main support site for using STM32 boards with the Arduino IDE: http://www.stm32duino.com/**
* Original LeafLabs "Docs:" http://docs.leaflabs.com/docs.leaflabs.com/index.html * Original LeafLabs "Docs:" http://docs.leaflabs.com/docs.leaflabs.com/index.html
**YouTube Videos:** **YouTube Videos:**
* 20141116: [Arduino 1.5.8 IDE with STM32 board](https://www.youtube.com/watch?v=-zwGnytGT8M) * 20141116: [Arduino 1.5.8 IDE with STM32 board](https://www.youtube.com/watch?v=-zwGnytGT8M)
* 20150413: [STM32 for Arduino 1.6.2 or newer (update)](https://www.youtube.com/watch?v=TePglhSkghg) * 20150413: [STM32 for Arduino 1.6.2 or newer (update)](https://www.youtube.com/watch?v=TePglhSkghg)
* 20150419: [Uploading via USB to Serial to STM32F103 boards](https://www.youtube.com/watch?v=G_RF0a0hrak) * 20150419: [Uploading via USB to Serial to STM32F103 boards](https://www.youtube.com/watch?v=G_RF0a0hrak)
##Additional Links & Info: ## Additional Links & Info:
* https://www.hackster.io/rayburne/4-dollar-90-mips-32-bit-72-mhz-arm-arduino * https://www.hackster.io/rayburne/4-dollar-90-mips-32-bit-72-mhz-arm-arduino
##Purchase info:
###Entry level boards
## Purchase info:
### Entry level boards
* [Ebay search for "arduino maple"](http://www.ebay.com/sch/i.html?_from=R40&_sacat=0&LH_BIN=1&_nkw=arduino+maple&_sop=15) (currently costs <$5 with shipping) * [Ebay search for "arduino maple"](http://www.ebay.com/sch/i.html?_from=R40&_sacat=0&LH_BIN=1&_nkw=arduino+maple&_sop=15) (currently costs <$5 with shipping)
* [AliExpress search for "leaflabs maple"] (http://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20150607085526&SearchText=leaflabs+maple) * [AliExpress search for "leaflabs maple"](http://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20150607085526&SearchText=leaflabs+maple)
### Bigger boards (You need to load the stm32duino bootloader) ### Bigger boards (You need to load the stm32duino bootloader)
Some suppliers have this board e.g.
Some supplier have this board e.g. * [ STM32F103VET ](http://www.ebay.com.au/itm/1PCS-STM32F103VET6-ARM-STM32-Minimum-System-Development-Board-Arduino-M77-/301433302819)
* [There is also a STM32F103ZET board which also works, however they are not always available. They have been listed as "STM32F103ZET6 Minimum System Development Board ARM STM32 Cortex-m3 M75"](http://www.ebay.com.au/itm/1pcs-STM32F103ZET6-Minimum-System-Development-Board-ARM-STM32-Cortex-m3-M75-/291305557264)
*[ STM32F103VET ](http://www.ebay.com.au/itm/1PCS-STM32F103VET6-ARM-STM32-Minimum-System-Development-Board-Arduino-M77-/301433302819)
*[There is also a STM32F103ZET board which also works, however they are not always available. They have been listed as "STM32F103ZET6 Minimum System Development Board ARM STM32 Cortex-m3 M75"]
(http://www.ebay.com.au/itm/1pcs-STM32F103ZET6-Minimum-System-Development-Board-ARM-STM32-Cortex-m3-M75-/291305557264)

View File

@ -4,6 +4,7 @@ menu.device_variant=Variant
menu.bootloader_version=Bootloader version menu.bootloader_version=Bootloader version
menu.upload_method=Upload method menu.upload_method=Upload method
menu.cpu_speed=CPU Speed(MHz) menu.cpu_speed=CPU Speed(MHz)
menu.opt=Optimize
############################################################## ##############################################################
mapleMini.name=Maple Mini mapleMini.name=Maple Mini
@ -25,26 +26,56 @@ mapleMini.upload.auto_reset=true
mapleMini.menu.bootloader_version.original = Original (17k RAM,108k Flash) mapleMini.menu.bootloader_version.original = Original (17k RAM,108k Flash)
mapleMini.menu.bootloader_version.original.build.vect=VECT_TAB_ADDR=0x8005000 mapleMini.menu.bootloader_version.original.build.vect=VECT_TAB_ADDR=0x8005000
mapleMini.menu.bootloader_version.original.build.ldscript=ld/flash.ld mapleMini.menu.bootloader_version.original.build.ldscript=ld/flash.ld
mapleMini.menu.bootloader_version.original.upload.ram.maximum_size=17408
mapleMini.menu.bootloader_version.original.upload.flash.maximum_size=110592
mapleMini.menu.bootloader_version.original.upload.maximum_size=110592 mapleMini.menu.bootloader_version.original.upload.maximum_size=110592
mapleMini.menu.bootloader_version.original.upload.maximum_data_size=17408
mapleMini.menu.bootloader_version.original.upload.altID=1 mapleMini.menu.bootloader_version.original.upload.altID=1
mapleMini.menu.bootloader_version.bootloader20 = Bootloader 2.0 (20k RAM,120k Flash) mapleMini.menu.bootloader_version.bootloader20 = Bootloader 2.0 (20k RAM,120k Flash)
mapleMini.menu.bootloader_version.bootloader20.build.vect=VECT_TAB_ADDR=0x8002000 mapleMini.menu.bootloader_version.bootloader20.build.vect=VECT_TAB_ADDR=0x8002000
mapleMini.menu.bootloader_version.bootloader20.build.ldscript=ld/bootloader_20.ld mapleMini.menu.bootloader_version.bootloader20.build.ldscript=ld/bootloader_20.ld
mapleMini.menu.bootloader_version.bootloader20.upload.ram.maximum_size=20480
mapleMini.menu.bootloader_version.bootloader20.upload.flash.maximum_size=122880
mapleMini.menu.bootloader_version.bootloader20.upload.maximum_size=122880 mapleMini.menu.bootloader_version.bootloader20.upload.maximum_size=122880
mapleMini.menu.bootloader_version.bootloader20.upload.maximum_data_size=20480
mapleMini.menu.bootloader_version.bootloader20.upload.altID=2 mapleMini.menu.bootloader_version.bootloader20.upload.altID=2
#-- CPU Clock frequency #-- CPU Clock frequency
mapleMini.menu.cpu_speed.speed_72mhz=72Mhz (Normal) mapleMini.menu.cpu_speed.speed_72mhz=72MHz (Normal)
mapleMini.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L mapleMini.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L
mapleMini.menu.cpu_speed.speed_48mhz=48Mhz (Slow - with USB) mapleMini.menu.cpu_speed.speed_48mhz=48MHz (Slow - with USB)
mapleMini.menu.cpu_speed.speed_48mhz.build.f_cpu=48000000L mapleMini.menu.cpu_speed.speed_48mhz.build.f_cpu=48000000L
mapleMini.menu.cpu_speed.speed_128mhz=Overclocked 128MHz NO USB SERIAL. MANUAL RESET NEEDED TO UPLOAD
mapleMini.menu.cpu_speed.speed_128mhz.build.f_cpu=128000000L
#-- Optimizations
mapleMini.menu.opt.osstd=Smallest (default)
mapleMini.menu.opt.osstd.build.flags.optimize=-Os
mapleMini.menu.opt.osstd.build.flags.ldspecs=
mapleMini.menu.opt.oslto=Smallest Code with LTO
mapleMini.menu.opt.oslto.build.flags.optimize=-Os -flto
mapleMini.menu.opt.oslto.build.flags.ldspecs=-flto
mapleMini.menu.opt.o1std=Fast (-O1)
mapleMini.menu.opt.o1std.build.flags.optimize=-O1
mapleMini.menu.opt.o1std.build.flags.ldspecs=
mapleMini.menu.opt.o1lto=Fast (-O1) with LTO
mapleMini.menu.opt.o1lto.build.flags.optimize=-O1 -flto
mapleMini.menu.opt.o1lto.build.flags.ldspecs=-flto
mapleMini.menu.opt.o2std=Faster (-O2)
mapleMini.menu.opt.o2std.build.flags.optimize=-O2
mapleMini.menu.opt.o2std.build.flags.ldspecs=
mapleMini.menu.opt.o2lto=Faster (-O2) with LTO
mapleMini.menu.opt.o2lto.build.flags.optimize=-O2 -flto
mapleMini.menu.opt.o2lto.build.flags.ldspecs=-flto
mapleMini.menu.opt.o3std=Fastest (-O3)
mapleMini.menu.opt.o3std.build.flags.optimize=-O3
mapleMini.menu.opt.o3std.build.flags.ldspecs=
mapleMini.menu.opt.o3lto=Fastest (-O3) with LTO
mapleMini.menu.opt.o3lto.build.flags.optimize=-O3 -flto
mapleMini.menu.opt.o3lto.build.flags.ldspecs=-flto
mapleMini.menu.opt.ogstd=Debug (-g)
mapleMini.menu.opt.ogstd.build.flags.optimize=-Og
mapleMini.menu.opt.ogstd.build.flags.ldspecs=
############################################################## ##############################################################
maple.name=Maple (Rev 3) maple.name=Maple (Rev 3)
@ -54,10 +85,9 @@ maple.pid.0=0x0004
maple.upload.tool=maple_upload maple.upload.tool=maple_upload
maple.upload.protocol=maple_dfu maple.upload.protocol=maple_dfu
maple.upload.maximum_size=108000 maple.upload.maximum_size=108000
maple.upload.maximum_data_size=17000
maple.upload.use_1200bps_touch=false maple.upload.use_1200bps_touch=false
maple.upload.file_type=bin maple.upload.file_type=bin
maple.upload.ram.maximum_size=17000
maple.upload.flash.maximum_size=108000
maple.upload.usbID=1EAF:0003 maple.upload.usbID=1EAF:0003
maple.upload.altID=1 maple.upload.altID=1
maple.upload.auto_reset=true maple.upload.auto_reset=true
@ -69,6 +99,45 @@ maple.build.ldscript=ld/flash.ld
maple.build.variant=maple maple.build.variant=maple
maple.build.vect=VECT_TAB_ADDR=0x8005000 maple.build.vect=VECT_TAB_ADDR=0x8005000
#-- CPU Clock frequency
maple.menu.cpu_speed.speed_72mhz=72Mhz (Normal)
maple.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L
maple.menu.cpu_speed.speed_48mhz=48Mhz (Slow - with USB)
maple.menu.cpu_speed.speed_48mhz.build.f_cpu=48000000L
maple.menu.cpu_speed.speed_128mhz=Overclocked 128Mhz NO USB SERIAL. MANUAL RESET NEEDED TO UPLOAD
maple.menu.cpu_speed.speed_128mhz.build.f_cpu=128000000L
#-- Optimizations
maple.menu.opt.osstd=Smallest (default)
maple.menu.opt.osstd.build.flags.optimize=-Os
maple.menu.opt.osstd.build.flags.ldspecs=
maple.menu.opt.oslto=Smallest Code with LTO
maple.menu.opt.oslto.build.flags.optimize=-Os -flto
maple.menu.opt.oslto.build.flags.ldspecs=-flto
maple.menu.opt.o1std=Fast (-O1)
maple.menu.opt.o1std.build.flags.optimize=-O1
maple.menu.opt.o1std.build.flags.ldspecs=
maple.menu.opt.o1lto=Fast (-O1) with LTO
maple.menu.opt.o1lto.build.flags.optimize=-O1 -flto
maple.menu.opt.o1lto.build.flags.ldspecs=-flto
maple.menu.opt.o2std=Faster (-O2)
maple.menu.opt.o2std.build.flags.optimize=-O2
maple.menu.opt.o2std.build.flags.ldspecs=
maple.menu.opt.o2lto=Faster (-O2) with LTO
maple.menu.opt.o2lto.build.flags.optimize=-O2 -flto
maple.menu.opt.o2lto.build.flags.ldspecs=-flto
maple.menu.opt.o3std=Fastest (-O3)
maple.menu.opt.o3std.build.flags.optimize=-O3
maple.menu.opt.o3std.build.flags.ldspecs=
maple.menu.opt.o3lto=Fastest (-O3) with LTO
maple.menu.opt.o3lto.build.flags.optimize=-O3 -flto
maple.menu.opt.o3lto.build.flags.ldspecs=-flto
maple.menu.opt.ogstd=Debug (-g)
maple.menu.opt.ogstd.build.flags.optimize=-Og
maple.menu.opt.ogstd.build.flags.ldspecs=
############################################################## ##############################################################
mapleRET6.name=Maple (RET6) mapleRET6.name=Maple (RET6)
@ -85,14 +154,53 @@ mapleRET6.build.vect=VECT_TAB_ADDR=0x8005000
mapleRET6.upload.tool=maple_upload mapleRET6.upload.tool=maple_upload
mapleRET6.upload.protocol=maple_dfu mapleRET6.upload.protocol=maple_dfu
mapleRET6.upload.maximum_size=262144 mapleRET6.upload.maximum_size=262144
mapleRET6.upload.maximum_data_size=49152
mapleRET6.upload.use_1200bps_touch=false mapleRET6.upload.use_1200bps_touch=false
mapleRET6.upload.file_type=bin mapleRET6.upload.file_type=bin
mapleRET6.upload.ram.maximum_size=49152
mapleRET6.upload.flash.maximum_size=262144
mapleRET6.upload.usbID=1EAF:0003 mapleRET6.upload.usbID=1EAF:0003
mapleRET6.upload.altID=1 mapleRET6.upload.altID=1
mapleRET6.upload.auto_reset=true mapleRET6.upload.auto_reset=true
#-- CPU Clock frequency
mapleRET6.menu.cpu_speed.speed_72mhz=72Mhz (Normal)
mapleRET6.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L
mapleRET6.menu.cpu_speed.speed_48mhz=48Mhz (Slow - with USB)
mapleRET6.menu.cpu_speed.speed_48mhz.build.f_cpu=48000000L
mapleRET6.menu.cpu_speed.speed_128mhz=Overclocked 128Mhz NO USB SERIAL. MANUAL RESET NEEDED TO UPLOAD
mapleRET6.menu.cpu_speed.speed_128mhz.build.f_cpu=128000000L
#-- Optimizations
mapleRET6.menu.opt.osstd=Smallest (default)
mapleRET6.menu.opt.osstd.build.flags.optimize=-Os
mapleRET6.menu.opt.osstd.build.flags.ldspecs=
mapleRET6.menu.opt.oslto=Smallest Code with LTO
mapleRET6.menu.opt.oslto.build.flags.optimize=-Os -flto
mapleRET6.menu.opt.oslto.build.flags.ldspecs=-flto
mapleRET6.menu.opt.o1std=Fast (-O1)
mapleRET6.menu.opt.o1std.build.flags.optimize=-O1
mapleRET6.menu.opt.o1std.build.flags.ldspecs=
mapleRET6.menu.opt.o1lto=Fast (-O1) with LTO
mapleRET6.menu.opt.o1lto.build.flags.optimize=-O1 -flto
mapleRET6.menu.opt.o1lto.build.flags.ldspecs=-flto
mapleRET6.menu.opt.o2std=Faster (-O2)
mapleRET6.menu.opt.o2std.build.flags.optimize=-O2
mapleRET6.menu.opt.o2std.build.flags.ldspecs=
mapleRET6.menu.opt.o2lto=Faster (-O2) with LTO
mapleRET6.menu.opt.o2lto.build.flags.optimize=-O2 -flto
mapleRET6.menu.opt.o2lto.build.flags.ldspecs=-flto
mapleRET6.menu.opt.o3std=Fastest (-O3)
mapleRET6.menu.opt.o3std.build.flags.optimize=-O3
mapleRET6.menu.opt.o3std.build.flags.ldspecs=
mapleRET6.menu.opt.o3lto=Fastest (-O3) with LTO
mapleRET6.menu.opt.o3lto.build.flags.optimize=-O3 -flto
mapleRET6.menu.opt.ogstd=Debug (-g)
mapleRET6.menu.opt.o3lto.build.flags.ldspecs=-flto
mapleRET6.menu.opt.ogstd.build.flags.optimize=-Og
mapleRET6.menu.opt.ogstd.build.flags.ldspecs=
############################################################## ##############################################################
microduino32_flash.name=Microduino Core STM32 to Flash microduino32_flash.name=Microduino Core STM32 to Flash
@ -102,10 +210,9 @@ microduino32_flash.pid.0=0x0004
microduino32_flash.upload.tool=maple_upload microduino32_flash.upload.tool=maple_upload
microduino32_flash.upload.protocol=maple_dfu microduino32_flash.upload.protocol=maple_dfu
microduino32_flash.upload.maximum_size=108000 microduino32_flash.upload.maximum_size=108000
microduino32_flash.upload.maximum_data_size=17000
microduino32_flash.upload.use_1200bps_touch=false microduino32_flash.upload.use_1200bps_touch=false
microduino32_flash.upload.file_type=bin microduino32_flash.upload.file_type=bin
microduino32_flash.upload.ram.maximum_size=17000
microduino32_flash.upload.flash.maximum_size=108000
microduino32_flash.upload.usbID=1EAF:0003 microduino32_flash.upload.usbID=1EAF:0003
microduino32_flash.upload.altID=1 microduino32_flash.upload.altID=1
microduino32_flash.upload.auto_reset=true microduino32_flash.upload.auto_reset=true
@ -125,16 +232,54 @@ microduino32_flash.build.error_led_port=GPIOB
microduino32_flash.build.error_led_pin=1 microduino32_flash.build.error_led_pin=1
microduino32_flash.build.gcc_ver=gcc-arm-none-eabi-4.8.3-2014q1 microduino32_flash.build.gcc_ver=gcc-arm-none-eabi-4.8.3-2014q1
#-- CPU Clock frequency
microduino32_flash.menu.cpu_speed.speed_72mhz=72Mhz (Normal)
microduino32_flash.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L
microduino32_flash.menu.cpu_speed.speed_48mhz=48Mhz (Slow - with USB)
microduino32_flash.menu.cpu_speed.speed_48mhz.build.f_cpu=48000000L
microduino32_flash.menu.cpu_speed.speed_128mhz=Overclocked 128Mhz NO USB SERIAL. MANUAL RESET NEEDED TO UPLOAD
microduino32_flash.menu.cpu_speed.speed_128mhz.build.f_cpu=128000000L
#-- Optimizations
microduino32_flash.menu.opt.osstd=Smallest (default)
microduino32_flash.menu.opt.osstd.build.flags.optimize=-Os
microduino32_flash.menu.opt.osstd.build.flags.ldspecs=
microduino32_flash.menu.opt.oslto=Smallest Code with LTO
microduino32_flash.menu.opt.oslto.build.flags.optimize=-Os -flto
microduino32_flash.menu.opt.oslto.build.flags.ldspecs=-flto
microduino32_flash.menu.opt.o1std=Fast (-O1)
microduino32_flash.menu.opt.o1std.build.flags.optimize=-O1
microduino32_flash.menu.opt.o1std.build.flags.ldspecs=
microduino32_flash.menu.opt.o1lto=Fast (-O1) with LTO
microduino32_flash.menu.opt.o1lto.build.flags.optimize=-O1 -flto
microduino32_flash.menu.opt.o1lto.build.flags.ldspecs=-flto
microduino32_flash.menu.opt.o2std=Faster (-O2)
microduino32_flash.menu.opt.o2std.build.flags.optimize=-O2
microduino32_flash.menu.opt.o2std.build.flags.ldspecs=
microduino32_flash.menu.opt.o2lto=Faster (-O2) with LTO
microduino32_flash.menu.opt.o2lto.build.flags.optimize=-O2 -flto
microduino32_flash.menu.opt.o2lto.build.flags.ldspecs=-flto
microduino32_flash.menu.opt.o3std=Fastest (-O3)
microduino32_flash.menu.opt.o3std.build.flags.optimize=-O3
microduino32_flash.menu.opt.o3std.build.flags.ldspecs=
microduino32_flash.menu.opt.o3lto=Fastest (-O3) with LTO
microduino32_flash.menu.opt.o3lto.build.flags.optimize=-O3 -flto
microduino32_flash.menu.opt.ogstd=Debug (-g)
microduino32_flash.menu.opt.o3lto.build.flags.ldspecs=-flto
microduino32_flash.menu.opt.ogstd.build.flags.optimize=-Og
microduino32_flash.menu.opt.ogstd.build.flags.ldspecs=
############################################################## ##############################################################
nucleo_f103rb.name=STM Nucleo F103RB (STLink) nucleo_f103rb.name=STM Nucleo F103RB (STLink)
nucleo_f103rb.upload.tool=stlink_upload nucleo_f103rb.upload.tool=stlink_upload
nucleo_f103rb.upload.protocol=maple_dfu nucleo_f103rb.upload.protocol=maple_dfu
nucleo_f103rb.upload.maximum_size=108000 nucleo_f103rb.upload.maximum_size=108000
nucleo_f103rb.upload.maximum_data_size=17000
nucleo_f103rb.upload.use_1200bps_touch=false nucleo_f103rb.upload.use_1200bps_touch=false
nucleo_f103rb.upload.file_type=bin nucleo_f103rb.upload.file_type=bin
nucleo_f103rb.upload.ram.maximum_size=17000
nucleo_f103rb.upload.flash.maximum_size=108000
nucleo_f103rb.upload.params.quiet=no nucleo_f103rb.upload.params.quiet=no
nucleo_f103rb.upload.usbID=1EAF:0003 nucleo_f103rb.upload.usbID=1EAF:0003
@ -147,7 +292,6 @@ nucleo_f103rb.build.core=maple
nucleo_f103rb.build.ldscript=ld/jtag.ld nucleo_f103rb.build.ldscript=ld/jtag.ld
nucleo_f103rb.build.variant=nucleo_f103rb nucleo_f103rb.build.variant=nucleo_f103rb
nucleo_f103rb.build.variant_system_lib=libmaple.a nucleo_f103rb.build.variant_system_lib=libmaple.a
nucleo_f103rb.build.vect=VECT_TAB_FLASH
nucleo_f103rb.build.density=STM32_MEDIUM_DENSITY nucleo_f103rb.build.density=STM32_MEDIUM_DENSITY
nucleo_f103rb.build.error_led_port=GPIOB nucleo_f103rb.build.error_led_port=GPIOB
nucleo_f103rb.build.error_led_pin=1 nucleo_f103rb.build.error_led_pin=1
@ -164,6 +308,35 @@ nucleo_f103rb.menu.device_variant.NucleoF103_HSE=Nucleo F103 @ 72 MHz w/ crystal
nucleo_f103rb.menu.device_variant.NucleoF103_HSE.build.f_cpu=72000000L nucleo_f103rb.menu.device_variant.NucleoF103_HSE.build.f_cpu=72000000L
nucleo_f103rb.menu.device_variant.NucleoF103_HSE.build.extra_flags=-DNUCLEO_HSE_CRYSTAL -DMCU_STM32F103RB -mthumb -march=armv7-m -D__STM32F1__ nucleo_f103rb.menu.device_variant.NucleoF103_HSE.build.extra_flags=-DNUCLEO_HSE_CRYSTAL -DMCU_STM32F103RB -mthumb -march=armv7-m -D__STM32F1__
#-- Optimizations
nucleo_f103rb.menu.opt.osstd=Smallest (default)
nucleo_f103rb.menu.opt.osstd.build.flags.optimize=-Os
nucleo_f103rb.menu.opt.osstd.build.flags.ldspecs=
nucleo_f103rb.menu.opt.oslto=Smallest Code with LTO
nucleo_f103rb.menu.opt.oslto.build.flags.optimize=-Os -flto
nucleo_f103rb.menu.opt.oslto.build.flags.ldspecs=-flto
nucleo_f103rb.menu.opt.o1std=Fast (-O1)
nucleo_f103rb.menu.opt.o1std.build.flags.optimize=-O1
nucleo_f103rb.menu.opt.o1std.build.flags.ldspecs=
nucleo_f103rb.menu.opt.o1lto=Fast (-O1) with LTO
nucleo_f103rb.menu.opt.o1lto.build.flags.optimize=-O1 -flto
nucleo_f103rb.menu.opt.o1lto.build.flags.ldspecs=-flto
nucleo_f103rb.menu.opt.o2std=Faster (-O2)
nucleo_f103rb.menu.opt.o2std.build.flags.optimize=-O2
nucleo_f103rb.menu.opt.o2std.build.flags.ldspecs=
nucleo_f103rb.menu.opt.o2lto=Faster (-O2) with LTO
nucleo_f103rb.menu.opt.o2lto.build.flags.optimize=-O2 -flto
nucleo_f103rb.menu.opt.o2lto.build.flags.ldspecs=-flto
nucleo_f103rb.menu.opt.o3std=Fastest (-O3)
nucleo_f103rb.menu.opt.o3std.build.flags.optimize=-O3
nucleo_f103rb.menu.opt.o3std.build.flags.ldspecs=
nucleo_f103rb.menu.opt.o3lto=Fastest (-O3) with LTO
nucleo_f103rb.menu.opt.o3lto.build.flags.optimize=-O3 -flto
nucleo_f103rb.menu.opt.ogstd=Debug (-g)
nucleo_f103rb.menu.opt.o3lto.build.flags.ldspecs=-flto
nucleo_f103rb.menu.opt.ogstd.build.flags.optimize=-Og
nucleo_f103rb.menu.opt.ogstd.build.flags.ldspecs=
###################### Generic STM32F103C ######################################## ###################### Generic STM32F103C ########################################
genericSTM32F103C.name=Generic STM32F103C series genericSTM32F103C.name=Generic STM32F103C series
@ -173,32 +346,34 @@ genericSTM32F103C.build.variant=generic_stm32f103c
genericSTM32F103C.build.vect=VECT_TAB_ADDR=0x8000000 genericSTM32F103C.build.vect=VECT_TAB_ADDR=0x8000000
genericSTM32F103C.build.core=maple genericSTM32F103C.build.core=maple
genericSTM32F103C.build.board=GENERIC_STM32F103C genericSTM32F103C.build.board=GENERIC_STM32F103C
genericSTM32F103C.build.error_led_port=GPIOC
genericSTM32F103C.build.error_led_pin=13
genericSTM32F103C.upload.use_1200bps_touch=false genericSTM32F103C.upload.use_1200bps_touch=false
genericSTM32F103C.upload.file_type=bin genericSTM32F103C.upload.file_type=bin
genericSTM32F103C.upload.auto_reset=true genericSTM32F103C.upload.auto_reset=true
genericSTM32F103C.upload.tool=maple_upload
genericSTM32F103C.upload.protocol=maple_dfu
## STM32F103C8 ------------------------- ## STM32F103C8 -------------------------
genericSTM32F103C.menu.device_variant.STM32F103C8=STM32F103C8 (20k RAM. 64k Flash) genericSTM32F103C.menu.device_variant.STM32F103C8=STM32F103C8 (20k RAM. 64k Flash)
genericSTM32F103C.menu.device_variant.STM32F103C8.build.cpu_flags=-DMCU_STM32F103C8 genericSTM32F103C.menu.device_variant.STM32F103C8.build.cpu_flags=-DMCU_STM32F103C8
genericSTM32F103C.menu.device_variant.STM32F103C8.build.ldscript=ld/jtag_c8.ld genericSTM32F103C.menu.device_variant.STM32F103C8.build.ldscript=ld/jtag_c8.ld
genericSTM32F103C.menu.device_variant.STM32F103C8.upload.maximum_size=65536 genericSTM32F103C.menu.device_variant.STM32F103C8.upload.maximum_size=65536
genericSTM32F103C.menu.device_variant.STM32F103C8.upload.ram.maximum_size=20480 genericSTM32F103C.menu.device_variant.STM32F103C8.upload.maximum_data_size=20480
genericSTM32F103C.menu.device_variant.STM32F103C8.upload.flash.maximum_size=65536
## STM32F103CB ------------------------- ## STM32F103CB -------------------------
genericSTM32F103C.menu.device_variant.STM32F103CB=STM32F103CB (20k RAM. 128k Flash) genericSTM32F103C.menu.device_variant.STM32F103CB=STM32F103CB (20k RAM. 128k Flash)
genericSTM32F103C.menu.device_variant.STM32F103CB.build.cpu_flags=-DMCU_STM32F103CB genericSTM32F103C.menu.device_variant.STM32F103CB.build.cpu_flags=-DMCU_STM32F103CB
genericSTM32F103C.menu.device_variant.STM32F103CB.build.ldscript=ld/jtag.ld genericSTM32F103C.menu.device_variant.STM32F103CB.build.ldscript=ld/jtag.ld
genericSTM32F103C.menu.device_variant.STM32F103CB.upload.maximum_size=131072 genericSTM32F103C.menu.device_variant.STM32F103CB.upload.maximum_size=131072
genericSTM32F103C.menu.device_variant.STM32F103CB.upload.ram.maximum_size=20480 genericSTM32F103C.menu.device_variant.STM32F103CB.upload.maximum_data_size=20480
genericSTM32F103C.menu.device_variant.STM32F103CB.upload.flash.maximum_size=131072
#---------------------------- UPLOAD METHODS --------------------------- #---------------------------- UPLOAD METHODS ---------------------------
genericSTM32F103C.menu.upload_method.DFUUploadMethod=STM32duino bootloader genericSTM32F103C.menu.upload_method.DFUUploadMethod=STM32duino bootloader
genericSTM32F103C.menu.upload_method.DFUUploadMethod.upload.protocol=maple_dfu genericSTM32F103C.menu.upload_method.DFUUploadMethod.upload.protocol=maple_dfu
genericSTM32F103C.menu.upload_method.DFUUploadMethod.upload.tool=maple_upload genericSTM32F103C.menu.upload_method.DFUUploadMethod.upload.tool=maple_upload
genericSTM32F103C.menu.upload_method.DFUUploadMethod.build.upload_flags=-DSERIAL_USB -DGENERIC_BOOTLOADER -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 genericSTM32F103C.menu.upload_method.DFUUploadMethod.build.upload_flags=-DSERIAL_USB -DGENERIC_BOOTLOADER
genericSTM32F103C.menu.upload_method.DFUUploadMethod.build.vect=VECT_TAB_ADDR=0x8002000 genericSTM32F103C.menu.upload_method.DFUUploadMethod.build.vect=VECT_TAB_ADDR=0x8002000
genericSTM32F103C.menu.upload_method.DFUUploadMethod.build.ldscript=ld/bootloader_20.ld genericSTM32F103C.menu.upload_method.DFUUploadMethod.build.ldscript=ld/bootloader_20.ld
genericSTM32F103C.menu.upload_method.DFUUploadMethod.upload.usbID=1EAF:0003 genericSTM32F103C.menu.upload_method.DFUUploadMethod.upload.usbID=1EAF:0003
@ -219,7 +394,6 @@ genericSTM32F103C.menu.upload_method.BMPMethod.upload.protocol=gdb_bmp
genericSTM32F103C.menu.upload_method.BMPMethod.upload.tool=bmp_upload genericSTM32F103C.menu.upload_method.BMPMethod.upload.tool=bmp_upload
genericSTM32F103C.menu.upload_method.BMPMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG genericSTM32F103C.menu.upload_method.BMPMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG
genericSTM32F103C.menu.upload_method.jlinkMethod=JLink genericSTM32F103C.menu.upload_method.jlinkMethod=JLink
genericSTM32F103C.menu.upload_method.jlinkMethod.upload.protocol=jlink genericSTM32F103C.menu.upload_method.jlinkMethod.upload.protocol=jlink
genericSTM32F103C.menu.upload_method.jlinkMethod.upload.tool=jlink_upload genericSTM32F103C.menu.upload_method.jlinkMethod.upload.tool=jlink_upload
@ -232,6 +406,38 @@ genericSTM32F103C.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L
genericSTM32F103C.menu.cpu_speed.speed_48mhz=48Mhz (Slow - with USB) genericSTM32F103C.menu.cpu_speed.speed_48mhz=48Mhz (Slow - with USB)
genericSTM32F103C.menu.cpu_speed.speed_48mhz.build.f_cpu=48000000L genericSTM32F103C.menu.cpu_speed.speed_48mhz.build.f_cpu=48000000L
genericSTM32F103C.menu.cpu_speed.speed_128mhz=Overclocked 128Mhz NO USB SERIAL. MANUAL RESET NEEDED TO UPLOAD
genericSTM32F103C.menu.cpu_speed.speed_128mhz.build.f_cpu=128000000L
#-- Optimizations
genericSTM32F103C.menu.opt.osstd=Smallest (default)
genericSTM32F103C.menu.opt.osstd.build.flags.optimize=-Os
genericSTM32F103C.menu.opt.osstd.build.flags.ldspecs=
genericSTM32F103C.menu.opt.oslto=Smallest Code with LTO
genericSTM32F103C.menu.opt.oslto.build.flags.optimize=-Os -flto
genericSTM32F103C.menu.opt.oslto.build.flags.ldspecs=-flto
genericSTM32F103C.menu.opt.o1std=Fast (-O1)
genericSTM32F103C.menu.opt.o1std.build.flags.optimize=-O1
genericSTM32F103C.menu.opt.o1std.build.flags.ldspecs=
genericSTM32F103C.menu.opt.o1lto=Fast (-O1) with LTO
genericSTM32F103C.menu.opt.o1lto.build.flags.optimize=-O1 -flto
genericSTM32F103C.menu.opt.o1lto.build.flags.ldspecs=-flto
genericSTM32F103C.menu.opt.o2std=Faster (-O2)
genericSTM32F103C.menu.opt.o2std.build.flags.optimize=-O2
genericSTM32F103C.menu.opt.o2std.build.flags.ldspecs=
genericSTM32F103C.menu.opt.o2lto=Faster (-O2) with LTO
genericSTM32F103C.menu.opt.o2lto.build.flags.optimize=-O2 -flto
genericSTM32F103C.menu.opt.o2lto.build.flags.ldspecs=-flto
genericSTM32F103C.menu.opt.o3std=Fastest (-O3)
genericSTM32F103C.menu.opt.o3std.build.flags.optimize=-O3
genericSTM32F103C.menu.opt.o3std.build.flags.ldspecs=
genericSTM32F103C.menu.opt.o3lto=Fastest (-O3) with LTO
genericSTM32F103C.menu.opt.o3lto.build.flags.optimize=-O3 -flto
genericSTM32F103C.menu.opt.ogstd=Debug (-g)
genericSTM32F103C.menu.opt.o3lto.build.flags.ldspecs=-flto
genericSTM32F103C.menu.opt.ogstd.build.flags.optimize=-Og
genericSTM32F103C.menu.opt.ogstd.build.flags.ldspecs=
########################### Generic STM32F103R ########################### ########################### Generic STM32F103R ###########################
genericSTM32F103R.name=Generic STM32F103R series genericSTM32F103R.name=Generic STM32F103R series
@ -244,27 +450,28 @@ genericSTM32F103R.build.board=GENERIC_STM32F103R
genericSTM32F103R.upload.use_1200bps_touch=false genericSTM32F103R.upload.use_1200bps_touch=false
genericSTM32F103R.upload.file_type=bin genericSTM32F103R.upload.file_type=bin
genericSTM32F103R.upload.auto_reset=true genericSTM32F103R.upload.auto_reset=true
genericSTM32F103R.upload.tool=maple_upload
genericSTM32F103R.upload.protocol=maple_dfu
genericSTM32F103R.menu.device_variant.STM32F103R8=STM32F103R8 (20k RAM. 64k Flash) genericSTM32F103R.menu.device_variant.STM32F103R8=STM32F103R8 (20k RAM. 64k Flash)
genericSTM32F103R.menu.device_variant.STM32F103R8.build.variant=generic_stm32f103r8 genericSTM32F103R.menu.device_variant.STM32F103R8.build.variant=generic_stm32f103r8
genericSTM32F103R.menu.device_variant.STM32F103R8.build.cpu_flags=-DMCU_STM32F103R8 genericSTM32F103R.menu.device_variant.STM32F103R8.build.cpu_flags=-DMCU_STM32F103R8
genericSTM32F103R.menu.device_variant.STM32F103R8.upload.maximum_size=65536 genericSTM32F103R.menu.device_variant.STM32F103R8.upload.maximum_size=65536
genericSTM32F103R.menu.device_variant.STM32F103R8.upload.ram.maximum_size=20480 genericSTM32F103R.menu.device_variant.STM32F103R8.upload.maximum_data_size=20480
genericSTM32F103R.menu.device_variant.STM32F103R8.upload.flash.maximum_size=65536
genericSTM32F103R.menu.device_variant.STM32F103R8.build.ldscript=ld/stm32f103r8.ld genericSTM32F103R.menu.device_variant.STM32F103R8.build.ldscript=ld/stm32f103r8.ld
genericSTM32F103R.menu.device_variant.STM32F103RB=STM32F103RB (20k RAM. 128k Flash) genericSTM32F103R.menu.device_variant.STM32F103RB=STM32F103RB (20k RAM. 128k Flash)
genericSTM32F103R.menu.device_variant.STM32F103RB.build.variant=generic_stm32f103r8 genericSTM32F103R.menu.device_variant.STM32F103RB.build.variant=generic_stm32f103r8
genericSTM32F103R.menu.device_variant.STM32F103RB.build.cpu_flags=-DMCU_STM32F103RB genericSTM32F103R.menu.device_variant.STM32F103RB.build.cpu_flags=-DMCU_STM32F103RB
genericSTM32F103R.menu.device_variant.STM32F103RB.upload.maximum_size=131072 genericSTM32F103R.menu.device_variant.STM32F103RB.upload.maximum_size=131072
genericSTM32F103R.menu.device_variant.STM32F103RB.upload.ram.maximum_size=20480 genericSTM32F103R.menu.device_variant.STM32F103RB.upload.maximum_data_size=20480
genericSTM32F103R.menu.device_variant.STM32F103RB.upload.flash.maximum_size=131072
genericSTM32F103R.menu.device_variant.STM32F103RB.build.ldscript=ld/stm32f103rb.ld genericSTM32F103R.menu.device_variant.STM32F103RB.build.ldscript=ld/stm32f103rb.ld
genericSTM32F103R.menu.device_variant.STM32F103RC=STM32F103RC (48k RAM. 256k Flash) genericSTM32F103R.menu.device_variant.STM32F103RC=STM32F103RC (48k RAM. 256k Flash)
genericSTM32F103R.menu.device_variant.STM32F103RC.build.variant=generic_stm32f103r genericSTM32F103R.menu.device_variant.STM32F103RC.build.variant=generic_stm32f103r
genericSTM32F103R.menu.device_variant.STM32F103RC.build.cpu_flags=-DMCU_STM32F103RC genericSTM32F103R.menu.device_variant.STM32F103RC.build.cpu_flags=-DMCU_STM32F103RC
genericSTM32F103R.menu.device_variant.STM32F103RC.upload.maximum_size=262144 genericSTM32F103R.menu.device_variant.STM32F103RC.upload.maximum_size=262144
genericSTM32F103R.menu.device_variant.STM32F103RC.upload.maximum_data_size=49152
genericSTM32F103R.menu.device_variant.STM32F103RC.upload.ram.maximum_size=49152 genericSTM32F103R.menu.device_variant.STM32F103RC.upload.ram.maximum_size=49152
genericSTM32F103R.menu.device_variant.STM32F103RC.upload.flash.maximum_size=262144 genericSTM32F103R.menu.device_variant.STM32F103RC.upload.flash.maximum_size=262144
genericSTM32F103R.menu.device_variant.STM32F103RC.build.ldscript=ld/stm32f103rc.ld genericSTM32F103R.menu.device_variant.STM32F103RC.build.ldscript=ld/stm32f103rc.ld
@ -273,8 +480,7 @@ genericSTM32F103R.menu.device_variant.STM32F103RE=STM32F103RE (64k RAM. 512k Fla
genericSTM32F103R.menu.device_variant.STM32F103RE.build.variant=generic_stm32f103r genericSTM32F103R.menu.device_variant.STM32F103RE.build.variant=generic_stm32f103r
genericSTM32F103R.menu.device_variant.STM32F103RE.build.cpu_flags=-DMCU_STM32F103RE genericSTM32F103R.menu.device_variant.STM32F103RE.build.cpu_flags=-DMCU_STM32F103RE
genericSTM32F103R.menu.device_variant.STM32F103RE.upload.maximum_size=524288 genericSTM32F103R.menu.device_variant.STM32F103RE.upload.maximum_size=524288
genericSTM32F103R.menu.device_variant.STM32F103RE.upload.ram.maximum_size=65536 genericSTM32F103R.menu.device_variant.STM32F103RE.upload.maximum_data_size=65536
genericSTM32F103R.menu.device_variant.STM32F103RE.upload.flash.maximum_size=524288
genericSTM32F103R.menu.device_variant.STM32F103RE.build.ldscript=ld/stm32f103re.ld genericSTM32F103R.menu.device_variant.STM32F103RE.build.ldscript=ld/stm32f103re.ld
#---------------------------- UPLOAD METHODS --------------------------- #---------------------------- UPLOAD METHODS ---------------------------
@ -282,7 +488,7 @@ genericSTM32F103R.menu.device_variant.STM32F103RE.build.ldscript=ld/stm32f103re.
genericSTM32F103R.menu.upload_method.DFUUploadMethod=STM32duino bootloader genericSTM32F103R.menu.upload_method.DFUUploadMethod=STM32duino bootloader
genericSTM32F103R.menu.upload_method.DFUUploadMethod.upload.protocol=maple_dfu genericSTM32F103R.menu.upload_method.DFUUploadMethod.upload.protocol=maple_dfu
genericSTM32F103R.menu.upload_method.DFUUploadMethod.upload.tool=maple_upload genericSTM32F103R.menu.upload_method.DFUUploadMethod.upload.tool=maple_upload
genericSTM32F103R.menu.upload_method.DFUUploadMethod.build.upload_flags=-DSERIAL_USB -DGENERIC_BOOTLOADER -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 genericSTM32F103R.menu.upload_method.DFUUploadMethod.build.upload_flags=-DSERIAL_USB -DGENERIC_BOOTLOADER
genericSTM32F103R.menu.upload_method.DFUUploadMethod.build.vect=VECT_TAB_ADDR=0x8002000 genericSTM32F103R.menu.upload_method.DFUUploadMethod.build.vect=VECT_TAB_ADDR=0x8002000
genericSTM32F103R.menu.upload_method.DFUUploadMethod.build.ldscript=ld/bootloader.ld genericSTM32F103R.menu.upload_method.DFUUploadMethod.build.ldscript=ld/bootloader.ld
genericSTM32F103R.menu.upload_method.DFUUploadMethod.upload.usbID=1EAF:0003 genericSTM32F103R.menu.upload_method.DFUUploadMethod.upload.usbID=1EAF:0003
@ -303,6 +509,46 @@ genericSTM32F103R.menu.upload_method.BMPMethod.upload.protocol=gdb_bmp
genericSTM32F103R.menu.upload_method.BMPMethod.upload.tool=bmp_upload genericSTM32F103R.menu.upload_method.BMPMethod.upload.tool=bmp_upload
genericSTM32F103R.menu.upload_method.BMPMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG genericSTM32F103R.menu.upload_method.BMPMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG
#-- CPU Clock frequency
genericSTM32F103R.menu.cpu_speed.speed_72mhz=72Mhz (Normal)
genericSTM32F103R.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L
genericSTM32F103R.menu.cpu_speed.speed_48mhz=48Mhz (Slow - with USB)
genericSTM32F103R.menu.cpu_speed.speed_48mhz.build.f_cpu=48000000L
genericSTM32F103R.menu.cpu_speed.speed_128mhz=Overclocked 128Mhz NO USB SERIAL. MANUAL RESET NEEDED TO UPLOAD
genericSTM32F103R.menu.cpu_speed.speed_128mhz.build.f_cpu=128000000L
#-- Optimizations
genericSTM32F103R.menu.opt.osstd=Smallest (default)
genericSTM32F103R.menu.opt.osstd.build.flags.optimize=-Os
genericSTM32F103R.menu.opt.osstd.build.flags.ldspecs=
genericSTM32F103R.menu.opt.oslto=Smallest Code with LTO
genericSTM32F103R.menu.opt.oslto.build.flags.optimize=-Os -flto
genericSTM32F103R.menu.opt.oslto.build.flags.ldspecs=-flto
genericSTM32F103R.menu.opt.o1std=Fast (-O1)
genericSTM32F103R.menu.opt.o1std.build.flags.optimize=-O1
genericSTM32F103R.menu.opt.o1std.build.flags.ldspecs=
genericSTM32F103R.menu.opt.o1lto=Fast (-O1) with LTO
genericSTM32F103R.menu.opt.o1lto.build.flags.optimize=-O1 -flto
genericSTM32F103R.menu.opt.o1lto.build.flags.ldspecs=-flto
genericSTM32F103R.menu.opt.o2std=Faster (-O2)
genericSTM32F103R.menu.opt.o2std.build.flags.optimize=-O2
genericSTM32F103R.menu.opt.o2std.build.flags.ldspecs=
genericSTM32F103R.menu.opt.o2lto=Faster (-O2) with LTO
genericSTM32F103R.menu.opt.o2lto.build.flags.optimize=-O2 -flto
genericSTM32F103R.menu.opt.o2lto.build.flags.ldspecs=-flto
genericSTM32F103R.menu.opt.o3std=Fastest (-O3)
genericSTM32F103R.menu.opt.o3std.build.flags.optimize=-O3
genericSTM32F103R.menu.opt.o3std.build.flags.ldspecs=
genericSTM32F103R.menu.opt.o3lto=Fastest (-O3) with LTO
genericSTM32F103R.menu.opt.o3lto.build.flags.optimize=-O3 -flto
genericSTM32F103R.menu.opt.ogstd=Debug (-g)
genericSTM32F103R.menu.opt.o3lto.build.flags.ldspecs=-flto
genericSTM32F103R.menu.opt.ogstd.build.flags.optimize=-Og
genericSTM32F103R.menu.opt.ogstd.build.flags.ldspecs=
###################### Generic STM32F103T ######################################## ###################### Generic STM32F103T ########################################
genericSTM32F103T.name=Generic STM32F103T series genericSTM32F103T.name=Generic STM32F103T series
@ -315,29 +561,29 @@ genericSTM32F103T.build.board=GENERIC_STM32F103T
genericSTM32F103T.upload.use_1200bps_touch=false genericSTM32F103T.upload.use_1200bps_touch=false
genericSTM32F103T.upload.file_type=bin genericSTM32F103T.upload.file_type=bin
genericSTM32F103T.upload.auto_reset=true genericSTM32F103T.upload.auto_reset=true
genericSTM32F103T.upload.tool=maple_upload
genericSTM32F103T.upload.protocol=maple_dfu
## STM32F103T8 ------------------------- ## STM32F103T8 -------------------------
genericSTM32F103T.menu.device_variant.STM32F103T8=STM32F103T8 (20k RAM. 64k Flash) genericSTM32F103T.menu.device_variant.STM32F103T8=STM32F103T8 (20k RAM. 64k Flash)
genericSTM32F103T.menu.device_variant.STM32F103T8.build.cpu_flags=-DMCU_STM32F103T8 genericSTM32F103T.menu.device_variant.STM32F103T8.build.cpu_flags=-DMCU_STM32F103T8
genericSTM32F103T.menu.device_variant.STM32F103T8.build.ldscript=ld/jtag_t8.ld genericSTM32F103T.menu.device_variant.STM32F103T8.build.ldscript=ld/jtag_t8.ld
genericSTM32F103T.menu.device_variant.STM32F103T8.upload.maximum_size=65536 genericSTM32F103T.menu.device_variant.STM32F103T8.upload.maximum_size=65536
genericSTM32F103T.menu.device_variant.STM32F103T8.upload.ram.maximum_size=20480 genericSTM32F103T.menu.device_variant.STM32F103T8.upload.maximum_data_size=20480
genericSTM32F103T.menu.device_variant.STM32F103T8.upload.flash.maximum_size=65536
## STM32F103TB ------------------------- ## STM32F103TB -------------------------
genericSTM32F103T.menu.device_variant.STM32F103TB=STM32F103TB (20k RAM. 128k Flash) genericSTM32F103T.menu.device_variant.STM32F103TB=STM32F103TB (20k RAM. 128k Flash)
genericSTM32F103T.menu.device_variant.STM32F103TB.build.cpu_flags=-DMCU_STM32F103TB genericSTM32F103T.menu.device_variant.STM32F103TB.build.cpu_flags=-DMCU_STM32F103TB
genericSTM32F103T.menu.device_variant.STM32F103TB.build.ldscript=ld/jtag.ld genericSTM32F103T.menu.device_variant.STM32F103TB.build.ldscript=ld/jtag.ld
genericSTM32F103T.menu.device_variant.STM32F103TB.upload.maximum_size=131072 genericSTM32F103T.menu.device_variant.STM32F103TB.upload.maximum_size=131072
genericSTM32F103T.menu.device_variant.STM32F103TB.upload.ram.maximum_size=20480 genericSTM32F103T.menu.device_variant.STM32F103TB.upload.maximum_data_size=20480
genericSTM32F103T.menu.device_variant.STM32F103TB.upload.flash.maximum_size=131072
#---------------------------- UPLOAD METHODS --------------------------- #---------------------------- UPLOAD METHODS ---------------------------
genericSTM32F103T.menu.upload_method.DFUUploadMethod=STM32duino bootloader genericSTM32F103T.menu.upload_method.DFUUploadMethod=STM32duino bootloader
genericSTM32F103T.menu.upload_method.DFUUploadMethod.upload.protocol=maple_dfu genericSTM32F103T.menu.upload_method.DFUUploadMethod.upload.protocol=maple_dfu
genericSTM32F103T.menu.upload_method.DFUUploadMethod.upload.tool=maple_upload genericSTM32F103T.menu.upload_method.DFUUploadMethod.upload.tool=maple_upload
genericSTM32F103T.menu.upload_method.DFUUploadMethod.build.upload_flags=-DSERIAL_USB -DGENERIC_BOOTLOADER -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 genericSTM32F103T.menu.upload_method.DFUUploadMethod.build.upload_flags=-DSERIAL_USB -DGENERIC_BOOTLOADER
genericSTM32F103T.menu.upload_method.DFUUploadMethod.build.vect=VECT_TAB_ADDR=0x8002000 genericSTM32F103T.menu.upload_method.DFUUploadMethod.build.vect=VECT_TAB_ADDR=0x8002000
genericSTM32F103T.menu.upload_method.DFUUploadMethod.build.ldscript=ld/bootloader_20.ld genericSTM32F103T.menu.upload_method.DFUUploadMethod.build.ldscript=ld/bootloader_20.ld
genericSTM32F103T.menu.upload_method.DFUUploadMethod.upload.usbID=1EAF:0003 genericSTM32F103T.menu.upload_method.DFUUploadMethod.upload.usbID=1EAF:0003
@ -358,41 +604,89 @@ genericSTM32F103T.menu.upload_method.BMPMethod.upload.protocol=gdb_bmp
genericSTM32F103T.menu.upload_method.BMPMethod.upload.tool=bmp_upload genericSTM32F103T.menu.upload_method.BMPMethod.upload.tool=bmp_upload
genericSTM32F103T.menu.upload_method.BMPMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG genericSTM32F103T.menu.upload_method.BMPMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG
#-- CPU Clock frequency
genericSTM32F103T.menu.cpu_speed.speed_72mhz=72Mhz (Normal)
genericSTM32F103T.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L
genericSTM32F103T.menu.cpu_speed.speed_48mhz=48Mhz (Slow - with USB)
genericSTM32F103T.menu.cpu_speed.speed_48mhz.build.f_cpu=48000000L
genericSTM32F103T.menu.cpu_speed.speed_128mhz=Overclocked 128Mhz NO USB SERIAL. MANUAL RESET NEEDED TO UPLOAD
genericSTM32F103T.menu.cpu_speed.speed_128mhz.build.f_cpu=128000000L
#-- Optimizations
genericSTM32F103T.menu.opt.osstd=Smallest (default)
genericSTM32F103T.menu.opt.osstd.build.flags.optimize=-Os
genericSTM32F103T.menu.opt.osstd.build.flags.ldspecs=
genericSTM32F103T.menu.opt.oslto=Smallest Code with LTO
genericSTM32F103T.menu.opt.oslto.build.flags.optimize=-Os -flto
genericSTM32F103T.menu.opt.oslto.build.flags.ldspecs=-flto
genericSTM32F103T.menu.opt.o1std=Fast (-O1)
genericSTM32F103T.menu.opt.o1std.build.flags.optimize=-O1
genericSTM32F103T.menu.opt.o1std.build.flags.ldspecs=
genericSTM32F103T.menu.opt.o1lto=Fast (-O1) with LTO
genericSTM32F103T.menu.opt.o1lto.build.flags.optimize=-O1 -flto
genericSTM32F103T.menu.opt.o1lto.build.flags.ldspecs=-flto
genericSTM32F103T.menu.opt.o2std=Faster (-O2)
genericSTM32F103T.menu.opt.o2std.build.flags.optimize=-O2
genericSTM32F103T.menu.opt.o2std.build.flags.ldspecs=
genericSTM32F103T.menu.opt.o2lto=Faster (-O2) with LTO
genericSTM32F103T.menu.opt.o2lto.build.flags.optimize=-O2 -flto
genericSTM32F103T.menu.opt.o2lto.build.flags.ldspecs=-flto
genericSTM32F103T.menu.opt.o3std=Fastest (-O3)
genericSTM32F103T.menu.opt.o3std.build.flags.optimize=-O3
genericSTM32F103T.menu.opt.o3std.build.flags.ldspecs=
genericSTM32F103T.menu.opt.o3lto=Fastest (-O3) with LTO
genericSTM32F103T.menu.opt.o3lto.build.flags.optimize=-O3 -flto
genericSTM32F103T.menu.opt.ogstd=Debug (-g)
genericSTM32F103T.menu.opt.o3lto.build.flags.ldspecs=-flto
genericSTM32F103T.menu.opt.ogstd.build.flags.optimize=-Og
genericSTM32F103T.menu.opt.ogstd.build.flags.ldspecs=
########################### Generic STM32F103V ########################### ########################### Generic STM32F103V ###########################
genericSTM32F103V.name=Generic STM32F103V series genericSTM32F103V.name=Generic STM32F103V series
genericSTM32F103V.vid.0=0x1EAF genericSTM32F103V.vid.0=0x1EAF
genericSTM32F103V.pid.0=0x0004 genericSTM32F103V.pid.0=0x0004
genericSTM32F103V.build.variant=generic_stm32f103v #genericSTM32F103V.build.variant=generic_stm32f103v
genericSTM32F103V.build.vect=VECT_TAB_ADDR=0x8000000 genericSTM32F103V.build.vect=VECT_TAB_ADDR=0x8000000
genericSTM32F103V.build.core=maple genericSTM32F103V.build.core=maple
genericSTM32F103V.build.board=GENERIC_STM32F103V genericSTM32F103V.build.board=GENERIC_STM32F103V
genericSTM32F103V.upload.use_1200bps_touch=false genericSTM32F103V.upload.use_1200bps_touch=false
genericSTM32F103V.upload.file_type=bin genericSTM32F103V.upload.file_type=bin
genericSTM32F103V.upload.auto_reset=true genericSTM32F103V.upload.auto_reset=true
genericSTM32F103V.upload.tool=maple_upload
genericSTM32F103V.upload.protocol=maple_dfu
genericSTM32F103V.build.error_led_port=GPIOE genericSTM32F103V.build.error_led_port=GPIOE
genericSTM32F103V.build.error_led_pin=6 genericSTM32F103V.build.error_led_pin=6
genericSTM32F103V.menu.device_variant.STM32F103VB=STM32F103VB
genericSTM32F103V.menu.device_variant.STM32F103VB.build.variant=generic_stm32f103vb
genericSTM32F103V.menu.device_variant.STM32F103VB.build.cpu_flags=-DMCU_STM32F103VB
genericSTM32F103V.menu.device_variant.STM32F103VB.upload.maximum_size=131072
genericSTM32F103V.menu.device_variant.STM32F103VB.upload.maximum_data_size=20480
genericSTM32F103V.menu.device_variant.STM32F103VB.build.ldscript=ld/stm32f103vb.ld
genericSTM32F103V.menu.device_variant.STM32F103VC=STM32F103VC genericSTM32F103V.menu.device_variant.STM32F103VC=STM32F103VC
genericSTM32F103V.menu.device_variant.STM32F103VC.build.variant=generic_stm32f103v
genericSTM32F103V.menu.device_variant.STM32F103VC.build.cpu_flags=-DMCU_STM32F103VC genericSTM32F103V.menu.device_variant.STM32F103VC.build.cpu_flags=-DMCU_STM32F103VC
genericSTM32F103V.menu.device_variant.STM32F103VC.upload.maximum_size=262144 genericSTM32F103V.menu.device_variant.STM32F103VC.upload.maximum_size=262144
genericSTM32F103V.menu.device_variant.STM32F103VC.upload.ram.maximum_size=49152 genericSTM32F103V.menu.device_variant.STM32F103VC.upload.maximum_data_size=49152
genericSTM32F103V.menu.device_variant.STM32F103VC.upload.flash.maximum_size=262144
genericSTM32F103V.menu.device_variant.STM32F103VC.build.ldscript=ld/stm32f103vc.ld genericSTM32F103V.menu.device_variant.STM32F103VC.build.ldscript=ld/stm32f103vc.ld
genericSTM32F103V.menu.device_variant.STM32F103VD=STM32F103VD genericSTM32F103V.menu.device_variant.STM32F103VD=STM32F103VD
genericSTM32F103V.menu.device_variant.STM32F103VD.build.variant=generic_stm32f103v
genericSTM32F103V.menu.device_variant.STM32F103VD.build.cpu_flags=-DMCU_STM32F103VD genericSTM32F103V.menu.device_variant.STM32F103VD.build.cpu_flags=-DMCU_STM32F103VD
genericSTM32F103V.menu.device_variant.STM32F103VD.upload.maximum_size=393216 genericSTM32F103V.menu.device_variant.STM32F103VD.upload.maximum_size=393216
genericSTM32F103V.menu.device_variant.STM32F103VD.upload.ram.maximum_size=65536 genericSTM32F103V.menu.device_variant.STM32F103VD.upload.maximum_data_size=65536
genericSTM32F103V.menu.device_variant.STM32F103VD.upload.flash.maximum_size=393216
genericSTM32F103V.menu.device_variant.STM32F103VD.build.ldscript=ld/stm32f103vd.ld genericSTM32F103V.menu.device_variant.STM32F103VD.build.ldscript=ld/stm32f103vd.ld
genericSTM32F103V.menu.device_variant.STM32F103VE=STM32F103VE genericSTM32F103V.menu.device_variant.STM32F103VE=STM32F103VE
genericSTM32F103V.menu.device_variant.STM32F103VE.build.variant=generic_stm32f103v
genericSTM32F103V.menu.device_variant.STM32F103VE.build.cpu_flags=-DMCU_STM32F103VE genericSTM32F103V.menu.device_variant.STM32F103VE.build.cpu_flags=-DMCU_STM32F103VE
genericSTM32F103V.menu.device_variant.STM32F103VE.upload.maximum_size=524288 genericSTM32F103V.menu.device_variant.STM32F103VE.upload.maximum_size=524288
genericSTM32F103V.menu.device_variant.STM32F103VE.upload.ram.maximum_size=65536 genericSTM32F103V.menu.device_variant.STM32F103VE.upload.maximum_data_size=65536
genericSTM32F103V.menu.device_variant.STM32F103VE.upload.flash.maximum_size=524288
genericSTM32F103V.menu.device_variant.STM32F103VE.build.ldscript=ld/stm32f103ve.ld genericSTM32F103V.menu.device_variant.STM32F103VE.build.ldscript=ld/stm32f103ve.ld
#---------------------------- UPLOAD METHODS --------------------------- #---------------------------- UPLOAD METHODS ---------------------------
@ -400,7 +694,7 @@ genericSTM32F103V.menu.device_variant.STM32F103VE.build.ldscript=ld/stm32f103ve.
genericSTM32F103V.menu.upload_method.DFUUploadMethod=STM32duino bootloader genericSTM32F103V.menu.upload_method.DFUUploadMethod=STM32duino bootloader
genericSTM32F103V.menu.upload_method.DFUUploadMethod.upload.protocol=maple_dfu genericSTM32F103V.menu.upload_method.DFUUploadMethod.upload.protocol=maple_dfu
genericSTM32F103V.menu.upload_method.DFUUploadMethod.upload.tool=maple_upload genericSTM32F103V.menu.upload_method.DFUUploadMethod.upload.tool=maple_upload
genericSTM32F103V.menu.upload_method.DFUUploadMethod.build.upload_flags=-DSERIAL_USB -DGENERIC_BOOTLOADER -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 genericSTM32F103V.menu.upload_method.DFUUploadMethod.build.upload_flags=-DSERIAL_USB -DGENERIC_BOOTLOADER
genericSTM32F103V.menu.upload_method.DFUUploadMethod.build.vect=VECT_TAB_ADDR=0x8002000 genericSTM32F103V.menu.upload_method.DFUUploadMethod.build.vect=VECT_TAB_ADDR=0x8002000
genericSTM32F103V.menu.upload_method.DFUUploadMethod.build.ldscript=ld/stm32f103veDFU.ld genericSTM32F103V.menu.upload_method.DFUUploadMethod.build.ldscript=ld/stm32f103veDFU.ld
genericSTM32F103V.menu.upload_method.DFUUploadMethod.upload.usbID=1EAF:0003 genericSTM32F103V.menu.upload_method.DFUUploadMethod.upload.usbID=1EAF:0003
@ -421,6 +715,45 @@ genericSTM32F103V.menu.upload_method.BMPMethod.upload.protocol=gdb_bmp
genericSTM32F103V.menu.upload_method.BMPMethod.upload.tool=bmp_upload genericSTM32F103V.menu.upload_method.BMPMethod.upload.tool=bmp_upload
genericSTM32F103V.menu.upload_method.BMPMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG genericSTM32F103V.menu.upload_method.BMPMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG
#-- CPU Clock frequency
genericSTM32F103V.menu.cpu_speed.speed_72mhz=72Mhz (Normal)
genericSTM32F103V.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L
genericSTM32F103V.menu.cpu_speed.speed_48mhz=48Mhz (Slow - with USB)
genericSTM32F103V.menu.cpu_speed.speed_48mhz.build.f_cpu=48000000L
genericSTM32F103V.menu.cpu_speed.speed_128mhz=Overclocked 128Mhz NO USB SERIAL. MANUAL RESET NEEDED TO UPLOAD
genericSTM32F103V.menu.cpu_speed.speed_128mhz.build.f_cpu=128000000L
#-- Optimizations
genericSTM32F103V.menu.opt.osstd=Smallest (default)
genericSTM32F103V.menu.opt.osstd.build.flags.optimize=-Os
genericSTM32F103V.menu.opt.osstd.build.flags.ldspecs=
genericSTM32F103V.menu.opt.oslto=Smallest Code with LTO
genericSTM32F103V.menu.opt.oslto.build.flags.optimize=-Os -flto
genericSTM32F103V.menu.opt.oslto.build.flags.ldspecs=-flto
genericSTM32F103V.menu.opt.o1std=Fast (-O1)
genericSTM32F103V.menu.opt.o1std.build.flags.optimize=-O1
genericSTM32F103V.menu.opt.o1std.build.flags.ldspecs=
genericSTM32F103V.menu.opt.o1lto=Fast (-O1) with LTO
genericSTM32F103V.menu.opt.o1lto.build.flags.optimize=-O1 -flto
genericSTM32F103V.menu.opt.o1lto.build.flags.ldspecs=-flto
genericSTM32F103V.menu.opt.o2std=Faster (-O2)
genericSTM32F103V.menu.opt.o2std.build.flags.optimize=-O2
genericSTM32F103V.menu.opt.o2std.build.flags.ldspecs=
genericSTM32F103V.menu.opt.o2lto=Faster (-O2) with LTO
genericSTM32F103V.menu.opt.o2lto.build.flags.optimize=-O2 -flto
genericSTM32F103V.menu.opt.o2lto.build.flags.ldspecs=-flto
genericSTM32F103V.menu.opt.o3std=Fastest (-O3)
genericSTM32F103V.menu.opt.o3std.build.flags.optimize=-O3
genericSTM32F103V.menu.opt.o3std.build.flags.ldspecs=
genericSTM32F103V.menu.opt.o3lto=Fastest (-O3) with LTO
genericSTM32F103V.menu.opt.o3lto.build.flags.optimize=-O3 -flto
genericSTM32F103V.menu.opt.ogstd=Debug (-g)
genericSTM32F103V.menu.opt.o3lto.build.flags.ldspecs=-flto
genericSTM32F103V.menu.opt.ogstd.build.flags.optimize=-Og
genericSTM32F103V.menu.opt.ogstd.build.flags.ldspecs=
########################### Generic STM32F103Z ########################### ########################### Generic STM32F103Z ###########################
genericSTM32F103Z.name=Generic STM32F103Z series genericSTM32F103Z.name=Generic STM32F103Z series
@ -433,26 +766,25 @@ genericSTM32F103Z.build.board=GENERIC_STM32F103Z
genericSTM32F103Z.upload.use_1200bps_touch=false genericSTM32F103Z.upload.use_1200bps_touch=false
genericSTM32F103Z.upload.file_type=bin genericSTM32F103Z.upload.file_type=bin
genericSTM32F103Z.upload.auto_reset=true genericSTM32F103Z.upload.auto_reset=true
genericSTM32F103Z.upload.tool=maple_upload
genericSTM32F103Z.upload.protocol=maple_dfu
genericSTM32F103Z.menu.device_variant.STM32F103ZC=STM32F103ZC genericSTM32F103Z.menu.device_variant.STM32F103ZC=STM32F103ZC
genericSTM32F103Z.menu.device_variant.STM32F103ZC.build.cpu_flags=-DMCU_STM32F103ZC genericSTM32F103Z.menu.device_variant.STM32F103ZC.build.cpu_flags=-DMCU_STM32F103ZC
genericSTM32F103Z.menu.device_variant.STM32F103ZC.upload.maximum_size=262144 genericSTM32F103Z.menu.device_variant.STM32F103ZC.upload.maximum_size=262144
genericSTM32F103Z.menu.device_variant.STM32F103ZC.upload.ram.maximum_size=49152 genericSTM32F103Z.menu.device_variant.STM32F103ZC.upload.maximum_data_size=49152
genericSTM32F103Z.menu.device_variant.STM32F103ZC.upload.flash.maximum_size=262144
genericSTM32F103Z.menu.device_variant.STM32F103ZC.build.ldscript=ld/stm32f103zc.ld genericSTM32F103Z.menu.device_variant.STM32F103ZC.build.ldscript=ld/stm32f103zc.ld
genericSTM32F103Z.menu.device_variant.STM32F103ZD=STM32F103ZD genericSTM32F103Z.menu.device_variant.STM32F103ZD=STM32F103ZD
genericSTM32F103Z.menu.device_variant.STM32F103ZD.build.cpu_flags=-DMCU_STM32F103ZD genericSTM32F103Z.menu.device_variant.STM32F103ZD.build.cpu_flags=-DMCU_STM32F103ZD
genericSTM32F103Z.menu.device_variant.STM32F103ZD.upload.maximum_size=393216 genericSTM32F103Z.menu.device_variant.STM32F103ZD.upload.maximum_size=393216
genericSTM32F103Z.menu.device_variant.STM32F103ZD.upload.ram.maximum_size=65536 genericSTM32F103Z.menu.device_variant.STM32F103ZD.upload.maximum_data_size=65536
genericSTM32F103Z.menu.device_variant.STM32F103ZD.upload.flash.maximum_size=393216
genericSTM32F103Z.menu.device_variant.STM32F103ZD.build.ldscript=ld/stm32f103zd.ld genericSTM32F103Z.menu.device_variant.STM32F103ZD.build.ldscript=ld/stm32f103zd.ld
genericSTM32F103Z.menu.device_variant.STM32F103ZE=STM32F103ZE genericSTM32F103Z.menu.device_variant.STM32F103ZE=STM32F103ZE
genericSTM32F103Z.menu.device_variant.STM32F103ZE.build.cpu_flags=-DMCU_STM32F103ZE genericSTM32F103Z.menu.device_variant.STM32F103ZE.build.cpu_flags=-DMCU_STM32F103ZE
genericSTM32F103Z.menu.device_variant.STM32F103ZE.upload.maximum_size=524288 genericSTM32F103Z.menu.device_variant.STM32F103ZE.upload.maximum_size=524288
genericSTM32F103Z.menu.device_variant.STM32F103ZE.upload.ram.maximum_size=65536 genericSTM32F103Z.menu.device_variant.STM32F103ZE.upload.maximum_data_size=65536
genericSTM32F103Z.menu.device_variant.STM32F103ZE.upload.flash.maximum_size=524288
genericSTM32F103Z.menu.device_variant.STM32F103ZE.build.ldscript=ld/stm32f103ze.ld genericSTM32F103Z.menu.device_variant.STM32F103ZE.build.ldscript=ld/stm32f103ze.ld
#---------------------------- UPLOAD METHODS --------------------------- #---------------------------- UPLOAD METHODS ---------------------------
@ -460,7 +792,7 @@ genericSTM32F103Z.menu.device_variant.STM32F103ZE.build.ldscript=ld/stm32f103ze.
genericSTM32F103Z.menu.upload_method.DFUUploadMethod=STM32duino bootloader genericSTM32F103Z.menu.upload_method.DFUUploadMethod=STM32duino bootloader
genericSTM32F103Z.menu.upload_method.DFUUploadMethod.upload.protocol=maple_dfu genericSTM32F103Z.menu.upload_method.DFUUploadMethod.upload.protocol=maple_dfu
genericSTM32F103Z.menu.upload_method.DFUUploadMethod.upload.tool=maple_upload genericSTM32F103Z.menu.upload_method.DFUUploadMethod.upload.tool=maple_upload
genericSTM32F103Z.menu.upload_method.DFUUploadMethod.build.upload_flags=-DSERIAL_USB -DGENERIC_BOOTLOADER -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 genericSTM32F103Z.menu.upload_method.DFUUploadMethod.build.upload_flags=-DSERIAL_USB -DGENERIC_BOOTLOADER
genericSTM32F103Z.menu.upload_method.DFUUploadMethod.build.vect=VECT_TAB_ADDR=0x8002000 genericSTM32F103Z.menu.upload_method.DFUUploadMethod.build.vect=VECT_TAB_ADDR=0x8002000
genericSTM32F103Z.menu.upload_method.DFUUploadMethod.build.ldscript=ld/stm32f103z_dfu.ld genericSTM32F103Z.menu.upload_method.DFUUploadMethod.build.ldscript=ld/stm32f103z_dfu.ld
genericSTM32F103Z.menu.upload_method.DFUUploadMethod.upload.usbID=1EAF:0003 genericSTM32F103Z.menu.upload_method.DFUUploadMethod.upload.usbID=1EAF:0003
@ -481,6 +813,45 @@ genericSTM32F103Z.menu.upload_method.BMPMethod.upload.protocol=gdb_bmp
genericSTM32F103Z.menu.upload_method.BMPMethod.upload.tool=bmp_upload genericSTM32F103Z.menu.upload_method.BMPMethod.upload.tool=bmp_upload
genericSTM32F103Z.menu.upload_method.BMPMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG genericSTM32F103Z.menu.upload_method.BMPMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG
#-- CPU Clock frequency
genericSTM32F103Z.menu.cpu_speed.speed_72mhz=72Mhz (Normal)
genericSTM32F103Z.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L
genericSTM32F103Z.menu.cpu_speed.speed_48mhz=48Mhz (Slow - with USB)
genericSTM32F103Z.menu.cpu_speed.speed_48mhz.build.f_cpu=48000000L
genericSTM32F103Z.menu.cpu_speed.speed_128mhz=Overclocked 128Mhz NO USB SERIAL. MANUAL RESET NEEDED TO UPLOAD
genericSTM32F103Z.menu.cpu_speed.speed_128mhz.build.f_cpu=128000000L
#-- Optimizations
genericSTM32F103Z.menu.opt.osstd=Smallest (default)
genericSTM32F103Z.menu.opt.osstd.build.flags.optimize=-Os
genericSTM32F103Z.menu.opt.osstd.build.flags.ldspecs=
genericSTM32F103Z.menu.opt.oslto=Smallest Code with LTO
genericSTM32F103Z.menu.opt.oslto.build.flags.optimize=-Os -flto
genericSTM32F103Z.menu.opt.oslto.build.flags.ldspecs=-flto
genericSTM32F103Z.menu.opt.o1std=Fast (-O1)
genericSTM32F103Z.menu.opt.o1std.build.flags.optimize=-O1
genericSTM32F103Z.menu.opt.o1std.build.flags.ldspecs=
genericSTM32F103Z.menu.opt.o1lto=Fast (-O1) with LTO
genericSTM32F103Z.menu.opt.o1lto.build.flags.optimize=-O1 -flto
genericSTM32F103Z.menu.opt.o1lto.build.flags.ldspecs=-flto
genericSTM32F103Z.menu.opt.o2std=Faster (-O2)
genericSTM32F103Z.menu.opt.o2std.build.flags.optimize=-O2
genericSTM32F103Z.menu.opt.o2std.build.flags.ldspecs=
genericSTM32F103Z.menu.opt.o2lto=Faster (-O2) with LTO
genericSTM32F103Z.menu.opt.o2lto.build.flags.optimize=-O2 -flto
genericSTM32F103Z.menu.opt.o2lto.build.flags.ldspecs=-flto
genericSTM32F103Z.menu.opt.o3std=Fastest (-O3)
genericSTM32F103Z.menu.opt.o3std.build.flags.optimize=-O3
genericSTM32F103Z.menu.opt.o3std.build.flags.ldspecs=
genericSTM32F103Z.menu.opt.o3lto=Fastest (-O3) with LTO
genericSTM32F103Z.menu.opt.o3lto.build.flags.optimize=-O3 -flto
genericSTM32F103Z.menu.opt.ogstd=Debug (-g)
genericSTM32F103Z.menu.opt.o3lto.build.flags.ldspecs=-flto
genericSTM32F103Z.menu.opt.ogstd.build.flags.optimize=-Og
genericSTM32F103Z.menu.opt.ogstd.build.flags.ldspecs=
###################### HYTiny STM32F103T ######################################## ###################### HYTiny STM32F103T ########################################
hytiny-stm32f103t.name=HYTiny STM32F103TB hytiny-stm32f103t.name=HYTiny STM32F103TB
@ -498,9 +869,7 @@ hytiny-stm32f103t.upload.auto_reset=true
hytiny-stm32f103t.build.cpu_flags=-DMCU_STM32F103CB hytiny-stm32f103t.build.cpu_flags=-DMCU_STM32F103CB
hytiny-stm32f103t.build.ldscript=ld/jtag.ld hytiny-stm32f103t.build.ldscript=ld/jtag.ld
hytiny-stm32f103t.upload.maximum_size=131072 hytiny-stm32f103t.upload.maximum_size=131072
hytiny-stm32f103t.upload.ram.maximum_size=20480 hytiny-stm32f103t.upload.maximum_data_size=20480
hytiny-stm32f103t.upload.flash.maximum_size=131072
#---------------------------- UPLOAD METHODS --------------------------- #---------------------------- UPLOAD METHODS ---------------------------
@ -534,71 +903,44 @@ hytiny-stm32f103t.menu.upload_method.jlinkMethod.upload.protocol=jlink
hytiny-stm32f103t.menu.upload_method.jlinkMethod.upload.tool=jlink_upload hytiny-stm32f103t.menu.upload_method.jlinkMethod.upload.tool=jlink_upload
hytiny-stm32f103t.menu.upload_method.jlinkMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DSERIAL_USB -DGENERIC_BOOTLOADER hytiny-stm32f103t.menu.upload_method.jlinkMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DSERIAL_USB -DGENERIC_BOOTLOADER
#-- CPU Clock frequency
hytiny-stm32f103t.menu.cpu_speed.speed_72mhz=72Mhz (Normal)
hytiny-stm32f103t.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L
###################### Generic GD32F103C ######################################## hytiny-stm32f103t.menu.cpu_speed.speed_48mhz=48Mhz (Slow - with USB)
hytiny-stm32f103t.menu.cpu_speed.speed_48mhz.build.f_cpu=48000000L
genericGD32F103C.name=Generic GD32F103C series hytiny-stm32f103t.menu.cpu_speed.speed_128mhz=Overclocked 128Mhz NO USB SERIAL. MANUAL RESET NEEDED TO UPLOAD
genericGD32F103C.build.variant=generic_GD32f103c hytiny-stm32f103t.menu.cpu_speed.speed_128mhz.build.f_cpu=128000000L
genericGD32F103C.build.vect=VECT_TAB_ADDR=0x8000000
genericGD32F103C.build.core=maple
genericGD32F103C.build.board=GENERIC_GD32F103C
genericGD32F103C.upload.use_1200bps_touch=false
genericGD32F103C.upload.file_type=bin
genericGD32F103C.upload.auto_reset=true
genericGD32F103C.build.cpu_flags=-DMCU_STM32F103CB
genericGD32F103C.build.f_cpu=72000000L
## GD32F103CB ------------------------- #-- Optimizations
genericGD32F103C.menu.device_variant.GD32F103CB=GD32F103CB (20k RAM. 128k Flash) hytiny-stm32f103t.menu.opt.osstd=Smallest (default)
genericGD32F103C.menu.device_variant.GD32F103CB.build.ldscript=ld/jtag.ld hytiny-stm32f103t.menu.opt.osstd.build.flags.optimize=-Os
genericGD32F103C.menu.device_variant.GD32F103CB.upload.maximum_size=131072 hytiny-stm32f103t.menu.opt.osstd.build.flags.ldspecs=
genericGD32F103C.menu.device_variant.GD32F103CB.upload.ram.maximum_size=20480 hytiny-stm32f103t.menu.opt.oslto=Smallest Code with LTO
genericGD32F103C.menu.device_variant.GD32F103CB.upload.flash.maximum_size=131072 hytiny-stm32f103t.menu.opt.oslto.build.flags.optimize=-Os -flto
hytiny-stm32f103t.menu.opt.oslto.build.flags.ldspecs=-flto
hytiny-stm32f103t.menu.opt.o1std=Fast (-O1)
## GD32F103C8 ------------------------- hytiny-stm32f103t.menu.opt.o1std.build.flags.optimize=-O1
genericGD32F103C.menu.device_variant.GD32F103C8=GD32F103C8 (20k RAM. 64k Flash) hytiny-stm32f103t.menu.opt.o1std.build.flags.ldspecs=
genericGD32F103C.menu.device_variant.GD32F103C8.build.ldscript=ld/jtag_c8.ld hytiny-stm32f103t.menu.opt.o1lto=Fast (-O1) with LTO
genericGD32F103C.menu.device_variant.GD32F103C8.upload.maximum_size=65536 hytiny-stm32f103t.menu.opt.o1lto.build.flags.optimize=-O1 -flto
genericGD32F103C.menu.device_variant.GD32F103C8.upload.ram.maximum_size=20480 hytiny-stm32f103t.menu.opt.o1lto.build.flags.ldspecs=-flto
genericGD32F103C.menu.device_variant.GD32F103C8.upload.flash.maximum_size=65536 hytiny-stm32f103t.menu.opt.o2std=Faster (-O2)
hytiny-stm32f103t.menu.opt.o2std.build.flags.optimize=-O2
#---------------------------- UPLOAD METHODS --------------------------- hytiny-stm32f103t.menu.opt.o2std.build.flags.ldspecs=
hytiny-stm32f103t.menu.opt.o2lto=Faster (-O2) with LTO
genericGD32F103C.menu.upload_method.DFUUploadMethod=GD32duino bootloader hytiny-stm32f103t.menu.opt.o2lto.build.flags.optimize=-O2 -flto
hytiny-stm32f103t.menu.opt.o2lto.build.flags.ldspecs=-flto
genericGD32F103C.menu.upload_method.DFUUploadMethod.upload.protocol=maple_dfu hytiny-stm32f103t.menu.opt.o3std=Fastest (-O3)
genericGD32F103C.menu.upload_method.DFUUploadMethod.upload.tool=maple_upload hytiny-stm32f103t.menu.opt.o3std.build.flags.optimize=-O3
genericGD32F103C.menu.upload_method.DFUUploadMethod.build.upload_flags=-DSERIAL_USB -DGENERIC_BOOTLOADER -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 hytiny-stm32f103t.menu.opt.o3std.build.flags.ldspecs=
genericGD32F103C.menu.upload_method.DFUUploadMethod.build.vect=VECT_TAB_ADDR=0x8002000 hytiny-stm32f103t.menu.opt.o3lto=Fastest (-O3) with LTO
genericGD32F103C.menu.upload_method.DFUUploadMethod.build.ldscript=ld/bootloader_20.ld hytiny-stm32f103t.menu.opt.o3lto.build.flags.optimize=-O3 -flto
genericGD32F103C.menu.upload_method.DFUUploadMethod.upload.usbID=1EAF:0003 hytiny-stm32f103t.menu.opt.ogstd=Debug (-g)
genericGD32F103C.menu.upload_method.DFUUploadMethod.upload.altID=2 hytiny-stm32f103t.menu.opt.o3lto.build.flags.ldspecs=-flto
hytiny-stm32f103t.menu.opt.ogstd.build.flags.optimize=-Og
genericGD32F103C.menu.upload_method.serialMethod=Serial hytiny-stm32f103t.menu.opt.ogstd.build.flags.ldspecs=
genericGD32F103C.menu.upload_method.serialMethod.upload.protocol=maple_serial
genericGD32F103C.menu.upload_method.serialMethod.upload.tool=serial_upload
genericGD32F103C.menu.upload_method.serialMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1
genericGD32F103C.menu.upload_method.STLinkMethod=STLink
genericGD32F103C.menu.upload_method.STLinkMethod.upload.protocol=STLink
genericGD32F103C.menu.upload_method.STLinkMethod.upload.tool=stlink_upload
genericGD32F103C.menu.upload_method.STLinkMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DSERIAL_USB -DGENERIC_BOOTLOADER
genericGD32F103C.menu.upload_method.BMPMethod=BMP (Black Magic Probe)
genericGD32F103C.menu.upload_method.BMPMethod.upload.protocol=gdb_bmp
genericGD32F103C.menu.upload_method.BMPMethod.upload.tool=bmp_upload
genericGD32F103C.menu.upload_method.BMPMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG
genericGD32F103C.menu.cpu_speed.speed_120mhz=120Mhz (overdrive)
genericGD32F103C.menu.cpu_speed.speed_120mhz.build.f_cpu=120000000L
genericGD32F103C.menu.cpu_speed.speed_96mhz=96Mhz (Stable)
genericGD32F103C.menu.cpu_speed.speed_96mhz.build.f_cpu=96000000L
genericGD32F103C.menu.cpu_speed.speed_72mhz=72Mhz (compatibility)
genericGD32F103C.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L
########################### STM32VLD to FLASH ########################### ########################### STM32VLD to FLASH ###########################
@ -620,13 +962,51 @@ STM32VLD.upload.auto_reset=true
STM32VLD.upload.params.quiet=no STM32VLD.upload.params.quiet=no
STM32VLD.build.cpu_flags=-DMCU_STM32F100RB STM32VLD.build.cpu_flags=-DMCU_STM32F100RB
##---------------------------- UPLOAD METHODS ---------------------------
#---------------------------- UPLOAD METHODS ---------------------------
STM32VLD.menu.upload_method.STLinkMethod=STLink STM32VLD.menu.upload_method.STLinkMethod=STLink
STM32VLD.menu.upload_method.STLinkMethod.upload.protocol=STLink STM32VLD.menu.upload_method.STLinkMethod.upload.protocol=STLink
STM32VLD.menu.upload_method.STLinkMethod.upload.tool=stlink_upload STM32VLD.menu.upload_method.STLinkMethod.upload.tool=stlink_upload
STM32VLD.menu.upload_method.STLinkMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG STM32VLD.menu.upload_method.STLinkMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG
#-- CPU Clock frequency
STM32VLD.menu.cpu_speed.speed_72mhz=72Mhz (Normal)
STM32VLD.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L
STM32VLD.menu.cpu_speed.speed_48mhz=48Mhz (Slow - with USB)
STM32VLD.menu.cpu_speed.speed_48mhz.build.f_cpu=48000000L
STM32VLD.menu.cpu_speed.speed_128mhz=Overclocked 128Mhz NO USB SERIAL. MANUAL RESET NEEDED TO UPLOAD
STM32VLD.menu.cpu_speed.speed_128mhz.build.f_cpu=128000000L
#-- Optimizations
STM32VLD.menu.opt.osstd=Smallest (default)
STM32VLD.menu.opt.osstd.build.flags.optimize=-Os
STM32VLD.menu.opt.osstd.build.flags.ldspecs=
STM32VLD.menu.opt.oslto=Smallest Code with LTO
STM32VLD.menu.opt.oslto.build.flags.optimize=-Os -flto
STM32VLD.menu.opt.oslto.build.flags.ldspecs=-flto
STM32VLD.menu.opt.o1std=Fast (-O1)
STM32VLD.menu.opt.o1std.build.flags.optimize=-O1
STM32VLD.menu.opt.o1std.build.flags.ldspecs=
STM32VLD.menu.opt.o1lto=Fast (-O1) with LTO
STM32VLD.menu.opt.o1lto.build.flags.optimize=-O1 -flto
STM32VLD.menu.opt.o1lto.build.flags.ldspecs=-flto
STM32VLD.menu.opt.o2std=Faster (-O2)
STM32VLD.menu.opt.o2std.build.flags.optimize=-O2
STM32VLD.menu.opt.o2std.build.flags.ldspecs=
STM32VLD.menu.opt.o2lto=Faster (-O2) with LTO
STM32VLD.menu.opt.o2lto.build.flags.optimize=-O2 -flto
STM32VLD.menu.opt.o2lto.build.flags.ldspecs=-flto
STM32VLD.menu.opt.o3std=Fastest (-O3)
STM32VLD.menu.opt.o3std.build.flags.optimize=-O3
STM32VLD.menu.opt.o3std.build.flags.ldspecs=
STM32VLD.menu.opt.o3lto=Fastest (-O3) with LTO
STM32VLD.menu.opt.o3lto.build.flags.optimize=-O3 -flto
STM32VLD.menu.opt.ogstd=Debug (-g)
STM32VLD.menu.opt.o3lto.build.flags.ldspecs=-flto
STM32VLD.menu.opt.ogstd.build.flags.optimize=-Og
STM32VLD.menu.opt.ogstd.build.flags.ldspecs=
################################################################################ ################################################################################

View File

@ -37,59 +37,6 @@
#include <libmaple/timer.h> #include <libmaple/timer.h>
#include <libmaple/usart.h> #include <libmaple/usart.h>
#if 0
#define DEFINE_HWSERIAL(name, n) \
HardwareSerial name(USART##n, \
BOARD_USART##n##_TX_PIN, \
BOARD_USART##n##_RX_PIN)
#define DEFINE_HWSERIAL_UART(name, n) \
HardwareSerial name(UART##n, \
BOARD_USART##n##_TX_PIN, \
BOARD_USART##n##_RX_PIN)
#ifdef SERIAL_USB
#if BOARD_HAVE_USART1
DEFINE_HWSERIAL(Serial1, 1);
#endif
#if BOARD_HAVE_USART2
DEFINE_HWSERIAL(Serial2, 2);
#endif
#if BOARD_HAVE_USART3
DEFINE_HWSERIAL(Serial3, 3);
#endif
#if BOARD_HAVE_UART4
DEFINE_HWSERIAL_UART(Serial4, 4);
#endif
#if BOARD_HAVE_UART5
DEFINE_HWSERIAL_UART(Serial5, 5);
#endif
#if BOARD_HAVE_USART6
DEFINE_HWSERIAL_UART(Serial6, 6);
#endif
#else
#if BOARD_HAVE_USART1
DEFINE_HWSERIAL(Serial, 1);
#endif
#if BOARD_HAVE_USART2
DEFINE_HWSERIAL(Serial1, 2);
#endif
#if BOARD_HAVE_USART3
DEFINE_HWSERIAL(Serial2, 3);
#endif
#if BOARD_HAVE_UART4
DEFINE_HWSERIAL_UART(Serial3, 4);
#endif
#if BOARD_HAVE_UART5
DEFINE_HWSERIAL_UART(Serial4, 5);
#endif
#if BOARD_HAVE_USART6
DEFINE_HWSERIAL_UART(Serial5, 6);
#endif
#endif
#endif
HardwareSerial::HardwareSerial(usart_dev *usart_device, HardwareSerial::HardwareSerial(usart_dev *usart_device,
uint8 tx_pin, uint8 tx_pin,
uint8 rx_pin) { uint8 rx_pin) {
@ -193,7 +140,8 @@ size_t HardwareSerial::write(unsigned char ch) {
return 1; return 1;
} }
/* edogaldo: Waits for the transmission of outgoing serial data to complete (Arduino 1.0 api specs) */
void HardwareSerial::flush(void) { void HardwareSerial::flush(void) {
usart_reset_rx(this->usart_device); while(!rb_is_empty(this->usart_device->wb)); // wait for TX buffer empty
usart_reset_tx(this->usart_device); while(!((this->usart_device->regs->SR) & (1<<USART_SR_TC_BIT))); // wait for TC (Transmission Complete) flag set
} }

View File

@ -30,6 +30,7 @@
#include "ext_interrupts.h" // for noInterrupts(), interrupts() #include "ext_interrupts.h" // for noInterrupts(), interrupts()
#include "wirish_math.h" #include "wirish_math.h"
#include <board/board.h> // for CYCLES_PER_MICROSECOND #include <board/board.h> // for CYCLES_PER_MICROSECOND
#include <libmaple/dma.h>
// TODO [0.1.0] Remove deprecated pieces // TODO [0.1.0] Remove deprecated pieces
@ -138,32 +139,24 @@ void HardwareTimer::detachInterrupt(int channel) {
timer_detach_interrupt(this->dev, (uint8)channel); timer_detach_interrupt(this->dev, (uint8)channel);
} }
void HardwareTimer::enableDMA(int channel) {
timer_dma_enable_req(this->dev, (uint8)channel);
}
void HardwareTimer::disableDMA(int channel) {
timer_dma_disable_req(this->dev, (uint8)channel);
}
void HardwareTimer::refresh(void) { void HardwareTimer::refresh(void) {
timer_generate_update(this->dev); timer_generate_update(this->dev);
} }
/* CARLOS Changes to add encoder mode.*/ void HardwareTimer::setMasterModeTrGo(uint32_t mode) {
this->dev->regs.bas->CR2 &= ~TIMER_CR2_MMS;
this->dev->regs.bas->CR2 |= mode;
}
//direction of movement. (to be better described).
uint8 HardwareTimer::getDirection(){
return get_direction(this->dev);
}
//set if the encoder will count edges on one, which or both channels.
void HardwareTimer::setEdgeCounting(uint32 counting) {
(dev->regs).gen->SMCR = counting;//TIMER_SMCR_SMS_ENCODER3; //choose encoder 3, counting on
}
uint8 HardwareTimer::getEdgeCounting() {
return (dev->regs).gen->SMCR;
}
//set the polarity of counting... not sure how interesting this is..
void HardwareTimer::setPolarity(){}
/* -- Deprecated predefined instances -------------------------------------- */ /* -- Deprecated predefined instances -------------------------------------- */
HardwareTimer Timer1(1); HardwareTimer Timer1(1);

View File

@ -177,7 +177,8 @@ public:
* This interrupt handler will be called when the timer's counter * This interrupt handler will be called when the timer's counter
* reaches the given channel compare value. * reaches the given channel compare value.
* *
* @param channel the channel to attach the ISR to, from 1 to 4. * @param channel the channel to attach the ISR to, from 0 to 4.
* Channel 0 is for overflow interrupt (update interrupt).
* @param handler The ISR to attach to the given channel. * @param handler The ISR to attach to the given channel.
* @see voidFuncPtr * @see voidFuncPtr
*/ */
@ -189,7 +190,8 @@ public:
* *
* The handler will no longer be called by this timer. * The handler will no longer be called by this timer.
* *
* @param channel the channel whose interrupt to detach, from 1 to 4. * @param channel the channel whose interrupt to detach, from 0 to 4.
* Channel 0 is for overflow interrupt (update interrupt).
* @see HardwareTimer::attachInterrupt() * @see HardwareTimer::attachInterrupt()
*/ */
void detachInterrupt(int channel); void detachInterrupt(int channel);
@ -209,24 +211,68 @@ public:
*/ */
void refresh(void); void refresh(void);
// SYFRE
/**
* @brief Set the Master mode TRGO signal
* These bits allow to select the information to be sent in master mode to slave timers for
* synchronization (TRGO).
* mode:
* TIMER_CR2_MMS_RESET
* TIMER_CR2_MMS_ENABLE
* TIMER_CR2_MMS_UPDATE
* TIMER_CR2_MMS_COMPARE_PULSE
* TIMER_CR2_MMS_COMPARE_OC1REF
* TIMER_CR2_MMS_COMPARE_OC2REF
* TIMER_CR2_MMS_COMPARE_OC3REF
* TIMER_CR2_MMS_COMPARE_OC4REF
*/
void setMasterModeTrGo(uint32_t mode);
void setSlaveFlags(uint32 flags) {
((this->dev)->regs).gen->SMCR = flags;
}
//CARLOS. //CARLOS.
/* /*
added these functions to make sense for the encoder mode. added these functions to make sense for the encoder mode.
*/ */
//direction of movement. (to be better described). //direction of movement. (to be better described).
uint8 getDirection(); uint8 getDirection() {
return get_direction(this->dev);
}
//set if the encoder will count edges on one, which or both channels. //set if the encoder will count edges on one, which or both channels.
void setEdgeCounting(uint32 counting); void setEdgeCounting(uint32 counting) {
uint8 getEdgeCounting(); //not sure if needed. setSlaveFlags(counting);
}
//set the polarity of counting... not sure how interesting this is.. //set the polarity of counting... not sure how interesting this is..
void setPolarity(); void setPolarity(uint8 channel, uint8 pol) {
timer_cc_set_pol(this->dev, channel, pol);
}
void setInputCaptureMode(uint8 channel, timer_ic_input_select input) {
input_capture_mode(this->dev, channel, input);
}
uint8_t getInputCaptureFlag(uint8 channel) {
return ( timer_get_status(this->dev) >> channel ) & 0x1;
}
uint8_t getInputCaptureFlagOverflow(uint8 channel) {
uint8 ret = ( timer_get_status(this->dev) >> (8+channel) ) & 0x1;
if ( ret ) timer_reset_status_bit(this->dev, (8+channel)); // clear flag
return ret;
}
//add the filtering definition for the input channel. //add the filtering definition for the input channel.
/* Escape hatch */ /**
* @brief Enable/disable DMA request for the input channel.
*/
void enableDMA(int channel);
void disableDMA(int channel);
/** /**
* @brief Get a pointer to the underlying libmaple timer_dev for * @brief Get a pointer to the underlying libmaple timer_dev for

View File

@ -47,12 +47,8 @@
*/ */
size_t Print::write(const char *str) { size_t Print::write(const char *str) {
size_t n = 0; if (str == NULL) return 0;
while (*str) { return write((const uint8_t *)str, strlen(str));
write(*str++);
n++;
}
return n;
} }
size_t Print::write(const void *buffer, uint32 size) { size_t Print::write(const void *buffer, uint32 size) {
@ -99,10 +95,6 @@ size_t Print::print(unsigned long n, int base) {
} }
size_t Print::print(long long n, int base) { size_t Print::print(long long n, int base) {
if (base == BYTE)
{
return write((uint8)n);
}
if (n < 0) { if (n < 0) {
print('-'); print('-');
n = -n; n = -n;
@ -111,13 +103,7 @@ size_t Print::print(long long n, int base) {
} }
size_t Print::print(unsigned long long n, int base) { size_t Print::print(unsigned long long n, int base) {
size_t c=0; return printNumber(n, base);
if (base == BYTE) {
c= write((uint8)n);
} else {
c= printNumber(n, base);
}
return c;
} }
size_t Print::print(double n, int digits) { size_t Print::print(double n, int digits) {

View File

@ -28,7 +28,6 @@
#include "Printable.h" #include "Printable.h"
enum { enum {
BYTE = 0,
BIN = 2, BIN = 2,
OCT = 8, OCT = 8,
DEC = 10, DEC = 10,

View File

@ -120,8 +120,12 @@ extern char* ltoa( long value, char *string, int radix )
return string; return string;
} }
#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 9 || \
extern char* utoa( unsigned long value, char *string, int radix ) (__GNUC_MINOR__ == 9 && __GNUC_PATCHLEVEL__ > 2)))
extern char* utoa( unsigned value, char *string, int radix )
#else
extern char* utoa( unsigned int value, char *string, int radix )
#endif
{ {
return ultoa( value, string, radix ) ; return ultoa( value, string, radix ) ;
} }

View File

@ -31,7 +31,12 @@ extern void itoa( int n, char s[] ) ;
extern char* itoa( int value, char *string, int radix ) ; extern char* itoa( int value, char *string, int radix ) ;
extern char* ltoa( long value, char *string, int radix ) ; extern char* ltoa( long value, char *string, int radix ) ;
extern char* utoa( unsigned long value, char *string, int radix ) ; #if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 9 || \
(__GNUC_MINOR__ == 9 && __GNUC_PATCHLEVEL__ > 2)))
extern char* utoa( unsigned value, char *string, int radix ) ;
#else
extern char* utoa( unsigned int value, char *string, int radix ) ;
#endif
extern char* ultoa( unsigned long value, char *string, int radix ) ; extern char* ultoa( unsigned long value, char *string, int radix ) ;
#endif /* 0 */ #endif /* 0 */

View File

@ -59,6 +59,7 @@ void adc_set_extsel(adc_dev *dev, adc_extsel_event event) {
uint32 cr2 = dev->regs->CR2; uint32 cr2 = dev->regs->CR2;
cr2 &= ~ADC_CR2_EXTSEL; cr2 &= ~ADC_CR2_EXTSEL;
cr2 |= event; cr2 |= event;
cr2 |= ADC_CR2_EXTTRIG;
dev->regs->CR2 = cr2; dev->regs->CR2 = cr2;
} }

View File

@ -72,7 +72,7 @@ adc_dev *ADC3 = &adc3;
adc irq routine. adc irq routine.
Added by bubulindo. Added by bubulindo.
*/ */
void __irq_adc() { __weak void __irq_adc() {
//get status //get status
uint32 adc_sr = ADC1->regs->SR; uint32 adc_sr = ADC1->regs->SR;
//End Of Conversion //End Of Conversion
@ -107,7 +107,7 @@ void __irq_adc() {
added by bubulindo added by bubulindo
*/ */
#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) #if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
void __irq_adc3() { __weak void __irq_adc3() {
//get status //get status
uint32 adc_sr = ADC3->regs->SR; uint32 adc_sr = ADC3->regs->SR;
//End Of Conversion //End Of Conversion
@ -175,8 +175,8 @@ void adc_attach_interrupt(adc_dev *dev,
* @param dev adc device * @param dev adc device
*/ */
void adc_calibrate(adc_dev *dev) { void adc_calibrate(adc_dev *dev) {
__io uint32 *rstcal_bit = bb_perip(&(dev->regs->CR2), 3); __IO uint32 *rstcal_bit = bb_perip(&(dev->regs->CR2), 3);
__io uint32 *cal_bit = bb_perip(&(dev->regs->CR2), 2); __IO uint32 *cal_bit = bb_perip(&(dev->regs->CR2), 2);
*rstcal_bit = 1; *rstcal_bit = 1;
while (*rstcal_bit) while (*rstcal_bit)
@ -203,7 +203,7 @@ void adc_foreach(void (*fn)(adc_dev*)) {
#endif #endif
} }
void adc_config_gpio(adc_dev *ignored, gpio_dev *gdev, uint8 bit) { void adc_config_gpio(adc_dev *ignored __attribute__((unused)), gpio_dev *gdev, uint8 bit) {
gpio_set_mode(gdev, bit, GPIO_INPUT_ANALOG); gpio_set_mode(gdev, bit, GPIO_INPUT_ANALOG);
} }

View File

@ -34,7 +34,7 @@
#include <libmaple/rcc.h> #include <libmaple/rcc.h>
#include <libmaple/bitband.h> #include <libmaple/bitband.h>
static inline __io uint32* data_register(uint8 reg); static inline __IO uint32* data_register(uint8 reg);
bkp_dev bkp = { bkp_dev bkp = {
.regs = BKP_BASE, .regs = BKP_BASE,
@ -78,7 +78,7 @@ void bkp_disable_writes(void) {
* medium-density devices, 42 on high-density devices). * medium-density devices, 42 on high-density devices).
*/ */
uint16 bkp_read(uint8 reg) { uint16 bkp_read(uint8 reg) {
__io uint32* dr = data_register(reg); __IO uint32* dr = data_register(reg);
if (!dr) { if (!dr) {
ASSERT(0); /* nonexistent register */ ASSERT(0); /* nonexistent register */
return 0; return 0;
@ -97,7 +97,7 @@ uint16 bkp_read(uint8 reg) {
* @see bkp_enable_writes() * @see bkp_enable_writes()
*/ */
void bkp_write(uint8 reg, uint16 val) { void bkp_write(uint8 reg, uint16 val) {
__io uint32* dr = data_register(reg); __IO uint32* dr = data_register(reg);
if (!dr) { if (!dr) {
ASSERT(0); /* nonexistent register */ ASSERT(0); /* nonexistent register */
return; return;
@ -112,7 +112,7 @@ void bkp_write(uint8 reg, uint16 val) {
*/ */
#define NR_LOW_DRS 10 #define NR_LOW_DRS 10
static inline __io uint32* data_register(uint8 reg) { static inline __IO uint32* data_register(uint8 reg) {
if (reg < 1 || reg > BKP_NR_DATA_REGS) { if (reg < 1 || reg > BKP_NR_DATA_REGS) {
return 0; return 0;
} }

View File

@ -52,7 +52,7 @@ void dma_init(dma_dev *dev) {
* Private API * Private API
*/ */
enum dma_atype _dma_addr_type(__io void *addr) { enum dma_atype _dma_addr_type(__IO void *addr) {
switch (stm32_block_purpose((void*)addr)) { switch (stm32_block_purpose((void*)addr)) {
/* Notice we're treating the code block as memory here. That's /* Notice we're treating the code block as memory here. That's
* correct for addresses in Flash and in [0x0, 0x7FFFFFF] * correct for addresses in Flash and in [0x0, 0x7FFFFFF]

View File

@ -86,7 +86,7 @@ static int cfg_dev_ok(dma_dev *dev, dma_tube_config *cfg) {
} }
/* Is addr acceptable for use as DMA src/dst? */ /* Is addr acceptable for use as DMA src/dst? */
static int cfg_mem_ok(__io void *addr) { static int cfg_mem_ok(__IO void *addr) {
enum dma_atype atype = _dma_addr_type(addr); enum dma_atype atype = _dma_addr_type(addr);
return atype == DMA_ATYPE_MEM || atype == DMA_ATYPE_PER; return atype == DMA_ATYPE_MEM || atype == DMA_ATYPE_PER;
} }
@ -293,7 +293,7 @@ dma_irq_cause dma_get_irq_cause(dma_dev *dev, dma_channel channel) {
return DMA_TRANSFER_ERROR; return DMA_TRANSFER_ERROR;
} }
void dma_set_mem_addr(dma_dev *dev, dma_channel channel, __io void *addr) { void dma_set_mem_addr(dma_dev *dev, dma_channel channel, __IO void *addr) {
dma_channel_reg_map *chan_regs; dma_channel_reg_map *chan_regs;
ASSERT_FAULT(!dma_is_channel_enabled(dev, channel)); ASSERT_FAULT(!dma_is_channel_enabled(dev, channel));
@ -302,7 +302,7 @@ void dma_set_mem_addr(dma_dev *dev, dma_channel channel, __io void *addr) {
chan_regs->CMAR = (uint32)addr; chan_regs->CMAR = (uint32)addr;
} }
void dma_set_per_addr(dma_dev *dev, dma_channel channel, __io void *addr) { void dma_set_per_addr(dma_dev *dev, dma_channel channel, __IO void *addr) {
dma_channel_reg_map *chan_regs; dma_channel_reg_map *chan_regs;
ASSERT_FAULT(!dma_is_channel_enabled(dev, channel)); ASSERT_FAULT(!dma_is_channel_enabled(dev, channel));
@ -341,12 +341,11 @@ void dma_set_per_addr(dma_dev *dev, dma_channel channel, __io void *addr) {
* @see dma_attach_interrupt() * @see dma_attach_interrupt()
* @see dma_enable() * @see dma_enable()
*/ */
__deprecated
void dma_setup_transfer(dma_dev *dev, void dma_setup_transfer(dma_dev *dev,
dma_channel channel, dma_channel channel,
__io void *peripheral_address, __IO void *peripheral_address,
dma_xfer_size peripheral_size, dma_xfer_size peripheral_size,
__io void *memory_address, __IO void *memory_address,
dma_xfer_size memory_size, dma_xfer_size memory_size,
uint32 mode) { uint32 mode) {
dma_channel_reg_map *channel_regs = dma_channel_regs(dev, channel); dma_channel_reg_map *channel_regs = dma_channel_regs(dev, channel);
@ -361,48 +360,48 @@ void dma_setup_transfer(dma_dev *dev,
* IRQ handlers * IRQ handlers
*/ */
void __irq_dma1_channel1(void) { __weak void __irq_dma1_channel1(void) {
dma_irq_handler(DMA1, DMA_CH1); dma_irq_handler(DMA1, DMA_CH1);
} }
void __irq_dma1_channel2(void) { __weak void __irq_dma1_channel2(void) {
dma_irq_handler(DMA1, DMA_CH2); dma_irq_handler(DMA1, DMA_CH2);
} }
void __irq_dma1_channel3(void) { __weak void __irq_dma1_channel3(void) {
dma_irq_handler(DMA1, DMA_CH3); dma_irq_handler(DMA1, DMA_CH3);
} }
void __irq_dma1_channel4(void) { __weak void __irq_dma1_channel4(void) {
dma_irq_handler(DMA1, DMA_CH4); dma_irq_handler(DMA1, DMA_CH4);
} }
void __irq_dma1_channel5(void) { __weak void __irq_dma1_channel5(void) {
dma_irq_handler(DMA1, DMA_CH5); dma_irq_handler(DMA1, DMA_CH5);
} }
void __irq_dma1_channel6(void) { __weak void __irq_dma1_channel6(void) {
dma_irq_handler(DMA1, DMA_CH6); dma_irq_handler(DMA1, DMA_CH6);
} }
void __irq_dma1_channel7(void) { __weak void __irq_dma1_channel7(void) {
dma_irq_handler(DMA1, DMA_CH7); dma_irq_handler(DMA1, DMA_CH7);
} }
#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) #if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
void __irq_dma2_channel1(void) { __weak void __irq_dma2_channel1(void) {
dma_irq_handler(DMA2, DMA_CH1); dma_irq_handler(DMA2, DMA_CH1);
} }
void __irq_dma2_channel2(void) { __weak void __irq_dma2_channel2(void) {
dma_irq_handler(DMA2, DMA_CH2); dma_irq_handler(DMA2, DMA_CH2);
} }
void __irq_dma2_channel3(void) { __weak void __irq_dma2_channel3(void) {
dma_irq_handler(DMA2, DMA_CH3); dma_irq_handler(DMA2, DMA_CH3);
} }
void __irq_dma2_channel4_5(void) { __weak void __irq_dma2_channel4_5(void) {
if ((DMA2_BASE->CCR4 & DMA_CCR_EN) && (DMA2_BASE->ISR & DMA_ISR_GIF4)) { if ((DMA2_BASE->CCR4 & DMA_CCR_EN) && (DMA2_BASE->ISR & DMA_ISR_GIF4)) {
dma_irq_handler(DMA2, DMA_CH4); dma_irq_handler(DMA2, DMA_CH4);
} }

View File

@ -41,7 +41,6 @@
# SP--> r0 # SP--> r0
.text .text
.globl __exc_hardfault
.globl __exc_nmi .globl __exc_nmi
.globl __exc_hardfault .globl __exc_hardfault
.globl __exc_memmanage .globl __exc_memmanage

View File

@ -200,7 +200,7 @@ void exti_detach_interrupt(exti_num num) {
* Private routines * Private routines
*/ */
void exti_do_select(__io uint32 *exti_cr, exti_num num, exti_cfg port) { void exti_do_select(__IO uint32 *exti_cr, exti_num num, exti_cfg port) {
uint32 shift = 4 * (num % 4); uint32 shift = 4 * (num % 4);
uint32 cr = *exti_cr; uint32 cr = *exti_cr;
cr &= ~(0xF << shift); cr &= ~(0xF << shift);
@ -212,31 +212,31 @@ void exti_do_select(__io uint32 *exti_cr, exti_num num, exti_cfg port) {
* Interrupt handlers * Interrupt handlers
*/ */
void __irq_exti0(void) { __weak void __irq_exti0(void) {
dispatch_single_exti(EXTI0); dispatch_single_exti(EXTI0);
} }
void __irq_exti1(void) { __weak void __irq_exti1(void) {
dispatch_single_exti(EXTI1); dispatch_single_exti(EXTI1);
} }
void __irq_exti2(void) { __weak void __irq_exti2(void) {
dispatch_single_exti(EXTI2); dispatch_single_exti(EXTI2);
} }
void __irq_exti3(void) { __weak void __irq_exti3(void) {
dispatch_single_exti(EXTI3); dispatch_single_exti(EXTI3);
} }
void __irq_exti4(void) { __weak void __irq_exti4(void) {
dispatch_single_exti(EXTI4); dispatch_single_exti(EXTI4);
} }
void __irq_exti9_5(void) { __weak void __irq_exti9_5(void) {
dispatch_extis(5, 9); dispatch_extis(5, 9);
} }
void __irq_exti15_10(void) { __weak void __irq_exti15_10(void) {
dispatch_extis(10, 15); dispatch_extis(10, 15);
} }

View File

@ -68,7 +68,7 @@ gpio_dev gpiod = {
/** GPIO port D device. */ /** GPIO port D device. */
gpio_dev* const GPIOD = &gpiod; gpio_dev* const GPIOD = &gpiod;
#ifdef STM32_HIGH_DENSITY #if STM32_NR_GPIO_PORTS > 4
gpio_dev gpioe = { gpio_dev gpioe = {
.regs = GPIOE_BASE, .regs = GPIOE_BASE,
.clk_id = RCC_GPIOE, .clk_id = RCC_GPIOE,
@ -106,7 +106,7 @@ void gpio_init_all(void) {
gpio_init(GPIOB); gpio_init(GPIOB);
gpio_init(GPIOC); gpio_init(GPIOC);
gpio_init(GPIOD); gpio_init(GPIOD);
#ifdef STM32_HIGH_DENSITY #if STM32_NR_GPIO_PORTS > 4
gpio_init(GPIOE); gpio_init(GPIOE);
gpio_init(GPIOF); gpio_init(GPIOF);
gpio_init(GPIOG); gpio_init(GPIOG);
@ -123,7 +123,7 @@ void gpio_init_all(void) {
*/ */
void gpio_set_mode(gpio_dev *dev, uint8 pin, gpio_pin_mode mode) { void gpio_set_mode(gpio_dev *dev, uint8 pin, gpio_pin_mode mode) {
gpio_reg_map *regs = dev->regs; gpio_reg_map *regs = dev->regs;
__io uint32 *cr = &regs->CRL + (pin >> 3); __IO uint32 *cr = &regs->CRL + (pin >> 3);
uint32 shift = (pin & 0x7) * 4; uint32 shift = (pin & 0x7) * 4;
uint32 tmp = *cr; uint32 tmp = *cr;
@ -140,9 +140,8 @@ void gpio_set_mode(gpio_dev *dev, uint8 pin, gpio_pin_mode mode) {
gpio_pin_mode gpio_get_mode(gpio_dev *dev, uint8 pin) { gpio_pin_mode gpio_get_mode(gpio_dev *dev, uint8 pin) {
gpio_reg_map *regs = dev->regs; gpio_reg_map *regs = dev->regs;
__io uint32 *cr = &regs->CRL + (pin >> 3); __IO uint32 *cr = &regs->CRL + (pin >> 3);
uint32 shift = (pin & 0x7) * 4; uint32 shift = (pin & 0x7) * 4;
uint32 tmp = *cr;
uint32 crMode = (*cr>>shift) & 0x0F; uint32 crMode = (*cr>>shift) & 0x0F;

View File

@ -324,7 +324,7 @@ void _i2c_irq_handler(i2c_dev *dev) {
/* /*
* EV6: Slave address sent * EV6: Slave address sent
*/ */
if (sr1 & I2C_SR1_ADDR) { if (sr1 & (I2C_SR1_ADDR|I2C_SR1_ADD10)) {
/* /*
* Special case event EV6_1 for master receiver. * Special case event EV6_1 for master receiver.
* Generate NACK and restart/stop condition after ADDR * Generate NACK and restart/stop condition after ADDR

View File

@ -76,19 +76,19 @@ void i2c_master_release_bus(const i2c_dev *dev) {
* IRQ handlers * IRQ handlers
*/ */
void __irq_i2c1_ev(void) { __weak void __irq_i2c1_ev(void) {
_i2c_irq_handler(I2C1); _i2c_irq_handler(I2C1);
} }
void __irq_i2c2_ev(void) { __weak void __irq_i2c2_ev(void) {
_i2c_irq_handler(I2C2); _i2c_irq_handler(I2C2);
} }
void __irq_i2c1_er(void) { __weak void __irq_i2c1_er(void) {
_i2c_irq_error_handler(I2C1); _i2c_irq_error_handler(I2C1);
} }
void __irq_i2c2_er(void) { __weak void __irq_i2c2_er(void) {
_i2c_irq_error_handler(I2C2); _i2c_irq_error_handler(I2C2);
} }

View File

@ -94,8 +94,8 @@ void rcc_switch_sysclk(rcc_sysclk_src sysclk_src) {
* won't work for you. */ * won't work for you. */
/* Returns the RCC register which controls the clock source. */ /* Returns the RCC register which controls the clock source. */
static inline __io uint32* rcc_clk_reg(rcc_clk clock) { static inline __IO uint32* rcc_clk_reg(rcc_clk clock) {
return (__io uint32*)((__io uint8*)RCC_BASE + (clock >> 8)); return (__IO uint32*)((__IO uint8*)RCC_BASE + (clock >> 8));
} }
/* Returns a mask in rcc_clk_reg(clock) to be used for turning the /* Returns a mask in rcc_clk_reg(clock) to be used for turning the

View File

@ -69,10 +69,12 @@ const struct rcc_dev_info rcc_dev_table[] = {
[RCC_FLITF] = { .clk_domain = AHB, .line_num = 4}, [RCC_FLITF] = { .clk_domain = AHB, .line_num = 4},
[RCC_SRAM] = { .clk_domain = AHB, .line_num = 2}, [RCC_SRAM] = { .clk_domain = AHB, .line_num = 2},
[RCC_USB] = { .clk_domain = APB1, .line_num = 23}, [RCC_USB] = { .clk_domain = APB1, .line_num = 23},
#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) #if STM32_NR_GPIO_PORTS > 4
[RCC_GPIOE] = { .clk_domain = APB2, .line_num = 6 }, [RCC_GPIOE] = { .clk_domain = APB2, .line_num = 6 },
[RCC_GPIOF] = { .clk_domain = APB2, .line_num = 7 }, [RCC_GPIOF] = { .clk_domain = APB2, .line_num = 7 },
[RCC_GPIOG] = { .clk_domain = APB2, .line_num = 8 }, [RCC_GPIOG] = { .clk_domain = APB2, .line_num = 8 },
#endif
#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
[RCC_UART4] = { .clk_domain = APB1, .line_num = 19 }, [RCC_UART4] = { .clk_domain = APB1, .line_num = 19 },
[RCC_UART5] = { .clk_domain = APB1, .line_num = 20 }, [RCC_UART5] = { .clk_domain = APB1, .line_num = 20 },
[RCC_TIMER5] = { .clk_domain = APB1, .line_num = 3 }, [RCC_TIMER5] = { .clk_domain = APB1, .line_num = 3 },
@ -132,11 +134,17 @@ void rcc_configure_pll(rcc_pll_cfg *pll_cfg) {
cfgr &= ~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLMUL); cfgr &= ~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLMUL);
cfgr |= pll_cfg->pllsrc | pll_mul; cfgr |= pll_cfg->pllsrc | pll_mul;
#ifdef XTAL16M
// 16MHz crystal (HSE)
// in this case we additionally set the Bit 17 (PLLXTPRE=1) => then HSE clock is divided by 2 before PLL entry
cfgr |= RCC_CFGR_PLLXTPRE;
#endif
RCC_BASE->CFGR = cfgr; RCC_BASE->CFGR = cfgr;
} }
void rcc_clk_enable(rcc_clk_id id) { void rcc_clk_enable(rcc_clk_id id) {
static __io uint32* enable_regs[] = { static __IO uint32* enable_regs[] = {
[APB1] = &RCC_BASE->APB1ENR, [APB1] = &RCC_BASE->APB1ENR,
[APB2] = &RCC_BASE->APB2ENR, [APB2] = &RCC_BASE->APB2ENR,
[AHB] = &RCC_BASE->AHBENR, [AHB] = &RCC_BASE->AHBENR,
@ -145,7 +153,7 @@ void rcc_clk_enable(rcc_clk_id id) {
} }
void rcc_reset_dev(rcc_clk_id id) { void rcc_reset_dev(rcc_clk_id id) {
static __io uint32* reset_regs[] = { static __IO uint32* reset_regs[] = {
[APB1] = &RCC_BASE->APB1RSTR, [APB1] = &RCC_BASE->APB1RSTR,
[APB2] = &RCC_BASE->APB2RSTR, [APB2] = &RCC_BASE->APB2RSTR,
}; };
@ -164,7 +172,7 @@ void rcc_set_prescaler(rcc_prescaler prescaler, uint32 divider) {
} }
void rcc_clk_disable(rcc_clk_id id) { void rcc_clk_disable(rcc_clk_id id) {
static __io uint32* enable_regs[] = { static __IO uint32* enable_regs[] = {
[APB1] = &RCC_BASE->APB1ENR, [APB1] = &RCC_BASE->APB1ENR,
[APB2] = &RCC_BASE->APB2ENR, [APB2] = &RCC_BASE->APB2ENR,
[AHB] = &RCC_BASE->AHBENR, [AHB] = &RCC_BASE->AHBENR,

View File

@ -84,7 +84,7 @@ void spi_slave_enable(spi_dev *dev, spi_mode mode, uint32 flags) {
} }
/** /**
* @brief Nonblocking SPI transmit. * @brief Blocking SPI transmit.
* @param dev SPI port to use for transmission * @param dev SPI port to use for transmission
* @param buf Buffer to transmit. The sizeof buf's elements are * @param buf Buffer to transmit. The sizeof buf's elements are
* inferred from dev's data frame format (i.e., are * inferred from dev's data frame format (i.e., are
@ -93,15 +93,21 @@ void spi_slave_enable(spi_dev *dev, spi_mode mode, uint32 flags) {
* @return Number of elements transmitted. * @return Number of elements transmitted.
*/ */
uint32 spi_tx(spi_dev *dev, const void *buf, uint32 len) { uint32 spi_tx(spi_dev *dev, const void *buf, uint32 len) {
uint32 txed = 0; uint32 txed = len;
uint8 byte_frame = spi_dff(dev) == SPI_DFF_8_BIT; spi_reg_map *regs = dev->regs;
while (spi_is_tx_empty(dev) && (txed < len)) { if ( spi_dff(dev) == SPI_DFF_8_BIT ) {
if (byte_frame) { const uint8 * dp8 = (const uint8*)buf;
dev->regs->DR = ((const uint8*)buf)[txed++]; while ( len-- ) {
} else { while ( (regs->SR & SPI_SR_TXE)==0 ) ; //while ( spi_is_tx_empty(dev)==0 ); // wait Tx to be empty
dev->regs->DR = ((const uint16*)buf)[txed++]; regs->DR = *dp8++;
} }
} } else {
const uint16 * dp16 = (const uint16*)buf;
while ( len-- ) {
while ( (regs->SR & SPI_SR_TXE)==0 ) ; //while ( spi_is_tx_empty(dev)==0 ); // wait Tx to be empty
regs->DR = *dp16++;
}
}
return txed; return txed;
} }

View File

@ -54,7 +54,7 @@ spi_dev *SPI3 = &spi3;
* Routines * Routines
*/ */
void spi_config_gpios(spi_dev *ignored, void spi_config_gpios(spi_dev *ignored __attribute__((unused)),
uint8 as_master, uint8 as_master,
gpio_dev *nss_dev, gpio_dev *nss_dev,
uint8 nss_bit, uint8 nss_bit,

View File

@ -76,9 +76,9 @@ __default_handler:
.weak __exc_pendsv .weak __exc_pendsv
.globl __exc_pendsv .globl __exc_pendsv
.set __exc_pendsv, __default_handler .set __exc_pendsv, __default_handler
.weak __exc_systick // .weak __exc_systick // __exc_systick() defined in STM32F1/cores/maple/libmaple/systick.c
.globl __exc_systick // .globl __exc_systick
.set __exc_systick, __default_handler // .set __exc_systick, __default_handler
.weak __irq_wwdg .weak __irq_wwdg
.globl __irq_wwdg .globl __irq_wwdg
.set __irq_wwdg, __default_handler .set __irq_wwdg, __default_handler
@ -97,110 +97,110 @@ __default_handler:
.weak __irq_rcc .weak __irq_rcc
.globl __irq_rcc .globl __irq_rcc
.set __irq_rcc, __default_handler .set __irq_rcc, __default_handler
.weak __irq_exti0 // .weak __irq_exti0 // __irq_exti0() defined in STM32F1/cores/maple/libmaple/exti.c
.globl __irq_exti0 // .globl __irq_exti0
.set __irq_exti0, __default_handler // .set __irq_exti0, __default_handler
.weak __irq_exti1 // .weak __irq_exti1 // __irq_exti1() defined in STM32F1/cores/maple/libmaple/exti.c
.globl __irq_exti1 // .globl __irq_exti1
.set __irq_exti1, __default_handler // .set __irq_exti1, __default_handler
.weak __irq_exti2 // .weak __irq_exti2 // __irq_exti2() defined in STM32F1/cores/maple/libmaple/exti.c
.globl __irq_exti2 // .globl __irq_exti2
.set __irq_exti2, __default_handler // .set __irq_exti2, __default_handler
.weak __irq_exti3 // .weak __irq_exti3 // __irq_exti3() defined in STM32F1/cores/maple/libmaple/exti.c
.globl __irq_exti3 // .globl __irq_exti3
.set __irq_exti3, __default_handler // .set __irq_exti3, __default_handler
.weak __irq_exti4 // .weak __irq_exti4 // __irq_exti4() defined in STM32F1/cores/maple/libmaple/exti.c
.globl __irq_exti4 // .globl __irq_exti4
.set __irq_exti4, __default_handler // .set __irq_exti4, __default_handler
.weak __irq_dma1_channel1 // .weak __irq_dma1_channel1 // __irq_dma1_channel1() defined in STM32F1/cores/maple/libmaple/dma_f1.c
.globl __irq_dma1_channel1 // .globl __irq_dma1_channel1
.set __irq_dma1_channel1, __default_handler // .set __irq_dma1_channel1, __default_handler
.weak __irq_dma1_channel2 // .weak __irq_dma1_channel2 // __irq_dma1_channel2() defined in STM32F1/cores/maple/libmaple/dma_f1.c
.globl __irq_dma1_channel2 // .globl __irq_dma1_channel2
.set __irq_dma1_channel2, __default_handler // .set __irq_dma1_channel2, __default_handler
.weak __irq_dma1_channel3 // .weak __irq_dma1_channel3 // __irq_dma1_channel3() defined in STM32F1/cores/maple/libmaple/dma_f1.c
.globl __irq_dma1_channel3 // .globl __irq_dma1_channel3
.set __irq_dma1_channel3, __default_handler // .set __irq_dma1_channel3, __default_handler
.weak __irq_dma1_channel4 // .weak __irq_dma1_channel4 // __irq_dma1_channel4() defined in STM32F1/cores/maple/libmaple/dma_f1.c
.globl __irq_dma1_channel4 // .globl __irq_dma1_channel4
.set __irq_dma1_channel4, __default_handler // .set __irq_dma1_channel4, __default_handler
.weak __irq_dma1_channel5 // .weak __irq_dma1_channel5 // __irq_dma1_channel5() defined in STM32F1/cores/maple/libmaple/dma_f1.c
.globl __irq_dma1_channel5 // .globl __irq_dma1_channel5
.set __irq_dma1_channel5, __default_handler // .set __irq_dma1_channel5, __default_handler
.weak __irq_dma1_channel6 // .weak __irq_dma1_channel6 // __irq_dma1_channel6() defined in STM32F1/cores/maple/libmaple/dma_f1.c
.globl __irq_dma1_channel6 // .globl __irq_dma1_channel6
.set __irq_dma1_channel6, __default_handler // .set __irq_dma1_channel6, __default_handler
.weak __irq_dma1_channel7 // .weak __irq_dma1_channel7 // __irq_dma1_channel7() defined in STM32F1/cores/maple/libmaple/dma_f1.c
.globl __irq_dma1_channel7 // .globl __irq_dma1_channel7
.set __irq_dma1_channel7, __default_handler // .set __irq_dma1_channel7, __default_handler
.weak __irq_adc // .weak __irq_adc // __irq_adc() defined in STM32F1/cores/maple/libmaple/adc_f1.c
.globl __irq_adc // .globl __irq_adc
.set __irq_adc, __default_handler // .set __irq_adc, __default_handler
.weak __irq_usb_hp_can_tx .weak __irq_usb_hp_can_tx
.globl __irq_usb_hp_can_tx .globl __irq_usb_hp_can_tx
.set __irq_usb_hp_can_tx, __default_handler .set __irq_usb_hp_can_tx, __default_handler
.weak __irq_usb_lp_can_rx0 // .weak __irq_usb_lp_can_rx0 // __irq_usb_lp_can_rx0() defined in STM32F1/cores/maple/libmaple/usb/stm32f1/usb.c
.globl __irq_usb_lp_can_rx0 // .globl __irq_usb_lp_can_rx0
.set __irq_usb_lp_can_rx0, __default_handler // .set __irq_usb_lp_can_rx0, __default_handler
.weak __irq_can_rx1 .weak __irq_can_rx1
.globl __irq_can_rx1 .globl __irq_can_rx1
.set __irq_can_rx1, __default_handler .set __irq_can_rx1, __default_handler
.weak __irq_can_sce .weak __irq_can_sce
.globl __irq_can_sce .globl __irq_can_sce
.set __irq_can_sce, __default_handler .set __irq_can_sce, __default_handler
.weak __irq_exti9_5 // .weak __irq_exti9_5 // __irq_exti9_5() defined in STM32F1/cores/maple/libmaple/exti.c
.globl __irq_exti9_5 // .globl __irq_exti9_5
.set __irq_exti9_5, __default_handler // .set __irq_exti9_5, __default_handler
.weak __irq_tim1_brk // .weak __irq_tim1_brk // __irq_tim1_brk() defined in STM32F1/cores/maple/libmaple/timer.c
.globl __irq_tim1_brk // .globl __irq_tim1_brk
.set __irq_tim1_brk, __default_handler // .set __irq_tim1_brk, __default_handler
.weak __irq_tim1_up // .weak __irq_tim1_up // __irq_tim1_up() defined in STM32F1/cores/maple/libmaple/timer.c
.globl __irq_tim1_up // .globl __irq_tim1_up
.set __irq_tim1_up, __default_handler // .set __irq_tim1_up, __default_handler
.weak __irq_tim1_trg_com // .weak __irq_tim1_trg_com // __irq_tim1_trg_com() defined in STM32F1/cores/maple/libmaple/timer.c
.globl __irq_tim1_trg_com // .globl __irq_tim1_trg_com
.set __irq_tim1_trg_com, __default_handler // .set __irq_tim1_trg_com, __default_handler
.weak __irq_tim1_cc // .weak __irq_tim1_cc // __irq_tim1_cc() defined in STM32F1/cores/maple/libmaple/timer.c
.globl __irq_tim1_cc // .globl __irq_tim1_cc
.set __irq_tim1_cc, __default_handler // .set __irq_tim1_cc, __default_handler
//
.weakref __irq_tim2, __default_handler // .weakref __irq_tim2, __default_handler // __irq_tim2() defined in STM32F1/cores/maple/libmaple/timer.c
.globl __irq_tim2 // .globl __irq_tim2
.weakref __irq_tim3, __default_handler // .weakref __irq_tim3, __default_handler // __irq_tim3() defined in STM32F1/cores/maple/libmaple/timer.c
.globl __irq_tim3 // .globl __irq_tim3
.weakref __irq_tim4, __default_handler // .weakref __irq_tim4, __default_handler // __irq_tim4() defined in STM32F1/cores/maple/libmaple/timer.c
.globl __irq_tim4 // .globl __irq_tim4
//
.weak __irq_i2c1_ev // .weak __irq_i2c1_ev // __irq_i2c1_ev() defined in STM32F1/cores/maple/libmaple/i2c_f1.c
.globl __irq_i2c1_ev // .globl __irq_i2c1_ev
.set __irq_i2c1_ev, __default_handler // .set __irq_i2c1_ev, __default_handler
.weak __irq_i2c1_er // .weak __irq_i2c1_er // __irq_i2c1_er() defined in STM32F1/cores/maple/libmaple/i2c_f1.c
.globl __irq_i2c1_er // .globl __irq_i2c1_er
.set __irq_i2c1_er, __default_handler // .set __irq_i2c1_er, __default_handler
.weak __irq_i2c2_ev // .weak __irq_i2c2_ev // __irq_i2c2_ev() defined in STM32F1/cores/maple/libmaple/i2c_f1.c
.globl __irq_i2c2_ev // .globl __irq_i2c2_ev
.set __irq_i2c2_ev, __default_handler // .set __irq_i2c2_ev, __default_handler
.weak __irq_i2c2_er // .weak __irq_i2c2_er // __irq_i2c2_er() defined in STM32F1/cores/maple/libmaple/i2c_f1.c
.globl __irq_i2c2_er // .globl __irq_i2c2_er
.set __irq_i2c2_er, __default_handler // .set __irq_i2c2_er, __default_handler
.weak __irq_spi1 .weak __irq_spi1
.globl __irq_spi1 .globl __irq_spi1
.set __irq_spi1, __default_handler .set __irq_spi1, __default_handler
.weak __irq_spi2 .weak __irq_spi2
.globl __irq_spi2 .globl __irq_spi2
.set __irq_spi2, __default_handler .set __irq_spi2, __default_handler
.weak __irq_usart1 // .weak __irq_usart1 // __irq_usart1() defined in STM32F1/cores/maple/libmaple/usart_f1.c
.globl __irq_usart1 // .globl __irq_usart1
.set __irq_usart1, __default_handler // .set __irq_usart1, __default_handler
.weak __irq_usart2 // .weak __irq_usart2 // __irq_usart2() defined in STM32F1/cores/maple/libmaple/usart_f1.c
.globl __irq_usart2 // .globl __irq_usart2
.set __irq_usart2, __default_handler // .set __irq_usart2, __default_handler
.weak __irq_usart3 // .weak __irq_usart3 // __irq_usart3() defined in STM32F1/cores/maple/libmaple/usart_f1.c
.globl __irq_usart3 // .globl __irq_usart3
.set __irq_usart3, __default_handler // .set __irq_usart3, __default_handler
.weak __irq_exti15_10 // .weak __irq_exti15_10 // __irq_exti15_10() defined in STM32F1/cores/maple/libmaple/exti.c
.globl __irq_exti15_10 // .globl __irq_exti15_10
.set __irq_exti15_10, __default_handler // .set __irq_exti15_10, __default_handler
.weak __irq_rtcalarm .weak __irq_rtcalarm
.globl __irq_rtcalarm .globl __irq_rtcalarm
.set __irq_rtcalarm, __default_handler .set __irq_rtcalarm, __default_handler
@ -208,55 +208,55 @@ __default_handler:
.globl __irq_usbwakeup .globl __irq_usbwakeup
.set __irq_usbwakeup, __default_handler .set __irq_usbwakeup, __default_handler
#if defined (STM32_HIGH_DENSITY) #if defined (STM32_HIGH_DENSITY)
.weak __irq_tim8_brk // .weak __irq_tim8_brk // __irq_tim8_brk() defined in STM32F1/cores/maple/libmaple/timer.c
.globl __irq_tim8_brk // .globl __irq_tim8_brk
.set __irq_tim8_brk, __default_handler // .set __irq_tim8_brk, __default_handler
.weak __irq_tim8_up // .weak __irq_tim8_up // __irq_tim8_up() defined in STM32F1/cores/maple/libmaple/timer.c
.globl __irq_tim8_up // .globl __irq_tim8_up
.set __irq_tim8_up, __default_handler // .set __irq_tim8_up, __default_handler
.weak __irq_tim8_trg_com // .weak __irq_tim8_trg_com // __irq_tim8_trg_com() defined in STM32F1/cores/maple/libmaple/timer.c
.globl __irq_tim8_trg_com // .globl __irq_tim8_trg_com
.set __irq_tim8_trg_com, __default_handler // .set __irq_tim8_trg_com, __default_handler
.weak __irq_tim8_cc // .weak __irq_tim8_cc // __irq_tim8_cc() defined in STM32F1/cores/maple/libmaple/timer.c
.globl __irq_tim8_cc // .globl __irq_tim8_cc
.set __irq_tim8_cc, __default_handler // .set __irq_tim8_cc, __default_handler
.weak __irq_adc3 // .weak __irq_adc3 // __irq_adc3() defined in STM32F1/cores/maple/libmaple/adc_f1.c
.globl __irq_adc3 // .globl __irq_adc3
.set __irq_adc3, __default_handler // .set __irq_adc3, __default_handler
.weak __irq_fsmc .weak __irq_fsmc
.globl __irq_fsmc .globl __irq_fsmc
.set __irq_fsmc, __default_handler .set __irq_fsmc, __default_handler
.weak __irq_sdio .weak __irq_sdio
.globl __irq_sdio .globl __irq_sdio
.set __irq_sdio, __default_handler .set __irq_sdio, __default_handler
.weak __irq_tim5 // .weak __irq_tim5 // __irq_tim5() defined in STM32F1/cores/maple/libmaple/timer.c
.globl __irq_tim5 // .globl __irq_tim5
.set __irq_tim5, __default_handler // .set __irq_tim5, __default_handler
.weak __irq_spi3 .weak __irq_spi3
.globl __irq_spi3 .globl __irq_spi3
.set __irq_spi3, __default_handler .set __irq_spi3, __default_handler
.weak __irq_uart4 // .weak __irq_uart4 // __irq_uart4() defined in STM32F1/cores/maple/libmaple/usart_f1.c
.globl __irq_uart4 // .globl __irq_uart4
.set __irq_uart4, __default_handler // .set __irq_uart4, __default_handler
.weak __irq_uart5 // .weak __irq_uart5 // __irq_uart5() defined in STM32F1/cores/maple/libmaple/usart_f1.c
.globl __irq_uart5 // .globl __irq_uart5
.set __irq_uart5, __default_handler // .set __irq_uart5, __default_handler
.weak __irq_tim6 // .weak __irq_tim6 // __irq_tim6() defined in STM32F1/cores/maple/libmaple/timer.c
.globl __irq_tim6 // .globl __irq_tim6
.set __irq_tim6, __default_handler // .set __irq_tim6, __default_handler
.weak __irq_tim7 // .weak __irq_tim7 // __irq_tim7() defined in STM32F1/cores/maple/libmaple/timer.c
.globl __irq_tim7 // .globl __irq_tim7
.set __irq_tim7, __default_handler // .set __irq_tim7, __default_handler
.weak __irq_dma2_channel1 // .weak __irq_dma2_channel1 // __irq_dma2_channel1() defined in STM32F1/cores/maple/libmaple/dma_f1.c
.globl __irq_dma2_channel1 // .globl __irq_dma2_channel1
.set __irq_dma2_channel1, __default_handler // .set __irq_dma2_channel1, __default_handler
.weak __irq_dma2_channel2 // .weak __irq_dma2_channel2 // __irq_dma2_channel2() defined in STM32F1/cores/maple/libmaple/dma_f1.c
.globl __irq_dma2_channel2 // .globl __irq_dma2_channel2
.set __irq_dma2_channel2, __default_handler // .set __irq_dma2_channel2, __default_handler
.weak __irq_dma2_channel3 // .weak __irq_dma2_channel3 // __irq_dma2_channel3() defined in STM32F1/cores/maple/libmaple/dma_f1.c
.globl __irq_dma2_channel3 // .globl __irq_dma2_channel3
.set __irq_dma2_channel3, __default_handler // .set __irq_dma2_channel3, __default_handler
.weak __irq_dma2_channel4_5 // .weak __irq_dma2_channel4_5 // __irq_dma2_channel4_5() defined in STM32F1/cores/maple/libmaple/dma_f1.c
.globl __irq_dma2_channel4_5 // .globl __irq_dma2_channel4_5
.set __irq_dma2_channel4_5, __default_handler // .set __irq_dma2_channel4_5, __default_handler
#endif /* STM32_HIGH_DENSITY */ #endif /* STM32_HIGH_DENSITY */

View File

@ -80,7 +80,7 @@ void systick_attach_callback(void (*callback)(void)) {
* SysTick ISR * SysTick ISR
*/ */
void __exc_systick(void) { __weak void __exc_systick(void) {
systick_uptime_millis++; systick_uptime_millis++;
if (systick_user_callback) { if (systick_user_callback) {
systick_user_callback(); systick_user_callback();

View File

@ -40,7 +40,6 @@ static void pwm_mode(timer_dev *dev, uint8 channel);
static void output_compare_mode(timer_dev *dev, uint8 channel); static void output_compare_mode(timer_dev *dev, uint8 channel);
static void encoder_mode(timer_dev *dev, uint8 channel) ;//CARLOS static void encoder_mode(timer_dev *dev, uint8 channel) ;//CARLOS
static inline void enable_irq(timer_dev *dev, timer_interrupt_id iid); static inline void enable_irq(timer_dev *dev, timer_interrupt_id iid);
/* /*
@ -236,6 +235,9 @@ void timer_set_mode(timer_dev *dev, uint8 channel, timer_mode mode) {
case TIMER_ENCODER: case TIMER_ENCODER:
encoder_mode(dev, channel); //find a way to pass all the needed stuff on the 8bit var encoder_mode(dev, channel); //find a way to pass all the needed stuff on the 8bit var
break; break;
case TIMER_INPUT_CAPTURE:// code from @Cesco
input_capture_mode(dev, channel, TIMER_IC_INPUT_DEFAULT);
break;
} }
} }
@ -327,7 +329,7 @@ static void output_compare_mode(timer_dev *dev, uint8 channel) {
} }
//added by CARLOS. //added by CARLOS.
static void encoder_mode(timer_dev *dev, uint8 channel) { static void encoder_mode(timer_dev *dev, uint8 channel __attribute__((unused))) {
//prescaler. //prescaler.
//(dev->regs).gen->PSC = 1; //(dev->regs).gen->PSC = 1;
@ -349,7 +351,10 @@ static void encoder_mode(timer_dev *dev, uint8 channel) {
timer_resume(dev); timer_resume(dev);
} }
void input_capture_mode(timer_dev *dev, uint8 channel, timer_ic_input_select input) {
timer_oc_set_mode(dev, channel, 0, input);
timer_cc_enable(dev, channel);
}
static void enable_adv_irq(timer_dev *dev, timer_interrupt_id id); static void enable_adv_irq(timer_dev *dev, timer_interrupt_id id);
static void enable_bas_gen_irq(timer_dev *dev); static void enable_bas_gen_irq(timer_dev *dev);
@ -473,78 +478,78 @@ static void enable_bas_gen_irq(timer_dev *dev) {
* file. * file.
*/ */
void __irq_tim1_brk(void) { __weak void __irq_tim1_brk(void) {
dispatch_adv_brk(TIMER1); dispatch_adv_brk(TIMER1);
#if STM32_HAVE_TIMER(9) #if STM32_HAVE_TIMER(9)
dispatch_tim_9_12(TIMER9); dispatch_tim_9_12(TIMER9);
#endif #endif
} }
void __irq_tim1_up(void) { __weak void __irq_tim1_up(void) {
dispatch_adv_up(TIMER1); dispatch_adv_up(TIMER1);
#if STM32_HAVE_TIMER(10) #if STM32_HAVE_TIMER(10)
dispatch_tim_10_11_13_14(TIMER10); dispatch_tim_10_11_13_14(TIMER10);
#endif #endif
} }
void __irq_tim1_trg_com(void) { __weak void __irq_tim1_trg_com(void) {
dispatch_adv_trg_com(TIMER1); dispatch_adv_trg_com(TIMER1);
#if STM32_HAVE_TIMER(11) #if STM32_HAVE_TIMER(11)
dispatch_tim_10_11_13_14(TIMER11); dispatch_tim_10_11_13_14(TIMER11);
#endif #endif
} }
void __irq_tim1_cc(void) { __weak void __irq_tim1_cc(void) {
dispatch_adv_cc(TIMER1); dispatch_adv_cc(TIMER1);
} }
void __irq_tim2(void) { __weak void __irq_tim2(void) {
dispatch_general(TIMER2); dispatch_general(TIMER2);
} }
void __irq_tim3(void) { __weak void __irq_tim3(void) {
dispatch_general(TIMER3); dispatch_general(TIMER3);
} }
void __irq_tim4(void) { __weak void __irq_tim4(void) {
dispatch_general(TIMER4); dispatch_general(TIMER4);
} }
#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) #if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
void __irq_tim5(void) { __weak void __irq_tim5(void) {
dispatch_general(TIMER5); dispatch_general(TIMER5);
} }
void __irq_tim6(void) { __weak void __irq_tim6(void) {
dispatch_basic(TIMER6); dispatch_basic(TIMER6);
} }
void __irq_tim7(void) { __weak void __irq_tim7(void) {
dispatch_basic(TIMER7); dispatch_basic(TIMER7);
} }
void __irq_tim8_brk(void) { __weak void __irq_tim8_brk(void) {
dispatch_adv_brk(TIMER8); dispatch_adv_brk(TIMER8);
#if STM32_HAVE_TIMER(12) #if STM32_HAVE_TIMER(12)
dispatch_tim_9_12(TIMER12); dispatch_tim_9_12(TIMER12);
#endif #endif
} }
void __irq_tim8_up(void) { __weak void __irq_tim8_up(void) {
dispatch_adv_up(TIMER8); dispatch_adv_up(TIMER8);
#if STM32_HAVE_TIMER(13) #if STM32_HAVE_TIMER(13)
dispatch_tim_10_11_13_14(TIMER13); dispatch_tim_10_11_13_14(TIMER13);
#endif #endif
} }
void __irq_tim8_trg_com(void) { __weak void __irq_tim8_trg_com(void) {
dispatch_adv_trg_com(TIMER8); dispatch_adv_trg_com(TIMER8);
#if STM32_HAVE_TIMER(14) #if STM32_HAVE_TIMER(14)
dispatch_tim_10_11_13_14(TIMER14); dispatch_tim_10_11_13_14(TIMER14);
#endif #endif
} }
void __irq_tim8_cc(void) { __weak void __irq_tim8_cc(void) {
dispatch_adv_cc(TIMER8); dispatch_adv_cc(TIMER8);
} }
#endif /* defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) */ #endif /* defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) */

View File

@ -200,24 +200,24 @@ void usart_foreach(void (*fn)(usart_dev*)) {
* Interrupt handlers. * Interrupt handlers.
*/ */
void __irq_usart1(void) { __weak void __irq_usart1(void) {
usart_irq(&usart1_rb, &usart1_wb, USART1_BASE); usart_irq(&usart1_rb, &usart1_wb, USART1_BASE);
} }
void __irq_usart2(void) { __weak void __irq_usart2(void) {
usart_irq(&usart2_rb, &usart2_wb, USART2_BASE); usart_irq(&usart2_rb, &usart2_wb, USART2_BASE);
} }
void __irq_usart3(void) { __weak void __irq_usart3(void) {
usart_irq(&usart3_rb, &usart3_wb, USART3_BASE); usart_irq(&usart3_rb, &usart3_wb, USART3_BASE);
} }
#ifdef STM32_HIGH_DENSITY #ifdef STM32_HIGH_DENSITY
void __irq_uart4(void) { __weak void __irq_uart4(void) {
usart_irq(&uart4_rb, &uart4_wb, UART4_BASE); usart_irq(&uart4_rb, &uart4_wb, UART4_BASE);
} }
void __irq_uart5(void) { __weak void __irq_uart5(void) {
usart_irq(&uart5_rb, &uart5_wb, UART5_BASE); usart_irq(&uart5_rb, &uart5_wb, UART5_BASE);
} }
#endif #endif

View File

@ -120,6 +120,12 @@ static void usb_suspend(void) {
USBLIB->state = USB_SUSPENDED; USBLIB->state = USB_SUSPENDED;
} }
void usb_power_off(void) {
USB_BASE->CNTR = USB_CNTR_FRES;
USB_BASE->ISTR = 0;
USB_BASE->CNTR = USB_CNTR_FRES + USB_CNTR_PDWN;
}
static void usb_resume_init(void) { static void usb_resume_init(void) {
uint16 cntr; uint16 cntr;
@ -184,7 +190,7 @@ static void usb_resume(RESUME_STATE eResumeSetVal) {
} }
#define SUSPEND_ENABLED 1 #define SUSPEND_ENABLED 1
void __irq_usb_lp_can_rx0(void) { __weak void __irq_usb_lp_can_rx0(void) {
uint16 istr = USB_BASE->ISTR; uint16 istr = USB_BASE->ISTR;
/* Use USB_ISR_MSK to only include code for bits we care about. */ /* Use USB_ISR_MSK to only include code for bits we care about. */
@ -268,6 +274,7 @@ static void handle_out0(void);
static void dispatch_ctr_lp() { static void dispatch_ctr_lp() {
uint16 istr; uint16 istr;
while (((istr = USB_BASE->ISTR) & USB_ISTR_CTR) != 0) { while (((istr = USB_BASE->ISTR) & USB_ISTR_CTR) != 0) {
/* TODO WTF, figure this out: RM0008 says CTR is read-only, /* TODO WTF, figure this out: RM0008 says CTR is read-only,
* but ST's firmware claims it's clear-only, and emphasizes * but ST's firmware claims it's clear-only, and emphasizes
@ -288,6 +295,7 @@ static void dispatch_ctr_lp() {
} }
} }
/* FIXME Dataflow on endpoint 0 RX/TX status is based off of ST's /* FIXME Dataflow on endpoint 0 RX/TX status is based off of ST's
* code, and is ugly/confusing in its use of SaveRState/SaveTState. * code, and is ugly/confusing in its use of SaveRState/SaveTState.
* Fixing this requires filling in handle_in0(), handle_setup0(), * Fixing this requires filling in handle_in0(), handle_setup0(),

View File

@ -62,8 +62,8 @@
#if !(defined(BOARD_maple) || defined(BOARD_maple_RET6) || \ #if !(defined(BOARD_maple) || defined(BOARD_maple_RET6) || \
defined(BOARD_maple_mini) || defined(BOARD_maple_native)) defined(BOARD_maple_mini) || defined(BOARD_maple_native))
#warning USB CDC ACM relies on LeafLabs board-specific configuration.\ //#warning USB CDC ACM relies on LeafLabs board-specific configuration.
You may have problems on non-LeafLabs boards. // You may have problems on non-LeafLabs boards.
#endif #endif
static void vcomDataTxCb(void); static void vcomDataTxCb(void);
@ -80,7 +80,6 @@ static uint8* usbGetConfigDescriptor(uint16 length);
static uint8* usbGetStringDescriptor(uint16 length); static uint8* usbGetStringDescriptor(uint16 length);
static void usbSetConfiguration(void); static void usbSetConfiguration(void);
static void usbSetDeviceAddress(void); static void usbSetDeviceAddress(void);
/* /*
* Descriptors * Descriptors
*/ */
@ -384,10 +383,16 @@ void usb_cdcacm_enable(gpio_dev *disc_dev, uint8 disc_bit) {
/* Present ourselves to the host. Writing 0 to "disc" pin must /* Present ourselves to the host. Writing 0 to "disc" pin must
* pull USB_DP pin up while leaving USB_DM pulled down by the * pull USB_DP pin up while leaving USB_DM pulled down by the
* transceiver. See USB 2.0 spec, section 7.1.7.3. */ * transceiver. See USB 2.0 spec, section 7.1.7.3. */
gpio_set_mode(disc_dev, disc_bit, GPIO_OUTPUT_PP);
gpio_write_bit(disc_dev, disc_bit, 0); if (disc_dev!=NULL)
{
gpio_set_mode(disc_dev, disc_bit, GPIO_OUTPUT_PP);
gpio_write_bit(disc_dev, disc_bit, 0);
}
/* Initialize the USB peripheral. */ /* Initialize the USB peripheral. */
/* One of the callbacks that will automatically happen from this will be to usbInit(),
which will power up the USB peripheral. */
usb_init_usblib(USBLIB, ep_int_in, ep_int_out); usb_init_usblib(USBLIB, ep_int_in, ep_int_out);
} }
@ -395,7 +400,13 @@ void usb_cdcacm_disable(gpio_dev *disc_dev, uint8 disc_bit) {
/* Turn off the interrupt and signal disconnect (see e.g. USB 2.0 /* Turn off the interrupt and signal disconnect (see e.g. USB 2.0
* spec, section 7.1.7.3). */ * spec, section 7.1.7.3). */
nvic_irq_disable(NVIC_USB_LP_CAN_RX0); nvic_irq_disable(NVIC_USB_LP_CAN_RX0);
gpio_write_bit(disc_dev, disc_bit, 1); if (disc_dev!=NULL)
{
gpio_write_bit(disc_dev, disc_bit, 1);
}
/* Powerdown the USB peripheral. It gets powered up again with usbInit(), which
gets called when usb_cdcacm_enable() is called. */
usb_power_off();
} }
void usb_cdcacm_putc(char ch) { void usb_cdcacm_putc(char ch) {
@ -445,6 +456,11 @@ uint8 usb_cdcacm_is_transmitting(void) {
return ( transmitting>0 ? transmitting : 0); return ( transmitting>0 ? transmitting : 0);
} }
int usb_cdcacm_tx_available()
{
return CDC_SERIAL_TX_BUFFER_SIZE - usb_cdcacm_get_pending() - 1;
}
uint16 usb_cdcacm_get_pending(void) { uint16 usb_cdcacm_get_pending(void) {
return (tx_head - tx_tail) & CDC_SERIAL_TX_BUFFER_SIZE_MASK; return (tx_head - tx_tail) & CDC_SERIAL_TX_BUFFER_SIZE_MASK;
} }
@ -637,7 +653,8 @@ static uint8* vcomGetSetLineCoding(uint16 length) {
static void usbInit(void) { static void usbInit(void) {
pInformation->Current_Configuration = 0; pInformation->Current_Configuration = 0;
USB_BASE->CNTR = USB_CNTR_FRES; // Reset and power up the peripheral.
USB_BASE->CNTR = USB_CNTR_FRES;
USBLIB->irq_mask = 0; USBLIB->irq_mask = 0;
USB_BASE->CNTR = USBLIB->irq_mask; USB_BASE->CNTR = USBLIB->irq_mask;

View File

@ -88,7 +88,7 @@ void _fail(const char* file, int line, const char* exp) {
* Provide an __assert_func handler to libc so that calls to assert() * Provide an __assert_func handler to libc so that calls to assert()
* get redirected to _fail. * get redirected to _fail.
*/ */
void __assert_func(const char* file, int line, const char* method, void __assert_func(const char* file, int line, const char* method __attribute__((unused)),
const char* expression) { const char* expression) {
_fail(file, line, expression); _fail(file, line, expression);
} }

View File

@ -0,0 +1,219 @@
/******************************************************************************
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*****************************************************************************/
/**
* @file libmaple/sdio.c
* @author stevstrong
* @brief Secure digital input/output interface.
*/
#include <libmaple/sdio.h>
#include <libmaple/gpio.h>
#include <boards.h>
#include "wirish.h"
//#include <libmaple/libmaple.h>
//#include <libmaple/rcc.h>
//#include <series/gpio.h>
//#include "wirish.h"
//#include "boards.h"
//
#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
sdio_dev * SDIO = SDIO_BASE;
#define DELAY_LONG 20
#define DELAY_SHORT 2
uint8_t dly = DELAY_LONG; // microseconds delay after accessing registers
/*
* SDIO convenience routines
*/
void sdio_gpios_init(void)
{
gpio_set_mode(PIN_MAP[BOARD_SDIO_D0].gpio_device, PIN_MAP[BOARD_SDIO_D0].gpio_bit, GPIO_AF_OUTPUT_PP);
/* gpio_set_mode(PIN_MAP[BOARD_SDIO_D1].gpio_device, PIN_MAP[BOARD_SDIO_D1].gpio_bit, GPIO_AF_OUTPUT_PP);
gpio_set_mode(PIN_MAP[BOARD_SDIO_D2].gpio_device, PIN_MAP[BOARD_SDIO_D2].gpio_bit, GPIO_AF_OUTPUT_PP);
gpio_set_mode(PIN_MAP[BOARD_SDIO_D3].gpio_device, PIN_MAP[BOARD_SDIO_D3].gpio_bit, GPIO_AF_OUTPUT_PP);
*/
gpio_set_mode(PIN_MAP[BOARD_SDIO_D1].gpio_device, PIN_MAP[BOARD_SDIO_D1].gpio_bit, GPIO_INPUT_PU);
gpio_set_mode(PIN_MAP[BOARD_SDIO_D2].gpio_device, PIN_MAP[BOARD_SDIO_D2].gpio_bit, GPIO_INPUT_PU);
gpio_set_mode(PIN_MAP[BOARD_SDIO_D3].gpio_device, PIN_MAP[BOARD_SDIO_D3].gpio_bit, GPIO_INPUT_PU);
gpio_set_mode(PIN_MAP[BOARD_SDIO_CLK].gpio_device, PIN_MAP[BOARD_SDIO_CLK].gpio_bit, GPIO_AF_OUTPUT_PP);
gpio_set_mode(PIN_MAP[BOARD_SDIO_CMD].gpio_device, PIN_MAP[BOARD_SDIO_CMD].gpio_bit, GPIO_AF_OUTPUT_PP);
/*
* Todo just remove it, not needed for F1.
*/
/*
gpio_set_af_mode(BOARD_SDIO_D0, 12);
gpio_set_af_mode(BOARD_SDIO_D1, 12);
gpio_set_af_mode(BOARD_SDIO_D2, 12);
gpio_set_af_mode(BOARD_SDIO_D3, 12);
gpio_set_af_mode(BOARD_SDIO_CLK, 12);
gpio_set_af_mode(BOARD_SDIO_CMD, 12);
*/
}
void sdio_gpios_deinit(void)
{
gpio_set_mode(PIN_MAP[BOARD_SDIO_D0].gpio_device, PIN_MAP[BOARD_SDIO_D0].gpio_bit, GPIO_INPUT_PU);
gpio_set_mode(PIN_MAP[BOARD_SDIO_D1].gpio_device, PIN_MAP[BOARD_SDIO_D1].gpio_bit, GPIO_INPUT_PU);
gpio_set_mode(PIN_MAP[BOARD_SDIO_D2].gpio_device, PIN_MAP[BOARD_SDIO_D2].gpio_bit, GPIO_INPUT_PU);
gpio_set_mode(PIN_MAP[BOARD_SDIO_D3].gpio_device, PIN_MAP[BOARD_SDIO_D3].gpio_bit, GPIO_INPUT_PU);
gpio_set_mode(PIN_MAP[BOARD_SDIO_CLK].gpio_device, PIN_MAP[BOARD_SDIO_CLK].gpio_bit, GPIO_INPUT_PU);
gpio_set_mode(PIN_MAP[BOARD_SDIO_CMD].gpio_device, PIN_MAP[BOARD_SDIO_CMD].gpio_bit, GPIO_INPUT_PU);
/*
* Todo just remove it, not needed for F1.
*/
/*
gpio_set_af_mode(BOARD_SDIO_D0, 0);
gpio_set_af_mode(BOARD_SDIO_D1, 0);
gpio_set_af_mode(BOARD_SDIO_D2, 0);
gpio_set_af_mode(BOARD_SDIO_D3, 0);
gpio_set_af_mode(BOARD_SDIO_CLK, 0);
gpio_set_af_mode(BOARD_SDIO_CMD, 0);
*/
}
/**
* @brief Initialize and reset the SDIO device.
*/
void sdio_init(void)
{
rcc_clk_enable(RCC_SDIO);
rcc_reset_dev(RCC_SDIO);
}
void sdio_power_on(void)
{
SDIO->POWER = SDIO_POWER_PWRCTRL_ON;
// After a data write, data cannot be written to this register for three SDIOCLK clock periods
// plus two PCLK2 clock periods.
delay_us(DELAY_LONG);
}
void sdio_power_off(void)
{
SDIO->POWER = SDIO_POWER_PWRCTRL_OFF;
// After a data write, data cannot be written to this register for three SDIOCLK clock periods
// plus two PCLK2 clock periods.
delay_us(DELAY_LONG);
}
void sdio_set_clock(uint32_t clk)
{
/*
* limit the SDIO master clock to 8/3 of PCLK2.See RM 22.3
* Also limited to no more than 48Mhz
*/
clk = min(clk,(SDIOCLK/3)*8);
clk = min(clk,36000000);
if (clk<1000000) dly = DELAY_LONG;
else dly = DELAY_SHORT;
/*
* round up divider, so we don't run the card over the speed supported.
*/
uint32 div = SDIOCLK/clk + (SDIOCLK % clk != 0) - 2;
sdio_disable();
//Serial.println(div,DEC);
SDIO->CLKCR = (SDIO->CLKCR & (~(SDIO_CLKCR_CLKDIV|SDIO_CLKCR_BYPASS))) | SDIO_CLKCR_PWRSAV | SDIO_CLKCR_HWFC_EN | SDIO_CLKCR_CLKEN | (div & SDIO_CLKCR_CLKDIV);
delay_us(dly);
}
void sdio_set_dbus_width(uint16_t bus_w)
{
SDIO->CLKCR = (SDIO->CLKCR & (~SDIO_CLKCR_WIDBUS)) | bus_w;
gpio_set_mode(PIN_MAP[BOARD_SDIO_D1].gpio_device, PIN_MAP[BOARD_SDIO_D1].gpio_bit, GPIO_AF_OUTPUT_PP);
gpio_set_mode(PIN_MAP[BOARD_SDIO_D2].gpio_device, PIN_MAP[BOARD_SDIO_D2].gpio_bit, GPIO_AF_OUTPUT_PP);
gpio_set_mode(PIN_MAP[BOARD_SDIO_D3].gpio_device, PIN_MAP[BOARD_SDIO_D3].gpio_bit, GPIO_AF_OUTPUT_PP);
delay_us(dly);
}
void sdio_set_dblock_size(uint8_t dbsize)
{
SDIO->DCTRL = (SDIO->DCTRL&(~SDIO_DCTRL_DBLOCKSIZE)) | ((dbsize&0xF)<<4);
delay_us(dly);
}
void sdio_enable(void)
{
SDIO->CLKCR |= SDIO_CLKCR_CLKEN;
delay_us(dly);
}
void sdio_disable(void)
{
SDIO->CLKCR ^= SDIO_CLKCR_CLKEN;
delay_us(dly);
}
/**
* @brief Configure and enable the SDIO device.
*/
void sdio_begin(void)
{
sdio_init();
sdio_power_on();
sdio_gpios_init();
// Set initial SCK rate.
sdio_set_clock(400000);
delay_us(200); // generate 80 pulses at 400kHz
}
/**
* @brief Disables the SDIO device.
*/
void sdio_end(void)
{
while ( sdio_cmd_xfer_ongoing() );
sdio_disable();
sdio_gpios_deinit();
sdio_power_off();
rcc_clk_disable(RCC_SDIO);
}
/**
* @brief Send command by the SDIO device.
*/
uint8_t sdio_cmd_send(uint16_t cmd_index_resp_type, uint32_t arg)
{
uint8_t retries = 10; // in case of errors
do { // retry command if errors detected
// clear interrupt flags - IMPORTANT!!!
SDIO->ICR = SDIO_ICR_CMD_FLAGS;
// write command
SDIO->ARG = arg;
SDIO->CMD = (uint32_t)(SDIO_CMD_CPSMEN | cmd_index_resp_type );
while ( (SDIO->STA&SDIO_STA_CMDACT) ) ; // wait for actual command transfer to finish
// wait for response, if the case
if ( cmd_index_resp_type&(SDIO_CMD_WAIT_SHORT_RESP|SDIO_CMD_WAIT_LONG_RESP) ) {
while ( !(SDIO->STA&(SDIO_STA_CMDREND|SDIO_STA_CMD_ERROR_FLAGS)) ) ;
} else break; // no response required
if ( SDIO->STA&(SDIO_STA_CMDREND|SDIO_STA_CTIMEOUT) )
break; // response received or timeout
// ignore CRC error for CMD5 and ACMD41
if ( ((cmd_index_resp_type&SDIO_CMD_CMDINDEX)==5) || ((cmd_index_resp_type&SDIO_CMD_CMDINDEX)==41) )
break;
} while ( (--retries) );
return (uint8_t)retries;
}
#endif // defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)

View File

@ -1,5 +1,6 @@
#include <wiring_pulse.h> #include <wiring_pulse.h>
#include "boards.h" #include "boards.h"
#include "variant.h"
/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH /* Measures the length (in microseconds) of a pulse on the pin; state is HIGH
* or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds * or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds
* to 3 minutes in length, but must be called at least a few dozen microseconds * to 3 minutes in length, but must be called at least a few dozen microseconds
@ -28,13 +29,13 @@
*/ */
uint32_t pulseIn( uint32_t pin, uint32_t state, uint32_t timeout ) uint32_t pulseIn( uint32_t pin, uint32_t state, uint32_t timeout )
{ {
// cache the port and bit of the pin in order to speed up the // cache the IDR address and bit of the pin in order to speed up the
// pulse width measuring loop and achieve finer resolution. calling // pulse width measuring loop and achieve finer resolution. calling
// digitalRead() instead yields much coarser resolution. // digitalRead() instead yields much coarser resolution.
gpio_dev *dev=PIN_MAP[pin].gpio_device; __IO uint32_t * const idr = portInputRegister(digitalPinToPort(pin));
uint32_t bit = (1U << PIN_MAP[pin].gpio_bit); const uint32_t bit = digitalPinToBitMask(pin);
const uint32_t stateMask = (state ? bit:0);
uint32_t width = 0; // keep initialization out of time critical area uint32_t width = 0; // keep initialization out of time critical area
@ -45,23 +46,23 @@ uint32_t pulseIn( uint32_t pin, uint32_t state, uint32_t timeout )
volatile uint32_t dummyWidth=0; volatile uint32_t dummyWidth=0;
// wait for any previous pulse to end // wait for any previous pulse to end
while ( (dev->regs->IDR & bit) == bit) { while ((*idr & bit) == stateMask) {
if (numloops++ == maxloops) { if (numloops++ == maxloops) {
return 0; return 0;
} }
dummyWidth++; dummyWidth++;
} }
// wait for the pulse to start // wait for the pulse to start
while ((dev->regs->IDR & bit) != bit) { while ((*idr & bit) != stateMask) {
if (numloops++ == maxloops) { if (numloops++ == maxloops) {
return 0; return 0;
} }
dummyWidth++; dummyWidth++;
} }
// wait for the pulse to stop // wait for the pulse to stop
while ((dev->regs->IDR & bit) == bit) { while ((*idr & bit) == stateMask) {
if (numloops++ == maxloops) { if (numloops++ == maxloops) {
return 0; return 0;
} }

View File

@ -37,5 +37,5 @@ void disableDebugPorts(void) {
} }
void enableDebugPorts(void) { void enableDebugPorts(void) {
afio_cfg_debug_ports(AFIO_DEBUG_FULL_SWJ); afio_cfg_debug_ports(AFIO_DEBUG_SW_ONLY);
} }

View File

@ -80,10 +80,13 @@ void pinMode(uint8 pin, WiringPinMode mode) {
gpio_set_mode(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit, outputMode); gpio_set_mode(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit, outputMode);
if (PIN_MAP[pin].timer_device != NULL) { if (PIN_MAP[pin].timer_device != NULL) {
/* Enable/disable timer channels if we're switching into or if ( pwm ) { // we're switching into PWM, enable timer channels
* out of PWM. */
timer_set_mode(PIN_MAP[pin].timer_device, timer_set_mode(PIN_MAP[pin].timer_device,
PIN_MAP[pin].timer_channel, PIN_MAP[pin].timer_channel,
pwm ? TIMER_PWM : TIMER_DISABLED); TIMER_PWM );
} else { // disable channel output in non pwm-Mode
timer_cc_disable(PIN_MAP[pin].timer_device,
PIN_MAP[pin].timer_channel);
}
} }
} }

View File

@ -60,7 +60,7 @@ uint8_t tone_ntimer = TONE_TIMER; // timer used to generate freque
bool tone_state = true; // last pin state for toggling bool tone_state = true; // last pin state for toggling
short tone_pin = -1; // pin for outputting sound short tone_pin = -1; // pin for outputting sound
short tone_freq = 444; // tone frequency (0=pause) short tone_freq = 444; // tone frequency (0=pause)
uint32_t tone_nhw = 0; // tone duration in number of half waves volatile uint32_t tone_nhw = 0; // tone duration in number of half waves
uint16_t tone_tcount = 0; // time between handler calls in 1/36 usec uint16_t tone_tcount = 0; // time between handler calls in 1/36 usec
uint16_t tone_ncount = 0; // handler call between toggling uint16_t tone_ncount = 0; // handler call between toggling
uint16_t tone_n = 0; // remaining handler calls before toggling uint16_t tone_n = 0; // remaining handler calls before toggling
@ -146,12 +146,12 @@ void tone(uint32_t pin, uint32_t freq, uint32_t duration) {
tone_timer->pause(); tone_timer->pause();
if(freq > 0 && duration >0 ){ if(freq > 0){
uint32_t count = (F_CPU/4)/freq; // timer counts per half wave uint32_t count = (F_CPU/4)/freq; // timer counts per half wave
tone_ncount = tone_n = (count>>16)+1; // number of 16-bit count chunk tone_ncount = tone_n = (count>>16)+1; // number of 16-bit count chunk
tone_tcount = count/tone_ncount; // size of count chunk tone_tcount = count/tone_ncount; // size of count chunk
if(duration > 0) // number of half waves to be generated if(duration > 0) // number of half waves to be generated
tone_nhw = ((duration*(freq>0?freq:100))/1000)<<1; tone_nhw = duration*freq*2/1000;
else // no duration specified, continuous sound until noTone() called else // no duration specified, continuous sound until noTone() called
tone_nhw = 0; tone_nhw = 0;
@ -186,6 +186,8 @@ void tone(uint32_t pin, uint32_t freq, uint32_t duration) {
pinMode(tone_pin, INPUT); pinMode(tone_pin, INPUT);
} }
//while(tone_nhw) ; // blocks till duration elapsed
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -37,7 +37,7 @@
#include <libmaple/usb_cdcacm.h> #include <libmaple/usb_cdcacm.h>
#include <libmaple/usb.h> #include <libmaple/usb.h>
#include <libmaple/iwdg.h> #include <libmaple/iwdg.h>
#include <libmaple/bkp.h>
#include "wirish.h" #include "wirish.h"
/* /*
@ -54,6 +54,9 @@ static void ifaceSetupHook(unsigned, void*);
*/ */
#define USB_TIMEOUT 50 #define USB_TIMEOUT 50
#if BOARD_HAVE_SERIALUSB
bool USBSerial::_hasBegun = false;
#endif
USBSerial::USBSerial(void) { USBSerial::USBSerial(void) {
#if !BOARD_HAVE_SERIALUSB #if !BOARD_HAVE_SERIALUSB
@ -62,8 +65,13 @@ USBSerial::USBSerial(void) {
} }
void USBSerial::begin(void) { void USBSerial::begin(void) {
#if BOARD_HAVE_SERIALUSB #if BOARD_HAVE_SERIALUSB
usb_cdcacm_enable(BOARD_USB_DISC_DEV, BOARD_USB_DISC_BIT); if (_hasBegun)
return;
_hasBegun = true;
usb_cdcacm_enable(BOARD_USB_DISC_DEV, (uint8_t)BOARD_USB_DISC_BIT);
usb_cdcacm_set_hooks(USB_CDCACM_HOOK_RX, rxHook); usb_cdcacm_set_hooks(USB_CDCACM_HOOK_RX, rxHook);
usb_cdcacm_set_hooks(USB_CDCACM_HOOK_IFACE_SETUP, ifaceSetupHook); usb_cdcacm_set_hooks(USB_CDCACM_HOOK_IFACE_SETUP, ifaceSetupHook);
#endif #endif
@ -75,6 +83,7 @@ void USBSerial::begin(unsigned long ignoreBaud)
volatile unsigned long removeCompilerWarningsIgnoreBaud=ignoreBaud; volatile unsigned long removeCompilerWarningsIgnoreBaud=ignoreBaud;
ignoreBaud=removeCompilerWarningsIgnoreBaud; ignoreBaud=removeCompilerWarningsIgnoreBaud;
begin();
} }
void USBSerial::begin(unsigned long ignoreBaud, uint8_t ignore) void USBSerial::begin(unsigned long ignoreBaud, uint8_t ignore)
{ {
@ -83,13 +92,16 @@ volatile uint8_t removeCompilerWarningsIgnore=ignore;
ignoreBaud=removeCompilerWarningsIgnoreBaud; ignoreBaud=removeCompilerWarningsIgnoreBaud;
ignore=removeCompilerWarningsIgnore; ignore=removeCompilerWarningsIgnore;
begin();
} }
void USBSerial::end(void) { void USBSerial::end(void) {
#if BOARD_HAVE_SERIALUSB #if BOARD_HAVE_SERIALUSB
usb_cdcacm_disable(BOARD_USB_DISC_DEV, BOARD_USB_DISC_BIT); usb_cdcacm_disable(BOARD_USB_DISC_DEV, (uint8_t)BOARD_USB_DISC_BIT);
usb_cdcacm_remove_hooks(USB_CDCACM_HOOK_RX | USB_CDCACM_HOOK_IFACE_SETUP); usb_cdcacm_remove_hooks(USB_CDCACM_HOOK_RX | USB_CDCACM_HOOK_IFACE_SETUP);
_hasBegun = false;
#endif #endif
} }
size_t USBSerial::write(uint8 ch) { size_t USBSerial::write(uint8 ch) {
@ -107,7 +119,7 @@ size_t n = 0;
size_t USBSerial::write(const uint8 *buf, uint32 len) size_t USBSerial::write(const uint8 *buf, uint32 len)
{ {
size_t n = 0; size_t n = 0;
if (!this->isConnected() || !buf) { if (!(bool) *this || !buf) {
return 0; return 0;
} }
@ -136,6 +148,8 @@ int USBSerial::peek(void)
} }
} }
int USBSerial::availableForWrite(void) { return usb_cdcacm_tx_available(); }
void USBSerial::flush(void) void USBSerial::flush(void)
{ {
/*Roger Clark. Rather slow method. Need to improve this */ /*Roger Clark. Rather slow method. Need to improve this */
@ -156,6 +170,19 @@ uint32 USBSerial::read(uint8 * buf, uint32 len) {
return rxed; return rxed;
} }
size_t USBSerial::readBytes(char *buf, const size_t& len)
{
size_t rxed=0;
unsigned long startMillis;
startMillis = millis();
if (len <= 0) return 0;
do {
rxed += usb_cdcacm_rx((uint8 *)buf + rxed, len - rxed);
if (rxed == len) return rxed;
} while(millis() - startMillis < _timeout);
return rxed;
}
/* Blocks forever until 1 byte is received */ /* Blocks forever until 1 byte is received */
int USBSerial::read(void) { int USBSerial::read(void) {
uint8 b; uint8 b;
@ -178,10 +205,6 @@ uint8 USBSerial::pending(void) {
return usb_cdcacm_get_pending(); return usb_cdcacm_get_pending();
} }
uint8 USBSerial::isConnected(void) {
return usb_is_connected(USBLIB) && usb_is_configured(USBLIB) && usb_cdcacm_get_dtr();
}
uint8 USBSerial::getDTR(void) { uint8 USBSerial::getDTR(void) {
return usb_cdcacm_get_dtr(); return usb_cdcacm_get_dtr();
} }
@ -190,6 +213,10 @@ uint8 USBSerial::getRTS(void) {
return usb_cdcacm_get_rts(); return usb_cdcacm_get_rts();
} }
USBSerial::operator bool() {
return usb_is_connected(USBLIB) && usb_is_configured(USBLIB) && usb_cdcacm_get_dtr();
}
#if BOARD_HAVE_SERIALUSB #if BOARD_HAVE_SERIALUSB
#ifdef SERIAL_USB #ifdef SERIAL_USB
USBSerial Serial; USBSerial Serial;
@ -211,7 +238,7 @@ enum reset_state_t {
static reset_state_t reset_state = DTR_UNSET; static reset_state_t reset_state = DTR_UNSET;
static void ifaceSetupHook(unsigned hook, void *requestvp) { static void ifaceSetupHook(unsigned hook __attribute__((unused)), void *requestvp) {
uint8 request = *(uint8*)requestvp; uint8 request = *(uint8*)requestvp;
// Ignore requests we're not interested in. // Ignore requests we're not interested in.
@ -238,20 +265,12 @@ static void ifaceSetupHook(unsigned hook, void *requestvp) {
break; break;
} }
#endif #endif
#if false
#if defined(BOOTLOADER_robotis)
uint8 dtr = usb_cdcacm_get_dtr();
uint8 rts = usb_cdcacm_get_rts();
if (rts && !dtr) {
reset_state = DTR_NEGEDGE;
}
#endif
if ((usb_cdcacm_get_baud() == 1200) && (reset_state == DTR_NEGEDGE)) { if ((usb_cdcacm_get_baud() == 1200) && (reset_state == DTR_NEGEDGE)) {
iwdg_init(IWDG_PRE_4, 10); iwdg_init(IWDG_PRE_4, 10);
while (1); while (1);
} }
#endif
} }
#define RESET_DELAY 100000 #define RESET_DELAY 100000
@ -262,41 +281,40 @@ static void wait_reset(void) {
} }
#endif #endif
#define STACK_TOP 0x20000800 #define STACK_TOP 0x20000800
#define EXC_RETURN 0xFFFFFFF9 #define EXC_RETURN 0xFFFFFFF9
#define DEFAULT_CPSR 0x61000000 #define DEFAULT_CPSR 0x61000000
static void rxHook(unsigned hook, void *ignored) { static void rxHook(unsigned hook __attribute__((unused)), void *ignored __attribute__((unused))) {
static const uint8 magic[4] = {'1', 'E', 'A', 'F'};
/* FIXME this is mad buggy; we need a new reset sequence. E.g. NAK /* FIXME this is mad buggy; we need a new reset sequence. E.g. NAK
* after each RX means you can't reset if any bytes are waiting. */ * after each RX means you can't reset if any bytes are waiting. */
if (reset_state == DTR_NEGEDGE) { if (reset_state == DTR_NEGEDGE) {
reset_state = DTR_LOW;
if (usb_cdcacm_data_available() >= 4) {
// The magic reset sequence is "1EAF".
#ifdef SERIAL_USB
static const uint8 magic[4] = {'1', 'E', 'A', 'F'};
#else
#if defined(BOOTLOADER_robotis)
static const uint8 magic[4] = {'C', 'M', '9', 'X'};
#else
static const uint8 magic[4] = {'1', 'E', 'A', 'F'};
#endif
#endif
if (usb_cdcacm_data_available() >= 4)
{
uint8 chkBuf[4]; uint8 chkBuf[4];
// Peek at the waiting bytes, looking for reset sequence, // Peek at the waiting bytes, looking for reset sequence,
// bailing on mismatch. // bailing on mismatch.
usb_cdcacm_peek_ex(chkBuf, usb_cdcacm_data_available() - 4, 4); usb_cdcacm_peek_ex(chkBuf, usb_cdcacm_data_available() - 4, 4);
for (unsigned i = 0; i < sizeof(magic); i++) { for (unsigned i = 0; i < sizeof(magic); i++) {
if (chkBuf[i] != magic[i]) { if (chkBuf[i] != magic[i])
{
reset_state = DTR_LOW;
return; return;
} }
} }
#ifdef SERIAL_USB #ifdef SERIAL_USB
// The magic reset sequence is "1EAF".
// Got the magic sequence -> reset, presumably into the bootloader. // Got the magic sequence -> reset, presumably into the bootloader.
// Return address is wait_reset, but we must set the thumb bit. // Return address is wait_reset, but we must set the thumb bit.
bkp_init();
bkp_enable_writes();
bkp_write(10, 0x424C);
bkp_disable_writes();
uintptr_t target = (uintptr_t)wait_reset | 0x1; uintptr_t target = (uintptr_t)wait_reset | 0x1;
asm volatile("mov r0, %[stack_top] \n\t" // Reset stack asm volatile("mov r0, %[stack_top] \n\t" // Reset stack
"mov sp, r0 \n\t" "mov sp, r0 \n\t"
@ -320,15 +338,9 @@ static void rxHook(unsigned hook, void *ignored) {
[cpsr] "r" (DEFAULT_CPSR) [cpsr] "r" (DEFAULT_CPSR)
: "r0", "r1", "r2"); : "r0", "r1", "r2");
#endif #endif
#if defined(BOOTLOADER_robotis)
iwdg_init(IWDG_PRE_4, 10);
#endif
/* Can't happen. */ /* Can't happen. */
ASSERT_FAULT(0); ASSERT_FAULT(0);
} }
} }
} }
#endif // BOARD_HAVE_SERIALUSB
#endif // BOARD_HAVE_SERIALUSB

View File

@ -44,38 +44,51 @@ public:
void begin(void); void begin(void);
// Roger Clark. Added dummy function so that existing Arduino sketches which specify baud rate will compile. // Roger Clark. Added dummy function so that existing Arduino sketches which specify baud rate will compile.
void begin(unsigned long); void begin(unsigned long);
void begin(unsigned long, uint8_t); void begin(unsigned long, uint8_t);
void end(void); void end(void);
operator bool() { return true; } // Roger Clark. This is needed because in cardinfo.ino it does if (!Serial) . It seems to be a work around for the Leonardo that we needed to implement just to be compliant with the API
virtual int available(void);// Changed to virtual virtual int available(void);// Changed to virtual
size_t readBytes(char *buf, const size_t& len);
uint32 read(uint8 * buf, uint32 len); uint32 read(uint8 * buf, uint32 len);
// uint8 read(void); // uint8 read(void);
// Roger Clark. added functions to support Arduino 1.0 API // Roger Clark. added functions to support Arduino 1.0 API
virtual int peek(void); virtual int peek(void);
virtual int read(void); virtual int read(void);
int availableForWrite(void); int availableForWrite(void);
virtual void flush(void); virtual void flush(void);
size_t write(uint8); size_t write(uint8);
size_t write(const char *str); size_t write(const char *str);
size_t write(const uint8*, uint32); size_t write(const uint8*, uint32);
uint8 getRTS(); uint8 getRTS();
uint8 getDTR(); uint8 getDTR();
uint8 isConnected();
uint8 pending(); uint8 pending();
/* SukkoPera: This is the Arduino way to check if an USB CDC serial
* connection is open.
* Used for instance in cardinfo.ino.
*/
operator bool();
/* Old libmaple way to check for serial connection.
*
* Deprecated, use the above.
*/
uint8 isConnected() __attribute__((deprecated("Use !Serial instead"))) { return (bool) *this; }
protected:
static bool _hasBegun;
}; };
#ifdef SERIAL_USB #ifdef SERIAL_USB
extern USBSerial Serial; extern USBSerial Serial;
#endif #endif
#endif #endif

View File

@ -104,5 +104,7 @@ typedef unsigned int word;
#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (F_CPU / 1000L) ) #define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (F_CPU / 1000L) )
#define microsecondsToClockCycles(a) ( (a) * (F_CPU / 1000000L) ) #define microsecondsToClockCycles(a) ( (a) * (F_CPU / 1000000L) )
#define digitalPinToInterrupt(pin) (pin)
#endif #endif

View File

@ -47,3 +47,12 @@ long random(long howsmall, long howbig) {
return random(diff) + howsmall; return random(diff) + howsmall;
} }
extern uint16_t makeWord( uint16_t w )
{
return w ;
}
extern uint16_t makeWord( uint8_t h, uint8_t l )
{
return (h << 8) | l ;
}

View File

@ -33,6 +33,7 @@
#define _WIRISH_WIRISH_MATH_H_ #define _WIRISH_WIRISH_MATH_H_
#include <math.h> #include <math.h>
#include <stdint.h>
/** /**
* @brief Initialize the pseudo-random number generator. * @brief Initialize the pseudo-random number generator.
@ -78,11 +79,12 @@ long random(long min, long max);
* @param toEnd the end of the value's mapped range. * @param toEnd the end of the value's mapped range.
* @return the mapped value. * @return the mapped value.
*/ */
static inline long map(long value, long fromStart, long fromEnd, // Fix by Pito 9/2017
long toStart, long toEnd) { static inline int32_t map(int32_t value, int32_t fromStart, int32_t fromEnd,
return (value - fromStart) * (toEnd - toStart) / (fromEnd - fromStart) + int32_t toStart, int32_t toEnd) {
toStart; return ((int64_t)(value - fromStart) * (toEnd - toStart)) / (fromEnd - fromStart) +
} toStart;
}
#define PI 3.1415926535897932384626433832795 #define PI 3.1415926535897932384626433832795
#define HALF_PI 1.5707963267948966192313216916398 #define HALF_PI 1.5707963267948966192313216916398
@ -161,4 +163,9 @@ double sqrt(double x);
*/ */
double pow(double x, double y); double pow(double x, double y);
extern uint16_t makeWord( uint16_t w ) ;
extern uint16_t makeWord( uint8_t h, uint8_t l ) ;
#define word(...) makeWord(__VA_ARGS__)
#endif #endif

View File

@ -32,11 +32,15 @@
#include <libmaple/libmaple_types.h> #include <libmaple/libmaple_types.h>
#include <libmaple/delay.h> #include <libmaple/delay.h>
#include "Arduino.h"
void delay(unsigned long ms) { void delay(unsigned long ms) {
uint32 start = millis(); uint32 start = millis();
while (millis() - start < ms) do
; {
yield();
}
while (millis() - start < ms);
} }
void delayMicroseconds(uint32 us) { void delayMicroseconds(uint32 us) {

View File

@ -55,7 +55,6 @@ typedef struct stm32_pin_info {
uint8 gpio_bit; /**< Pin's GPIO port bit. */ uint8 gpio_bit; /**< Pin's GPIO port bit. */
uint8 timer_channel; /**< Timer channel, or 0 if none. */ uint8 timer_channel; /**< Timer channel, or 0 if none. */
uint8 adc_channel; /**< Pin ADC channel, or ADCx if none. */ uint8 adc_channel; /**< Pin ADC channel, or ADCx if none. */
uint8 pinMode; /**< mode specific by pinMode call (Roger Clark added to optimize compatibility with Arduino API*/
} stm32_pin_info; } stm32_pin_info;
/** /**

View File

@ -47,7 +47,7 @@ void loop() {
// Prints value unaltered, i.e. the raw binary version of the // Prints value unaltered, i.e. the raw binary version of the
// byte. The serial monitor interprets all bytes as // byte. The serial monitor interprets all bytes as
// ASCII, so 33, the first number, will show up as '!' // ASCII, so 33, the first number, will show up as '!'
Serial.print(thisByte, BYTE); Serial.write(thisByte);
Serial.print(", dec: "); Serial.print(", dec: ");
// Prints value as string as an ASCII-encoded decimal (base 10). // Prints value as string as an ASCII-encoded decimal (base 10).

View File

@ -44,8 +44,8 @@ void loop() {
// Plays a MIDI note. Doesn't check to see that cmd is greater than // Plays a MIDI note. Doesn't check to see that cmd is greater than
// 127, or that data values are less than 127: // 127, or that data values are less than 127:
void noteOn(int cmd, int pitch, int velocity) { void noteOn(int cmd, int pitch, int velocity) {
Serial1.print(cmd, BYTE); Serial1.write(cmd);
Serial1.print(pitch, BYTE); Serial1.write(pitch);
Serial1.print(velocity, BYTE); Serial1.write(velocity);
} }

View File

@ -50,15 +50,15 @@ void loop() {
// read switch, map it to 0 or 255 // read switch, map it to 0 or 255
thirdSensor = map(digitalRead(2), 0, 1, 0, 255); thirdSensor = map(digitalRead(2), 0, 1, 0, 255);
// send sensor values: // send sensor values:
Serial.print(firstSensor, BYTE); Serial.write(firstSensor);
Serial.print(secondSensor, BYTE); Serial.write(secondSensor);
Serial.print(thirdSensor, BYTE); Serial.write(thirdSensor);
} }
} }
void establishContact() { void establishContact() {
while (Serial.available() <= 0) { while (Serial.available() <= 0) {
Serial.print('A', BYTE); // send a capital A Serial.write('A'); // send a capital A
delay(300); delay(300);
} }
} }

View File

@ -26,6 +26,6 @@ void loop() {
// Read from Serial1, send over USB on Maple (or uses hardware serial 1 and hardware serial 2 on non-maple boards: // Read from Serial1, send over USB on Maple (or uses hardware serial 1 and hardware serial 2 on non-maple boards:
if (Serial1.available()) { if (Serial1.available()) {
inByte = Serial1.read(); inByte = Serial1.read();
Serial.print(inByte, BYTE); Serial.write(inByte);
} }
} }

View File

@ -9,27 +9,27 @@
int n = 0; int n = 0;
void setup() { void setup() {
// initialize the digital pin as an output. // initialize the digital pin as an output.
pinMode(33, OUTPUT); pinMode(LED_BUILTIN, OUTPUT);
// Initialize virtual COM over USB on Maple Mini // Initialize virtual COM over USB on Maple Mini
Serial.begin(9600); // BAUD has no effect on USB serial: placeholder for physical UART Serial.begin(9600); // BAUD has no effect on USB serial: placeholder for physical UART
// wait for serial monitor to be connected. // wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) while (!Serial)
{ {
digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off digitalWrite(LED_BUILTIN,!digitalRead(LED_BUILTIN)); // Turn the LED from off to on, or on to off
delay(100); // fast blink delay(100); // fast blink
} }
Serial.println("Blink LED & count Demo"); Serial.println("Blink LED & count Demo");
} }
void loop() { void loop() {
digitalWrite(33, HIGH); // set the LED on digitalWrite(LED_BUILTIN, HIGH); // set the LED on
delay(500); // wait for a second delay(500); // wait for a second
digitalWrite(33, LOW); // set the LED off digitalWrite(LED_BUILTIN, LOW); // set the LED off
Serial.print("Loop #: "); Serial.print("Loop #: ");
n++; n++;
Serial.println(n); Serial.println(n);
delay(500); // wait delay(500); // wait
} }

View File

@ -18,7 +18,7 @@ void setup()
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
Serial.setTimeout(timeoutPeriod); // default is 1 second Serial.setTimeout(timeoutPeriod); // default is 1 second
// wait for serial monitor to be connected. // wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) while (!Serial)
{ {
digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off
delay(100); // fast blink delay(100); // fast blink

View File

@ -19,7 +19,7 @@ void setup()
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
Serial.setTimeout(timeoutPeriod); // default is 1 second Serial.setTimeout(timeoutPeriod); // default is 1 second
// wait for serial monitor to be connected. // wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) while (!Serial)
{ {
digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off
delay(100); // fast blink delay(100); // fast blink

View File

@ -38,7 +38,7 @@ void setup(void)
pinMode(A_RANDOM_ANALOG_PIN, INPUT_ANALOG); pinMode(A_RANDOM_ANALOG_PIN, INPUT_ANALOG);
// wait for serial monitor to be connected. // wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) while (!Serial)
{ {
digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off
delay(100); // fast blink delay(100); // fast blink
@ -48,7 +48,7 @@ void setup(void)
setup_temperature_sensor(); setup_temperature_sensor();
// announce start up // announce start up
if(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())) if(Serial)
Serial.println("Temp mon startup"); Serial.println("Temp mon startup");
} }
@ -69,7 +69,7 @@ void loop(void)
t2 = micros(); t2 = micros();
vsense = adc_read(ADC1, 16); vsense = adc_read(ADC1, 16);
t3 = micros(); t3 = micros();
if(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())) { if(Serial) {
sprintf(buf,"%04x %08x %04x %08x" , vsense, t3-t2, alogpin, t2-t1); sprintf(buf,"%04x %08x %04x %08x" , vsense, t3-t2, alogpin, t2-t1);
Serial.println(buf); Serial.println(buf);
} }

View File

@ -29,7 +29,7 @@ void setup()
pinMode(33, OUTPUT); pinMode(33, OUTPUT);
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
// wait for serial monitor to be connected. // wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) while (!Serial)
{ {
digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off
delay(100); // fast blink delay(100); // fast blink

View File

@ -18,7 +18,7 @@ void setup() {
pinMode(33, OUTPUT); pinMode(33, OUTPUT);
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
// wait for serial monitor to be connected. // wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) while (!Serial)
{ {
digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off
delay(100); // fast blink delay(100); // fast blink

View File

@ -18,7 +18,7 @@ void setup() {
pinMode(33, OUTPUT); pinMode(33, OUTPUT);
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
// wait for serial monitor to be connected. // wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) while (!Serial)
{ {
digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off
delay(100); // fast blink delay(100); // fast blink

View File

@ -15,7 +15,7 @@ void setup()
pinMode(33, OUTPUT); pinMode(33, OUTPUT);
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
// wait for serial monitor to be connected. // wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) while (!Serial)
{ {
digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off
delay(100); // fast blink delay(100); // fast blink

View File

@ -17,7 +17,7 @@ void setup() // run once, when the sketch starts
pinMode(33, OUTPUT); pinMode(33, OUTPUT);
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
// wait for serial monitor to be connected. // wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) while (!Serial)
{ {
digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off
delay(100); // fast blink delay(100); // fast blink

View File

@ -16,7 +16,7 @@ void setup() // run once, when the sketch starts
pinMode(33, OUTPUT); pinMode(33, OUTPUT);
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
// wait for serial monitor to be connected. // wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) while (!Serial)
{ {
digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off
delay(100); // fast blink delay(100); // fast blink

View File

@ -13,7 +13,7 @@ void setup() {
pinMode(33, OUTPUT); pinMode(33, OUTPUT);
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UAR Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UAR
// wait for serial monitor to be connected. // wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) while (!Serial)
{ {
digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off
delay(100); // fast blink delay(100); // fast blink

View File

@ -34,7 +34,7 @@ void setup() {
pinMode(33, OUTPUT); pinMode(33, OUTPUT);
Serial.begin(); // USB does not require BAUD Serial.begin(); // USB does not require BAUD
// wait for serial monitor to be connected. // wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) while (!Serial)
{ {
digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off
delay(100); // fast blink delay(100); // fast blink
@ -67,7 +67,7 @@ void loop() {
// Prints value unaltered, i.e. the raw binary version of the // Prints value unaltered, i.e. the raw binary version of the
// byte. The serial monitor interprets all bytes as // byte. The serial monitor interprets all bytes as
// ASCII, so 33, the first number, will show up as '!' // ASCII, so 33, the first number, will show up as '!'
Serial.print(thisByte, BYTE); Serial.write(thisByte);
Serial.print(", dec: "); Serial.print(", dec: ");
// Prints value as string as an ASCII-encoded decimal (base 10). // Prints value as string as an ASCII-encoded decimal (base 10).

View File

@ -19,7 +19,7 @@ void setup() {
pinMode(33, OUTPUT); pinMode(33, OUTPUT);
Serial.begin(9600); Serial.begin(9600);
// wait for serial monitor to be connected. // wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) while (!Serial)
{ {
digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off
delay(100); // fast blink delay(100); // fast blink

View File

@ -32,24 +32,24 @@ void setup()
pinMode(BUTTON_PIN, INPUT_PULLUP); pinMode(BUTTON_PIN, INPUT_PULLUP);
// Setup LED Timer // Setup LED Timer
Timer2.setChannel1Mode(TIMER_OUTPUTCOMPARE); Timer2.setMode(TIMER_CH1, TIMER_OUTPUTCOMPARE);
Timer2.setPeriod(LED_RATE); // in microseconds Timer2.setPeriod(LED_RATE); // in microseconds
Timer2.setCompare1(1); // overflow might be small Timer2.setCompare(TIMER_CH1, 1); // overflow might be small
Timer2.attachCompare1Interrupt(handler_led); Timer2.attachInterrupt(TIMER_CH1, handler_led);
// Setup Counting Timers // Setup Counting Timers
Timer3.setChannel1Mode(TIMER_OUTPUTCOMPARE); Timer3.setMode(TIMER_CH1, TIMER_OUTPUTCOMPARE);
Timer4.setChannel1Mode(TIMER_OUTPUTCOMPARE); Timer4.setMode(TIMER_CH1, TIMER_OUTPUTCOMPARE);
Timer3.pause(); Timer3.pause();
Timer4.pause(); Timer4.pause();
Timer3.setCount(0); Timer3.setCount(0);
Timer4.setCount(0); Timer4.setCount(0);
Timer3.setOverflow(30000); Timer3.setOverflow(30000);
Timer4.setOverflow(30000); Timer4.setOverflow(30000);
Timer3.setCompare1(1000); // somewhere in the middle Timer3.setCompare(TIMER_CH1, 1000); // somewhere in the middle
Timer4.setCompare1(1000); Timer4.setCompare(TIMER_CH1, 1000);
Timer3.attachCompare1Interrupt(handler1); Timer3.attachInterrupt(TIMER_CH1, handler1);
Timer4.attachCompare1Interrupt(handler2); Timer4.attachInterrupt(TIMER_CH1, handler2);
Timer3.resume(); Timer3.resume();
Timer4.resume(); Timer4.resume();

View File

@ -0,0 +1,67 @@
/*
* Example of the Timer Input Capture mode combined with one pulse mode
*
* This example uses:
* - Timer2 channel 1 as capture input
* - Timer2 channel 2 to generate the pulses,
* - Timer 3 to generate a PWM trigger signal for capture input
*/
#include <Streaming.h>
const uint16_t pulseDelay = 200;
const uint16_t pulseWidth = 200;
//-----------------------------------------------------------------------------
void toggle_led()
{
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
//-----------------------------------------------------------------------------
void setup()
{
// setup PA1 (Timer2 channel 2) to PWM (one pulse mode)
pinMode(PA1, PWM);
// setup PA0 (Timer 2 channel 1) as input (capture input mode)
pinMode(PA0, INPUT);
// stop the timers before configuring them
Timer2.pause();
Timer2.setPrescaleFactor(72); // 1 µs resolution
Timer2.setCompare(TIMER_CH2, pulseDelay);
Timer2.setOverflow(pulseWidth + pulseDelay-1);
// counter setup in one pulse mode, as slave triggered by TI1
TIMER2_BASE->CR1 = ( TIMER_CR1_OPM ); // one pulse mode
Timer2.setSlaveFlags( TIMER_SMCR_TS_TI1FP1 | TIMER_SMCR_SMS_TRIGGER );
// channel 1: capture input on rising edge
Timer2.setMode(TIMER_CH1, TIMER_INPUT_CAPTURE);
//Timer2.setPolarity(TIMER_CH1, 1); // trigger on falling edge
// channel 2: invert polarity (we want low for CNT<CCR2)
Timer2.setPolarity(TIMER_CH2, 1);
// start timer 2
Timer2.refresh();
Timer2.resume(); // let timer 2 run
// setup PA6 (Timer3 channel 1) to generate 1 ms period PWM with 10% DC
pinMode(PA6, PWM);
Timer3.pause();
Timer3.setPrescaleFactor(72); // 1 µs resolution
Timer3.setCompare(TIMER_CH1, 100);
Timer3.setOverflow(1000);
Timer3.refresh();
Timer3.resume(); // let timer 3 run
}
uint32_t t;
//-----------------------------------------------------------------------------
void loop()
{
if ( (millis()-t)>=1000 )
{
t = millis();
toggle_led();
}
}

View File

@ -0,0 +1,77 @@
/*
* Example of the Timer Input Capture mode to measure PWM pulse width and period.
*
* This example uses:
* - Timer2 channel 1 as capture input
* - Timer3 to generate a PWM trigger signal for capture input
*/
#include <Streaming.h>
const uint8_t pwmPulse = 20; // ms
const uint8_t pwmPeriod = 50; // ms
//-----------------------------------------------------------------------------
void toggle_led()
{
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
//-----------------------------------------------------------------------------
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
// setup PA0 (Timer 2 channel 1) as input capture mode
pinMode(PA0, INPUT);
while (!Serial); delay(1000);
Serial << "Example of the Timer Input Capture mode to measure PWM pulse width and period\n\n";
// stop the timers before configuring them
Timer2.pause();
Timer3.pause();
Timer2.setPrescaleFactor(72); // 1 microsecond resolution
// setup timer 2 channel 1 capture on rising edge
Timer2.setInputCaptureMode(TIMER_CH1, TIMER_IC_INPUT_DEFAULT); // use default input TI1
// setup timer 2 channel 2 capture on falling edge
Timer2.setInputCaptureMode(TIMER_CH2, TIMER_IC_INPUT_SWITCH); // use switched input TI1
Timer2.setPolarity(TIMER_CH2, 1); // trigger on falling edge
// counter setup as slave triggered by TI1 in reset mode
Timer2.setSlaveFlags( TIMER_SMCR_TS_TI1FP1 | TIMER_SMCR_SMS_RESET );
Timer2.refresh();
Timer2.getCompare(TIMER_CH1); // clear capture flag
Timer2.getCompare(TIMER_CH2); // clear capture flag
Timer2.resume(); // let timer 2 run
// setup PA6 (Timer3 channel 1) to generate 1 ms period PWM with 10% DC
pinMode(PA6, PWM);
Timer3.setPrescaleFactor(72); // 1 µs resolution
Timer3.setCompare(TIMER_CH1, pwmPulse*1000);
Timer3.setOverflow(pwmPeriod*1000);
Timer3.refresh();
Timer3.resume(); // let timer 3 run
// discard first reading
// wait for first period end
while ( !Timer2.getInputCaptureFlag(TIMER_CH1) );
Timer2.getCompare(TIMER_CH1); // clear capture flag
}
//-----------------------------------------------------------------------------
void loop()
{
if ( Timer2.getInputCaptureFlag(TIMER_CH2) ) // high pulse end
{
Serial << "PWM pulse width: " << Timer2.getCompare(TIMER_CH2);
}
if ( Timer2.getInputCaptureFlag(TIMER_CH1) ) // period end
{
Serial << ", period: " << Timer2.getCompare(TIMER_CH1) << endl;
toggle_led();
//delay(500); // read the values only 2 times per second
}
}

View File

@ -10,3 +10,7 @@
# Constants (LITERAL1) # Constants (LITERAL1)
####################################### #######################################
OUTPUT_OPEN_DRAIN LITERAL1
INPUT_ANALOG LITERAL1
INPUT_PULLDOWN LITERAL1
PWM LITERAL1

View File

@ -59,451 +59,15 @@ POSSIBILITY OF SUCH DAMAGE.
#define pgm_read_byte(addr) (*(const unsigned char *)(addr)) #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#endif #endif
Adafruit_GFX::Adafruit_GFX(int16_t w, int16_t h): Adafruit_GFX_AS::Adafruit_GFX_AS(int16_t w, int16_t h): Adafruit_GFX(w, h)
WIDTH(w), HEIGHT(h)
{ {
_width = WIDTH;
_height = HEIGHT;
rotation = 0;
cursor_y = cursor_x = 0;
textsize = 1;
textcolor = textbgcolor = 0xFFFF;
wrap = true;
}
// Draw a circle outline
void Adafruit_GFX::drawCircle(int16_t x0, int16_t y0, int16_t r,
uint16_t color) {
int16_t f = 1 - r;
int16_t ddF_x = 1;
int16_t ddF_y = -2 * r;
int16_t x = 0;
int16_t y = r;
drawPixel(x0 , y0+r, color);
drawPixel(x0 , y0-r, color);
drawPixel(x0+r, y0 , color);
drawPixel(x0-r, y0 , color);
while (x<y) {
if (f >= 0) {
y--;
ddF_y += 2;
f += ddF_y;
}
x++;
ddF_x += 2;
f += ddF_x;
drawPixel(x0 + x, y0 + y, color);
drawPixel(x0 - x, y0 + y, color);
drawPixel(x0 + x, y0 - y, color);
drawPixel(x0 - x, y0 - y, color);
drawPixel(x0 + y, y0 + x, color);
drawPixel(x0 - y, y0 + x, color);
drawPixel(x0 + y, y0 - x, color);
drawPixel(x0 - y, y0 - x, color);
}
}
void Adafruit_GFX::drawCircleHelper( int16_t x0, int16_t y0,
int16_t r, uint8_t cornername, uint16_t color) {
int16_t f = 1 - r;
int16_t ddF_x = 1;
int16_t ddF_y = -2 * r;
int16_t x = 0;
int16_t y = r;
while (x<y) {
if (f >= 0) {
y--;
ddF_y += 2;
f += ddF_y;
}
x++;
ddF_x += 2;
f += ddF_x;
if (cornername & 0x4) {
drawPixel(x0 + x, y0 + y, color);
drawPixel(x0 + y, y0 + x, color);
}
if (cornername & 0x2) {
drawPixel(x0 + x, y0 - y, color);
drawPixel(x0 + y, y0 - x, color);
}
if (cornername & 0x8) {
drawPixel(x0 - y, y0 + x, color);
drawPixel(x0 - x, y0 + y, color);
}
if (cornername & 0x1) {
drawPixel(x0 - y, y0 - x, color);
drawPixel(x0 - x, y0 - y, color);
}
}
}
void Adafruit_GFX::fillCircle(int16_t x0, int16_t y0, int16_t r,
uint16_t color) {
drawFastVLine(x0, y0-r, 2*r+1, color);
fillCircleHelper(x0, y0, r, 3, 0, color);
}
// Used to do circles and roundrects
void Adafruit_GFX::fillCircleHelper(int16_t x0, int16_t y0, int16_t r,
uint8_t cornername, int16_t delta, uint16_t color) {
int16_t f = 1 - r;
int16_t ddF_x = 1;
int16_t ddF_y = -2 * r;
int16_t x = 0;
int16_t y = r;
while (x<y) {
if (f >= 0) {
y--;
ddF_y += 2;
f += ddF_y;
}
x++;
ddF_x += 2;
f += ddF_x;
if (cornername & 0x1) {
drawFastVLine(x0+x, y0-y, 2*y+1+delta, color);
drawFastVLine(x0+y, y0-x, 2*x+1+delta, color);
}
if (cornername & 0x2) {
drawFastVLine(x0-x, y0-y, 2*y+1+delta, color);
drawFastVLine(x0-y, y0-x, 2*x+1+delta, color);
}
}
}
// Bresenham's algorithm - thx wikpedia
void Adafruit_GFX::drawLine(int16_t x0, int16_t y0,
int16_t x1, int16_t y1,
uint16_t color) {
int16_t steep = abs(y1 - y0) > abs(x1 - x0);
if (steep) {
swap(x0, y0);
swap(x1, y1);
}
if (x0 > x1) {
swap(x0, x1);
swap(y0, y1);
}
int16_t dx, dy;
dx = x1 - x0;
dy = abs(y1 - y0);
int16_t err = dx / 2;
int16_t ystep;
if (y0 < y1) {
ystep = 1;
} else {
ystep = -1;
}
for (; x0<=x1; x0++) {
if (steep) {
drawPixel(y0, x0, color);
} else {
drawPixel(x0, y0, color);
}
err -= dy;
if (err < 0) {
y0 += ystep;
err += dx;
}
}
}
// Draw a rectangle
void Adafruit_GFX::drawRect(int16_t x, int16_t y,
int16_t w, int16_t h,
uint16_t color) {
drawFastHLine(x, y, w, color);
drawFastHLine(x, y+h-1, w, color);
drawFastVLine(x, y, h, color);
drawFastVLine(x+w-1, y, h, color);
}
void Adafruit_GFX::drawFastVLine(int16_t x, int16_t y,
int16_t h, uint16_t color) {
// Update in subclasses if desired!
drawLine(x, y, x, y+h-1, color);
}
void Adafruit_GFX::drawFastHLine(int16_t x, int16_t y,
int16_t w, uint16_t color) {
// Update in subclasses if desired!
drawLine(x, y, x+w-1, y, color);
}
void Adafruit_GFX::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
uint16_t color) {
// Update in subclasses if desired!
for (int16_t i=x; i<x+w; i++) {
drawFastVLine(i, y, h, color);
}
}
void Adafruit_GFX::fillScreen(uint16_t color) {
fillRect(0, 0, _width, _height, color);
}
// Draw a rounded rectangle
void Adafruit_GFX::drawRoundRect(int16_t x, int16_t y, int16_t w,
int16_t h, int16_t r, uint16_t color) {
// smarter version
drawFastHLine(x+r , y , w-2*r, color); // Top
drawFastHLine(x+r , y+h-1, w-2*r, color); // Bottom
drawFastVLine(x , y+r , h-2*r, color); // Left
drawFastVLine(x+w-1, y+r , h-2*r, color); // Right
// draw four corners
drawCircleHelper(x+r , y+r , r, 1, color);
drawCircleHelper(x+w-r-1, y+r , r, 2, color);
drawCircleHelper(x+w-r-1, y+h-r-1, r, 4, color);
drawCircleHelper(x+r , y+h-r-1, r, 8, color);
}
// Fill a rounded rectangle
void Adafruit_GFX::fillRoundRect(int16_t x, int16_t y, int16_t w,
int16_t h, int16_t r, uint16_t color) {
// smarter version
fillRect(x+r, y, w-2*r, h, color);
// draw four corners
fillCircleHelper(x+w-r-1, y+r, r, 1, h-2*r-1, color);
fillCircleHelper(x+r , y+r, r, 2, h-2*r-1, color);
}
// Draw a triangle
void Adafruit_GFX::drawTriangle(int16_t x0, int16_t y0,
int16_t x1, int16_t y1,
int16_t x2, int16_t y2, uint16_t color) {
drawLine(x0, y0, x1, y1, color);
drawLine(x1, y1, x2, y2, color);
drawLine(x2, y2, x0, y0, color);
}
// Fill a triangle
void Adafruit_GFX::fillTriangle ( int16_t x0, int16_t y0,
int16_t x1, int16_t y1,
int16_t x2, int16_t y2, uint16_t color) {
int16_t a, b, y, last;
// Sort coordinates by Y order (y2 >= y1 >= y0)
if (y0 > y1) {
swap(y0, y1); swap(x0, x1);
}
if (y1 > y2) {
swap(y2, y1); swap(x2, x1);
}
if (y0 > y1) {
swap(y0, y1); swap(x0, x1);
}
if(y0 == y2) { // Handle awkward all-on-same-line case as its own thing
a = b = x0;
if(x1 < a) a = x1;
else if(x1 > b) b = x1;
if(x2 < a) a = x2;
else if(x2 > b) b = x2;
drawFastHLine(a, y0, b-a+1, color);
return;
}
int16_t
dx01 = x1 - x0,
dy01 = y1 - y0,
dx02 = x2 - x0,
dy02 = y2 - y0,
dx12 = x2 - x1,
dy12 = y2 - y1,
sa = 0,
sb = 0;
// For upper part of triangle, find scanline crossings for segments
// 0-1 and 0-2. If y1=y2 (flat-bottomed triangle), the scanline y1
// is included here (and second loop will be skipped, avoiding a /0
// error there), otherwise scanline y1 is skipped here and handled
// in the second loop...which also avoids a /0 error here if y0=y1
// (flat-topped triangle).
if(y1 == y2) last = y1; // Include y1 scanline
else last = y1-1; // Skip it
for(y=y0; y<=last; y++) {
a = x0 + sa / dy01;
b = x0 + sb / dy02;
sa += dx01;
sb += dx02;
/* longhand:
a = x0 + (x1 - x0) * (y - y0) / (y1 - y0);
b = x0 + (x2 - x0) * (y - y0) / (y2 - y0);
*/
if(a > b) swap(a,b);
drawFastHLine(a, y, b-a+1, color);
}
// For lower part of triangle, find scanline crossings for segments
// 0-2 and 1-2. This loop is skipped if y1=y2.
sa = dx12 * (y - y1);
sb = dx02 * (y - y0);
for(; y<=y2; y++) {
a = x1 + sa / dy12;
b = x0 + sb / dy02;
sa += dx12;
sb += dx02;
/* longhand:
a = x1 + (x2 - x1) * (y - y1) / (y2 - y1);
b = x0 + (x2 - x0) * (y - y0) / (y2 - y0);
*/
if(a > b) swap(a,b);
drawFastHLine(a, y, b-a+1, color);
}
}
void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
const uint8_t *bitmap, int16_t w, int16_t h,
uint16_t color) {
int16_t i, j, byteWidth = (w + 7) / 8;
for(j=0; j<h; j++) {
for(i=0; i<w; i++ ) {
if(pgm_read_byte(bitmap + j * byteWidth + i / 8) & (128 >> (i & 7))) {
drawPixel(x+i, y+j, color);
}
}
}
}
//#if ARDUINO >= 100
size_t Adafruit_GFX::write(uint8_t c) {
//#else
//void Adafruit_GFX::write(uint8_t c) {
//#endif
if (c == '\n') {
cursor_y += textsize*8;
cursor_x = 0;
} else if (c == '\r') {
// skip em
} else {
drawChar(cursor_x, cursor_y, c, textcolor, textbgcolor, textsize);
cursor_x += textsize*6;
if (wrap && (cursor_x > (_width - textsize*6))) {
cursor_y += textsize*8;
cursor_x = 0;
}
}
//#if ARDUINO >= 100
return 1;
//#endif
}
// Draw a character
void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c,
uint16_t color, uint16_t bg, uint8_t size) {
#ifdef LOAD_GLCD
if((x >= _width) || // Clip right
(y >= _height) || // Clip bottom
((x + 6 * size - 1) < 0) || // Clip left
((y + 8 * size - 1) < 0)) // Clip top
return;
for (int8_t i=0; i<6; i++ ) {
uint8_t line;
if (i == 5)
line = 0x0;
else
line = pgm_read_byte(font+(c*5)+i);
for (int8_t j = 0; j<8; j++) {
if (line & 0x1) {
if (size == 1) // default size
drawPixel(x+i, y+j, color);
else { // big size
fillRect(x+(i*size), y+(j*size), size, size, color);
}
} else if (bg != color) {
if (size == 1) // default size
drawPixel(x+i, y+j, bg);
else { // big size
fillRect(x+i*size, y+j*size, size, size, bg);
}
}
line >>= 1;
}
}
#endif
}
void Adafruit_GFX::setCursor(int16_t x, int16_t y) {
cursor_x = x;
cursor_y = y;
}
void Adafruit_GFX::setTextSize(uint8_t s) {
textsize = (s > 0) ? s : 1;
}
void Adafruit_GFX::setTextColor(uint16_t c) {
// For 'transparent' background, we'll set the bg
// to the same as fg instead of using a flag
textcolor = textbgcolor = c;
}
void Adafruit_GFX::setTextColor(uint16_t c, uint16_t b) {
textcolor = c;
textbgcolor = b;
}
void Adafruit_GFX::setTextWrap(boolean w) {
wrap = w;
}
uint8_t Adafruit_GFX::getRotation(void) {
return rotation;
}
void Adafruit_GFX::setRotation(uint8_t x) {
rotation = (x & 3);
switch(rotation) {
case 0:
case 2:
_width = WIDTH;
_height = HEIGHT;
break;
case 1:
case 3:
_width = HEIGHT;
_height = WIDTH;
break;
}
}
// Return the size of the display (per current rotation)
int16_t Adafruit_GFX::width(void) {
return _width;
}
int16_t Adafruit_GFX::height(void) {
return _height;
}
void Adafruit_GFX::invertDisplay(boolean i) {
// Do nothing, must be subclassed if supported
} }
/*************************************************************************************** /***************************************************************************************
** Function name: drawUnicode ** Function name: drawUnicode
** Descriptions: draw a unicode ** Descriptions: draw a unicode
***************************************************************************************/ ***************************************************************************************/
int16_t Adafruit_GFX::drawUnicode(uint16_t uniCode, int16_t x, int16_t y, int16_t size) int16_t Adafruit_GFX_AS::drawUnicode(uint16_t uniCode, int16_t x, int16_t y, int16_t size)
{ {
if (size) uniCode -= 32; if (size) uniCode -= 32;
@ -615,7 +179,7 @@ return (width+gap)*textsize; // x +
** Function name: drawNumber unsigned with size ** Function name: drawNumber unsigned with size
** Descriptions: drawNumber ** Descriptions: drawNumber
***************************************************************************************/ ***************************************************************************************/
int16_t Adafruit_GFX::drawNumber(long long_num,int16_t poX, int16_t poY, int16_t size) int16_t Adafruit_GFX_AS::drawNumber(long long_num,int16_t poX, int16_t poY, int16_t size)
{ {
char tmp[10]; char tmp[10];
if (long_num < 0) sprintf(tmp, "%li", long_num); if (long_num < 0) sprintf(tmp, "%li", long_num);
@ -627,7 +191,7 @@ int16_t Adafruit_GFX::drawNumber(long long_num,int16_t poX, int16_t poY, int16_t
** Function name: drawChar ** Function name: drawChar
** Descriptions: draw char ** Descriptions: draw char
***************************************************************************************/ ***************************************************************************************/
int16_t Adafruit_GFX::drawChar(char c, int16_t x, int16_t y, int16_t size) int16_t Adafruit_GFX_AS::drawChar(char c, int16_t x, int16_t y, int16_t size)
{ {
return drawUnicode(c, x, y, size); return drawUnicode(c, x, y, size);
} }
@ -636,7 +200,7 @@ int16_t Adafruit_GFX::drawChar(char c, int16_t x, int16_t y, int16_t size)
** Function name: drawString ** Function name: drawString
** Descriptions: draw string ** Descriptions: draw string
***************************************************************************************/ ***************************************************************************************/
int16_t Adafruit_GFX::drawString(char *string, int16_t poX, int16_t poY, int16_t size) int16_t Adafruit_GFX_AS::drawString(char *string, int16_t poX, int16_t poY, int16_t size)
{ {
int16_t sumX = 0; int16_t sumX = 0;
@ -654,7 +218,7 @@ int16_t Adafruit_GFX::drawString(char *string, int16_t poX, int16_t poY, int16_t
** Function name: drawCentreString ** Function name: drawCentreString
** Descriptions: draw string across centre ** Descriptions: draw string across centre
***************************************************************************************/ ***************************************************************************************/
int16_t Adafruit_GFX::drawCentreString(char *string, int16_t dX, int16_t poY, int16_t size) int16_t Adafruit_GFX_AS::drawCentreString(char *string, int16_t dX, int16_t poY, int16_t size)
{ {
int16_t sumX = 0; int16_t sumX = 0;
int16_t len = 0; int16_t len = 0;
@ -703,7 +267,7 @@ int16_t Adafruit_GFX::drawCentreString(char *string, int16_t dX, int16_t poY, in
** Function name: drawRightString ** Function name: drawRightString
** Descriptions: draw string right justified ** Descriptions: draw string right justified
***************************************************************************************/ ***************************************************************************************/
int16_t Adafruit_GFX::drawRightString(char *string, int16_t dX, int16_t poY, int16_t size) int16_t Adafruit_GFX_AS::drawRightString(char *string, int16_t dX, int16_t poY, int16_t size)
{ {
int16_t sumX = 0; int16_t sumX = 0;
int16_t len = 0; int16_t len = 0;
@ -754,7 +318,7 @@ int16_t Adafruit_GFX::drawRightString(char *string, int16_t dX, int16_t poY, int
** Function name: drawFloat ** Function name: drawFloat
** Descriptions: drawFloat ** Descriptions: drawFloat
***************************************************************************************/ ***************************************************************************************/
int16_t Adafruit_GFX::drawFloat(float floatNumber, int16_t decimal, int16_t poX, int16_t poY, int16_t size) int16_t Adafruit_GFX_AS::drawFloat(float floatNumber, int16_t decimal, int16_t poX, int16_t poY, int16_t size)
{ {
unsigned long temp=0; unsigned long temp=0;
float decy=0.0; float decy=0.0;

View File

@ -1,64 +1,20 @@
#ifndef _ADAFRUIT_GFX_H #ifndef _ADAFRUIT_GFX_AS_H
#define _ADAFRUIT_GFX_H #define _ADAFRUIT_GFX_AS_H
#include "Load_fonts.h" #include "Load_fonts.h"
#if ARDUINO >= 100 #include <Adafruit_GFX.h>
#include "Arduino.h"
#include "Print.h"
#else
#include "WProgram.h"
#endif
#define swap(a, b) { int16_t t = a; a = b; b = t; } #define swap(a, b) { int16_t t = a; a = b; b = t; }
class Adafruit_GFX : public Print { /** This class provides a few extensions to Adafruit_GFX, mostly for compatibility with
* existing code. Note that the fonts ("size" parameter) are not the same ones use as the
public: * ones provided by Adafruit_GFX. Using any of the functions defined in this class will
* therefore pull additional font tables into flash. If that is an issue, try to stick
Adafruit_GFX(int16_t w, int16_t h); // Constructor * to the base class, or trim down the fonts loaded in Load_fonts.h . */
class Adafruit_GFX_AS : public Adafruit_GFX {
// This MUST be defined by the subclass: public:
virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0; Adafruit_GFX_AS(int16_t w, int16_t h); // Constructor
// These MAY be overridden by the subclass to provide device-specific
// optimized code. Otherwise 'generic' versions are used.
virtual void
drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color),
drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color),
drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color),
drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color),
fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color),
fillScreen(uint16_t color),
invertDisplay(boolean i);
// These exist only with Adafruit_GFX (no subclass overrides)
void
drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color),
drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,
uint16_t color),
fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color),
fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,
int16_t delta, uint16_t color),
drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
int16_t x2, int16_t y2, uint16_t color),
fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
int16_t x2, int16_t y2, uint16_t color),
drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
int16_t radius, uint16_t color),
fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
int16_t radius, uint16_t color),
drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
int16_t w, int16_t h, uint16_t color),
drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,
uint16_t bg, uint8_t size),
setCursor(int16_t x, int16_t y),
setTextColor(uint16_t c),
setTextColor(uint16_t c, uint16_t bg),
setTextSize(uint8_t s),
setTextWrap(boolean w),
setRotation(uint8_t r);
int16_t drawUnicode(uint16_t uniCode, int16_t x, int16_t y, int16_t size); int16_t drawUnicode(uint16_t uniCode, int16_t x, int16_t y, int16_t size);
int16_t drawNumber(long long_num,int16_t poX, int16_t poY, int16_t size); int16_t drawNumber(long long_num,int16_t poX, int16_t poY, int16_t size);
int16_t drawChar(char c, int16_t x, int16_t y, int16_t size); int16_t drawChar(char c, int16_t x, int16_t y, int16_t size);
@ -66,32 +22,6 @@ class Adafruit_GFX : public Print {
int16_t drawCentreString(char *string, int16_t dX, int16_t poY, int16_t size); int16_t drawCentreString(char *string, int16_t dX, int16_t poY, int16_t size);
int16_t drawRightString(char *string, int16_t dX, int16_t poY, int16_t size); int16_t drawRightString(char *string, int16_t dX, int16_t poY, int16_t size);
int16_t drawFloat(float floatNumber,int16_t decimal,int16_t poX, int16_t poY, int16_t size); int16_t drawFloat(float floatNumber,int16_t decimal,int16_t poX, int16_t poY, int16_t size);
#if ARDUINO >= 100
virtual size_t write(uint8_t);
#else
virtual void write(uint8_t);
#endif
int16_t
height(void),
width(void);
uint8_t getRotation(void);
protected:
const int16_t
WIDTH, HEIGHT; // This is the 'raw' display w/h - never changes
int16_t
_width, _height, // Display w/h as modified by current rotation
cursor_x, cursor_y;
uint16_t
textcolor, textbgcolor;
uint8_t
textsize,
rotation;
boolean
wrap; // If set, 'wrap' text at right edge of display
}; };
#endif // _ADAFRUIT_GFX_H #endif // _ADAFRUIT_GFX_AS_H

View File

@ -1,14 +1,22 @@
This library has minor modifications to support STM32. This library adds a few font-related functions on top of the Adafruit_GFX library (which you need to install, separately).
It also was modified to include additional fonts.
This is the core graphics library for all our displays, providing a common set of graphics primitives (points, lines, circles, etc.). It needs to be paired with a hardware-specific library for each display device we carry (to handle the lower-level functions). Historically, Adafruit_GFX_AS started as a fork of Adafruit_GFX. Most importantly, it added support for using additional fonts,
before similar functionality became available in Adafruit_GFX.
Today, the main point of this library is to continue supporting projects that have made use of the functions added in Adafruit_GFX_AS,
while also being fully compatible with Adafruit_GFX (which is used as the base class). It is not recommended to use the functions
provided by the Adafruit_GFX_AS class in newly developed code.
To use this library with a driver that is not based on Adafruit_GFX_AS, all you will have to do is to replace "Adafrui_GFX" with "Adafruit_GFX_AS"
in your driver code. This will usually be three places: The #include-directive, the base-class declaration, and the call to the base-contstructor.
Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries. Adafruit_GFX Written by Limor Fried/Ladyada for Adafruit Industries.
Adafruit_GFX_AS funtions added by "Bodmer"(?)
BSD license, check license.txt for more information. BSD license, check license.txt for more information.
All text above must be included in any redistribution. All text above must be included in any redistribution.
To download, click the DOWNLOAD ZIP button, uncompress and rename the uncompressed folder Adafruit_GFX. Confirm that the Adafruit_GFX folder contains Adafruit_GFX.cpp and Adafruit_GFX.h To download, click the DOWNLOAD ZIP button, uncompress and rename the uncompressed folder Adafruit_GFX_AS. Confirm that the Adafruit_GFX_AS folder contains Adafruit_GFX_AS.cpp and Adafruit_GFX_AS.h
Place the Adafruit_GFX library folder your <arduinosketchfolder>/Libraries/ folder. You may need to create the Libraries subfolder if its your first library. Restart the IDE. Place the Adafruit_GFX_AS library folder your <arduinosketchfolder>/Libraries/ folder. You may need to create the Libraries subfolder if its your first library. Restart the IDE.

View File

@ -4,120 +4,27 @@ This library has been modified for the Maple Mini.
Includes DMA transfers on DMA1 CH2 and CH3. Includes DMA transfers on DMA1 CH2 and CH3.
*/ */
#include <Adafruit_ILI9341_STM.h> #include <Adafruit_ILI9341_STM.h>
#include <avr/pgmspace.h>
#include <limits.h>
#include <libmaple/dma.h>
#include "pins_arduino.h"
#include "wiring_private.h"
#include <SPI.h> // Using library SPI in folder: D:\Documents\Arduino\hardware\STM32\STM32F1XX\libraries\SPI
// Constructor when using software SPI. All output pins are configurable.
Adafruit_ILI9341_STM::Adafruit_ILI9341_STM(int8_t cs, int8_t dc, int8_t mosi,
int8_t sclk, int8_t rst, int8_t miso) : Adafruit_GFX(ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT) {
_cs = cs;
_dc = dc;
_mosi = mosi;
_miso = miso;
_sclk = sclk;
_rst = rst;
hwSPI = false;
}
// Constructor when using hardware SPI. Faster, but must use SPI pins // Constructor when using hardware SPI. Faster, but must use SPI pins
// specific to each board type (e.g. 11,13 for Uno, 51,52 for Mega, etc.) // specific to each board type (e.g. 11,13 for Uno, 51,52 for Mega, etc.)
Adafruit_ILI9341_STM::Adafruit_ILI9341_STM(int8_t cs, int8_t dc, int8_t rst) : Adafruit_GFX(ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT) { Adafruit_ILI9341_STM::Adafruit_ILI9341_STM(int8_t cs, int8_t dc, int8_t rst) : Adafruit_GFX_AS(ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT)
{
_cs = cs; _cs = cs;
_dc = dc; _dc = dc;
_rst = rst; _rst = rst;
hwSPI = true;
_mosi = _sclk = 0;
} }
void Adafruit_ILI9341_STM::spiwrite(uint8_t c) { void Adafruit_ILI9341_STM::writecommand(uint8_t c)
{
//Serial.print("0x"); Serial.print(c, HEX); Serial.print(", "); dc_command();
cs_clear();
if (hwSPI)
{
#if defined (__AVR__)
uint8_t backupSPCR = SPCR;
SPCR = mySPCR;
SPDR = c;
while (!(SPSR & _BV(SPIF)));
SPCR = backupSPCR;
#elif defined(TEENSYDUINO)
SPI.transfer(c);
#elif defined (__STM32F1__)
SPI.write(c);
#elif defined (__arm__)
SPI.setClockDivider(11); // 8-ish MHz (full! speed!)
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
SPI.transfer(c);
#endif
} else {
// Fast SPI bitbang swiped from LPD8806 library
for (uint8_t bit = 0x80; bit; bit >>= 1) {
if (c & bit) {
//digitalWrite(_mosi, HIGH);
*mosiport |= mosipinmask;
} else {
//digitalWrite(_mosi, LOW);
*mosiport &= ~mosipinmask;
}
//digitalWrite(_sclk, HIGH);
*clkport |= clkpinmask;
//digitalWrite(_sclk, LOW);
*clkport &= ~clkpinmask;
}
}
}
void Adafruit_ILI9341_STM::writecommand(uint8_t c) {
*dcport &= ~dcpinmask;
*csport &= ~cspinmask;
spiwrite(c); spiwrite(c);
dc_data();
*csport |= cspinmask;
} }
void Adafruit_ILI9341_STM::writedata(uint8_t c) {
*dcport |= dcpinmask;
*csport &= ~cspinmask;
spiwrite(c);
*csport |= cspinmask;
}
// If the SPI library has transaction support, these functions
// establish settings and protect from interference from other
// libraries. Otherwise, they simply do nothing.
#ifdef SPI_HAS_TRANSACTION
static inline void spi_begin(void) __attribute__((always_inline));
static inline void spi_begin(void) {
#ifdef __STM32F1__
SPI.beginTransaction(SPISettings(36000000, MSBFIRST, SPI_MODE0));
#else
SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));
#endif
}
static inline void spi_end(void) __attribute__((always_inline));
static inline void spi_end(void) {
SPI.endTransaction();
}
#else
#define spi_begin()
#define spi_end()
#endif
// Rather than a bazillion writecommand() and writedata() calls, screen // Rather than a bazillion writecommand() and writedata() calls, screen
// initialization commands and arguments are organized in these tables // initialization commands and arguments are organized in these tables
// stored in PROGMEM. The table may look bulky, but that's mostly the // stored in PROGMEM. The table may look bulky, but that's mostly the
@ -128,8 +35,8 @@ static inline void spi_end(void) {
// Companion code to the above tables. Reads and issues // Companion code to the above tables. Reads and issues
// a series of LCD commands stored in PROGMEM byte array. // a series of LCD commands stored in PROGMEM byte array.
void Adafruit_ILI9341_STM::commandList(uint8_t *addr) { void Adafruit_ILI9341_STM::commandList(uint8_t *addr)
{
uint8_t numCommands, numArgs; uint8_t numCommands, numArgs;
uint16_t ms; uint16_t ms;
@ -152,57 +59,24 @@ void Adafruit_ILI9341_STM::commandList(uint8_t *addr) {
} }
void Adafruit_ILI9341_STM::begin(void) { void Adafruit_ILI9341_STM::begin(SPIClass & spi, uint32_t freq)
if (_rst > 0) { {
pinMode(_rst, OUTPUT); mSPI = spi;
digitalWrite(_rst, LOW); _freq = freq;
} _safe_freq = (freq>SAFE_FREQ) ? SAFE_FREQ : _freq;
pinMode(_dc, OUTPUT); pinMode(_dc, OUTPUT);
pinMode(_cs, OUTPUT); pinMode(_cs, OUTPUT);
csport = portOutputRegister(digitalPinToPort(_cs)); csport = portSetRegister(_cs);
cspinmask = digitalPinToBitMask(_cs); cspinmask = digitalPinToBitMask(_cs);
dcport = portOutputRegister(digitalPinToPort(_dc)); cs_set(); // deactivate chip
dcport = portSetRegister(_dc);
dcpinmask = digitalPinToBitMask(_dc); dcpinmask = digitalPinToBitMask(_dc);
if (hwSPI) { // Using hardware SPI mSPI.beginTransaction(SPISettings(_safe_freq, MSBFIRST, SPI_MODE0, DATA_SIZE_8BIT));
#if defined (__AVR__)
SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV2); // 8 MHz (full! speed!)
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
mySPCR = SPCR;
#elif defined(TEENSYDUINO)
SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV2); // 8 MHz (full! speed!)
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
#elif defined (__STM32F1__)
SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV2);
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
#elif defined (__arm__)
SPI.begin();
SPI.setClockDivider(11); // 8-ish MHz (full! speed!)
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
#endif
} else {
pinMode(_sclk, OUTPUT);
pinMode(_mosi, OUTPUT);
pinMode(_miso, INPUT);
clkport = portOutputRegister(digitalPinToPort(_sclk));
clkpinmask = digitalPinToBitMask(_sclk);
mosiport = portOutputRegister(digitalPinToPort(_mosi));
mosipinmask = digitalPinToBitMask(_mosi);
*clkport &= ~clkpinmask;
*mosiport &= ~mosipinmask;
}
// toggle RST low to reset // toggle RST low to reset
if (_rst > 0) { if (_rst > 0) {
pinMode(_rst, OUTPUT);
digitalWrite(_rst, HIGH); digitalWrite(_rst, HIGH);
delay(5); delay(5);
digitalWrite(_rst, LOW); digitalWrite(_rst, LOW);
@ -225,7 +99,6 @@ void Adafruit_ILI9341_STM::begin(void) {
*/ */
//if(cmdList) commandList(cmdList); //if(cmdList) commandList(cmdList);
if (hwSPI) spi_begin();
writecommand(0xEF); writecommand(0xEF);
writedata(0x03); writedata(0x03);
writedata(0x80); writedata(0x80);
@ -268,7 +141,7 @@ void Adafruit_ILI9341_STM::begin(void) {
writedata(0x10); //SAP[2:0];BT[3:0] writedata(0x10); //SAP[2:0];BT[3:0]
writecommand(ILI9341_VMCTR1); //VCM control writecommand(ILI9341_VMCTR1); //VCM control
writedata(0x3e); //<2F>Աȶȵ<C8B6><C8B5><EFBFBD> writedata(0x3e);
writedata(0x28); writedata(0x28);
writecommand(ILI9341_VMCTR2); //VCM control2 writecommand(ILI9341_VMCTR2); //VCM control2
@ -330,176 +203,129 @@ void Adafruit_ILI9341_STM::begin(void) {
writedata(0x0F); writedata(0x0F);
writecommand(ILI9341_SLPOUT); //Exit Sleep writecommand(ILI9341_SLPOUT); //Exit Sleep
if (hwSPI) spi_end();
delay(120); delay(120);
if (hwSPI) spi_begin();
writecommand(ILI9341_DISPON); //Display on writecommand(ILI9341_DISPON); //Display on
if (hwSPI) spi_end(); delay(120);
cs_set();
_width = ILI9341_TFTWIDTH;
_height = ILI9341_TFTHEIGHT;
mSPI.beginTransaction(SPISettings(_freq, MSBFIRST, SPI_MODE0, DATA_SIZE_16BIT));
} }
void Adafruit_ILI9341_STM::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, void Adafruit_ILI9341_STM::setAddrWindow(uint16_t x0, uint16_t y0,
uint16_t y1) { uint16_t x1, uint16_t y1)
#if defined (__STM32F1__) {
writecommand(ILI9341_CASET); // Column addr set writecommand(ILI9341_CASET); // Column addr set
*dcport |= dcpinmask; spiwrite(x0);
*csport &= ~cspinmask; spiwrite(x1);
SPI.setDataSize (SPI_CR1_DFF);
SPI.write(x0);
SPI.write(x1);
// SPI.setDataSize (0);
writecommand(ILI9341_PASET); // Row addr set writecommand(ILI9341_PASET); // Row addr set
*dcport |= dcpinmask; spiwrite(y0);
*csport &= ~cspinmask; spiwrite(y1);
// SPI.setDataSize (SPI_CR1_DFF);
SPI.write(y0);
SPI.write(y1);
SPI.setDataSize (0);
writecommand(ILI9341_RAMWR); // write to RAM writecommand(ILI9341_RAMWR); // write to RAM
#else
writecommand(ILI9341_CASET); // Column addr set
writedata(x0 >> 8);
writedata(x0 & 0xFF); // XSTART
writedata(x1 >> 8);
writedata(x1 & 0xFF); // XEND
writecommand(ILI9341_PASET); // Row addr set
writedata(y0 >> 8);
writedata(y0); // YSTART
writedata(y1 >> 8);
writedata(y1); // YEND
writecommand(ILI9341_RAMWR); // write to RAM
#endif
} }
void Adafruit_ILI9341_STM::pushColor(uint16_t color) { void Adafruit_ILI9341_STM::pushColors(void * colorBuffer, uint16_t nr_pixels, uint8_t async)
if (hwSPI) spi_begin(); {
//digitalWrite(_dc, HIGH); cs_clear();
*dcport |= dcpinmask;
//digitalWrite(_cs, LOW);
*csport &= ~cspinmask;
spiwrite(color >> 8); if (async==0) {
mSPI.dmaSend(colorBuffer, nr_pixels, 1);
cs_set();
} else {
mSPI.dmaSendAsync(colorBuffer, nr_pixels, 1);
}
}
void Adafruit_ILI9341_STM::pushColor(uint16_t color)
{
cs_clear();
spiwrite(color); spiwrite(color);
cs_set();
*csport |= cspinmask;
//digitalWrite(_cs, HIGH);
if (hwSPI) spi_end();
} }
void Adafruit_ILI9341_STM::drawPixel(int16_t x, int16_t y, uint16_t color) { void Adafruit_ILI9341_STM::drawPixel(int16_t x, int16_t y, uint16_t color)
{
if ((x < 0) || (x >= _width) || (y < 0) || (y >= _height)) return; if ((x < 0) || (x >= _width) || (y < 0) || (y >= _height)) return;
if (hwSPI) spi_begin();
setAddrWindow(x, y, x + 1, y + 1); setAddrWindow(x, y, x + 1, y + 1);
*dcport |= dcpinmask;
*csport &= ~cspinmask;
spiwrite(color >> 8);
spiwrite(color); spiwrite(color);
*csport |= cspinmask; cs_set();
if (hwSPI) spi_end();
} }
void Adafruit_ILI9341_STM::drawFastVLine(int16_t x, int16_t y, int16_t h, void Adafruit_ILI9341_STM::drawFastVLine(int16_t x, int16_t y, int16_t h,
uint16_t color) { uint16_t color)
{
// Rudimentary clipping // Rudimentary clipping
if ((x >= _width) || (y >= _height || h < 1)) return; if ((x >= _width) || (y >= _height || h < 1)) return;
if ((y + h - 1) >= _height) if ((y + h - 1) >= _height)
h = _height - y; h = _height - y;
if (h < 2 ) { if (h < 2 ) {
drawPixel(x, y, color); drawPixel(x, y, color);
return; return;
} }
// if (hwSPI) spi_begin();
setAddrWindow(x, y, x, y + h - 1); setAddrWindow(x, y, x, y + h - 1);
*dcport |= dcpinmask; if (h>DMA_ON_LIMIT) {
*csport &= ~cspinmask; lineBuffer[0] = color;
mSPI.dmaSend(lineBuffer, h, 0);
#if defined (__STM32F1__) } else {
SPI.setDataSize (SPI_CR1_DFF); // Set SPI 16bit mode mSPI.write(color, h);
lineBuffer[0] = color;
SPI.dmaSend(lineBuffer, h, 0);
SPI.setDataSize (0);
#else
uint8_t hi = color >> 8, lo = color;
while (h--) {
spiwrite(hi);
spiwrite(lo);
} }
#endif cs_set();
*csport |= cspinmask;
} }
void Adafruit_ILI9341_STM::drawFastHLine(int16_t x, int16_t y, int16_t w, void Adafruit_ILI9341_STM::drawFastHLine(int16_t x, int16_t y, int16_t w,
uint16_t color) { uint16_t color)
{
// Rudimentary clipping // Rudimentary clipping
if ((x >= _width) || (y >= _height || w < 1)) return; if ((x >= _width) || (y >= _height || w < 1)) return;
if ((x + w - 1) >= _width) w = _width - x; if ((x + w - 1) >= _width) w = _width - x;
if (w < 2 ) { if (w < 2 ) {
drawPixel(x, y, color); drawPixel(x, y, color);
return; return;
} }
// if (hwSPI) spi_begin();
setAddrWindow(x, y, x + w - 1, y); setAddrWindow(x, y, x + w - 1, y);
*dcport |= dcpinmask;
*csport &= ~cspinmask;
#if defined (__STM32F1__) if (w>DMA_ON_LIMIT) {
SPI.setDataSize (SPI_CR1_DFF); // Set spi 16bit mode lineBuffer[0] = color;
lineBuffer[0] = color; mSPI.dmaSend(lineBuffer, w, 0);
SPI.dmaSend(lineBuffer, w, 0); } else {
SPI.setDataSize (0); mSPI.write(color, w);
#else }
uint8_t hi = color >> 8, lo = color; cs_set();
while (w--) {
spiwrite(hi);
spiwrite(lo);
}
#endif
*csport |= cspinmask;
//digitalWrite(_cs, HIGH);
// if (hwSPI) spi_end();
} }
void Adafruit_ILI9341_STM::fillScreen(uint16_t color) { void Adafruit_ILI9341_STM::fillScreen(uint16_t color)
#if defined (__STM32F1__) {
setAddrWindow(0, 0, _width - 1, _height - 1);
*dcport |= dcpinmask;
*csport &= ~cspinmask;
SPI.setDataSize (SPI_CR1_DFF); // Set spi 16bit mode
lineBuffer[0] = color; lineBuffer[0] = color;
SPI.dmaSend(lineBuffer, (65535), 0); setAddrWindow(0, 0, _width - 1, _height - 1);
SPI.dmaSend(lineBuffer, ((_width * _height) - 65535), 0); uint32_t nr_bytes = _width * _height;
SPI.setDataSize (0); while ( nr_bytes>65535 ) {
nr_bytes -= 65535;
#else mSPI.dmaSend(lineBuffer, (65535), 0);
fillRect(0, 0, _width, _height, color); }
#endif mSPI.dmaSend(lineBuffer, nr_bytes, 0);
cs_set();
} }
// fill a rectangle // fill a rectangle
void Adafruit_ILI9341_STM::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, void Adafruit_ILI9341_STM::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
uint16_t color) { uint16_t color)
{
lineBuffer[0] = color;
// rudimentary clipping (drawChar w/big text requires this) // rudimentary clipping (drawChar w/big text requires this)
if ((x >= _width) || (y >= _height || h < 1 || w < 1)) return; if ((x >= _width) || (y >= _height || h < 1 || w < 1)) return;
if ((x + w - 1) >= _width) w = _width - x; if ((x + w - 1) >= _width) w = _width - x;
@ -508,43 +334,26 @@ void Adafruit_ILI9341_STM::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
drawPixel(x, y, color); drawPixel(x, y, color);
return; return;
} }
if (hwSPI) spi_begin();
setAddrWindow(x, y, x + w - 1, y + h - 1);
*dcport |= dcpinmask; setAddrWindow(x, y, x + w - 1, y + h - 1);
*csport &= ~cspinmask; uint32_t nr_bytes = w * h;
#if defined (__STM32F1__) if ( nr_bytes>DMA_ON_LIMIT ) {
SPI.setDataSize (SPI_CR1_DFF); // Set spi 16bit mode while ( nr_bytes>65535 ) {
lineBuffer[0] = color; nr_bytes -= 65535;
if (w*h <= 65535) { mSPI.dmaSend(lineBuffer, (65535), 0);
SPI.dmaSend(lineBuffer, (w*h), 0);
}
else {
SPI.dmaSend(lineBuffer, (65535), 0);
SPI.dmaSend(lineBuffer, ((w*h) - 65535), 0);
}
SPI.setDataSize (0);
#else
uint8_t hi = color >> 8, lo = color;
for(y=h; y>0; y--)
{
for(x=w; x>0; x--)
{
SPI.write(hi);
SPI.write(lo);
} }
mSPI.dmaSend(lineBuffer, nr_bytes, 0);
} else {
mSPI.write(color, nr_bytes);
} }
#endif cs_set();
*csport |= cspinmask;
if (hwSPI) spi_end();
} }
/* /*
* Draw lines faster by calculating straight sections and drawing them with fastVline and fastHline. * Draw lines faster by calculating straight sections and drawing them with fastVline and fastHline.
*/ */
#if defined (__STM32F1__) void Adafruit_ILI9341_STM::drawLine(int16_t x0, int16_t y0,
void Adafruit_ILI9341_STM::drawLine(int16_t x0, int16_t y0,int16_t x1, int16_t y1, uint16_t color) int16_t x1, int16_t y1, uint16_t color)
{ {
if ((y0 < 0 && y1 <0) || (y0 > _height && y1 > _height)) return; if ((y0 < 0 && y1 <0) || (y0 > _height && y1 > _height)) return;
if ((x0 < 0 && x1 <0) || (x0 > _width && x1 > _width)) return; if ((x0 < 0 && x1 <0) || (x0 > _width && x1 > _width)) return;
@ -600,8 +409,6 @@ void Adafruit_ILI9341_STM::drawLine(int16_t x0, int16_t y0,int16_t x1, int16_t y
} }
int16_t xbegin = x0; int16_t xbegin = x0;
lineBuffer[0] = color;
*csport &= ~cspinmask;
if (steep) { if (steep) {
for (; x0 <= x1; x0++) { for (; x0 <= x1; x0++) {
err -= dy; err -= dy;
@ -649,11 +456,7 @@ void Adafruit_ILI9341_STM::drawLine(int16_t x0, int16_t y0,int16_t x1, int16_t y
drawFastHLine(xbegin, y0, x0 - xbegin, color); drawFastHLine(xbegin, y0, x0 - xbegin, color);
} }
} }
*csport |= cspinmask;
} }
#endif
// Pass 8-bit (each) R,G,B, get back 16-bit packed color // Pass 8-bit (each) R,G,B, get back 16-bit packed color
uint16_t Adafruit_ILI9341_STM::color565(uint8_t r, uint8_t g, uint8_t b) { uint16_t Adafruit_ILI9341_STM::color565(uint8_t r, uint8_t g, uint8_t b) {
@ -669,116 +472,133 @@ uint16_t Adafruit_ILI9341_STM::color565(uint8_t r, uint8_t g, uint8_t b) {
#define MADCTL_BGR 0x08 #define MADCTL_BGR 0x08
#define MADCTL_MH 0x04 #define MADCTL_MH 0x04
void Adafruit_ILI9341_STM::setRotation(uint8_t m) { void Adafruit_ILI9341_STM::setRotation(uint8_t m)
{
if (hwSPI) spi_begin();
writecommand(ILI9341_MADCTL);
rotation = m % 4; // can't be higher than 3 rotation = m % 4; // can't be higher than 3
switch (rotation) { switch (rotation) {
case 0: case 0:
writedata(MADCTL_MX | MADCTL_BGR); m = (MADCTL_MX | MADCTL_BGR);
_width = ILI9341_TFTWIDTH; _width = ILI9341_TFTWIDTH;
_height = ILI9341_TFTHEIGHT; _height = ILI9341_TFTHEIGHT;
break; break;
case 1: case 1:
writedata(MADCTL_MV | MADCTL_BGR); m = (MADCTL_MV | MADCTL_BGR);
_width = ILI9341_TFTHEIGHT; _width = ILI9341_TFTHEIGHT;
_height = ILI9341_TFTWIDTH; _height = ILI9341_TFTWIDTH;
break; break;
case 2: case 2:
writedata(MADCTL_MY | MADCTL_BGR); m = (MADCTL_MY | MADCTL_BGR);
_width = ILI9341_TFTWIDTH; _width = ILI9341_TFTWIDTH;
_height = ILI9341_TFTHEIGHT; _height = ILI9341_TFTHEIGHT;
break; break;
case 3: case 3:
writedata(MADCTL_MX | MADCTL_MY | MADCTL_MV | MADCTL_BGR); m = (MADCTL_MX | MADCTL_MY | MADCTL_MV | MADCTL_BGR);
_width = ILI9341_TFTHEIGHT; _width = ILI9341_TFTHEIGHT;
_height = ILI9341_TFTWIDTH; _height = ILI9341_TFTWIDTH;
break; break;
} }
if (hwSPI) spi_end(); mSPI.setDataSize(DATA_SIZE_8BIT);
writecommand(ILI9341_MADCTL);
writedata(m);
cs_set();
mSPI.setDataSize(DATA_SIZE_16BIT);
} }
void Adafruit_ILI9341_STM::invertDisplay(boolean i) { void Adafruit_ILI9341_STM::invertDisplay(boolean i)
if (hwSPI) spi_begin(); {
writecommand(i ? ILI9341_INVON : ILI9341_INVOFF); writecommand(i ? ILI9341_INVON : ILI9341_INVOFF);
if (hwSPI) spi_end(); cs_set();
} }
////////// stuff not actively being used, but kept for posterity uint16_t Adafruit_ILI9341_STM::readPixel(int16_t x, int16_t y)
{
mSPI.beginTransaction(SPISettings(_safe_freq, MSBFIRST, SPI_MODE0, DATA_SIZE_8BIT));
writecommand(ILI9341_CASET); // Column addr set
spiwrite16(x);
spiwrite16(x);
writecommand(ILI9341_PASET); // Row addr set
spiwrite16(y);
spiwrite16(y);
writecommand(ILI9341_RAMRD); // read GRAM
(void)spiread(); //dummy read
uint8_t r = spiread();
uint8_t g = spiread();
uint8_t b = spiread();
cs_set();
uint8_t Adafruit_ILI9341_STM::spiread(void) { mSPI.beginTransaction(SPISettings(_freq, MSBFIRST, SPI_MODE0, DATA_SIZE_16BIT));
uint8_t r = 0;
if (hwSPI) { return color565(r, g, b);
#if defined (__AVR__) }
uint8_t backupSPCR = SPCR;
SPCR = mySPCR;
SPDR = 0x00;
while (!(SPSR & _BV(SPIF)));
r = SPDR;
SPCR = backupSPCR;
#elif defined(TEENSYDUINO)
r = SPI.transfer(0x00);
#elif defined (__STM32F1__)
r = SPI.transfer(0x00);
#elif defined (__arm__)
SPI.setClockDivider(11); // 8-ish MHz (full! speed!)
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
r = SPI.transfer(0x00);
#endif
} else {
for (uint8_t i = 0; i < 8; i++) { uint16_t Adafruit_ILI9341_STM::readPixels(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t *buf)
digitalWrite(_sclk, LOW); {
digitalWrite(_sclk, HIGH); mSPI.beginTransaction(SPISettings(_safe_freq, MSBFIRST, SPI_MODE0, DATA_SIZE_8BIT));
r <<= 1;
if (digitalRead(_miso)) writecommand(ILI9341_CASET); // Column addr set
r |= 0x1; spiwrite16(x1);
} spiwrite16(x2);
writecommand(ILI9341_PASET); // Row addr set
spiwrite16(y1);
spiwrite16(y2);
writecommand(ILI9341_RAMRD); // read GRAM
(void)spiread(); //dummy read
uint8_t r, g, b;
uint16_t len = (x2-x1+1)*(y2-y1+1);
uint16_t ret = len;
while (len--) {
r = spiread();
g = spiread();
b = spiread();
*buf++ = color565(r, g, b);
} }
//Serial.print("read: 0x"); Serial.print(r, HEX); cs_set();
return r; mSPI.beginTransaction(SPISettings(_freq, MSBFIRST, SPI_MODE0, DATA_SIZE_16BIT));
return ret;
} }
uint8_t Adafruit_ILI9341_STM::readdata(void) {
digitalWrite(_dc, HIGH); uint16_t Adafruit_ILI9341_STM::readPixelsRGB24(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t *buf)
digitalWrite(_cs, LOW); {
mSPI.beginTransaction(SPISettings(_safe_freq, MSBFIRST, SPI_MODE0, DATA_SIZE_8BIT));
writecommand(ILI9341_CASET); // Column addr set
spiwrite16(x1);
spiwrite16(x2);
writecommand(ILI9341_PASET); // Row addr set
spiwrite16(y1);
spiwrite16(y2);
writecommand(ILI9341_RAMRD); // read GRAM
(void)spiread(); //dummy read
uint8_t r, g, b;
uint16_t len = (x2-x1+1)*(y2-y1+1);
uint16_t ret = len;
mSPI.dmaTransfer(buf, buf, len*3);
cs_set();
mSPI.beginTransaction(SPISettings(_freq, MSBFIRST, SPI_MODE0, DATA_SIZE_16BIT));
return ret;
}
uint8_t Adafruit_ILI9341_STM::readcommand8(uint8_t c, uint8_t index)
{
// the SPI clock must be set lower
mSPI.beginTransaction(SPISettings(_safe_freq, MSBFIRST, SPI_MODE0, DATA_SIZE_8BIT));
writecommand(c);
uint8_t r = spiread(); uint8_t r = spiread();
digitalWrite(_cs, HIGH); cs_set();
mSPI.beginTransaction(SPISettings(_freq, MSBFIRST, SPI_MODE0, DATA_SIZE_16BIT));
return r; return r;
} }
uint8_t Adafruit_ILI9341_STM::readcommand8(uint8_t c, uint8_t index) {
if (hwSPI) spi_begin();
digitalWrite(_dc, LOW); // command
digitalWrite(_cs, LOW);
spiwrite(0xD9); // woo sekret command?
digitalWrite(_dc, HIGH); // data
spiwrite(0x10 + index);
digitalWrite(_cs, HIGH);
digitalWrite(_dc, LOW);
//if(hwSPI) digitalWrite(_sclk, LOW);
digitalWrite(_cs, LOW);
spiwrite(c);
digitalWrite(_dc, HIGH);
uint8_t r = spiread();
digitalWrite(_cs, HIGH);
if (hwSPI) spi_end();
return r;
}
/* /*
uint16_t Adafruit_ILI9341_STM::readcommand16(uint8_t c) { uint16_t Adafruit_ILI9341_STM::readcommand16(uint8_t c) {

View File

@ -7,9 +7,12 @@ This library has been modified for the Maple Mini
#define _ADAFRUIT_ILI9341H_ #define _ADAFRUIT_ILI9341H_
#include "Arduino.h" #include "Arduino.h"
#include "Print.h"
#include <Adafruit_GFX_AS.h> #include <Adafruit_GFX_AS.h>
#include <avr/pgmspace.h> #include <SPI.h>
#ifndef swap
#define swap(a, b) { int16_t t = a; a = b; b = t; }
#endif
#define ILI9341_TFTWIDTH 240 #define ILI9341_TFTWIDTH 240
#define ILI9341_TFTHEIGHT 320 #define ILI9341_TFTHEIGHT 320
@ -92,21 +95,19 @@ This library has been modified for the Maple Mini
#define ILI9341_GREENYELLOW 0xAFE5 /* 173, 255, 47 */ #define ILI9341_GREENYELLOW 0xAFE5 /* 173, 255, 47 */
#define ILI9341_PINK 0xF81F #define ILI9341_PINK 0xF81F
class Adafruit_ILI9341_STM : public Adafruit_GFX { class Adafruit_ILI9341_STM : public Adafruit_GFX_AS {
public: public:
Adafruit_ILI9341_STM(int8_t _CS, int8_t _DC, int8_t _MOSI, int8_t _SCLK,
int8_t _RST, int8_t _MISO);
Adafruit_ILI9341_STM(int8_t _CS, int8_t _DC, int8_t _RST = -1); Adafruit_ILI9341_STM(int8_t _CS, int8_t _DC, int8_t _RST = -1);
void begin(void), void begin(SPIClass & spi, uint32_t freq=48000000);
setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1), void begin(void) { begin(SPI); }
void setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1),
pushColor(uint16_t color), pushColor(uint16_t color),
pushColors(void * colorBuffer, uint16_t nr_pixels, uint8_t async=0),
fillScreen(uint16_t color), fillScreen(uint16_t color),
#if defined (__STM32F1__)
drawLine(int16_t x0, int16_t y0,int16_t x1, int16_t y1, uint16_t color), drawLine(int16_t x0, int16_t y0,int16_t x1, int16_t y1, uint16_t color),
#endif
drawPixel(int16_t x, int16_t y, uint16_t color), drawPixel(int16_t x, int16_t y, uint16_t color),
drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color), drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color),
drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color), drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color),
@ -117,43 +118,49 @@ class Adafruit_ILI9341_STM : public Adafruit_GFX {
uint16_t color565(uint8_t r, uint8_t g, uint8_t b); uint16_t color565(uint8_t r, uint8_t g, uint8_t b);
/* These are not for current use, 8-bit protocol only! */ /* These are not for current use, 8-bit protocol only! */
uint8_t readdata(void), uint16_t readPixel(int16_t x, int16_t y);
readcommand8(uint8_t reg, uint8_t index = 0); uint16_t readPixels(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t *buf);
uint16_t readPixelsRGB24(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t *buf);
uint8_t readcommand8(uint8_t reg, uint8_t index = 0);
/* /*
uint16_t readcommand16(uint8_t); uint16_t readcommand16(uint8_t);
uint32_t readcommand32(uint8_t); uint32_t readcommand32(uint8_t);
void dummyclock(void); */
*/
void spiwrite(uint8_t), #define DMA_ON_LIMIT 250 // do DMA only for more data than this
writecommand(uint8_t c), #define SAFE_FREQ 24000000ul // 24MHz for reading
writedata(uint8_t d),
commandList(uint8_t *addr);
uint8_t spiread(void);
#define writePixel drawPixel
#define dc_command() ( *dcport =(uint32_t)dcpinmask<<16 ) // 0
#define dc_data() ( *dcport =(uint32_t)dcpinmask ) // 1
#define cs_clear() ( *csport =(uint32_t)cspinmask<<16 )
#define cs_set() ( *csport =(uint32_t)cspinmask )
#define clk_clear() ( *clkport =(uint32_t)clkpinmask<<16 )
#define clk_set() ( *clkport =(uint32_t)clkpinmask )
#define mosi_clear() ( *mosiport=(uint32_t)misopinmask<<16 )
#define mosi_set() ( *mosiport=(uint32_t)misopinmask )
#define miso_in() ( (*misoport)&misopinmask )
inline uint8_t spiread(void) { return mSPI.transfer(0x00); }
inline uint8_t readdata(void) { return mSPI.transfer(0x00); }
inline void writedata(uint8_t c) { mSPI.write(c); }
inline void spiwrite(uint16_t c) { mSPI.write(c); }
inline void spiwrite16(uint16_t c) { mSPI.write16(c); } // 8 bit mode
void writecommand(uint8_t c),
commandList(uint8_t *addr);
private: private:
uint8_t tabcolor; uint32_t _freq, _safe_freq;
SPIClass & mSPI = SPI;
volatile uint32_t *csport, *dcport;
int8_t _cs, _dc, _rst;
uint16_t cspinmask, dcpinmask;
boolean hwSPI; uint16_t lineBuffer[ILI9341_TFTHEIGHT]; // DMA buffer. 16bit color data per pixel
#if defined (__AVR__) || defined(TEENSYDUINO)
uint8_t mySPCR;
volatile uint8_t *mosiport, *clkport, *dcport, *rsport, *csport;
int8_t _cs, _dc, _rst, _mosi, _miso, _sclk;
uint8_t mosipinmask, clkpinmask, cspinmask, dcpinmask;
#elif defined (__STM32F1__)
volatile uint32 *mosiport, *clkport, *dcport, *rsport, *csport;
uint32_t _cs, _dc, _rst, _mosi, _miso, _sclk;
uint32_t mosipinmask, clkpinmask, cspinmask, dcpinmask;
uint16_t lineBuffer[ILI9341_TFTHEIGHT]; // DMA buffer. 16bit color data per pixel
#elif defined (__arm__)
volatile RwReg *mosiport, *clkport, *dcport, *rsport, *csport;
uint32_t _cs, _dc, _rst, _mosi, _miso, _sclk;
uint32_t mosipinmask, clkpinmask, cspinmask, dcpinmask;
#endif
}; };
#endif #endif

View File

@ -15,7 +15,7 @@
#include "SPI.h" #include "SPI.h"
#include "Adafruit_GFX.h" #include "Adafruit_GFX_AS.h"
#include "Adafruit_ILI9341_STM.h" #include "Adafruit_ILI9341_STM.h"
// For the Adafruit shield, these are the default. // For the Adafruit shield, these are the default.
@ -346,4 +346,4 @@ unsigned long testFilledRoundRects() {
} }
return micros() - start; return micros() - start;
} }

View File

@ -3,7 +3,7 @@
// //
//Thanks to Adafruit forums member Asteroid for the original sketch! //Thanks to Adafruit forums member Asteroid for the original sketch!
// //
#include <Adafruit_GFX.h> #include <Adafruit_GFX_AS.h>
#include <SPI.h> #include <SPI.h>
#include <Wire.h> #include <Wire.h>
#include <Adafruit_ILI9341_STM.h> #include <Adafruit_ILI9341_STM.h>

View File

@ -3,7 +3,7 @@
// //
//Thanks to Adafruit forums member Asteroid for the original sketch! //Thanks to Adafruit forums member Asteroid for the original sketch!
// //
#include <Adafruit_GFX.h> #include <Adafruit_GFX_AS.h>
#include <SPI.h> #include <SPI.h>
#include <Wire.h> #include <Wire.h>
#include <Adafruit_ILI9341_STM.h> #include <Adafruit_ILI9341_STM.h>

View File

@ -14,7 +14,7 @@
****************************************************/ ****************************************************/
#include <Adafruit_GFX.h> // Core graphics library #include <Adafruit_GFX_AS.h> // Core graphics library
#include "Adafruit_ILI9341_STM.h" // Hardware-specific library #include "Adafruit_ILI9341_STM.h" // Hardware-specific library
#include <SPI.h> #include <SPI.h>
#include <SD.h> #include <SD.h>

View File

@ -14,10 +14,10 @@
****************************************************/ ****************************************************/
#include <Adafruit_GFX.h> // Core graphics library #include <Adafruit_GFX_AS.h> // Core graphics library
#include <SPI.h> #include <SPI.h>
#include <Wire.h> // this is needed even tho we aren't using it #include <Wire.h> // this is needed even tho we aren't using it
#include <Adafruit_ILI9341.h> #include <Adafruit_ILI9341_STM.h>
#include <Adafruit_STMPE610.h> #include <Adafruit_STMPE610.h>
// This is calibration data for the raw touch data to the screen coordinates // This is calibration data for the raw touch data to the screen coordinates

View File

@ -22,13 +22,17 @@ All text above, and the splash screen below must be included in any redistributi
//#endif //#endif
#include <stdlib.h> #include <stdlib.h>
//#include <HWIRE.h>
#include <HardWire.h> #include <Wire.h>
//HardWire HWIRE(1,I2C_FAST_MODE); // I2c1 //TwoWire WIRE(1,I2C_FAST_MODE); // I2c1
HardWire HWIRE(2,I2C_FAST_MODE); // I2c2 //TwoWire WIRE(2,I2C_FAST_MODE); // I2c2
#include "Adafruit_GFX.h" #include "Adafruit_GFX.h"
#include "Adafruit_SSD1306_STM32.h" #include "Adafruit_SSD1306_STM32.h"
#ifndef swap
#define swap(a, b) { int16_t t = a; a = b; b = t; }
#endif
// the memory buffer for the LCD // the memory buffer for the LCD
static uint8_t buffer[SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH / 8] = { static uint8_t buffer[SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH / 8] = {
@ -193,7 +197,7 @@ void Adafruit_SSD1306::begin(uint8_t vccstate, uint8_t i2caddr, bool reset) {
else else
{ {
// I2C Init // I2C Init
HWIRE.begin(); Wire.begin();
#ifdef __SAM3X8E__ #ifdef __SAM3X8E__
// Force 400 KHz I2C, rawr! (Uses pins 20, 21 for SDA, SCL) // Force 400 KHz I2C, rawr! (Uses pins 20, 21 for SDA, SCL)
@ -355,10 +359,10 @@ void Adafruit_SSD1306::ssd1306_command(uint8_t c) {
{ {
// I2C // I2C
uint8_t control = 0x00; // Co = 0, D/C = 0 uint8_t control = 0x00; // Co = 0, D/C = 0
HWIRE.beginTransmission(_i2caddr); Wire.beginTransmission(_i2caddr);
WIRE_WRITE(control); WIRE_WRITE(control);
WIRE_WRITE(c); WIRE_WRITE(c);
HWIRE.endTransmission(); Wire.endTransmission();
} }
} }
@ -469,10 +473,10 @@ void Adafruit_SSD1306::ssd1306_data(uint8_t c) {
{ {
// I2C // I2C
uint8_t control = 0x40; // Co = 0, D/C = 1 uint8_t control = 0x40; // Co = 0, D/C = 1
HWIRE.beginTransmission(_i2caddr); Wire.beginTransmission(_i2caddr);
WIRE_WRITE(control); WIRE_WRITE(control);
WIRE_WRITE(c); WIRE_WRITE(c);
HWIRE.endTransmission(); Wire.endTransmission();
} }
} }
@ -521,14 +525,14 @@ void Adafruit_SSD1306::display(void) {
// I2C // I2C
for (uint16_t i=0; i<(SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8); i++) { for (uint16_t i=0; i<(SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8); i++) {
// send a bunch of data in one xmission // send a bunch of data in one xmission
HWIRE.beginTransmission(_i2caddr); Wire.beginTransmission(_i2caddr);
WIRE_WRITE(0x40); WIRE_WRITE(0x40);
for (uint8_t x=0; x<16; x++) { for (uint8_t x=0; x<16; x++) {
WIRE_WRITE(buffer[i]); WIRE_WRITE(buffer[i]);
i++; i++;
} }
i--; i--;
HWIRE.endTransmission(); Wire.endTransmission();
} }
/* /*
#ifndef __SAM3X8E__ #ifndef __SAM3X8E__

View File

@ -18,10 +18,10 @@ All text above, and the splash screen must be included in any redistribution
#if ARDUINO >= 100 #if ARDUINO >= 100
#include "Arduino.h" #include "Arduino.h"
#define WIRE_WRITE HWIRE.write #define WIRE_WRITE Wire.write
#else #else
#include "WProgram.h" #include "WProgram.h"
#define WIRE_WRITE HWIRE.send #define WIRE_WRITE Wire.send
#endif #endif
/* /*
#ifdef __SAM3X8E__ #ifdef __SAM3X8E__

View File

@ -1,6 +1,6 @@
STM32 adaption by Matthias Diro, 25.03.2015 STM32 adaption by Matthias Diro, 25.03.2015
Things to know: Things to know:
This adaption uses hardware I2C (hardwire.h), Port: I2c2. SDA=0, SCL=1 on maple mini This adaption uses hardware I2C (now Wire.h), Port: I2c2. SDA=0, SCL=1 on maple mini
To change it to Port I2C1: To change it to Port I2C1:
//HardWire HWIRE(1,I2C_FAST_MODE); // I2c1 //TwoWire WIRE(1,I2C_FAST_MODE); // I2c1
HardWire HWIRE(2,I2C_FAST_MODE); // I2c2 TwoWire WIRE(2,I2C_FAST_MODE); // I2c2

View File

@ -1,7 +1,7 @@
/* /*
STM32 adaption by Matthias Diro, tested with maple mini and heltec OLED 12864 I2c; adress: 0x3C (SPI should work, but I didn't own one) STM32 adaption by Matthias Diro, tested with maple mini and heltec OLED 12864 I2c; adress: 0x3C (SPI should work, but I didn't own one)
Things to know: Things to know:
This adaption uses hardware I2C (hardwire.h), Port: I2c2. SDA=0, SCL=1 on maple mini This adaption uses hardware I2C (now Wire.h), Port: I2c2. SDA=0, SCL=1 on maple mini
further details: STM32_README.txt further details: STM32_README.txt
*/ */
/********************************************************************* /*********************************************************************

View File

@ -13,10 +13,10 @@ uint16 EEPROMClass::EE_CheckPage(uint32 pageBase, uint16 status)
uint32 pageEnd = pageBase + (uint32)PageSize; uint32 pageEnd = pageBase + (uint32)PageSize;
// Page Status not EEPROM_ERASED and not a "state" // Page Status not EEPROM_ERASED and not a "state"
if ((*(__io uint16*)pageBase) != EEPROM_ERASED && (*(__io uint16*)pageBase) != status) if ((*(__IO uint16*)pageBase) != EEPROM_ERASED && (*(__IO uint16*)pageBase) != status)
return EEPROM_BAD_FLASH; return EEPROM_BAD_FLASH;
for(pageBase += 4; pageBase < pageEnd; pageBase += 4) for(pageBase += 4; pageBase < pageEnd; pageBase += 4)
if ((*(__io uint32*)pageBase) != 0xFFFFFFFF) // Verify if slot is empty if ((*(__IO uint32*)pageBase) != 0xFFFFFFFF) // Verify if slot is empty
return EEPROM_BAD_FLASH; return EEPROM_BAD_FLASH;
return EEPROM_OK; return EEPROM_OK;
} }
@ -31,9 +31,9 @@ uint16 EEPROMClass::EE_CheckPage(uint32 pageBase, uint16 status)
FLASH_Status EEPROMClass::EE_ErasePage(uint32 pageBase) FLASH_Status EEPROMClass::EE_ErasePage(uint32 pageBase)
{ {
FLASH_Status FlashStatus; FLASH_Status FlashStatus;
uint16 data = (*(__io uint16*)(pageBase)); uint16 data = (*(__IO uint16*)(pageBase));
if ((data == EEPROM_ERASED) || (data == EEPROM_VALID_PAGE) || (data == EEPROM_RECEIVE_DATA)) if ((data == EEPROM_ERASED) || (data == EEPROM_VALID_PAGE) || (data == EEPROM_RECEIVE_DATA))
data = (*(__io uint16*)(pageBase + 2)) + 1; data = (*(__IO uint16*)(pageBase + 2)) + 1;
else else
data = 0; data = 0;
@ -73,8 +73,8 @@ uint16 EEPROMClass::EE_CheckErasePage(uint32 pageBase, uint16 status)
*/ */
uint32 EEPROMClass::EE_FindValidPage(void) uint32 EEPROMClass::EE_FindValidPage(void)
{ {
uint16 status0 = (*(__io uint16*)PageBase0); // Get Page0 actual status uint16 status0 = (*(__IO uint16*)PageBase0); // Get Page0 actual status
uint16 status1 = (*(__io uint16*)PageBase1); // Get Page1 actual status uint16 status1 = (*(__IO uint16*)PageBase1); // Get Page1 actual status
if (status0 == EEPROM_VALID_PAGE && status1 == EEPROM_ERASED) if (status0 == EEPROM_VALID_PAGE && status1 == EEPROM_ERASED)
return PageBase0; return PageBase0;
@ -100,14 +100,14 @@ uint16 EEPROMClass::EE_GetVariablesCount(uint32 pageBase, uint16 skipAddress)
for (pageBase += 6; pageBase < pageEnd; pageBase += 4) for (pageBase += 6; pageBase < pageEnd; pageBase += 4)
{ {
varAddress = (*(__io uint16*)pageBase); varAddress = (*(__IO uint16*)pageBase);
if (varAddress == 0xFFFF || varAddress == skipAddress) if (varAddress == 0xFFFF || varAddress == skipAddress)
continue; continue;
count++; count++;
for(idx = pageBase + 4; idx < pageEnd; idx += 4) for(idx = pageBase + 4; idx < pageEnd; idx += 4)
{ {
nextAddress = (*(__io uint16*)idx); nextAddress = (*(__IO uint16*)idx);
if (nextAddress == varAddress) if (nextAddress == varAddress)
{ {
count--; count--;
@ -140,7 +140,7 @@ uint16 EEPROMClass::EE_PageTransfer(uint32 newPage, uint32 oldPage, uint16 SkipA
// Find first free element in new page // Find first free element in new page
for (newIdx = newPage + 4; newIdx < newEnd; newIdx += 4) for (newIdx = newPage + 4; newIdx < newEnd; newIdx += 4)
if ((*(__io uint32*)newIdx) == 0xFFFFFFFF) // Verify if element if ((*(__IO uint32*)newIdx) == 0xFFFFFFFF) // Verify if element
break; // contents are 0xFFFFFFFF break; // contents are 0xFFFFFFFF
if (newIdx >= newEnd) if (newIdx >= newEnd)
return EEPROM_OUT_SIZE; return EEPROM_OUT_SIZE;
@ -150,13 +150,13 @@ uint16 EEPROMClass::EE_PageTransfer(uint32 newPage, uint32 oldPage, uint16 SkipA
for (; oldIdx > oldEnd; oldIdx -= 4) for (; oldIdx > oldEnd; oldIdx -= 4)
{ {
address = *(__io uint16*)oldIdx; address = *(__IO uint16*)oldIdx;
if (address == 0xFFFF || address == SkipAddress) if (address == 0xFFFF || address == SkipAddress)
continue; // it's means that power off after write data continue; // it's means that power off after write data
found = 0; found = 0;
for (idx = newPage + 6; idx < newIdx; idx += 4) for (idx = newPage + 6; idx < newIdx; idx += 4)
if ((*(__io uint16*)(idx)) == address) if ((*(__IO uint16*)(idx)) == address)
{ {
found = 1; found = 1;
break; break;
@ -167,7 +167,7 @@ uint16 EEPROMClass::EE_PageTransfer(uint32 newPage, uint32 oldPage, uint16 SkipA
if (newIdx < newEnd) if (newIdx < newEnd)
{ {
data = (*(__io uint16*)(oldIdx - 2)); data = (*(__IO uint16*)(oldIdx - 2));
FlashStatus = FLASH_ProgramHalfWord(newIdx, data); FlashStatus = FLASH_ProgramHalfWord(newIdx, data);
if (FlashStatus != FLASH_COMPLETE) if (FlashStatus != FLASH_COMPLETE)
@ -223,9 +223,9 @@ uint16 EEPROMClass::EE_VerifyPageFullWriteVariable(uint16 Address, uint16 Data)
for (idx = pageEnd - 2; idx > pageBase; idx -= 4) for (idx = pageEnd - 2; idx > pageBase; idx -= 4)
{ {
if ((*(__io uint16*)idx) == Address) // Find last value for address if ((*(__IO uint16*)idx) == Address) // Find last value for address
{ {
count = (*(__io uint16*)(idx - 2)); // Read last data count = (*(__IO uint16*)(idx - 2)); // Read last data
if (count == Data) if (count == Data)
return EEPROM_OK; return EEPROM_OK;
if (count == 0xFFFF) if (count == 0xFFFF)
@ -240,7 +240,7 @@ uint16 EEPROMClass::EE_VerifyPageFullWriteVariable(uint16 Address, uint16 Data)
// Check each active page address starting from begining // Check each active page address starting from begining
for (idx = pageBase + 4; idx < pageEnd; idx += 4) for (idx = pageBase + 4; idx < pageEnd; idx += 4)
if ((*(__io uint32*)idx) == 0xFFFFFFFF) // Verify if element if ((*(__IO uint32*)idx) == 0xFFFFFFFF) // Verify if element
{ // contents are 0xFFFFFFFF { // contents are 0xFFFFFFFF
FlashStatus = FLASH_ProgramHalfWord(idx, Data); // Set variable data FlashStatus = FLASH_ProgramHalfWord(idx, Data); // Set variable data
if (FlashStatus != FLASH_COMPLETE) if (FlashStatus != FLASH_COMPLETE)
@ -303,8 +303,8 @@ uint16 EEPROMClass::init(void)
FLASH_Unlock(); FLASH_Unlock();
Status = EEPROM_NO_VALID_PAGE; Status = EEPROM_NO_VALID_PAGE;
status0 = (*(__io uint16 *)PageBase0); status0 = (*(__IO uint16 *)PageBase0);
status1 = (*(__io uint16 *)PageBase1); status1 = (*(__IO uint16 *)PageBase1);
switch (status0) switch (status0)
{ {
@ -407,7 +407,7 @@ uint16 EEPROMClass::format(void)
status = EE_CheckErasePage(PageBase0, EEPROM_VALID_PAGE); status = EE_CheckErasePage(PageBase0, EEPROM_VALID_PAGE);
if (status != EEPROM_OK) if (status != EEPROM_OK)
return status; return status;
if ((*(__io uint16*)PageBase0) == EEPROM_ERASED) if ((*(__IO uint16*)PageBase0) == EEPROM_ERASED)
{ {
// Set Page0 as valid page: Write VALID_PAGE at Page0 base address // Set Page0 as valid page: Write VALID_PAGE at Page0 base address
FlashStatus = FLASH_ProgramHalfWord(PageBase0, EEPROM_VALID_PAGE); FlashStatus = FLASH_ProgramHalfWord(PageBase0, EEPROM_VALID_PAGE);
@ -437,7 +437,7 @@ uint16 EEPROMClass::erases(uint16 *Erases)
if (pageBase == 0) if (pageBase == 0)
return EEPROM_NO_VALID_PAGE; return EEPROM_NO_VALID_PAGE;
*Erases = (*(__io uint16*)pageBase+2); *Erases = (*(__IO uint16*)pageBase+2);
return EEPROM_OK; return EEPROM_OK;
} }
@ -485,9 +485,9 @@ uint16 EEPROMClass::read(uint16 Address, uint16 *Data)
// Check each active page address starting from end // Check each active page address starting from end
for (pageBase += 6; pageEnd >= pageBase; pageEnd -= 4) for (pageBase += 6; pageEnd >= pageBase; pageEnd -= 4)
if ((*(__io uint16*)pageEnd) == Address) // Compare the read address with the virtual address if ((*(__IO uint16*)pageEnd) == Address) // Compare the read address with the virtual address
{ {
*Data = (*(__io uint16*)(pageEnd - 2)); // Get content of Address-2 which is variable value *Data = (*(__IO uint16*)(pageEnd - 2)); // Get content of Address-2 which is variable value
return EEPROM_OK; return EEPROM_OK;
} }

View File

@ -17,7 +17,7 @@
*/ */
static void delay(void) static void delay(void)
{ {
__io uint32 i = 0; __IO uint32 i = 0;
for(i = 0xFF; i != 0; i--) { } for(i = 0xFF; i != 0; i--) { }
} }
@ -122,7 +122,7 @@ FLASH_Status FLASH_ProgramHalfWord(uint32 Address, uint16 Data)
{ {
/* if the previous operation is completed, proceed to program the new data */ /* if the previous operation is completed, proceed to program the new data */
FLASH_BASE->CR |= FLASH_CR_PG; FLASH_BASE->CR |= FLASH_CR_PG;
*(__io uint16*)Address = Data; *(__IO uint16*)Address = Data;
/* Wait for last operation to be completed */ /* Wait for last operation to be completed */
status = FLASH_WaitForLastOperation(ProgramTimeout); status = FLASH_WaitForLastOperation(ProgramTimeout);
if(status != FLASH_TIMEOUT) if(status != FLASH_TIMEOUT)

Some files were not shown because too many files have changed in this diff Show More