Repository: QuantumLeaps/qpn
Branch: master
Commit: 779ef14dc1c7
Files: 828
Total size: 8.9 MB
Directory structure:
gitextract_iaujvinz/
├── .gitignore
├── .gitmodules
├── GPLv3.txt
├── LICENSE.txt
├── README.md
├── doxygen/
│ ├── Doxyfile
│ ├── Doxyfile-CHM
│ ├── api.dox
│ ├── exa.dox
│ ├── exa_apps.dox
│ ├── exa_native.dox
│ ├── exa_os.dox
│ ├── gs.dox
│ ├── history.dox
│ ├── img/
│ │ └── img.htm
│ ├── lint.dox
│ ├── macros.h
│ ├── main.dox
│ ├── make.bat
│ ├── modules.dox
│ ├── ports.dox
│ ├── ports_arm-cm.dox
│ ├── ports_native.dox
│ ├── ports_os.dox
│ ├── preview.js
│ ├── rsm.bat
│ ├── rsm_qpn.cfg
│ ├── snippets/
│ │ ├── qepn_qhist.c
│ │ ├── qepn_qhsm.c
│ │ ├── qepn_qhsm_ctor.c
│ │ ├── qepn_qhsm_use.c
│ │ ├── qepn_qinit.c
│ │ ├── qepn_qtran.c
│ │ ├── qfn_armx.c
│ │ ├── qfn_main.c
│ │ ├── qfn_post.c
│ │ ├── qfn_postx.c
│ │ ├── qfn_qactive.c
│ │ ├── qfn_tickx.c
│ │ ├── qkn_lock.c
│ │ └── qkn_oncontextsw.c
│ └── struct.dox
├── examples/
│ ├── README.url
│ ├── arm-cm/
│ │ ├── README.url
│ │ ├── blinky_efm32-slstk3401a/
│ │ │ ├── README.txt
│ │ │ ├── README.url
│ │ │ ├── blinky.c
│ │ │ ├── blinky.h
│ │ │ ├── bsp.h
│ │ │ ├── main.c
│ │ │ ├── qk/
│ │ │ │ ├── armclang/
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── blinky-qk.uvoptx
│ │ │ │ │ └── blinky-qk.uvprojx
│ │ │ │ ├── bsp.c
│ │ │ │ ├── gnu/
│ │ │ │ │ ├── Makefile
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── blinky-qk.ld
│ │ │ │ │ └── flash.bat
│ │ │ │ └── iar/
│ │ │ │ ├── README.txt
│ │ │ │ ├── blinky-qk.ewd
│ │ │ │ ├── blinky-qk.ewp
│ │ │ │ ├── blinky-qk.eww
│ │ │ │ └── blinky-qk.icf
│ │ │ ├── qpn_conf.h
│ │ │ └── qv/
│ │ │ ├── armclang/
│ │ │ │ ├── README.txt
│ │ │ │ ├── blinky-qv.uvoptx
│ │ │ │ └── blinky-qv.uvprojx
│ │ │ ├── bsp.c
│ │ │ ├── gnu/
│ │ │ │ ├── Makefile
│ │ │ │ ├── README.txt
│ │ │ │ ├── blinky-qv.ld
│ │ │ │ └── flash.bat
│ │ │ └── iar/
│ │ │ ├── README.txt
│ │ │ ├── blinky-qv.ewd
│ │ │ ├── blinky-qv.ewp
│ │ │ ├── blinky-qv.eww
│ │ │ └── blinky-qv.icf
│ │ ├── blinky_ek-tm4c123gxl/
│ │ │ ├── README.txt
│ │ │ ├── README.url
│ │ │ ├── blinky.c
│ │ │ ├── blinky.h
│ │ │ ├── bsp.h
│ │ │ ├── main.c
│ │ │ ├── qk/
│ │ │ │ ├── arm/
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── blinky-qk.uvoptx
│ │ │ │ │ └── blinky-qk.uvprojx
│ │ │ │ ├── armclang/
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── blinky-qk.uvoptx
│ │ │ │ │ └── blinky-qk.uvprojx
│ │ │ │ ├── bsp.c
│ │ │ │ ├── gnu/
│ │ │ │ │ ├── .ccsproject
│ │ │ │ │ ├── .cproject
│ │ │ │ │ ├── .project
│ │ │ │ │ ├── Makefile
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── blinky-qk.ld
│ │ │ │ │ └── flash.bat
│ │ │ │ └── iar/
│ │ │ │ ├── README.txt
│ │ │ │ ├── blinky-qk.ewd
│ │ │ │ ├── blinky-qk.ewp
│ │ │ │ ├── blinky-qk.eww
│ │ │ │ └── blinky-qk.icf
│ │ │ ├── qpn_conf.h
│ │ │ └── qv/
│ │ │ ├── arm/
│ │ │ │ ├── README.txt
│ │ │ │ ├── blinky-qv.uvoptx
│ │ │ │ └── blinky-qv.uvprojx
│ │ │ ├── armclang/
│ │ │ │ ├── README.txt
│ │ │ │ ├── blinky-qv.uvoptx
│ │ │ │ └── blinky-qv.uvprojx
│ │ │ ├── bsp.c
│ │ │ ├── gnu/
│ │ │ │ ├── .ccsproject
│ │ │ │ ├── .cproject
│ │ │ │ ├── .project
│ │ │ │ ├── Makefile
│ │ │ │ ├── README.txt
│ │ │ │ ├── blinky-qv.ld
│ │ │ │ └── flash.bat
│ │ │ └── iar/
│ │ │ ├── README.txt
│ │ │ ├── blinky-qv.ewd
│ │ │ ├── blinky-qv.ewp
│ │ │ ├── blinky-qv.eww
│ │ │ └── blinky-qv.icf
│ │ ├── dpp_efm32-slstk3401a/
│ │ │ ├── README.txt
│ │ │ ├── README.url
│ │ │ ├── bsp.h
│ │ │ ├── dpp.h
│ │ │ ├── dpp.qm
│ │ │ ├── main.c
│ │ │ ├── philo.c
│ │ │ ├── qk/
│ │ │ │ ├── armclang/
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── dpp-qk.uvoptx
│ │ │ │ │ └── dpp-qk.uvprojx
│ │ │ │ ├── bsp.c
│ │ │ │ ├── gnu/
│ │ │ │ │ ├── Makefile
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── dpp-qk.ld
│ │ │ │ │ └── flash.bat
│ │ │ │ └── iar/
│ │ │ │ ├── README.txt
│ │ │ │ ├── dpp-qk.ewd
│ │ │ │ ├── dpp-qk.ewp
│ │ │ │ ├── dpp-qk.eww
│ │ │ │ └── dpp-qk.icf
│ │ │ ├── qpn_conf.h
│ │ │ ├── qv/
│ │ │ │ ├── armclang/
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── dpp-qv.uvoptx
│ │ │ │ │ └── dpp-qv.uvprojx
│ │ │ │ ├── bsp.c
│ │ │ │ ├── gnu/
│ │ │ │ │ ├── Makefile
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── dpp-qv.ld
│ │ │ │ │ └── flash.bat
│ │ │ │ └── iar/
│ │ │ │ ├── README.txt
│ │ │ │ ├── dpp-qv.ewd
│ │ │ │ ├── dpp-qv.ewp
│ │ │ │ ├── dpp-qv.eww
│ │ │ │ └── dpp-qv.icf
│ │ │ ├── table.c
│ │ │ └── win32-gui/
│ │ │ ├── Resource.rc
│ │ │ ├── bsp.c
│ │ │ ├── dpp-gui.sln
│ │ │ ├── dpp-gui.vcxproj
│ │ │ ├── dpp-gui.vcxproj.filters
│ │ │ └── resource.h
│ │ ├── dpp_ek-tm4c123gxl/
│ │ │ ├── README.txt
│ │ │ ├── README.url
│ │ │ ├── bsp.h
│ │ │ ├── dpp.h
│ │ │ ├── dpp.qm
│ │ │ ├── lint-plus/
│ │ │ │ ├── README.txt
│ │ │ │ ├── lin.bat
│ │ │ │ └── options.lnt
│ │ │ ├── main.c
│ │ │ ├── philo.c
│ │ │ ├── qk/
│ │ │ │ ├── arm/
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── dpp-qk.uvoptx
│ │ │ │ │ └── dpp-qk.uvprojx
│ │ │ │ ├── armclang/
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── dpp-qk.uvoptx
│ │ │ │ │ └── dpp-qk.uvprojx
│ │ │ │ ├── bsp.c
│ │ │ │ ├── gnu/
│ │ │ │ │ ├── .ccsproject
│ │ │ │ │ ├── .cproject
│ │ │ │ │ ├── .project
│ │ │ │ │ ├── Makefile
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── dpp-qk.ld
│ │ │ │ │ └── flash.bat
│ │ │ │ └── iar/
│ │ │ │ ├── README.txt
│ │ │ │ ├── dpp-qk.ewd
│ │ │ │ ├── dpp-qk.ewp
│ │ │ │ ├── dpp-qk.eww
│ │ │ │ └── dpp-qk.icf
│ │ │ ├── qpn_conf.h
│ │ │ ├── qv/
│ │ │ │ ├── arm/
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── dpp-qv.uvoptx
│ │ │ │ │ └── dpp-qv.uvprojx
│ │ │ │ ├── armclang/
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── dpp-qv.uvoptx
│ │ │ │ │ └── dpp-qv.uvprojx
│ │ │ │ ├── bsp.c
│ │ │ │ ├── gnu/
│ │ │ │ │ ├── .ccsproject
│ │ │ │ │ ├── .cproject
│ │ │ │ │ ├── .project
│ │ │ │ │ ├── Makefile
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── dpp-qv.ld
│ │ │ │ │ └── flash.bat
│ │ │ │ └── iar/
│ │ │ │ ├── README.txt
│ │ │ │ ├── dpp-qv.ewd
│ │ │ │ ├── dpp-qv.ewp
│ │ │ │ ├── dpp-qv.eww
│ │ │ │ └── dpp-qv.icf
│ │ │ └── table.c
│ │ ├── dpp_mbed-lpc1768/
│ │ │ ├── README.txt
│ │ │ ├── README.url
│ │ │ ├── bsp.h
│ │ │ ├── dpp.h
│ │ │ ├── dpp.qm
│ │ │ ├── main.c
│ │ │ ├── philo.c
│ │ │ ├── qk/
│ │ │ │ ├── armclang/
│ │ │ │ │ ├── dpp-qk.uvoptx
│ │ │ │ │ └── dpp-qk.uvprojx
│ │ │ │ ├── bsp.c
│ │ │ │ ├── gnu/
│ │ │ │ │ ├── Makefile
│ │ │ │ │ └── dpp-qk.ld
│ │ │ │ └── iar/
│ │ │ │ ├── dpp-qk.ewd
│ │ │ │ ├── dpp-qk.ewp
│ │ │ │ ├── dpp-qk.eww
│ │ │ │ └── dpp-qk.icf
│ │ │ ├── qpn_conf.h
│ │ │ ├── qv/
│ │ │ │ ├── armclang/
│ │ │ │ │ ├── dpp-qv.uvoptx
│ │ │ │ │ └── dpp-qv.uvprojx
│ │ │ │ ├── bsp.c
│ │ │ │ ├── gnu/
│ │ │ │ │ ├── Makefile
│ │ │ │ │ └── dpp-qv.ld
│ │ │ │ └── iar/
│ │ │ │ ├── dpp-qv.ewd
│ │ │ │ ├── dpp-qv.ewp
│ │ │ │ ├── dpp-qv.eww
│ │ │ │ └── dpp-qv.icf
│ │ │ └── table.c
│ │ ├── dpp_nucleo-l053r8/
│ │ │ ├── README.txt
│ │ │ ├── README.url
│ │ │ ├── bsp.h
│ │ │ ├── dpp.h
│ │ │ ├── dpp.qm
│ │ │ ├── main.c
│ │ │ ├── philo.c
│ │ │ ├── qk/
│ │ │ │ ├── armclang/
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── dpp-qk.uvoptx
│ │ │ │ │ └── dpp-qk.uvprojx
│ │ │ │ ├── bsp.c
│ │ │ │ ├── gnu/
│ │ │ │ │ ├── .cproject
│ │ │ │ │ ├── .project
│ │ │ │ │ ├── Makefile
│ │ │ │ │ ├── dpp-qk.ld
│ │ │ │ │ ├── dpp-qk_nucleo-l053r8.elf.launch
│ │ │ │ │ └── stm32_flash.ld
│ │ │ │ └── iar/
│ │ │ │ ├── dpp-qk.ewd
│ │ │ │ ├── dpp-qk.ewp
│ │ │ │ ├── dpp-qk.eww
│ │ │ │ └── dpp-qk.icf
│ │ │ ├── qpn_conf.h
│ │ │ ├── qv/
│ │ │ │ ├── armclang/
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── dpp-qv.uvoptx
│ │ │ │ │ └── dpp-qv.uvprojx
│ │ │ │ ├── bsp.c
│ │ │ │ ├── gnu/
│ │ │ │ │ ├── .cproject
│ │ │ │ │ ├── .project
│ │ │ │ │ ├── Makefile
│ │ │ │ │ └── dpp-qv.ld
│ │ │ │ └── iar/
│ │ │ │ ├── dpp-qv.ewd
│ │ │ │ ├── dpp-qv.ewp
│ │ │ │ ├── dpp-qv.eww
│ │ │ │ └── dpp-qv.icf
│ │ │ └── table.c
│ │ ├── dpp_nucleo-l152re/
│ │ │ ├── README.txt
│ │ │ ├── README.url
│ │ │ ├── bsp.h
│ │ │ ├── dpp.h
│ │ │ ├── dpp.qm
│ │ │ ├── main.c
│ │ │ ├── philo.c
│ │ │ ├── qk/
│ │ │ │ ├── armclang/
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── dpp-qk.uvoptx
│ │ │ │ │ └── dpp-qk.uvprojx
│ │ │ │ ├── bsp.c
│ │ │ │ ├── gnu/
│ │ │ │ │ ├── .cproject
│ │ │ │ │ ├── .project
│ │ │ │ │ ├── Makefile
│ │ │ │ │ └── dpp-qk.ld
│ │ │ │ └── iar/
│ │ │ │ ├── dpp-qk.ewd
│ │ │ │ ├── dpp-qk.ewp
│ │ │ │ ├── dpp-qk.eww
│ │ │ │ └── dpp-qk.icf
│ │ │ ├── qpn_conf.h
│ │ │ ├── qv/
│ │ │ │ ├── armclang/
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── dpp-qv.uvoptx
│ │ │ │ │ └── dpp-qv.uvprojx
│ │ │ │ ├── bsp.c
│ │ │ │ ├── gnu/
│ │ │ │ │ ├── .cproject
│ │ │ │ │ ├── .project
│ │ │ │ │ ├── Makefile
│ │ │ │ │ └── dpp-qv.ld
│ │ │ │ └── iar/
│ │ │ │ ├── dpp-qv.ewd
│ │ │ │ ├── dpp-qv.ewp
│ │ │ │ ├── dpp-qv.eww
│ │ │ │ └── dpp-qv.icf
│ │ │ └── table.c
│ │ ├── game_efm32-slstk3401a/
│ │ │ ├── README.txt
│ │ │ ├── README.url
│ │ │ ├── bsp.h
│ │ │ ├── game.h
│ │ │ ├── game.qm
│ │ │ ├── main.c
│ │ │ ├── mine1.c
│ │ │ ├── mine2.c
│ │ │ ├── missile.c
│ │ │ ├── qk/
│ │ │ │ ├── armclang/
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── game-qk.uvoptx
│ │ │ │ │ └── game-qk.uvprojx
│ │ │ │ ├── bsp.c
│ │ │ │ ├── gnu/
│ │ │ │ │ ├── Makefile
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── flash.bat
│ │ │ │ │ └── game-qk.ld
│ │ │ │ └── iar/
│ │ │ │ ├── README.txt
│ │ │ │ ├── game-qk.ewd
│ │ │ │ ├── game-qk.ewp
│ │ │ │ ├── game-qk.eww
│ │ │ │ └── game-qk.icf
│ │ │ ├── qpn_conf.h
│ │ │ ├── qv/
│ │ │ │ ├── armclang/
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── game-qv.uvoptx
│ │ │ │ │ └── game-qv.uvprojx
│ │ │ │ ├── bsp.c
│ │ │ │ ├── gnu/
│ │ │ │ │ ├── Makefile
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── flash.bat
│ │ │ │ │ └── game-qv.ld
│ │ │ │ └── iar/
│ │ │ │ ├── README.txt
│ │ │ │ ├── game-qv.ewd
│ │ │ │ ├── game-qv.ewp
│ │ │ │ ├── game-qv.eww
│ │ │ │ └── game-qv.icf
│ │ │ ├── ship.c
│ │ │ ├── tunnel.c
│ │ │ └── win32-gui/
│ │ │ ├── Resource.rc
│ │ │ ├── bsp.c
│ │ │ ├── game-gui.sln
│ │ │ ├── game-gui.vcxproj
│ │ │ ├── game-gui.vcxproj.filters
│ │ │ └── resource.h
│ │ └── pelican_ek-tm4c123gxl/
│ │ ├── README.url
│ │ ├── bsp.h
│ │ ├── main.c
│ │ ├── pelican.c
│ │ ├── pelican.h
│ │ ├── pelican.qm
│ │ ├── qk/
│ │ │ ├── armclang/
│ │ │ │ ├── README.txt
│ │ │ │ ├── pelican-qk.uvoptx
│ │ │ │ └── pelican-qk.uvprojx
│ │ │ ├── bsp.c
│ │ │ ├── gnu/
│ │ │ │ ├── Makefile
│ │ │ │ ├── README.txt
│ │ │ │ ├── flash.bat
│ │ │ │ └── pelican-qk.ld
│ │ │ └── iar/
│ │ │ ├── README.txt
│ │ │ ├── pelican-qk.ewd
│ │ │ ├── pelican-qk.ewp
│ │ │ ├── pelican-qk.eww
│ │ │ └── pelican-qk.icf
│ │ ├── qpn_conf.h
│ │ └── qv/
│ │ ├── armclang/
│ │ │ ├── README.txt
│ │ │ ├── pelican-qv.uvoptx
│ │ │ └── pelican-qv.uvprojx
│ │ ├── bsp.c
│ │ ├── gnu/
│ │ │ ├── Makefile
│ │ │ ├── README.txt
│ │ │ ├── flash.bat
│ │ │ └── pelican-qv.ld
│ │ └── iar/
│ │ ├── README.txt
│ │ ├── pelican-qv.ewd
│ │ ├── pelican-qv.ewp
│ │ ├── pelican-qv.eww
│ │ └── pelican-qv.icf
│ ├── arm7-9/
│ │ ├── README.url
│ │ └── dpp_at91sam7s-ek/
│ │ ├── README.url
│ │ ├── bsp.h
│ │ ├── dpp.h
│ │ ├── dpp.qm
│ │ ├── main.c
│ │ ├── philo.c
│ │ ├── qk/
│ │ │ └── iar/
│ │ │ ├── at91SAM7S64.icf
│ │ │ ├── bsp.c
│ │ │ ├── dpp-qk.ewd
│ │ │ ├── dpp-qk.ewp
│ │ │ └── dpp-qk.eww
│ │ ├── qpn_conf.h
│ │ ├── qv/
│ │ │ └── iar/
│ │ │ ├── at91SAM7S64.icf
│ │ │ ├── bsp.c
│ │ │ ├── dpp-qv.ewd
│ │ │ ├── dpp-qv.ewp
│ │ │ └── dpp-qv.eww
│ │ └── table.c
│ ├── avr/
│ │ ├── README.url
│ │ ├── blinky_arduino-uno/
│ │ │ ├── README.url
│ │ │ ├── blinky.c
│ │ │ ├── blinky.h
│ │ │ ├── bsp.h
│ │ │ ├── main.c
│ │ │ ├── qk/
│ │ │ │ ├── gnu/
│ │ │ │ │ ├── Makefile
│ │ │ │ │ ├── README.txt
│ │ │ │ │ ├── bsp.c
│ │ │ │ │ └── flash.bat
│ │ │ │ └── iar/
│ │ │ │ ├── blinky-qk.ewd
│ │ │ │ ├── blinky-qk.ewp
│ │ │ │ ├── blinky-qk.eww
│ │ │ │ ├── bsp.c
│ │ │ │ └── flash.bat
│ │ │ ├── qpn_conf.h
│ │ │ └── qv/
│ │ │ ├── gnu/
│ │ │ │ ├── Makefile
│ │ │ │ ├── README.txt
│ │ │ │ ├── bsp.c
│ │ │ │ └── flash.bat
│ │ │ └── iar/
│ │ │ ├── blinky-qv.ewd
│ │ │ ├── blinky-qv.ewp
│ │ │ ├── blinky-qv.eww
│ │ │ ├── bsp.c
│ │ │ └── flash.bat
│ │ └── dpp_arduino-uno/
│ │ ├── README.url
│ │ ├── bsp.h
│ │ ├── dpp.h
│ │ ├── dpp.qm
│ │ ├── main.c
│ │ ├── philo.c
│ │ ├── qk/
│ │ │ ├── gnu/
│ │ │ │ ├── Makefile
│ │ │ │ ├── README.txt
│ │ │ │ ├── bsp.c
│ │ │ │ └── flash.bat
│ │ │ └── iar/
│ │ │ ├── README.txt
│ │ │ ├── bsp.c
│ │ │ ├── dpp-qk.ewd
│ │ │ ├── dpp-qk.ewp
│ │ │ ├── dpp-qk.eww
│ │ │ ├── flash.bat
│ │ │ └── spy.bat
│ │ ├── qpn_conf.h
│ │ ├── qv/
│ │ │ ├── gnu/
│ │ │ │ ├── Makefile
│ │ │ │ ├── README.txt
│ │ │ │ ├── bsp.c
│ │ │ │ ├── flash.bat
│ │ │ │ └── spy.bat
│ │ │ └── iar/
│ │ │ ├── README.txt
│ │ │ ├── bsp.c
│ │ │ ├── dpp-qv.ewd
│ │ │ ├── dpp-qv.ewp
│ │ │ ├── dpp-qv.eww
│ │ │ ├── flash.bat
│ │ │ └── spy.bat
│ │ └── table.c
│ ├── msp430/
│ │ ├── README.url
│ │ ├── blinky_msp-exp430f5529lp/
│ │ │ ├── README.url
│ │ │ ├── blinky.c
│ │ │ ├── blinky.h
│ │ │ ├── bsp.h
│ │ │ ├── main.c
│ │ │ ├── qk/
│ │ │ │ ├── bsp.c
│ │ │ │ ├── ccs/
│ │ │ │ │ ├── .ccsproject
│ │ │ │ │ ├── .cproject
│ │ │ │ │ ├── .project
│ │ │ │ │ └── lnk_msp430f5529.cmd
│ │ │ │ └── iar/
│ │ │ │ ├── blinky-qk.ewd
│ │ │ │ ├── blinky-qk.ewp
│ │ │ │ └── blinky-qk.eww
│ │ │ ├── qpn_conf.h
│ │ │ └── qv/
│ │ │ ├── bsp.c
│ │ │ ├── ccs/
│ │ │ │ ├── .ccsproject
│ │ │ │ ├── .cproject
│ │ │ │ ├── .project
│ │ │ │ └── lnk_msp430f5529.cmd
│ │ │ └── iar/
│ │ │ ├── blinky-qv.ewd
│ │ │ ├── blinky-qv.ewp
│ │ │ └── blinky-qv.eww
│ │ ├── blinky_msp-exp430g2/
│ │ │ ├── README.url
│ │ │ ├── blinky.c
│ │ │ ├── blinky.h
│ │ │ ├── bsp.h
│ │ │ ├── main.c
│ │ │ ├── qk/
│ │ │ │ ├── bsp.c
│ │ │ │ ├── ccs/
│ │ │ │ │ ├── .ccsproject
│ │ │ │ │ ├── .cproject
│ │ │ │ │ ├── .project
│ │ │ │ │ └── lnk_msp430g2553.cmd
│ │ │ │ └── iar/
│ │ │ │ ├── blinky-qk.ewd
│ │ │ │ ├── blinky-qk.ewp
│ │ │ │ └── blinky-qk.eww
│ │ │ ├── qpn_conf.h
│ │ │ └── qv/
│ │ │ ├── bsp.c
│ │ │ ├── ccs/
│ │ │ │ ├── .ccsproject
│ │ │ │ ├── .cproject
│ │ │ │ ├── .project
│ │ │ │ └── lnk_msp430g2553.cmd
│ │ │ └── iar/
│ │ │ ├── blinky-qv.ewd
│ │ │ ├── blinky-qv.ewp
│ │ │ └── blinky-qv.eww
│ │ └── dpp_msp-exp430g2/
│ │ ├── README.url
│ │ ├── bsp.h
│ │ ├── dpp.h
│ │ ├── dpp.qm
│ │ ├── main.c
│ │ ├── philo.c
│ │ ├── qk/
│ │ │ ├── bsp.c
│ │ │ ├── ccs/
│ │ │ │ ├── .ccsproject
│ │ │ │ ├── .cproject
│ │ │ │ ├── .project
│ │ │ │ └── lnk_msp430g2553.cmd
│ │ │ └── iar/
│ │ │ ├── dpp-qk.ewd
│ │ │ ├── dpp-qk.ewp
│ │ │ └── dpp-qk.eww
│ │ ├── qpn_conf.h
│ │ ├── qv/
│ │ │ ├── bsp.c
│ │ │ ├── ccs/
│ │ │ │ ├── .ccsproject
│ │ │ │ ├── .cproject
│ │ │ │ ├── .project
│ │ │ │ └── lnk_msp430g2553.cmd
│ │ │ └── iar/
│ │ │ ├── dpp-qv.ewd
│ │ │ ├── dpp-qv.ewp
│ │ │ └── dpp-qv.eww
│ │ └── table.c
│ ├── pic24_dspic/
│ │ ├── blinky_microstick2-pic24/
│ │ │ ├── blinky.c
│ │ │ ├── blinky.h
│ │ │ ├── bsp.h
│ │ │ ├── main.c
│ │ │ ├── qk/
│ │ │ │ └── xc16/
│ │ │ │ ├── Makefile
│ │ │ │ ├── bsp.c
│ │ │ │ └── nbproject/
│ │ │ │ ├── Makefile-default.mk
│ │ │ │ ├── Makefile-genesis.properties
│ │ │ │ ├── Makefile-impl.mk
│ │ │ │ ├── Makefile-local-default.mk
│ │ │ │ ├── Makefile-local-release.mk
│ │ │ │ ├── Makefile-release.mk
│ │ │ │ ├── Makefile-variables.mk
│ │ │ │ ├── Package-default.bash
│ │ │ │ ├── Package-release.bash
│ │ │ │ ├── configurations.xml
│ │ │ │ ├── private/
│ │ │ │ │ ├── configurations.xml
│ │ │ │ │ ├── private.properties
│ │ │ │ │ └── private.xml
│ │ │ │ ├── project.properties
│ │ │ │ └── project.xml
│ │ │ ├── qpn_conf.h
│ │ │ └── qv/
│ │ │ └── xc16/
│ │ │ ├── Makefile
│ │ │ ├── bsp.c
│ │ │ └── nbproject/
│ │ │ ├── Makefile-default.mk
│ │ │ ├── Makefile-genesis.properties
│ │ │ ├── Makefile-impl.mk
│ │ │ ├── Makefile-local-default.mk
│ │ │ ├── Makefile-local-release.mk
│ │ │ ├── Makefile-release.mk
│ │ │ ├── Makefile-variables.mk
│ │ │ ├── Package-default.bash
│ │ │ ├── Package-release.bash
│ │ │ ├── configurations.xml
│ │ │ ├── private/
│ │ │ │ ├── configurations.xml
│ │ │ │ ├── private.properties
│ │ │ │ └── private.xml
│ │ │ ├── project.properties
│ │ │ └── project.xml
│ │ ├── dpp_microstick2-pic24/
│ │ │ ├── bsp.h
│ │ │ ├── dpp.h
│ │ │ ├── dpp.qm
│ │ │ ├── main.c
│ │ │ ├── philo.c
│ │ │ ├── qk/
│ │ │ │ └── xc16/
│ │ │ │ ├── Makefile
│ │ │ │ ├── bsp.c
│ │ │ │ └── nbproject/
│ │ │ │ ├── Makefile-default.mk
│ │ │ │ ├── Makefile-genesis.properties
│ │ │ │ ├── Makefile-impl.mk
│ │ │ │ ├── Makefile-local-default.mk
│ │ │ │ ├── Makefile-local-release.mk
│ │ │ │ ├── Makefile-release.mk
│ │ │ │ ├── Makefile-variables.mk
│ │ │ │ ├── Package-default.bash
│ │ │ │ ├── Package-release.bash
│ │ │ │ ├── configurations.xml
│ │ │ │ ├── private/
│ │ │ │ │ ├── configurations.xml
│ │ │ │ │ ├── private.properties
│ │ │ │ │ └── private.xml
│ │ │ │ ├── project.properties
│ │ │ │ └── project.xml
│ │ │ ├── qpn_conf.h
│ │ │ ├── qv/
│ │ │ │ └── xc16/
│ │ │ │ ├── Makefile
│ │ │ │ ├── bsp.c
│ │ │ │ └── nbproject/
│ │ │ │ ├── Makefile-default.mk
│ │ │ │ ├── Makefile-genesis.properties
│ │ │ │ ├── Makefile-impl.mk
│ │ │ │ ├── Makefile-local-default.mk
│ │ │ │ ├── Makefile-local-release.mk
│ │ │ │ ├── Makefile-release.mk
│ │ │ │ ├── Makefile-variables.mk
│ │ │ │ ├── Package-default.bash
│ │ │ │ ├── Package-release.bash
│ │ │ │ ├── configurations.xml
│ │ │ │ ├── private/
│ │ │ │ │ ├── configurations.xml
│ │ │ │ │ ├── private.properties
│ │ │ │ │ └── private.xml
│ │ │ │ ├── project.properties
│ │ │ │ └── project.xml
│ │ │ └── table.c
│ │ └── pelican_microstick2-pic24/
│ │ ├── bsp.h
│ │ ├── main.c
│ │ ├── pelican.c
│ │ ├── pelican.h
│ │ ├── pelican.qm
│ │ ├── qk/
│ │ │ └── xc16/
│ │ │ ├── Makefile
│ │ │ ├── bsp.c
│ │ │ └── nbproject/
│ │ │ ├── Makefile-default.mk
│ │ │ ├── Makefile-genesis.properties
│ │ │ ├── Makefile-impl.mk
│ │ │ ├── Makefile-local-default.mk
│ │ │ ├── Makefile-local-release.mk
│ │ │ ├── Makefile-release.mk
│ │ │ ├── Makefile-variables.mk
│ │ │ ├── Package-default.bash
│ │ │ ├── Package-release.bash
│ │ │ ├── configurations.xml
│ │ │ ├── private/
│ │ │ │ ├── configurations.xml
│ │ │ │ ├── private.properties
│ │ │ │ └── private.xml
│ │ │ ├── project.properties
│ │ │ └── project.xml
│ │ ├── qpn_conf.h
│ │ └── qv/
│ │ └── xc16/
│ │ ├── Makefile
│ │ ├── bsp.c
│ │ └── nbproject/
│ │ ├── Makefile-default.mk
│ │ ├── Makefile-genesis.properties
│ │ ├── Makefile-impl.mk
│ │ ├── Makefile-local-default.mk
│ │ ├── Makefile-local-release.mk
│ │ ├── Makefile-release.mk
│ │ ├── Makefile-variables.mk
│ │ ├── Package-default.bash
│ │ ├── Package-release.bash
│ │ ├── configurations.xml
│ │ ├── private/
│ │ │ ├── configurations.xml
│ │ │ ├── private.properties
│ │ │ └── private.xml
│ │ ├── project.properties
│ │ └── project.xml
│ └── workstation/
│ ├── README.txt
│ ├── blinky/
│ │ ├── Makefile
│ │ ├── README.txt
│ │ ├── blinky.c
│ │ ├── blinky.qm
│ │ └── qpn_conf.h
│ ├── calc/
│ │ ├── Makefile
│ │ ├── bsp.c
│ │ ├── bsp.h
│ │ ├── calc.c
│ │ ├── calc.h
│ │ ├── calc.qm
│ │ ├── main.c
│ │ └── qpn_conf.h
│ ├── comp/
│ │ ├── Makefile
│ │ ├── alarm.c
│ │ ├── alarm.h
│ │ ├── bsp.c
│ │ ├── bsp.h
│ │ ├── clock.h
│ │ ├── comp.c
│ │ ├── main.c
│ │ └── qpn_conf.h
│ ├── defer/
│ │ ├── Makefile
│ │ ├── bsp.c
│ │ ├── bsp.h
│ │ ├── defer.c
│ │ ├── defer.h
│ │ ├── main.c
│ │ └── qpn_conf.h
│ ├── dpp/
│ │ ├── Makefile
│ │ ├── bsp.c
│ │ ├── bsp.h
│ │ ├── dpp.h
│ │ ├── dpp.qm
│ │ ├── dpp.sln
│ │ ├── dpp.vcxproj
│ │ ├── dpp.vcxproj.filters
│ │ ├── main.c
│ │ ├── philo.c
│ │ ├── qpn_conf.h
│ │ └── table.c
│ ├── dpp-comp/
│ │ ├── Makefile
│ │ ├── bsp.c
│ │ ├── bsp.h
│ │ ├── dpp.h
│ │ ├── dpp.sln
│ │ ├── dpp.vcxproj
│ │ ├── dpp.vcxproj.filters
│ │ ├── dpp_comp.qm
│ │ ├── main.c
│ │ ├── philo.c
│ │ ├── qpn_conf.h
│ │ └── table.c
│ ├── dpp-gui/
│ │ └── README.txt
│ ├── game-gui/
│ │ └── README.txt
│ ├── history/
│ │ ├── Makefile
│ │ ├── bsp.c
│ │ ├── bsp.h
│ │ ├── history.c
│ │ ├── history.h
│ │ ├── history.qm
│ │ ├── main.c
│ │ └── qpn_conf.h
│ ├── pelican/
│ │ ├── Makefile
│ │ ├── bsp.c
│ │ ├── bsp.h
│ │ ├── main.c
│ │ ├── pelican.c
│ │ ├── pelican.h
│ │ ├── pelican.qm
│ │ └── qpn_conf.h
│ ├── qhsmtst/
│ │ ├── Makefile
│ │ ├── bsp.c
│ │ ├── bsp.h
│ │ ├── log.txt
│ │ ├── main.c
│ │ ├── qhsmtst.c
│ │ ├── qhsmtst.h
│ │ ├── qhsmtst.qm
│ │ └── qpn_conf.h
│ ├── reminder/
│ │ ├── Makefile
│ │ ├── bsp.c
│ │ ├── bsp.h
│ │ ├── main.c
│ │ ├── qpn_conf.h
│ │ ├── reminder.c
│ │ └── reminder.h
│ └── reminder2/
│ ├── Makefile
│ ├── bsp.c
│ ├── bsp.h
│ ├── main.c
│ ├── qpn_conf.h
│ ├── reminder2.c
│ └── reminder2.h
├── include/
│ ├── qassert.h
│ ├── qepn.h
│ ├── qfn.h
│ ├── qkn.h
│ ├── qpn.h
│ ├── qstamp.c
│ └── qvn.h
├── ports/
│ ├── README.url
│ ├── arm-cm/
│ │ ├── README.url
│ │ ├── qk/
│ │ │ ├── arm/
│ │ │ │ ├── qfn_port.h
│ │ │ │ └── qkn_port.c
│ │ │ ├── armclang/
│ │ │ │ ├── qfn_port.h
│ │ │ │ └── qkn_port.c
│ │ │ ├── gnu/
│ │ │ │ ├── qfn_port.h
│ │ │ │ └── qkn_port.c
│ │ │ └── iar/
│ │ │ ├── qfn_port.h
│ │ │ └── qkn_port.c
│ │ └── qv/
│ │ ├── arm/
│ │ │ ├── qfn_port.h
│ │ │ └── qvn_port.c
│ │ ├── armclang/
│ │ │ ├── qfn_port.h
│ │ │ └── qvn_port.c
│ │ ├── gnu/
│ │ │ ├── qfn_port.h
│ │ │ └── qvn_port.c
│ │ └── iar/
│ │ ├── qfn_port.h
│ │ └── qvn_port.c
│ ├── arm7-9/
│ │ ├── README.url
│ │ ├── qk/
│ │ │ ├── README.url
│ │ │ ├── gnu/
│ │ │ │ ├── qfn_port.h
│ │ │ │ └── qkn_port.s
│ │ │ └── iar/
│ │ │ ├── qfn_port.h
│ │ │ └── qkn_port.s
│ │ └── qv/
│ │ ├── README.url
│ │ ├── gnu/
│ │ │ ├── qfn_port.h
│ │ │ └── qvn_port.s
│ │ └── iar/
│ │ ├── qfn_port.h
│ │ └── qvn_port.s
│ ├── avr/
│ │ ├── README.txt
│ │ ├── README.url
│ │ ├── qk/
│ │ │ ├── gnu/
│ │ │ │ ├── README.txt
│ │ │ │ └── qfn_port.h
│ │ │ └── iar/
│ │ │ └── qfn_port.h
│ │ └── qv/
│ │ ├── gnu/
│ │ │ ├── README.txt
│ │ │ └── qfn_port.h
│ │ └── iar/
│ │ └── qfn_port.h
│ ├── lint-plus/
│ │ ├── 16bit/
│ │ │ ├── cpu.lnt
│ │ │ └── stdint.h
│ │ ├── 32bit/
│ │ │ ├── cpu.lnt
│ │ │ └── stdint.h
│ │ ├── au-ds.lnt
│ │ ├── au-misra3-amd1.lnt
│ │ ├── au-misra3.lnt
│ │ ├── lin.bat
│ │ ├── options.lnt
│ │ ├── qkn/
│ │ │ └── qfn_port.h
│ │ ├── qpn.lnt
│ │ ├── qpn_conf.h
│ │ ├── qvn/
│ │ │ └── qfn_port.h
│ │ ├── std.lnt
│ │ └── stdbool.h
│ ├── msp430/
│ │ ├── README.txt
│ │ ├── README.url
│ │ ├── qk/
│ │ │ ├── ccs/
│ │ │ │ ├── README.txt
│ │ │ │ └── qfn_port.h
│ │ │ └── iar/
│ │ │ └── qfn_port.h
│ │ └── qv/
│ │ ├── ccs/
│ │ │ ├── README.txt
│ │ │ └── qfn_port.h
│ │ └── iar/
│ │ └── qfn_port.h
│ ├── pic24_dspic/
│ │ ├── qk/
│ │ │ └── xc16/
│ │ │ ├── qfn_port.h
│ │ │ └── qkn_port.c
│ │ └── qv/
│ │ └── xc16/
│ │ └── qfn_port.h
│ ├── posix-qv/
│ │ ├── README.url
│ │ ├── qfn_port.h
│ │ ├── qfn_posix.c
│ │ └── safe_std.h
│ └── win32-qv/
│ ├── README.url
│ ├── qfn_port.h
│ ├── qfn_win32.c
│ ├── qwin_gui.c
│ ├── qwin_gui.h
│ └── safe_std.h
└── src/
├── qfn/
│ ├── qepn.c
│ └── qfn.c
├── qkn/
│ └── qkn.c
└── qvn/
└── qvn.c
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
*.obj
*.o
*.d
*.lib
*.a
*.elf
*.err
*.hex
*.exe
*.EXE
*.map
*.dep
*.pdf
*.PDF
*.Hbp
*.nav
*.tps
*.tws
*.tmp
*.log
*.chm
*.zip
*.pdb
*.ncb
*.suo
*.chw
*.sfr
*.ewt
*.user
*.avrsuo
*.Debug
*.Release
lint*.txt
*.Miro
*.bak
*.qlc
JLink*.*
version-*
metrics.dox
html/
test_priv/
dbg/
rel/
spy/
build/
build_rel/
build_spy/
settings/
.settings/
targetConfigs/
Debug/
Release/
lib/
obj/
output/
================================================
FILE: .gitmodules
================================================
[submodule "3rd_party"]
path = 3rd_party
url = https://github.com/QuantumLeaps/3rd_party-qpn.git
================================================
FILE: GPLv3.txt
================================================
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
================================================
FILE: LICENSE.txt
================================================
The QP-nano Real-Time Embedded Framework (RTEF) is licensed under the
dual-licensing model, in which both the open source and traditional
closed source software distribution models are combined. For more
information, please see:
https://www.state-machine.com/licensing
****
NOTE: If your company has a policy forbidding open source in your
product, all QP frameworks can be licensed commercially, in which
case you don't use any open source license and you do not violate
your policy.
****
Contact Information:
====================
- https://www.state-machine.com
- mailto:info@state-machine.com
================================================
FILE: README.md
================================================

---------------------------------------------------------------------------
# What's New?
**NOTE:** QP-nano has been **discontinued** from active development
and support and is **not recommended** for new designs. This QP-nano
repository is preserved for the existing user base.
**LICENSING:** If you are interested in commercial licensing QP-nano,
please refer to section [QP-nano Licensing](#qp-nano-licensing).
**QM Tool Compatibility:** The last QM version that supports code
generation for QP-nano is
[QM 5.2.3 released on 2022-11-18](https://www.state-machine.com/qm/history.html#qm_5_2_3).
Newer QM versions no longer support QP-nano.
# Documentation
The offline HTML documentation for **this** particular version of QP-nano
is located in the folder html/. To view the offline documentation, open
the file html/index.html in your web browser.
The online HTML documention for the **latest** version of QP-nano is located
at: https://www.state-machine.com/qpn/
# About QP-nano
QP-nano (Quantum Platform Nano) is an ultra-lightweight, open source
[Real-Time Embedded Framework (RTEF)][RTEF] for building modern embedded
software as systems of asynchronous, event-driven [active objects][Active]
(actors). The [QP-nano] framework is a member of a larger [QP] family
consisting of [QP/C], [QP/C++], and [QP-nano] frameworks, which are all
strictly quality controlled, thoroughly documented, and [commercially
licensable][Lic].
## Safer Model of Concurrency
The [QP] framework family is based on the [Active Object][Active] (**actor**)
design pattern, which inherently supports and automatically enforces the
following best practices of concurrent programming:
- Keep data isolated and bound to active objects' threads. Threads should
hide (**encapsulate**) their private data and other resources, and not
share them with the rest of the system.
- Communicate among active object threads **asynchronously** via event
objects. Using asynchronous events keeps the threads running truly
independently, **without blocking** on each other.
- Active object threads should spend their lifetime responding to incoming
events, so their mainline should consist of an **event-loop** that handles
events one at a time (to completion), thus avoiding any concurrency hazards
within an active object thread itself.
This architecture is generally **safer**, more responsive and easier to
understand and maintain than the shared-state concurrency of a conventional
RTOS. It also provides higher level of abstraction and the *correct*
abstractions to effectively apply **modeling** and **code generation** to
deeply embedded real-time systems.
## Hierarchical State Machines
The behavior of active objects is specified in QP-nano by means of
[Hierarchical State Machines][HSM] (UML statecharts). The framework
supports manual coding of UML state machines in C as well as automatic
**code generation** by means of the free [QM modeling tool][QM].
## Built-in Real-Time Kernels
The QP-nano framework can run on bare-metal single-chip microcontrollers,
completely replacing a traditional "superloop" or an RTOS. The framework
contains a selection of **built-in real-time kernels**, such as the
cooperative QV-nano kernel and the preemptive non-blocking QK-nano kernel.
Native QP-nano ports and ready-to-use examples are provided for such CPUs
MSP430, AVRmega, and ARM Cortex-M (M0/M0+/M3/M4).
## Maturity
With 60,000 downloads a year, the [QP] family is the most popular such
solution on the embedded software market. It provides a modern, reusable
architecture for embedded applications, which combines the active-object
model of concurrency with hierarchical state machines.
# Getting Started with QP-nano
The [QP-nano Reference Manual](https://www.state-machine.com/qpn/) provides
instructions on how to download, install, and get started with QP-nano quickly.
The [AppNote: "Getting Started with QP-nano"][AN] contains also a tutorial,
in which you build a simple "Blinky" application.
# QP-nano Licensing
QP-nano is licensed under the
[dual licensing model](https://www.state-machine.com/licensing),
in which both the open source software distribution mechanism and
traditional closed source software distribution models are combined.
> **NOTE:** Even though QP-nano has been discontinued, Quantum Leaps will
continue to provide commercial licenses for QP-nano to customers still
interested in deploying QP-nano in closed-source products. These commercial
licenses will NOT provide technical support and will be discounted accordingly.
# QP-nano Documentation
The **QP-nano Manual** is located online at: https://www.state-machine.com/qpn
# 3rd-Party QP-nano Ports/Adaptations
[QPN-PIC16](https://github.com/aschatte/qpn) is an adaptation of the
QP-nano framework to the
[Microchip PIC16](https://www.microchip.com/en-us/products/microcontrollers-and-microprocessors/8-bit-mcus/pic-mcus)
architecture as compiled by the MPALB-X IDE using the XC8 compiler (C90/C99).
It allows QP-nano models developed using the QM modeling tool to be integrated
with the QV-nano kernel to build
[Active Object](https://www.state-machine.com/active-object) applications.
The very limited resources of the PIC16 family of MCUs, primarily the hardware
stack, required a special version of QP-nano and a QM-Modeler editing
post-processor, `QM2HSM.exe`, to effect.
# How to get help?
- [Free Support Forum](https://sourceforge.net/p/qpc/discussion/668726)
- [Bug Reports](https://sourceforge.net/p/qpc/bugs/)
- [Feature Requests](https://sourceforge.net/p/qpc/feature-requests/)
- [Quantum Leaps website](https://www.state-machine.com)
- [Quantum Leaps licensing](https://www.state-machine.com/licensing)
- [info@state-machine.com](mailto:info@state-machine.com)
[RTEF]:
[QP]:
[QP/C]:
[QP/C++]:
[QP-nano]:
[QM]:
[Active]:
[HSM]:
[Lic]:
[AN]:
================================================
FILE: doxygen/Doxyfile
================================================
# Doxyfile 1.9.4
@INCLUDE = ../../ql-doxygen/ql-doxyfile
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "QP-nano"
PROJECT_NUMBER = "6.9.0"
PROJECT_BRIEF = "Real-Time Embedded Framework"
PROJECT_LOGO = ../../ql-doxygen/images/logo_ql.png
OUTPUT_DIRECTORY =
CREATE_SUBDIRS = NO
CREATE_SUBDIRS_LEVEL = 6
ALLOW_UNICODE_NAMES = NO
OUTPUT_LANGUAGE = English
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = NO
ABBREVIATE_BRIEF = "The $name class" \
"The $name widget" \
"The $name file" \
is \
provides \
specifies \
contains \
represents \
a \
an \
the
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = NO
STRIP_FROM_PATH =
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = YES
JAVADOC_BANNER = NO
QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
PYTHON_DOCSTRING = YES
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 4
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_JAVA = NO
OPTIMIZE_FOR_FORTRAN = NO
OPTIMIZE_OUTPUT_VHDL = NO
OPTIMIZE_OUTPUT_SLICE = NO
EXTENSION_MAPPING = lnt=Objective-C
MARKDOWN_SUPPORT = YES
TOC_INCLUDE_HEADINGS = 4
AUTOLINK_SUPPORT = YES
BUILTIN_STL_SUPPORT = NO
CPP_CLI_SUPPORT = NO
SIP_SUPPORT = NO
IDL_PROPERTY_SUPPORT = YES
DISTRIBUTE_GROUP_DOC = NO
GROUP_NESTED_COMPOUNDS = NO
SUBGROUPING = YES
INLINE_GROUPED_CLASSES = YES
INLINE_SIMPLE_STRUCTS = YES
TYPEDEF_HIDES_STRUCT = YES
LOOKUP_CACHE_SIZE = 0
NUM_PROC_THREADS = 1
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
EXTRACT_PRIV_VIRTUAL = NO
EXTRACT_PACKAGE = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = NO
EXTRACT_ANON_NSPACES = NO
RESOLVE_UNNAMED_PARAMS = YES
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = NO
HIDE_SCOPE_NAMES = YES
HIDE_COMPOUND_REFERENCE= NO
SHOW_HEADERFILE = YES
SHOW_INCLUDE_FILES = YES
SHOW_GROUPED_MEMB_INC = NO
FORCE_LOCAL_INCLUDES = NO
INLINE_INFO = YES
SORT_MEMBER_DOCS = NO
SORT_BRIEF_DOCS = NO
SORT_MEMBERS_CTORS_1ST = NO
SORT_GROUP_NAMES = NO
SORT_BY_SCOPE_NAME = NO
STRICT_PROTO_MATCHING = NO
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS = QPN
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_FILES = YES
SHOW_NAMESPACES = YES
FILE_VERSION_FILTER =
LAYOUT_FILE =
CITE_BIB_FILES =
#---------------------------------------------------------------------------
# Configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_IF_INCOMPLETE_DOC = YES
WARN_NO_PARAMDOC = NO
WARN_AS_ERROR = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LINE_FORMAT = "at line $line of file $file"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# Configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = main.dox \
gs.dox \
struct.dox \
api.dox \
exa.dox \
exa_apps.dox \
exa_native.dox \
exa_os.dox \
ports.dox \
ports_native.dox \
ports_arm-cm.dox \
ports_os.dox \
history.dox \
macros.h \
../../ql-doxygen/help.dox \
metrics.dox \
modules.dox \
../include \
../src
INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.dox \
*.h \
*.hpp \
*.c \
*.cpp \
*.s \
*.asm \
*.lnt
RECURSIVE = YES
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXCLUDE_SYMBOLS = QP_IMPL
EXAMPLE_PATH = snippets \
../include \
../src \
../ports \
../examples
EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO
IMAGE_PATH = images \
../../ql-doxygen/images
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
FILTER_SOURCE_PATTERNS =
USE_MDFILE_AS_MAINPAGE =
#---------------------------------------------------------------------------
# Configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = YES
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = NO
REFERENCES_RELATION = NO
REFERENCES_LINK_SOURCE = YES
SOURCE_TOOLTIPS = YES
USE_HTAGS = NO
VERBATIM_HEADERS = YES
CLANG_ASSISTED_PARSING = NO
CLANG_ADD_INC_PATHS = YES
CLANG_OPTIONS =
CLANG_DATABASE_PATH =
#---------------------------------------------------------------------------
# Configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = YES
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = ../html
HTML_FILE_EXTENSION = .html
HTML_HEADER = ../../ql-doxygen/ql-header-awesome.html
HTML_FOOTER = ../../ql-doxygen/ql-footer-awesome.html
HTML_STYLESHEET =
HTML_EXTRA_STYLESHEET = ../../ql-doxygen/doxygen-awesome.css \
../../ql-doxygen/doxygen-awesome-sidebar-only.css \
../../ql-doxygen/doxygen-awesome-sidebar-only-darkmode-toggle.css \
../../ql-doxygen/ql-awesome.css
HTML_EXTRA_FILES = ../../ql-doxygen/doxygen-awesome-darkmode-toggle.js \
../../ql-doxygen/doxygen-awesome-fragment-copy-button.js \
../../ql-doxygen/doxygen-awesome-paragraph-link.js \
../../ql-doxygen/ql-preview.js
HTML_COLORSTYLE_HUE = 209
HTML_COLORSTYLE_SAT = 255
HTML_COLORSTYLE_GAMMA = 113
HTML_TIMESTAMP = NO
HTML_DYNAMIC_MENUS = YES
HTML_DYNAMIC_SECTIONS = NO
HTML_INDEX_NUM_ENTRIES = 100
GENERATE_DOCSET = NO
DOCSET_FEEDNAME = "Doxygen generated docs"
DOCSET_FEEDURL =
DOCSET_BUNDLE_ID = com.state-machine.doc
DOCSET_PUBLISHER_ID = com.state-machine.doc
DOCSET_PUBLISHER_NAME = QuantumLeaps
GENERATE_HTMLHELP = NO
CHM_FILE = ../qpn.chm
HHC_LOCATION =
GENERATE_CHI = NO
CHM_INDEX_ENCODING =
BINARY_TOC = YES
TOC_EXPAND = NO
GENERATE_QHP = NO
QCH_FILE =
QHP_NAMESPACE = com.state-machine.qp
QHP_VIRTUAL_FOLDER = doc
QHP_CUST_FILTER_NAME =
QHP_CUST_FILTER_ATTRS =
QHP_SECT_FILTER_ATTRS =
QHG_LOCATION =
GENERATE_ECLIPSEHELP = NO
ECLIPSE_DOC_ID = com.state-machine.qp
DISABLE_INDEX = NO
GENERATE_TREEVIEW = YES
FULL_SIDEBAR = NO
ENUM_VALUES_PER_LINE = 4
TREEVIEW_WIDTH = 335
EXT_LINKS_IN_WINDOW = NO
OBFUSCATE_EMAILS = NO
HTML_FORMULA_FORMAT = png
FORMULA_FONTSIZE = 10
FORMULA_TRANSPARENT = YES
FORMULA_MACROFILE =
USE_MATHJAX = NO
MATHJAX_VERSION = MathJax_2
MATHJAX_FORMAT = HTML-CSS
MATHJAX_RELPATH = https://cdn.jsdelivr.net/npm/mathjax@2
MATHJAX_EXTENSIONS =
MATHJAX_CODEFILE =
SEARCHENGINE = YES
SERVER_BASED_SEARCH = NO
EXTERNAL_SEARCH = NO
SEARCHENGINE_URL =
SEARCHDATA_FILE = searchdata.xml
EXTERNAL_SEARCH_ID = QPN
EXTRA_SEARCH_MAPPINGS =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED = Q_PARAM_SIZE=2 \
QF_TIMEEVT_CTR_SIZE=2 \
QF_TIMEEVT_PERIODIC \
QF_TIMEEVT_USAGE \
QK_SCHED_LOCK \
QK_ON_CONTEXT_SW
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
================================================
FILE: doxygen/Doxyfile-CHM
================================================
# Doxyfile 1.9.2
@INCLUDE = Doxyfile
#---------------------------------------------------------------------------
# Configuration options related to the HTML output
#---------------------------------------------------------------------------
HTML_OUTPUT = tmp
HTML_HEADER = ../../ql-doxygen/header.html
HTML_FOOTER = ../../ql-doxygen/footer.html
HTML_EXTRA_STYLESHEET = ../../ql-doxygen/ql.css \
../../ql-doxygen/preview.js
HTML_EXTRA_FILES =
GENERATE_HTMLHELP = YES
================================================
FILE: doxygen/api.dox
================================================
/*! @page api API Reference
@tableofcontents
@section api_qepn QEP-nano (Hierarchical State Machines)
QEP is a universal, UML-compliant event processor that enables developers to code UML state machines in highly readable ANSI-C, in which every state machine element is mapped to code precisely, unambiguously, and exactly once (traceability). QEP fully supports hierarchical state nesting, which is the fundamental mechanism for reusing behavior across many states instead of repeating the same actions and transitions over and over again.
@subsection api_qep_hsm Hierarchical State Machines
- ::QHsm class
- QHsm_ctor()
- QHSM_INIT()
- QHSM_DISPATCH()
- QHsm_state()
- QHsm_top()
@section api_qfn QF-nano (Active Object Framework)
QF is a portable, event-driven, real-time framework for execution of active objects (concurrent state machines) specifically designed for real-time embedded (RTE) systems.
@subsection api_qfn_act Active Objects
- ::QActive class
- QActive_ctor()
- QACTIVE_POST()
- QACTIVE_POST_X()
@subsection api_qfn_time Time Events
- QF_tickXISR()
- QActive_armX()
- QActive_disarmX()
@section api_qvn QV-nano (Cooperative Kernel)
QV is a simple **cooperative** kernel (previously called "Vanilla" kernel). This kernel executes active objects one at a time, with priority-based scheduling performed before processing of each event. Due to naturally short duration of event processing in state machines, the simple QV kernel is often adequate for many real-time systems.
The QV scheduler is engaged after every RTC step of any @termref{active object} to choose the next active object to execute. The QV scheduler always chooses the highest-priority active object that has any events in its event queue. The QV scheduler then extracts the next event from this queue and dispatches it to the state machine associated with the active object. The state machine runs to completion, after which the QV scheduler runs and the cycle repeats.
Please note that because the state machines always return to the QV scheduler after each RTC step, a single stack can be used to process all state machines (memory-friendly architecture).
The QV scheduler can also very easily detect when all event queues are empty, at which point it can call the idle callback to let the application put the CPU and peripherals to a low-power sleep mode (power-friendly architecture).
Given the simplicity, portability, and low-resource consumption, the QV scheduler is very attractive. It allows you to partition the problem into active objects and execute these active objects orderly. The task-level response of this scheduler is the longest RTC step in the whole system, but because event-driven active objects don’t block, the RTC steps tend to be very short (typically just a few microseconds). Also, often you can break up longer RTC steps into shorter pieces, by posting an event to self and returning (“Reminder” state pattern). The self-posted event then triggers the continuation of longer processing.
@subsection api_qv_init Kernel Initialization and Control
- QV_INIT()
- QF_run()
- QV_onIdle()
- QV_CPU_SLEEP()
@section api_qkn QK-nano (Preemptive Run-to-Completion Kernel)
QK is a tiny **preemptive**, priority-based, non-blocking kernel designed specifically for executing active objects. QK runs active objects in the same way as prioritized interrupt controller (such as NVIC in ARM Cortex-M) runs interrupts using the single stack. Active objects process their events in run-to-completion (RTC) fashion and remove themselves from the call stack, the same way as nested interrupts remove themselves from the stack upon completion. At the same time high-priority active objects can preempt lower-priority active objects, just like interrupts can preempt each other under a prioritized interrupt controller. QK meets all the requirement of the Rate Monotonic Scheduling (a.k.a. Rate Monotonic Analysis RMA) and can be used in hard real-time systems.
@subsection api_qkn_ctrl Kernel Initialization and Control
- QK_INIT()
- QF_run()
- QK_onIdle()
- QK_schedLock()
- QK_schedUnlock()
@subsection api_qkn_isr Interrupt Management
- QK_ISR_ENTRY()
- QK_ISR_EXIT()
*/
================================================
FILE: doxygen/exa.dox
================================================
/*! @page exa Examples
@tableofcontents
@section exa_gen General Comments
The QP-nano distribution contains many @subpage exa_ref "example projects" to demonstrate various QP-nano features. Each example project is described on its own dedicated page that you can find using several criteria (see @ref exa_ref). The example projects have the following main goals:
- **to help you learn how to use QP-nano** — the examples show the intended way of using QP-nano features and structuring QP-nano applications.
- **to provide you with a starting point for your own projects** — the examples are complete working projects, with correctly pre-configured tools, such as compiler options, linker script, debugger setup, etc.
@note
It is highly recommended that you create your own projects by **copying and modifying** existing example projects rather than starting your QP-nano projects from scratch.
@subsection exa_code Example Code Structure
Starting with QP-nano release 5.4.0, **all** examples are bundled into the QP-nano download, as opposed to being distributed as separate QP Development Kits (QDKs). The main benefit is of this approach is that it greatly reduces chances of mistakes in combining the mainline QP-nano code with various QDKs. The downside is that the QP-nano distribution becomes quite large and that examples can't be added or updated independently from the QP-nano baseline code.
All examples are located in sub-directories of the examples @ref qpn_files "top-level folder", with the hierarchical organization outlined below:
examples
arm-cm — Native examples for ARM-Cortex-M (bare-metal) [A]
blinky_ek-tm4c123gxl — Blinky example for EK-TM4C123GXL board
qk — Version for the @ref comp_qk "preemptive QK kernel"
blinky — Blinky example for workstations (console app)
dpp — DPP example for workstations (console app)
. . . — Other examples for workstations (console app)
A @subpage exa_native "Native examples" are located in sub-directories named after the CPU architecture, such as arm-cm for ARM Cortex-M. Under that directory, the sub-directories blinky_ek-tm4c123gxl contain the specific example on the specified board, such as "Blinky" on the EK-TM4C123GXL board here. In the specific example folder, you find sub-folders for the @ref comp_qk "QK" and @ref comp_qv "QV" kernels, respectively.
B @subpage exa_os "Examples for Workstations" are located in sub-directory workstation. These examples can be built on Windows, Linux and MacOS.
@note
Because the QP-nano distribution contains *all* examples, the number of sub-directories and files in the examples folder may seem daunting. However, knowing the structure of the examples folder, you can simply **delete** the sub-directories that are not interesting to you.
@subsection exa_sec_apps Example Applications
To demonstrate QP-nano features on an embedded board, you need to create an application that does "something interesting". Instead of inventing this "something interesting" for each and every example, the example projects implement one of the three @subpage exa_apps "example applications", which are described on the separate pages:
- @ref blinky
- @ref dpp
- @ref pelican
- @ref game
With the exception of the game application, all other example applications can be implemented on a board with just a couple of LEDs. The @ref game application is a bit more involved and requires a small graphic display on the board.
Beyond these basic applications for demonstrating and testing the various @ref ports "QP-nano ports", the QP-nano distribution contains all examples described in the book Practical UML Statecharts in C/C++, 2nd Edition
@sa
@ref exa_os
@subsection exa_sec_boards Development Boards
While some provided examples can run on your @ref exa_os "desktop computer", most embedded example projects require special hardware in form of @ref exa_sec_boards, which you need to acquire to be able to run the examples. The boards chosen for the examples are generally inexpensive and self-contained with no need for external hardware (such as external JTAG debuggers or power supplies).
@subsection exa_sec_tools Development Tools
Most provided examples require special embedded cross-development tools, such as embedded compilers, linkers, debuggers and IDEs, which you need to acquire independently from the QP-nano distribution. Generally, the examples work with the free (size limited) evaluation versions of the commercial tools. The examples list the versions of tools they were developed and tested with. Please refer to the @ref exa_ref "cross-reference section" @ref exa_sec_tools to see which embedded toolsets are used.
@subsection exa_sec_conf Build Configurations
QP examples @ref ports "QP ports" are provided in the following three **build configurations**:
- **Debug** — this configuration is built with full debugging information and minimal optimization. When the QP framework finds no events to process, the framework busy-idles until there are new events to process.
- **Release** — this configuration is built with no debugging information and high optimization. Single-stepping and debugging at the source-code level is effectively impossible due to the lack of debugging information and optimized code, but the debugger can be used to download and start the executable. When the QP framework finds no events to process, the framework puts the CPU to sleep until there are new events to process.
@remark
Why do you need multiple build configurations?@n
The different phases of embedded software life cycle pose different challenges. During the development and maintenance phase, for example, the emphasis is on the ease of debugging and verifying the correctness of the code, which require lower levels of optimization and special scaffolding code. In contrast, for releasing the code in the final product, the emphasis is on small memory footprint and CPU time efficiency, which require high-level of optimization and removal of any scaffolding code. To address these conflicting needs, the same source code is compiled into multiple **build configurations** that differ in the use of compiler options and activation of the scaffolding code.
@subsection exa_sec_qm QM Models
Many example projects contain code auto-generated by the QM modeling tool. Such projects always contain the corresponding **QM model** file, which you can open in QM, modify, and re-generate the code.
@note
The auto-generated files are saved as **read-only**. This protects them from inadvertent modifications, which will get lost when the files are re-generated by QM (or QMC). All modifications to the auto-generated code should be done in the QM model, not in the code.
@subsection exa_sec_3rd Third-Party Code
The QP-nano example projects often need to use various additional code, such as MCU register definition files, startup code, device drivers, etc., which are provided by Third-Party vendors. All such code is located in the 3rd_party @ref qpn_files "top-level folder".
@note
As far as possible, the code in the 3rd_party folder has been left unchanged from the original source. (Any modified code is clearly identified by top-level comments that detail the applied changes.) For that reason, the Third-Party code might produce **compilation warnings** in your builds.
The code in the 3rd_party folder comes from various sources, and Quantum
Leaps, LLC expressly makes **no claims of ownership** to any of this code, even though some of the code might be customized or modified by Quantum Leaps.
@attention
The Third-Party software components included in the 3rd_party folder are licensed under a variety of different licensing terms that are defined by the respective owners of this software and are spelled out in the `README.txt` or `LICENSE.txt` files included in the respective
sub-folders.
@section exa_own Creating your Own QP-nano Projects
Perhaps the most important fact of life to remember is that in embedded systems nothing works until everything works. This means that you should always start with a working system and gradually evolve it, changing one thing at a time and making sure that it keeps working every step of the way.
Keeping this in mind, the provided QP-nano application examples, such as the super-simple Blinky, or a bit more advanced @ref dpp or @ref game, allow you to get started with a working project rather than starting from scratch. You should also always try one of the provided example projects on the same evaluation board that it was designed for, before making any changes.
Only after convincing yourself that the example project works "as is", you can think about creating your own projects. At this point, the easiest and recommended way is to copy the existing working example project folder (such as the Blinky example) and rename it.
After copying the project folder, you still need to change the name of the project/workspace. The easiest and safest way to do this is to open the project/workspace in the corresponding IDE and use the Save As... option to save the project under a different name. You can do this also with the QM model file, which you can open in QM and "Save As" a different model.
@note
By copying and re-naming an existing, working project, as opposed to creating a new one from scratch, you inherit the correct compiler and linker options an other project settings, which will help you get started much faster.
@section exa_doc Next Steps and Further Reading About QP and QM
To work with QP-nano effectively, you need to learn a bit more about active objects and state machines. Below is a list of links to enable you to further your knowledge:
1. The book “Practical UML Statecharts in C/C++, 2nd Edition” [PSiCC2] and the companion web-page to the book (https://www.state-machine.com/psicc2/
2. Free Support Forum for QP/QM (https://sourceforge.net/p/qpc/discussion/668726 )
3. QP Code Downloads summary (https://www.state-machine.com/downloads )
4. QP Application Notes (https://www.state-machine.com/doc/an )
5. "State Space" Blog (http://embeddedgurus.com/state-space/ )
@next{exa_ref}
*/
/*##########################################################################*/
/*! @page exa_ref Cross-Reference
@tableofcontents
@section exa_ref_native Native Examples (by Built-in Kernel)
- @ref exa_qv
- @ref exa_qk
@section exa_ref_native Native Examples (by Processor)
- @ref exa_arm-cm (Cortex-M0/M0+/M3/M4/M4F)
- @ref exa_arm7-9 ("classic ARM")
- @ref exa_msp430 ("classic" MSP430 and "extended" MSP430x)
- @ref exa_avr (8-bit megaAVR)
@section exa_ref_os Examples for Third-Party OS
- @subpage exa_os
@section exa_ref_boards Examples by Development Board
The boards chosen for the examples are generally inexpensive and self-contained with minimal need for external hardware (such as external JTAG debuggers or power supplies). Also, all the selected boards provide a virtual COM port (ideally).
@note
You can hover the mouse cursor over the icon in the list below to see the picture of the board.
- ARM Cortex-M Boards:
- EK-TM4C123GXL (TivaC LaunchPad)
- EFM32-SLSTK3401A
- mbed-LPC1768
- NUCLEO-L053R8
- NUCLEO-L152RE
- EK-LM3S6965
- STM32F4-Discovery
- ARM7 Boards:
- AT91SAM7S-EK
- MSP430 Boards:
- MSP-EXP430G2 (MSP430 LaunchPad)
- MSP-EXP430F5529LP (MSP430X LaunchPad)
- AVR (megaAVR) Boards:
- Arduino-UNO
@section exa_ref_mcu Native Examples by MCU Architecture
- ARM Cortex-M0/M0+
- @ref arm-cm_dpp_nucleo-l053r8
- ARM Cortex-M3
- @ref arm-cm_dpp_nucleo-l152re
- @ref arm-cm_dpp_mbed-lpc1768
- ARM Cortex-M4F (with hardware FPU)
- @ref arm-cm_blinky_ek-tm4c123gxl
- @ref arm-cm_blinky_efm32-slstk3401a
- @ref arm-cm_dpp_ek-tm4c123gxl
- @ref arm-cm_dpp_efm32-slstk3401a
- @ref arm-cm_game_efm32-slstk3401a
- ARM7 / ARM9
- @ref arm7-9_dpp_at91sam7s-ek
- MSP430
- @ref msp430_blinky_msp-exp430g2
- @ref msp430_blinky_msp-exp430f5529lp
- @ref msp430_dpp_msp-exp430g2
- AVRmega
- @ref avr_blinky_arduino-uno
- @ref avr_dpp_arduino-uno
- PIC24 /dsPIC (coming soon...)
- PIC32 (coming soon...)
- Renesas RX (coming soon...)
- TI TMS320C28x (C28x) (coming soon...)
- TI TMS320C55x (C55x) (coming soon...)
@section exa_ref_tool Native Examples by Development Toolchain
@n
@subsection exa_ref_arm-clang ARM-Clang Toolchain (ARM Compiler 6)
- @ref arm-cm_dpp_nucleo-l053r8
- @ref arm-cm_dpp_ek-tm4c123gxl
@subsection exa_ref_arm-keil ARM-Keil Toolchain (ARM Compiler 5)
- @ref arm-cm_blinky_ek-tm4c123gxl
- @ref arm-cm_blinky_efm32-slstk3401a
- @ref arm-cm_dpp_ek-tm4c123gxl
- @ref arm-cm_dpp_efm32-slstk3401a
- @ref arm-cm_dpp_nucleo-l053r8
- @ref arm-cm_dpp_nucleo-l152re
- @ref arm-cm_game_efm32-slstk3401a
@subsection exa_ref_gnu-arm GNU-ARM (command-line with Makefile, importable to Eclipse)
- @ref arm-cm_blinky_ek-tm4c123gxl
- @ref arm-cm_blinky_efm32-slstk3401a
- @ref arm-cm_dpp_ek-tm4c123gxl
- @ref arm-cm_dpp_efm32-slstk3401a
- @ref arm-cm_dpp_mbed-lpc1768
- @ref arm-cm_dpp_nucleo-l053r8
- @ref arm-cm_dpp_nucleo-l152re
- @ref arm-cm_game_efm32-slstk3401a
- @ref arm7-9_dpp_at91sam7s-ek
@subsection exa_ref_gnu-ccs GNU-ARM with TI CCS IDE
- @ref arm-cm_dpp_ek-tm4c123gxl
@subsection exa_ref_iar-arm IAR EWARM
- @ref arm-cm_blinky_ek-tm4c123gxl
- @ref arm-cm_blinky_efm32-slstk3401a
- @ref arm-cm_dpp_ek-tm4c123gxl
- @ref arm-cm_dpp_efm32-slstk3401a
- @ref arm-cm_dpp_mbed-lpc1768
- @ref arm-cm_dpp_nucleo-l053r8
- @ref arm-cm_dpp_nucleo-l152re
- @ref arm-cm_game_efm32-slstk3401a
- @ref arm7-9_dpp_at91sam7s-ek
@subsection exa_ref_ti-arm TI ARM with CCS IDE
- @ref arm-cm_dpp_ek-tm4c123gxl
@subsection exa_ref_ccs-430 CCS for MSP430
- @ref msp430_blinky_msp-exp430g2
- @ref msp430_blinky_msp-exp430f5529lp
- @ref msp430_dpp_msp-exp430g2
@subsection exa_ref_iar-430 IAR EW430
- @ref msp430_blinky_msp-exp430g2
- @ref msp430_blinky_msp-exp430f5529lp
- @ref msp430_dpp_msp-exp430g2
@subsection exa_ref_iar-avr GNU-AVR
- @ref avr_blinky_arduino-uno
- @ref avr_dpp_arduino-uno
@subsection exa_ref_iar-avr IAR-AVR
- @ref avr_blinky_arduino-uno
- @ref avr_dpp_arduino-uno
@section exa_ref_vendor Examples by MCU Vendor
- Atmel
- @ref arm7-9_dpp_at91sam7s-ek
- @ref avr_blinky_arduino-uno
- @ref avr_dpp_arduino-uno
- NXP
- @ref arm-cm_dpp_mbed-lpc1768
- Silicon Labs
- @ref arm-cm_blinky_efm32-slstk3401a
- @ref arm-cm_dpp_efm32-slstk3401a
- @ref arm-cm_game_efm32-slstk3401a
- STMicroelectronics
- @ref arm-cm_dpp_nucleo-l053r8
- @ref arm-cm_dpp_nucleo-l152re
- Texas Instruments
- @ref arm-cm_blinky_ek-tm4c123gxl
- @ref arm-cm_dpp_ek-tm4c123gxl
- @ref arm-cm_game_efm32-slstk3401a
@next{exa_native}
*/
================================================
FILE: doxygen/exa_apps.dox
================================================
/*##########################################################################*/
/*! @page exa_apps Example Applications
To demonstrate QP-nano features, you need to create an application that does "something interesting". Instead of inventing this "something interesting" for each and every example, most of the example projects implement one of the three example applications, which are described on the separate pages:
- @subpage blinky
- @subpage pelican
- @subpage dpp
- @subpage game
Additionally, the QP-nano distribution contains several application examples described in the PSiCC2 book.
- Calculator
- QHsmTst
- PELICAN
- ...
*/
/*##########################################################################*/
/*! @page blinky Simple Blinky Application
The ultra-simple Blinky example is the embedded systems' equivalent of the venerable "Hello World!" program, that is, the simplest possible working QP application that does "something". In the case of Blinky, this "something" is blinking an LED at the rate of 1Hz, where an LED turns on and remains on for 0.5 seconds on then turns off and remains off for 0.5 seconds.
@image html blinky_ek-tm4c123gxl.gif Blinky on EK-TM4C123GLX (TivaC LaunchPad)
The ultra-simple Blinky application, which consists of just one active object named `Blinky`, is intentionally kept small and illustrates only the most basic QP features, such as:
- defining a simple Blinky active object (AO) @ref oop "class";
- hand-coding the simple state machine of the Blinky AO;
- using a periodic time event;
- initializing the QP framework; and
- starting an AO.
@section blinky_sm State Machine
The very simple state machine of the Blinky AO is shown in the figure below:
@image html SM_blinky.png "State Machine of the Blinky AO"
1 The top-most initial transition in this state machine arms a QP time event (QTimeEvt_armX()) to deliver the `TIMEOUT` signal every half second, so that the LED can stay on for one half second and off for the other half.
2 The initial transition leads to state "off", which turns the LED off in the entry action (`BSP_ledOff()`).
3 When the `TIMEOUT` event arrives in the "off" state, the "off" state transitions to the "on" state
4 The "on" state turns the LED on in the entry action (`BSP_ledOn()`).
5 When the `TIMEOUT` event arrives in the "on" state, the "on" state transitions back to "off", which cases execution of the entry action, in which the LED is turned off. From that point on the cycle repeats forever because the `TIMEOUT` events keep getting generated at the pre-determined rate.
@section blinky_code State Machine Code
The Blinky state machine shown above is implemented in the blinky.c source file, as shown in the
listing below. The code has been specifically organized not to access target resources directly, but instead encapsulate all such access in the calls to the BSP (Board Support Package). So for example, instead of turning the LED on and off by writing to a specific GPIO register on an embedded board, the code calls the BSP functions `BSP_ledOn()` and `BSP_ledOff()`. These functions can then be defined differently for each Target board (or even a desktop workstation), without the need to change the state machine code.
@note
The Blinky source code (blinky.c) is actually the same on all platforms, including Windows
and the embedded boards. The only difference is in the Board Support Package (bsp.c), which is
specific for the target.
@includelineno examples/arm-cm/blinky_ek-tm4c123gxl/blinky.c
As you can see, the structure of the state machine is very clearly recognizable in this code. Please refer to the Application Note A Crash Course in UML State Machines for exact explanation of the state machine coding techniques.
@subsection blinky_ao Defining Active Object (AO) Class
- hand-coding the simple state machine of the Blinky AO;
- using a periodic time event;
- initializing the QP framework; and
- starting an AO.
@next{dpp}
*/
/*##########################################################################*/
/*! @page pelican PEdestrian LIght CONtrolled (PELICAN) Crossing
@image html under_construction.jpg
@next{game}
*/
/*##########################################################################*/
/*! @page dpp Dining Philosophers Problem (DPP)
@image html dpp_win32.jpg
@image html under_construction.jpg
@next{game}
*/
/*##########################################################################*/
/*! @page game "Fly 'n' Shoot" Game
@image html game_win32.jpg
@image html under_construction.jpg
*/
================================================
FILE: doxygen/exa_native.dox
================================================
/*##########################################################################*/
/*! @page exa_native Native Examples (Built-in Kernels)
The QP-nano framework contains real-time kernels (@ref comp_qv and @ref comp_qk), so it can run natively ("bare-metal") on single-chip microcontrollers, completely replacing a traditional RTOS. Click on the following links to see examples for the specified built-in kernels:
- @subpage exa_qv
- @subpage exa_qk
Click on the following links to see examples for the specified CPU architectures:
- @subpage exa_arm-cm
- @subpage exa_arm7-9
- @subpage exa_msp430
- @subpage exa_avr
*/
/*##########################################################################*/
/*! @page exa_qv QV-nano Kernel (Non-Preemptive, Priority-Based, Non-Blocking)
@note
You can hover the mouse cursor over the icon in the list below to see the picture of the board.
- @ref arm-cm_blinky_ek-tm4c123gxl
- @ref arm-cm_blinky_efm32-slstk3401a
- @ref arm-cm_dpp_ek-tm4c123gxl
- @ref arm-cm_dpp_efm32-slstk3401a
- @ref arm-cm_dpp_nucleo-l053r8
- @ref arm-cm_dpp_nucleo-l152re
- @ref arm-cm_game_efm32-slstk3401a
- @ref arm7-9_dpp_at91sam7s-ek
- @ref msp430_blinky_msp-exp430g2
- @ref msp430_blinky_msp-exp430f5529lp
- @ref msp430_dpp_msp-exp430g2
*/
/*##########################################################################*/
/*! @page exa_qk QK-nano Kernel (Preemptive, Priority-Based, Non-Blocking)
@note
You can hover the mouse cursor over the icon in the list below to see the picture of the board.
- @ref arm-cm_blinky_ek-tm4c123gxl
- @ref arm-cm_blinky_efm32-slstk3401a
- @ref arm-cm_dpp_ek-tm4c123gxl
- @ref arm-cm_dpp_efm32-slstk3401a
- @ref arm-cm_dpp_nucleo-l053r8
- @ref arm-cm_dpp_nucleo-l152re
- @ref arm-cm_game_efm32-slstk3401a
- @ref arm7-9_dpp_at91sam7s-ek
- @ref msp430_blinky_msp-exp430g2
- @ref msp430_blinky_msp-exp430f5529lp
- @ref msp430_dpp_msp-exp430g2
*/
/*##########################################################################*/
/*! @page exa_arm-cm ARM Cortex-M (Cortex-M0/M0+/M3/M4F)
@note
You can hover the mouse cursor over the icon in the list below to see the picture of the board.
- @subpage arm-cm_blinky_ek-tm4c123gxl
- @subpage arm-cm_blinky_efm32-slstk3401a
- @subpage arm-cm_dpp_ek-tm4c123gxl
- @subpage arm-cm_dpp_efm32-slstk3401a
- @subpage arm-cm_dpp_mbed-lpc1768
- @subpage arm-cm_dpp_nucleo-l053r8
- @subpage arm-cm_dpp_nucleo-l152re
- @subpage arm-cm_game_efm32-slstk3401a
*/
/*##########################################################################*/
/*! @page exa_arm7-9 ARM7/ARM9 ("classic" ARM)
@note
You can hover the mouse cursor over the icon in the list below to see the picture of the board.
- @subpage arm7-9_dpp_at91sam7s-ek
*/
/*##########################################################################*/
/*! @page exa_msp430 MSP430 ("classic" MSP430 and "extended" MSP430x)
@note
You can hover the mouse cursor over the icon in the list below to see the picture of the board.
- @subpage msp430_blinky_msp-exp430g2
- @subpage msp430_blinky_msp-exp430f5529lp
- @subpage msp430_dpp_msp-exp430g2
*/
/*##########################################################################*/
/*! @page arm-cm_blinky_ek-tm4c123gxl Blinky on EK-TM4C123GXL
@tableofcontents
This example implements the @ref blinky "Blinky sample application" on the EK-TM4C123GLX board (ARM Cortex-M4F).
@image html bd_EK-TM4C123GXL.jpg EK-TM4C123GXL board
The Blinky example is located in the directory qpc/examples/arm-cm/blinky_ek-tm4c123gxl, which is organized as follows:
@code{.x}
qpn/ - QP-nano installation directory
+-examples/ - QP-nano examples directory (application)
| +-arm-cm/ - QP-nano examples for ARM Cortex-M
| | +-blinky_ek-tm4c123gxl/ - Blinky example on the EK-TM4C123GLX board
| | | +-qk/ - QK version
| | | | +-arm/ - ARM-KEIL toolchain
| | | | | +-blinky-qk.uvprojx - uVision project
| | | | +-gnu/ - GNU-ARM toolchain
| | | | | +-Makefile - Makefile for building the project
| | | | +-iar/ - IAR-ARM toolchain
| | | | | +-blinky-qk.eww - IAR EW-ARM workspace
| | | | +-bsp.c - BSP for the QK-nano kernel
| | | +-qv/ - QV version
| | | | +-arm/ - ARM-KEIL toolchain
| | | | | +-blinky-qk.uvprojx - uVision project
| | | | +-gnu/ - GNU-ARM toolchain
| | | | | +-Makefile - Makefile for building the project with GNU-ARM
| | | | +-iar/ - IAR-ARM toolchain
| | | | | +-blinky-qk.eww - IAR EW-ARM workspace
| | | | +-bsp.c - BSP for the QV-nano kernel
| | | +-win32-qv/ - Windows emulation (single thread)
| | | | +-Makefile - Makefile for building the project with MinGW
| | | | +-bsp.c - BSP for the Win32-QV
@endcode
@section arm-cm_blinky_ek-tm4c123gxl_feat Features Demonstrated
- cooperative QV-nano kernel
+ with ARM-KEIL toolchain
+ with GNU-ARM toolchain
+ with IAR-ARM toolchain
- preemptive run-to-completion QK-nano kernel
+ with ARM-KEIL toolchain
+ with GNU-ARM toolchain
+ with IAR-ARM toolchain
- Windows emulation (console, single threaded: win32-qv)
@section arm-cm_blinky_ek-tm4c123gxl_run Running the Example
Once programmed into the board, the example blinks the on-board LED about once a second.
@image html blinky_ek-tm4c123gxl.gif Blinky on EK-TM4C123GLX (TivaC LaunchPad)
@section arm-cm_blinky_ek-tm4c123gxl_win Windows Emulation
The Windows emulation is a simple console application that produces the following output:
@image html blinky_win32.png Blinky emulation running in a Windows console
@next{arm-cm_blinky_efm32-slstk3401a}
*/
/*##########################################################################*/
/*! @page arm-cm_blinky_efm32-slstk3401a Blinky on EFM32-SLSTK3401A
@tableofcontents
This example implements the @ref blinky "Blinky sample application" on the EFM32-SLSTK3401A board (ARM Cortex-M4F).
@image html bd_EFM32-SLSTK3401A.jpg EFM32-SLSTK3401A board
The Blinky example is located in the directory qpc/examples/arm-cm/blinky_efm32-slstk3401a, which is organized as follows:
@code{.x}
qpn/ - QP-nano installation directory
+-examples/ - QP-nano examples directory (application)
| +-arm-cm/ - QP-nano examples for ARM Cortex-M
| | +-blinky_efm32-slstk3401a/ - Blinky example on the EFM32-SLSTK3401A board
| | | +-qk/ - QK version
| | | | +-arm/ - ARM-KEIL toolchain
| | | | | +-blinky-qk.uvprojx - uVision project
| | | | +-gnu/ - GNU-ARM toolchain
| | | | | +-Makefile - Makefile for building the project
| | | | +-iar/ - IAR-ARM toolchain
| | | | | +-blinky-qk.eww - IAR EW-ARM workspace
| | | | +-bsp.c - BSP for the QK-nano kernel
| | | +-qv/ - QV version
| | | | +-arm/ - ARM-KEIL toolchain
| | | | | +-blinky-qk.uvprojx - uVision project
| | | | +-gnu/ - GNU-ARM toolchain
| | | | | +-Makefile - Makefile for building the project with GNU-ARM
| | | | +-iar/ - IAR-ARM toolchain
| | | | | +-blinky-qk.eww - IAR EW-ARM workspace
| | | | +-bsp.c - BSP for the QV-nano kernel
| | | +-workstation/ - Examples for workstations (Windows, Linux, MacOS)
| | | | +-Makefile - Makefile for building the project with MinGW
| | | | +-bsp.c - BSP for workstations
@endcode
@section arm-cm_blinky_efm32-slstk3401a_feat Features Demonstrated
- cooperative QV-nano kernel
+ with ARM-KEIL toolchain
+ with GNU-ARM toolchain
+ with IAR-ARM toolchain
- preemptive run-to-completion QK-nano kernel
+ with ARM-KEIL toolchain
+ with GNU-ARM toolchain
+ with IAR-ARM toolchain
- Windows emulation (console, single threaded: win32-qv)
@section arm-cm_blinky_efm32-slstk3401a_run Running the Example
Once programmed into the board, the example blinks the on-board LED about once a second.
@section arm-cm_blinky_efm32-slstk3401a_win Windows Emulation
The Windows emulation is a simple console application that produces the following output:
@image html blinky_win32.png Blinky emulation running in a Windows console
@next{arm-cm_dpp_ek-tm4c123gxl}
*/
/*##########################################################################*/
/*! @page arm-cm_dpp_ek-tm4c123gxl DPP on EK-TM4C123GXL
@tableofcontents
This example implements the @ref dpp "Dining Philosophers Problem" sample application on the EK-TM4C123GLX board (ARM Cortex-M4F).
@image html bd_EK-TM4C123GXL.jpg EK-TM4C123GXL board
The DPP example is located in the directory qpc/examples/arm-cm/dpp_ek-tm4c123gxl, which is organized as follows:
@code{.x}
qpn/ - QP-nano installation directory
+-examples/ - QP-nano examples directory (applications)
| +-arm-cm/ - QP-nano examples for ARM Cortex-M
| | +-dpp_ek-tm4c123gxl/ - DPP example on the EK-TM4C123GLX board
| | | +-lint/ - PC-Lint version (static analysis of the application code)
| | | | +-lin.bat - batch file for running the PC-Lint
| | | | +-options.lnt - PC-Lint options file for the DPP application code
| | | +-qk/ - QK version
| | | | +-arm/ - ARM-KEIL toolchain
| | | | | +-dpp-qk.uvprojx - uVision project
| | | | +-gnu/ - GNU-ARM toolchain
| | | | | +-Makefile - Makefile for building the project
| | | | +-iar/ - IAR-ARM toolchain
| | | | | +-dpp-qk.eww - IAR EW-ARM workspace
| | | | +-ti/ - TI-ARM toolchain (CCS)
| | | | | +-.ccsproject - CCS project
| | | | | +-.cproject - C Eclipse project
| | | | | +-.project - Eclipse project
| | | | +-bsp.c - BSP for the QK-nano kernel
| | | | +-main.c - main() for the QK-nano kernel
| | | +-qv/ - QV version
| | | | +-arm/ - ARM-KEIL toolchain
| | | | | +-dpp-qk.uvprojx - uVision project
| | | | +-gnu/ - GNU-ARM toolchain
| | | | | +-Makefile - Makefile for building the project with GNU-ARM
| | | | +-iar/ - IAR-ARM toolchain
| | | | | +-blinky-qk.eww - IAR EW-ARM workspace
| | | | +-bsp.c - BSP for the QV-nano kernel
| | | | +-main.c - main() for the QV-nano kernel
@endcode
@section arm-cm_dpp_ek-tm4c123gxl_feat Features Demonstrated
- cooperative QV-nano kernel
+ with ARM-KEIL toolchain
+ with GNU-ARM toolchain
+ with IAR-ARM toolchain
+ with TI-ARM toolchain (CCS)
- preemptive run-to-completion QK-nano kernel
+ with ARM-KEIL toolchain
+ with GNU-ARM toolchain
+ with IAR-ARM toolchain
+ with TI-ARM toolchain (CCS)
- Windows emulation with GUI (single threaded, win32-qv)
@section arm-cm_dpp_ek-tm4c123gxl_run Running the Example
Once programmed into the board, the example rapidly toggles the Blue LED from the idle loop (blue LED glows) and toggles the Red and Green LEDs as the Philosophers change their state. Additionally, you can depress and hold the SW1 button (left) to PAUSE the application (Table transitions into the "paused" state). Releasing the SW1 button causes transition back to the "serving" state.
*/
/*##########################################################################*/
/*! @page arm-cm_dpp_efm32-slstk3401a DPP on EFM32-SLSTK3401A
@tableofcontents
This example implements the @ref dpp "Dining Philosophers Problem" sample application on the EFM32-SLSTK3401A board (ARM Cortex-M4F).
@image html bd_EFM32-SLSTK3401A.jpg EFM32-SLSTK3401A board
The DPP example is located in the directory qpc/examples/arm-cm/dpp_efm32-slstk3401a and includes versions for @ref qv "cooperative QV-nano kernel", the @ref qk "preemptive QK-nano kernel", and the @ref qxk "preemptive dual mode QXK RTOS kernel" each provided for the ARM-KEIL, GNU-ARM, and IAR-ARM. The following annotated directory listing describes the contents of the example folder:
@code{.x}
qpn/ - QP-nano installation directory
+-examples/ - QP-nano examples directory (application)
| +-arm-cm/ - QP-nano examples for ARM Cortex-M
| | +-dpp_efm32-slstk3401a/ - DPP example on the EK-TM4C123GLX board
| | | +-lint/ - PC-Lint version (static analysis of the application code)
| | | | +-lin.bat - batch file for running the PC-Lint
| | | | +-options.lnt - PC-Lint options file for the DPP application code
| | | +-qk/ - QK version
| | | | +-arm/ - ARM-KEIL toolchain
| | | | | +-dpp-qk.uvprojx - uVision project
| | | | +-gnu/ - GNU-ARM toolchain
| | | | | +-Makefile - Makefile for building the project
| | | | +-iar/ - IAR-ARM toolchain
| | | | | +-dpp-qk.eww - IAR EW-ARM workspace
| | | | +-bsp.c - BSP for the QK-nano kernel
| | | | +-main.c - main() for the QK-nano kernel
| | | +-qv/ - QV version
| | | | +-arm/ - ARM-KEIL toolchain
| | | | | +-dpp-qk.uvprojx - uVision project
| | | | +-gnu/ - GNU-ARM toolchain
| | | | | +-Makefile - Makefile for building the project with GNU-ARM
| | | | +-iar/ - IAR-ARM toolchain
| | | | | +-blinky-qk.eww - IAR EW-ARM workspace
| | | | +-bsp.c - BSP for the QV-nano kernel
| | | | +-main.c - main() for the QV-nano kernel
@endcode
@section arm-cm_dpp_efm32-slstk3401a_feat Features Demonstrated
- cooperative QV-nano kernel
+ with ARM-KEIL toolchain
+ with GNU-ARM toolchain
+ with IAR-ARM toolchain
- preemptive run-to-completion QK-nano kernel
+ with ARM-KEIL toolchain
+ with GNU-ARM toolchain
+ with IAR-ARM toolchain
- Windows emulation with GUI (single threaded, win32-qv)
@section arm-cm_dpp_efm32-slstk3401a_run Running the Example
Once programmed into the board, the example rapidly toggles the LED1 from the idle loop (LED1 glows) and toggles LED0 as the Philosophers change their state. Additionally, you can depress and hold the BTN0 button (left) to PAUSE the application (Table transitions into the "paused" state). Releasing the BTN0 button causes transition back to the "serving" state.
*/
/*##########################################################################*/
/*! @page arm-cm_dpp_mbed-lpc1768 DPP on mbed-LPC1768
@image html bd_mbed-LPC1768.jpg mbed-LPC1768 board
Dining Philosophers Problem (DPP) example for NXP LPC1768 MCU (Cortex-M3) with GNU-ARM toolchain.
@image html mbed-LPC1768_button.jpg Adding External Button to mbed-LPC1768
@n
@n
@image html under_construction.jpg
*/
/*##########################################################################*/
/*! @page arm-cm_dpp_nucleo-l053r8 DPP on NUCLEO-L053R8
@image html bd_nucleo-l053r8.jpg NUCLEO-L053R8 board
@ref dpp "Dining Philosophers Problem (DPP)" example for NUCLEO-L053R8 MCU (Cortex-M0+).
Demonstrated built-in kernels:
- cooperative @ref qv with ARM-Clang, ARM-Keil, GNU-ARM (Makefile and Atollic TRUEstudio), and IAR-ARM toolchains
- preemptive, run-to-completion @ref qk with ARM-Clang, ARM-Keil, GNU-ARM, and IAR-ARM toolchains
Features:
- multiple active objects, including 5 instances of the same AO class (Philo)
- QK_onContextSw() callback function
*/
/*##########################################################################*/
/*! @page arm-cm_dpp_nucleo-l152re DPP on NUCLEO-L152RE
@image html bd_nucleo-l152re.jpg NUCLEO-L152RE board
@ref dpp "Dining Philosophers Problem (DPP)" example for NUCLEO-L152RE MCU (Cortex-M3).
Demonstrated built-in kernels:
- cooperative @ref qv with ARM-Clang, ARM-Keil, GNU-ARM, and IAR-ARM toolchains
- preemptive, run-to-completion @ref qk with ARM-Clang, ARM-Keil, GNU-ARM, and IAR-ARM toolchains
Features:
- multiple active objects, including 5 instances of the same AO class (Philo)
*/
/*##########################################################################*/
/*! @page arm-cm_game_efm32-slstk3401a "Fly 'n' Shoot" Game on EFM32-SLSTK3401A
@image html bd_EFM32-SLSTK3401A.jpg EFM32-SLSTK3401A board
"Fly 'n' Shoot" game example for Silicon Labs Pearl Gecko MCU (Cortex-M4F), ARM (MDK-ARM), GNU-ARM, IAR EWARM toolsets.
@image html game_win32.png Game emulation running in Windows GUI
@n
@n
@image html under_construction.jpg
*/
/*##########################################################################*/
/*! @page exa_arm7-9 ARM7 / ARM9
The native (bare-metal) QP-nano examples for the "classic" ARM7/ARM9 are as follows:
- @subpage arm7-9_dpp_at91sam7s-ek
*/
/*##########################################################################*/
/*! @page arm7-9_dpp_at91sam7s-ek DPP on AT91SAM7S-EK
@image html bd_AT91SAM7S-EK.jpg AT91SAM7S-EK board
Dining Philosophers Problem (DPP) example for Atmel AT91SAM7S MCU (ARM7) with GNU-ARM toolset.
@image html under_construction.jpg
*/
/*##########################################################################*/
/*! @page exa_avr AVR (AVRmega)
The native (bare-metal) QP-nano examples for the 8-bit AVRmega are as follows:
- @subpage avr_blinky_arduino-uno
- @subpage avr_dpp_arduino-uno
*/
/*##########################################################################*/
/*! @page avr_blinky_arduino-uno Blinky on Arduino-UNO
@image html bd_Arduino-UNO.jpg Arduino-UNO board
Simple Blinky example for Arduino-UNO with GNU-AVR and IAR-AVR toolsets.
@image html under_construction.jpg
*/
/*##########################################################################*/
/*! @page avr_dpp_arduino-uno DPP on Arduino-UNO
@image html bd_Arduino-UNO.jpg Arduino-UNO board
Dining Philosophers Problem (DPP) example for Arduino-UNO with GNU-AVR and IAR-AVR toolsets.
@image html Arduino-UNO_button.jpg Adding External Button to Arduino-UNO
@n
@n
@image html Arduino-UNO_button_schem.jpg External Button Schematics
@n
@n
@image html under_construction.jpg
*/
/*##########################################################################*/
/*! @page exa_msp430 MSP430
The native (bare-metal) QP-nano examples for MSP430 are as follows:
- @subpage msp430_blinky_msp-exp430g2
- @subpage msp430_blinky_msp-exp430f5529lp
- @subpage msp430_dpp_msp-exp430g2
*/
/*##########################################################################*/
/*! @page msp430_blinky_msp-exp430g2 Blinky on MSP-EXP430G2
@image html bd_MSP-EXP430G2.jpg MSP-EXP430G2 board
Simple Blinky example for MSP-EXP430G2 with CCS-430 and IAR-430 toolsets.
@image html under_construction.jpg
*/
/*##########################################################################*/
/*! @page msp430_blinky_msp-exp430f5529lp Blinky on MSP-EXP430F5529LP
@image html bd_MSP-EXP430F5529LP.jpg MSP-EXP430F5529LP board
Simple Blinky example for MSP-EXP430F5529LP with CCS-430 and IAR-430 toolsets.
@image html under_construction.jpg
*/
/*##########################################################################*/
/*! @page msp430_dpp_msp-exp430g2 DPP on MSP-EXP430G2
@image html bd_MSP-EXP430G2.jpg MSP-EXP430G2 board
DPP example for MSP-EXP430G2 with CCS-430 and IAR-430 toolsets.
@image html under_construction.jpg
*/
================================================
FILE: doxygen/exa_os.dox
================================================
/*##########################################################################*/
/*! @page exa_os Examples for Workstations (Windows/POSIX)
- blinky Simple "Blinky" for Windows (command line)
- calc Calculator example from Chapter 2 of PSiCC2
- comp Orthogonal Component design pattern
- comp_qm Orthogonal Component with QM model design pattern
- defer Deferred Event design pattern
- dpp DPP (command-line)
- dpp-comp DPP with the "Orthogonal Component" pattern (command-line)
- dpp-gui DPP (with GUI on Windows)
- game-gui "Fly 'n' Shoot" game from Chapter 1 of PSiCC2
- history Transition-to-History design pattern (hand-coded)
- pelican PEdestrian LIgth CONtrolled Crossing (command line)
- qhsmtst Test State Machine based on ::QHsm with QM model
- reminder Reminder design pattern from Chapter 5 of PSiCC2
- reminder2 Reminder design pattern different version
@sa
@ref win32-qv "QP-nano Win32-QV Emulation"
*/
================================================
FILE: doxygen/gs.dox
================================================
/*! @page gs Getting Started
@section gs_obtain Downloading & Installing QP-nano™
@tableofcontents
The most recommended way of obtaining QP-nano™ is by downloading the QP-bundle™, which includes QP-nano™ as well as other QP frameworks and also the QM™ modeling tool and the QTools™ collection. The main advantage of obtaining QP-nano™ bundled together like that is that you get all components, tools and examples ready to go.
@note
QP-bundle™ is the **most recommended** way of downloading and installing QP-nano™. However, if you are allergic to installers and GUIs or don't have administrator privileges you can also **download and install QP-nano™ separately** as described in the Application Note: "Getting Started with QP-nano" below.
@section gs_an Getting Started with QP-nano App Note
The Quantum Leaps Application Note Getting Started with QP-nano provides step-by-step instructions on how to get started with QP-nano quickly.
@htmlonly
Application Note: Getting Started with QP-nano
@endhtmlonly
@section gs_files Directories and Files
The following annotated directory tree lists the top-level directories provided in the standard QP-nano distribution.
qpn
3rd_party — Third-Party code used in the QP-nano @ref ports "ports" and @ref exa "examples"
examples — @ref exa "QP-nano Examples"
ports — @ref ports "QP-nano Ports"
include — Platform-independent QP-nano API (see include)
source — Platform-independent QP-nano source code (see @ref source)
@note
The standard QP-nano distribution contains many @ref exa "Example Projects", which are specifically designed to help you learn to use QP-nano and to serve you as starting points for your own projects.
@next{struct}
*/
================================================
FILE: doxygen/history.dox
================================================
/**
@page history Revision History
@section qpn_6_9_0 Version 6.9.0, 2020-08-21
- Applied the Doxygen commands `extends` and `memberof` to indicate inheritance and to explicitly specify base classes for all derived classes (e.g., QActive extends QHsm).
- Fixed some errors in documentation comments in source code, etc.
- Bumped version to 6.9.0 for compatibility with QM 5.1.3
@attention
This is the last QP-nano release. The QP-nano framework is being __phased out__ and is not recommended for new product development.
@section qpn_6_8_2 Version 6.8.2, 2020-06-30
- Updated 3rd_party/CMSIS to version 5.7.0
- Updated example projects for ARM Cortex-M with ARM/KEIL to use the startup in the odler ARM assembly (as opposed to ARMCLANG assembly)
- Updated the doxygen styling
@section qpn_6_8_1 Version 6.8.1, 2020-04-04
Fixedhe following bugs:
This release updates the QP-nano ports and examples for workstations (Windows and POSIX) by consistently applying the "safe" versions of services from `` and ``. The "portable" versions of these services are defined as macros in the `safe_std.h` header file and include the following services:
- `MEMMOVE_S()` -> `memmove_s()`
- `STRCPY_S()` -> `strcpy_s()`
- `STRCPY_S()` -> `strcpy_s()`
- `STRCAT_S()` -> `strcat_s()`
- `SNPRINTF_S()` -> `_snprintf_s()`
- `PRINTF_S()` -> `printf_s()`
- `FPRINTF_S()` ->`fprintf_s()`
- `FREAD_S()` -> `fread_s()`
- `FOPEN_S()` -> `fopen_s()`
- `LOCALTIME_S()` -> `localtime_s()`
These "safe" functions are mapped to the best approximation of these services available on a given platform. For example, `STRCPY_S()` is mapped to `strcpy_s()` on Windows and `strcpy()` on POSIX (Linux/MacOS/etc.).
Finally, this release consistently applies the #Q_NORETURN macro to the Q_onAssert() implementations in the QP-nano examples.
@section qpn_6_8_0 Version 6.8.0, 2020-03-21
Source code changes:
- Fixed inconsistencies between QP API declarations in the .h files and definitions in the .c files, such as different parameter names in declarations and definitions (MISRA-C:2012).
- Removed a lot of excessive type casting of compile-time constants, such as `(uint8_t)0`, which is now coded simply as `0U`
- Introduced #Q_NORETURN macro for Q_onAssert(), which can (if defined) inform the compiler that Q_onAssert() does not return. This can potentially improve the code generation and can improve diagnostics generated by the compiler as well as static code analysis tools.
Updated Examples:
Converted most of the examples for ARM-MDK from the no-longer maintained compiler-5 (RVDS) to the new ARM Compiler-6 (ARM-clang). The examples for ARM Compiler-6 are located in the `armclang` sub-directories.
@note
The older ARM Compiler-5 is still supported, but will be phased out in the future. The only examples for ARM Compiler-5 are for the EK-TM4C123GXL (TivaC LanuchPad) board. These examples are located in the `arm` sub-directories.
@section qpn_6_7_0 Version 6.7.0, 2019-12-30
The main purpose of this release is providing improved compliance with MISRA-C:2012 (including MISRA-C:2012-Amendment-1) and also to provide support for the [PC-Lint-Plus](https://www.gimpel.com/) static analysis tool (see also feature request [#169](https://sourceforge.net/p/qpc/feature-requests/169/)). Specifically, the QP-nano source code and some examples have been adjusted to comply with MISRA-C:2012-Amendment-1 rules, with all deviations captured in the PC-Lint-Plus configuration files. These PC-Lint-Plus configuration files have been provided in the new "port" to PC-Lint-Plus in the directory qpn/ports/lint-plus/.
@note
The support for the older PC-Lint 9.x and the older MISRA-C:2004 has been dropped to avoid confusion and conflicts with the newer MISRA-C:2012 and the newer PC-Lint-Plus.
This release also includes the offline documentation for **this** particular version of QP-nano (in the `html/` folder). To view the offline documentation, open the file `html/index.html` in your web browser. (The online HTML documention for the **latest** version of QP-nano remains located at: https://www.state-machine.com/qpc/ )
Also, this release drops (no longer supports) the following depricated facilities from the qpn.h header file:
- Q_ROM_VAR - just remove from your code
- Q_RENTRANT - just remove from your code
- QMSM_INIT() - use QHSM_INIT() instead
- QMSM_DISPATCH() - use QHSM_DISPATCH() instead
- QF_onIdle() - use QV_onIdle() instead
- QMsm_ctor() - use QHsm_ctor() instead
- QMsm_init() - use QHSM_INIT() instead
- QMsm_dispatch() - use QHSM_DISPATCH() instead
- QMActive_ctor() - use QActive_ctor() instead
- QMsm_init() - use QHSM_INIT() instead
- QActive_post() - use QACTIVE_POST() instead
- QActive_postISR() - use QACTIVE_POST_ISR() instead
- QActive_arm() - use QActive_armX() instead
- QActive_disarm() - use QActive_disarmX() instead
- Q_TIMERSET - define QF_TIMEEVT_USAGE instead
Also, this release updates the Windows-GUI examples with the QWIN Prototyping Toolkit to work with the latest Visual Studio 2019 and specifically with the Resource Editor now available. Specifically here, the Game-GUI example (qpn\examples\arm-cm\game_efm32-slstk3401a\win32-gui) and the DPP-GUI example (qpn\examples\arm-cm\dpp_efm32-slstk3401a\win32-gui) have been updated to build with the Visual Studio 2019.
Finally, this release fixes the following bugs:
- [bug#255 "IAR-ARM "Multi-file Compilation" fails for QK and QXK applications"](https://sourceforg/bugs/255/)
@section qpn_6_6_0 Version 6.6.0, 2019-10-31
The main purpose of this release is the change in distribution of the QP-nano framework, which is now bundled together with the other QP frameworks (QP/C and QP/C++) as well as QM, and the QTools collection into "QP-bundle". This "QP-bundle" provides a single, streamlined and simplified download and installation of all QP frameworks and all the accompanying tools.
This release brings also the following changes:
- removed "//" (double slash) from all comments for compliance with the MISRA-C:2012 required Rule 3.1. (The "//" sequence was used in the URLs, such as "http://...").
- converted inclusion guards in header files to uppercase as per coding convention for macros.
- replaced "vtbl" with "vtable" in QP-nano source code
- extended the range of #Q_PARAM_SIZE to 8 (8 corresponding to uint64_t)
- fixed [bug#252 qassert.h used as standalone in qpn](https://sourceforge.net/p/qpc/bugs/252/)
@section qpn_6_5_1 Version 6.5.1, 2019-06-11
This release adds ports and examples for PIC24/dsPIC 16-bit MCUs with MPLAB-X and XC16 compiler toolchain.
@section qpn_6_5_0 Version 6.5.0, 2019-03-30
This QP-nano release matches the [QM release 4.5.0](https://www.state-machine.com/qm/history.html#qm_4_5_0), which introduced new implementation for QP/C++. Even though this has no impact on the QP-nano state machine implementation with QM, this release is needed for compatibility checking between QP and QM. This release comes with several models for **QM 4.5.0**.
@section qpn_6_4_0 Version 6.4.0, 2019-02-10
This release brings the following changes:
- added assertion to QHSM_INIT() to make sure the the virtual-pinter (vptr) is initialized
@note
These additional assertions require #Q_DEFINE_THIS_FILE or #Q_DEFINE_THIS_MODULE at the top of the .c file that calls QHSM_INIT().
- modified qassert.h to work correctly when assertions are disabled with #Q_NASSERT and also updated the QP/C source code to build correctly without assertions
- modified Makefiles for workstations (Windows and POSIX) to use compiler options -std=c99 for C and -std=c++11 for C++ as well as -pedantic option.
@section qpn_6_3_8 Version 6.3.8, 2018-12-31
The main purpose of this release is the update the `Makefiles` that use the [GNU-ARM Embedded Toolchain](https://developer.arm.com/open-source/gnu-toolchain/gnu-rm) to match the recent update in [QTools for Windows 6.3.8](https://sourceforge.net/projects/qpc/files/QTools/). Specifically, all `Makefiles` in the `examples` directory have been updated to use the GNU-ARM toolchain located in `qtools\gnu_arm-none-eabi` and use the tools prefix **arm-none-eabi-**.
@note
The `Makefiles` that use the GNU-ARM included in this release require [QTools for Windows version 6.3.8 or newer](https://sourceforge.net/projects/qpc/files/QTools/) and will **NOT** work with the older QTools collection.
@section qpn_6_3_7 Version 6.3.7, 2018-12-07
The main purpose of this release is re-designing of the @ref exa_os "examples for workstations" (previously `win32-qv` and `posix-qv`). All these types of examples have been consolidated in the @ref exa_os "exampes/workstation" folder, where the provided `Makefiles` have been extended to be cross-platform so that they work on Windows, Linux, and MacOS without changes. To facilitate the creation of truly portable, cross-platform examples, the existing @ref ports_os "QP ports to Windows/POSIX" have been augmented with abstractions for portable console access.
@section qpn_6_3_3 Version 6.3.3, 2018-06-22
This release fixes the following bugs:
- [bugs:#218 "__flash attribute in avr port"](https://sourceforge.net/p/qpc/bugs/218/)
- [bug#216 "Generated code for QP version check violates MISRA-C Rule 10.1"](https://sourceforge.net/p/qpc/bugs/216/).
- [bug#217 "GNU-ARM -fstack-protector incompatible with the QP ports to GNU-ARM"](https://sourceforge.net/p/qpc/bugs/217/).
- [bug#215 "QP is internally inconsistent in calling assertion macros"](https://sourceforge.net/p/qpc/bugs/215/).
Also, this release demonstrates the new features of QM 4.3.0 in several example models (qpn/examples/ directory).
Finally, this release updates `3rd_party/CMSIS/Include` to the latest version from GitHub.
@section qpn_6_3_0 Version 6.3.0, 2018-05-10
This release improves the command-line scripts for flash programming of the supported MCUs. Specifically, the flash.bat batch files for EFM32-SLSTK3401A, EK-TM4C123GXL, and for Arudino UNO have been updated.
@section qpn_6_2_0 Version 6.2.0, 2018-03-16
This release updates the QP-nano ports to win32-qv and posix-qv to allow a "tickless" mode, where the "tickerThread" is not created. This mode is set by configuring the system clock tick rate to 0 (QF_setTickRate(0)).
Additionally, this revision updates the posix-qv port implementation to wait for the condition variable in a customary wile() loop.
@section qpn_6_1_1 Version 6.1.1, 2018-02-18
The main purpose of this release is adding the context-switch callback to the preemptive @ref qkn "QK-nano" kernel. The QK_onContextSw() callback function provides a mechanism to perform additional custom operations when QK switches context from one thread to another. To avoid extra overhead when this functionality is not needed and for backwards-compatiblity with the existing applications, the callback is enabled only when the macro #QK_ON_CONTEXT_SW is defined. The macro can be defined either directly in command-line for the compiler, or in the QK-nano port file (qpn_port.h). Examples for the context-switch callbacks have been provided for the @ref arm-cm_dpp_nucleo-l053r8 "NUCLEO-L053R8" (Cortex-M0+) and the @ref arm-cm_dpp_ek-tm4c123gxl "EK-TM4C123GXL" (Cortex-M4F).
Another purpose of this release is adding the support for the [ARM Compiler 6 (ARM-Clang)](https://developer.arm.com/products/software-development-tools/compilers/arm-compiler), which is a C/C++ toolchain for ARM processors based on the modern [Clang frontend](https://clang.llvm.org/) and the [LLVM framework](https://llvm.org/). This release adds the ARM-Clang ports and examples for all built-in kernels (QV-nano and QK-nano) for the ARM Cortex-M CPU cores.
Also, this release changes the ARM Cortex-M ports for the IAR-ARM toolchain in that it replaces the assembly modules with the equivalent C implementation. All existing example projects for IAR-ARM have been updated to use the `qkn_port.c` files instead of `qkn_port.s` files.
Also, this release adds new project files for the Atollic TRUEstudio for STM32. The TRUEstudio projects (Eclipse) have been added for the @ref arm-cm_dpp_nucleo-l053r8 "NUCLEO-L053R8" (Cortex-M0+) and the @ref arm-cm_dpp_nucleo-l152re "NUCLEO-L152RE" (Cortex-M3).
Finally, this relese updates the CMSIS to version 5.3.0 (see `qpn/3rd_party/CMSIS`
@section qpn_6_0_4 Version 6.0.4, 2018-01-10
This release replaces assembly with C implementation in the ARM-KEIL ports or the QK-nano kernel to Cortex-M to take advantage of the `__asm` functions. (NOTE: this change has impact on the existing QP-nano applications that use the ARM-KEIL toolchain and the QK kernel.)
Also, this release adds an example of the Dining Philosophers Problem (DPP) re-designed with the ["Orthogonal Component" state pattern](https://www.state-machine.com/doc/Pattern_Orthogonal.pdf). The application uses only one active object (Table), while the Philos are stateful components of Table. The example is located in `qpn\examples\win32-qv\dpp_comp`.
@section qpn_6_0_3 Version 6.0.3, 2017-12-12
This release replaces attributes of ::QActive class and ::QTimeEvtCtr type from type uint_fast8_t to uint8_t. For the ARM Cortex-M port, these changes reduce the memory footprint of each ::QActive instance from 40 to 26 bytes (35% improvement).
Also, the ARM Cortex-M port and examples for the TI-ARM compiler have been removed. (Projects for the TI CCS can use the GNU-ARM toolchain and the existing GNU-ARM ports).
@section qpn_6_0_1 Version 6.0.1, 2017-11-10
This release includes a workaround for the GNU-ARM compiler bug for the ARMv6-M architecture (Cortex-M0/M0+/M1), which can lead to generation of incorrect code for the QP-nano critical section at certain gcc optimization levels (such as -O). This bug was first discovered and filed as [bug#184](https://sourceforge.net/p/qpc/bugs/184/). The bug affected the GNU-ARM ports to both built-in kernels @ref qvn "QV-nano" and @ref qkn "QK-nano".
@attention
This release no longer contains the directory `qpn/source`, which was scheduled to be phased out in QP5. In QP6 the source code is found only in the `qpn/src` directory.
@note
This QP-nano 6.0.1 release is the minimum version required in the upcoming QM 4.1.0.
@section qpn_5_9_8 Version 5.9.8, 2017-09-15
This release implements the feature request
#126 "Allow non-asserting
event posting for zero-margin allocations". Specifically, calling
ACTIVE_POST_X() and ACTIVE_POST_X_ISR() with the margin argument of zero
will no longer assert if the allocation/posting fails.
The asserting version is these macros uses the special value of the @p margin
argument of #QF_NO_MARGIN.
Improved comments in the soruce code.
Modifed ARM Cortex-M examples with the GNU-ARM toolset to be consistent with QP/C++ (support for RTTI and C++ Exception handling), as follows:
- removed definitions of `_init()` and `_fini()` from the GNU-ARM startup code for all supported boards in the `3rd_party` directory
- commented out the call to `__libc_init_array()` in the GNU-ARM startup code for all supported boards in the `3rd_party` directory (because it requires `_init()`)
- Modified all GNU-ARM linker scripts (.ld files) to add the following symbols:
@verbatim
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >RAM
__exidx_end = .;
@endverbatim
-----------------------------------------------------------------------------
@section qpn_5_9_7 Version 5.9.7, 2017-08-18
This release phases out the QK-nano mutex and replaces it with an equivalent selective QK-nano scheduler locking up to the specified ceiling priority. Specifically, this feature has been implemented with two new operations QK_schedLock() and QK_schedUnlock(). This is done with consistency with the QK and QXK kernels in QP/C/C++. The advantage of the new implementation is also the ability of the scheduler locks to nest, which was not the case with the QK-nano mutex.
All related QK-nano examples have been updated to use the selective scheduler locking instead of the mutex. The new blocking QXK mutex has been demonstrated in the following updated examples:
- @ref arm-cm_dpp_efm32-slstk3401a
- @ref arm-cm_dpp_ek-tm4c123gxl
@attention
The changes to QK-nano **break backwards-compatibly** with the existing code that relies these features. In the existing code, the mutexes should be replaced with selective scheduler locking.
This release also updates CMSIS to version 5.1.0 (3rd_party/CMSIS).
This release also adds the @ref api "API Reference" section to the QP-nano documentation.
-----------------------------------------------------------------------------
@section qpn_5_9_6 Version 5.9.6, 2017-08-04
This release changes the organization of the QP-nano source code to make it more friendly for the Eclipse CDT, as proposed in the feature request #123 "Eclipse-friendly source directory structure for QP". Specifically, the QP-nano source code is now provided in the `qpn/src/` directory with the following structure:
@verbatim
qpn\
+-source\ - exitsting source directory with "flat" structure
| (for backwards-compatibility)
+-src\ - new source directory grouped by functionality
+-qfn\ - core framework (QEP-nano + QF-nano)
+-qkn\ - QK-nano kernel
+-qvn\ - QV-nano kernel
@endverbatim
This release consistently changes all example projects (for all toolchains) to use the **src/** directory for QP-nano source code, instead of the **source/** directory.
@note The original `qpn/source` directory is still provided for backwards compatibility with the existing QP-nano projects. This directory will be phased out in the future QP-nano releases. Please use the new source code structure provided in the `qpn/src` directory.
Finally, this release adds protection in the IRQ priorities initialization in QK-nano/QV-nano for ARM Cortex-M3/M4/M7, so that the number of IRQs is extracted from bits 0-2 of the ICTR register (INTLINESNUM).
@section qpn_5_9_5 Version 5.9.5, 2017-07-20
This release fixes the following bug:
- bug#178 "GNU-ARM compiler reports "Error: unaligned opcodes..." in startup code for QP/C/C++/nano examples". The bug fix entails modifying the startup code for the GNU-ARM compiler in the `3rd_party` directory. Specifically, the proper alignment directives have been added to the inline assembly in the exception handlers.
@section qpn_5_9_3 Version 5.9.3, 2017-07-03
This release fixes the following bugs:
- bug#176 "Incorrect initialization of PendSV interrupt priority in
QK-nano for ARM Cortex-M0/M0+"
(https://sourceforge.net/p/qpc/bugs/176/)
- bug#162 "QF critical sections require modification for M7 core"
https://sourceforge.net/p/qpc/bugs/162/
Additionally, this release adapts the Makefiles for GNU-ARM to the new
location of the GNU-ARM toolset, which is now included in the QTools
Collection (v 5.9.1) for Windows.
This release also upgrades CMSIS to version 5.0.2.
@section qpn_5_8_2 Version 5.8.2, 2017-02-08
This release improves compatibility of assertion numbering between
QP-nano and QP/C/C++. Specifically, qepn.c file now uses the same
assertion-IDs as qep_hsm.c (QP/C) and qep_hsm.cpp (QP/C++).
This release upgrades CMSIS to version 5.0.1.
Finally, this release fixes the following bugs:
- bug#152 Typo (qpc\ports\arm7-9\qk\gnu\qk_port.s:42) prevents compilation
@section qpn_5_8_1 Version 5.8.1, 2016-12-16
This release is in response to a recent finding that many QP users of the
ports to ARM Cortex-M3/M4 forget to explicitly set their interrupt priorities,
as described in the AppNote "Setting ARM Cortex-M Interrupt Priorities in QP 5.x".
Specifically, this release improves safety of QP ports to ARM Cortex-M3/M4,
by initializing the interrupt priorities to a safe default in a generic,
portable way. This QP port includes such a fix for QV-nano/QK-nano ports to ARM Cortex-M3/M4.
Changes in detail:
- modified the QV and QK source code to call QV_init() and QK_init(), respectively.
- modified the ARM Cortex-M ports of QV-nano and QK-nano to initialize
priorities all exceptions and IRQs to the safe value #QF_BASEPRI.
@note The QV-nano ports to ARM Cortex-M now have a new **qvn_port.c** module that needs to
be added to the build.
- added the header file **cmsis_ccs.h** to qpc/3rd_party/CMSIS/Include directory
(used in the examples for the Code Composer Studio). The file has been
dropped during the upgrade to CMSIS 5.0.1, because it is not part of the
standard distribution.
@section qpn_5_8_0 Version 5.8.0, 2016-11-07
This release simplifies the QP-nano framework by removing the QMsm-style
state machine implementation strategy introduced in version 5.0.0. Moving
forward, the only supported state machine implementation strategy in
QP-nano will be the QHsm-strategy and the upcoming QM 4.x will provide
only the QHsm-strategy for QP-nano applications.
Specifically, the QMsm base class, and QMActive base class have been
removed, along with the accompanying macros. The QP-nano compatibility
layer (file qpn.h) provides some of these macros for backwards-
compatibility, but the underlying implementation must be, in fact,
based on QHsm.
All examples and QM models have been updated to use only the QHsm-style
implementation strategy. The models also require the new upcoming QM 4.0.0.
Additionally, this release fixes the following bugs:
-bug#144 Obsolete Win32 API in qwin_gui.c
Finally, this release includes the latest CMSIS-5, which now replaces the
older CMSIS-4.5.
@section qpn_5_7_3 Version 5.7.3, 2016-10-07
This release fixes the following bugs:
- bug#140 (PendSV_Handler() exception stacked PC not halfword aligned).
@section qpn_5_7_2 Version 5.7.2, 2016-09-30
This release changes the internal QK-nano implementation to match the QK
kernel implementation used in QP/C and QP/C++. (e.g., QK_sched_() has been
renamed to QK_activate_() and QK_schedPrio_() to QK_sched_()). These
changes fall into the category of refactoring and have no impact on the API
or performance.
@section qpn_5_7_0 Version 5.7.0, 2016-08-31
This release release changes once more the QK-nano port to ARM Cortex-M, to reduce the interrupt latecy. This has been achieved by shortening the critical section in the PendSV exception. Also, this QK port to Cortex-M no longer uses the NMI exception.
Finally, this release replaces all absolute paths with relative paths in all CCS-Eclipse project files (for TivaC, Hercules, and MSP430).
@section qpn_5_6_5 Version 5.6.5, 2016-06-09
This release adds support for the new board: EFM32-SLSTK3401A (Pearl Gecko Starter Kit from Silicon Labs). This board replaces the Stellaris EK-LM3S811 board, which has been discontinued. (The Stellaris EK-LM3S811 board had been used in the "Fly 'n' Shoot" game example accompanying the PSiCC2 book).
This release also introduces a new version of the QWIN GUI Toolkit in the Windows prototypes for the "Fly 'n' Shoot" game and the DPP-GUI
version (see https://www.state-machine.com/products/index#QWIN).
Additionally, this release also includes the QP-nano integration with the emWin emgedded GUI from SEGGER, which is also the same product as
uC/GUI distributed by Micrium (@ref exa_emwin).
Finally, this relase comes with updated project files for TI Code Composer Studio (both for ARM Cortex-M and for MSP430).
This release fixes the following bugs:
- bug#130 (POSIX port stop->start leads to reuse of sestroyed mutex).
@section qpn_5_6_4 Version 5.6.4, 2016-04-25
This release fixes two serious bugs:
- Bug #126 (https://sourceforge.net/p/qpc/bugs/126 ) in the QK preemptive scheduler introduced in QP 5.6.2.
- Bug #128 (https://sourceforge.net/p/qpc/bugs/128 ) in the QK port to ARM Cortex-M introduced back in QP 5.6.1
@section qpn_5_6_2 Version 5.6.2, 2016-04-06
The main purpose of this release is to eliminate the need to define the QF_MAX_ACTIVE macro (the number of active objects) in qpn_conf.h header file and match it with the dimension of the QF_active[] global array.
Instead, starting with this QP-nano version, the dimension of the QF_active[] array can be passed as the argument to the QF_init() function, as follows: QF_init(Q_DIM(QF_active));
@note For backwards compatibility the QF_MAX_ACTIVE macro, if defined, is still recognized and calling QF_init(Q_DIM(QF_active)) from main() is not necessary.
Changes in detail:
1. Added internal variable QF_maxActive_ to store the number of active objects and replaced all occurrences of QF_MAX_ACTIVE with it.
2. Moved the implementation of QF_init() from qfn_init.c to qfn.c and changed it to take the maxActive argument.
3. Eliminated the source file qfn_init.c.
4. Modified the POSIX-QV port to use the new initialization strategy
5. Modified the WIN32-QV port to use the new initialization strategy
6. Removed the macro QF_MAX_ACTIVE from all examples and added call to QF_init(Q_DIM(QF_active)) instead.
7. Fixed the 3rd-party file startup_stm32l32l1xx.c to include exceptions for Cortex-M3 (MemManage_Handler, BusFault_Handler, and UsageFault_Handler).
8. Updated the 3rd-party files for the EK-TM4C123GXL board (TivaC LaunchPad).
@section qpn_5_6_1 Version 5.6.1, 2016-01-11
This QP-nano release provides a new version of the QK-nano ports to ARM Cortex-M, which do not use the SVC_Handler (Supervisor Call). This is done to make the QK-nano ports compatible with various "hypervisors" (such as mbed uVisor or Nordic SoftDevice), which use the SVC exception. This release contains the updated QK-nano ports to ARM Cortex-M for all supported compilers: ARM-Keil, GNU-ARM, IAR EWARM, and TI-CCS-ARM.
Changes in detail:
1. Modified the ARM Cortex-M QK-nano ports to not use the SVC_Handler.
2. Modified the GNU-ARM ports of QK for ARM Cortex-M, to use the __ARM_ARCH macro to distinguish among different architectures (ARCHv6 vs ARCHv7).
3. Added error directives to source files from different built-in kernels (QV and QK) to generate meaningful error messages when these files are mixed in one project. For example, a project based on QV will report errors when source files for QK-nano are included in it.
4. Updated CMSIS from 4.2 to 4.3 in qpn/3rd-party/CMSIS
@section qpn_5_5_1 Version 5.5.1, 2015-10-06
This release adds state machine operations for implementing the shallow history mechanism. The operations are called QMsm_childStateObj() and QHsm_childState(), for QMsm and QHsm classes, respectively, because they compute a child state of a given parent, such that the child belongs to the same state hierarchy as the current state.
This release also improves the AAPCS compliance of the ARM Cortex-M port to the QK preemptive kernel. Specifically, the PendSV handler in assembly did not always maintain the 8-byte stack alignment, which is required by AAPCS. This version corrects the stack misalignment in the qk_port.s files for all supported ARM compilers (ARM-Keil, GNU, IAR, and TI CCS). All these ports should also be ready for ARM Cortex-M7.
Also, this release adds support for the TI CCS ARM compiler. Specifically, a new ARM Cortex-M ports have been added (in directories `qpn\ports\arm-cm\qk\ti\` and `qpn\ports\arm-cm\qk\ti\`) and TI CCS example projects have been provided (in directories `qpn\examples\arm-cm\dpp_ek-tm4c123gxl\qk\ti\` and `qpn\examples\arm-cm\dpp_ek-tm4c123gxl\qv\ti\`).
Changes in detail:
1. Added the new prototypes QMsm_childStateObj() and QHsm_childState() to qepn.h
2. Added implementation of QMsm_childStateObj() and QHsm_childState() to qepn.c
3. Modified the qk_port.s assembly implementation for all supported ARM Cortex-M toolsets (ARM-Keil, GNU, IAR, and TI CCS)
4. Added QP-nano Cortex-M port to TI CCS.
5. Added CCS example projects in `qpn\ports\arm-cm\qk\ti\` and `qpn\ports\arm-cm\qk\ti\
@section qpn_5_4_2 Version 5.4.2, 2015-06-07
The main focus of this release is to improve the support for "dual targeting" of QP-nano applications, which is developing of deeply embedded code as much as possible on the desktop OS, such as Windows. Experience shows that "dual targeting" dramatically improves productivity of embedded systems developers, perhaps more than any other technique.
This release makes it possible to use exactly the **same** application code, main function, and the Board Support Package interface (bsp.h) on both deeply embedded target and on Windows. The only differences between these targets can be completely encapsulated in the Board Support Package implementation (bsp.c).
The support for "dual targeting" in this QP-nano release works both for Win32 console and Win32 GUI applications. The Win32-GUI support enables developers to easily emulate the front-panels of the embedded devices, with LCD-screens (graphical and segmented), LEDs, buttons, switches, sliders, etc.
Changes in detail:
1. Modified the QP-nano port to Windows (@ref win32-qv) so that it supports both Win32 console and Win32-GUI applications. The newly introduced pre-processor #WIN32_GUI macro is now required to use the Win32-GUI facilities.
2. Added portable "safe" macros from `` and `` to the QP-nano port to Windows. These macros encapsulate the differences between Microsoft Visual C++ and other compilers (such as MinGW).
3. Simplified the structure of the QP-nano Windows port by eliminating one level of directories for the compilers used. Both VC++ and MinGW builds can now be run in the same port directory.
4. Modified the QF_stop() function in the QP-nano port to @ref win32-qv, so that it unblocks the QV event-loop and thus lets the application terminate.
5. Modified all examples for Windows to use the new port structure.
6. Improved all Makefiles (for the MinGW toolset) in all Windows examples, to make them easier to adapt to custom applications, both Win32 console and Win32 GUI.
7. Moved several examples from the `examples/win32/` and examples/win32-qv directories to `examples/arm-cm/` directory with native embedded examples for ARM Cortex-M. This co-location of the Win32 emulation with the embedded code running on the actual board demonstrates better the "dual targeting" development approach.
8. Made the ::QActiveCB (::QActive Control Block) to the QP-nano backwards-compatibility layer as deprecated. Instead, the newer QP-nano applications should use ::QMActiveCB.
9. Updated all Windows examples to the latest QP API by compiling the code with the macro #QP_API_VERSION set to 9999 (latest API without backwards compatibility)
@section qpn_5_4_0 Version 5.4.0, 2015-05-31
This release changes the basic philosophy of packaging and distributing the QP-nano framework by **combining** the "QP-nano Baseline Code" with all currently available "QP-nano Development Kits" (QDK-nano). This is done to eliminate any potential mistakes in downloading and installing separate pieces of code.
This release also changes the active object class hierarchy so that ::QMActive is now more fundamental and is the base class for ::QActive. (Previously ::QMActive was a subclass of ::QActive). The newly added documentation section about @ref classes "QP-nano Design" shows the current class hierarchy.
@note
Because the types ::QMActive and ::QActive are equivalent in QP-nano, this change has minimal impact on the applications, but it is now more correct to use ::QMActive as the base class for all "opaque" active object pointers.
Additionally, this release alignes the QP-nano framework better with the rest of the QP framework family (QP/C and QP/C++), so that fewer changes are needed to move applications between QP-nano and QP/C.
Finally, this release adds periodic time events (timers) to QP-nano. The feature is demonstrated by many provided examples (e.g., "Blinky", "Fly 'n' Shoot" game, PELICAN crossing).
The aforementioned changes have also the following ripple effects:
1. The structure of the QP-nano ports has been modified to match QP/C and to avoid repetitions. The QP-nano application no longer need to provide and #include the complete port `qpn_port.h` header file, which is now deprecated. Insted QP-nano application code needs to #include the qpn.h (QP-nano API) header file, which also now contains the QP-nano backwards-compatibility layer.
2. The application is now only responsible for providing the qpn_conf.h file to set up the basic configuration for QP-nano. Examples of the `qpn_config.h` configurations are provided in all supplied QP-nano examples.
3. The actual port (e.g., the interrupt disabling policy for tasks and interrupts, interrupt entry/exit code, etc.) is included from the @ref ports folder. This @ref ports folder has been reorganized to contain all currently available QP-nano ports. The ports are organized into two categories: @ref ports_native "native QP-nano ports" ("bare-metal") and @ref ports_os "ports to big operating systems" (Windows and Linux).(**NOTE**: the ports are now documented in the this QP-nano Reference Manual. Each port sub-directory contains a README link to the corresponding page in the online documentation)
4. Expanded the QP-nano time events (timers) with the ability to fire periodically. The feature is controlled by the preprocessor switch #QF_TIMEEVT_PERIODIC. When this macro is defined (in the `qpn_config.h` header file), the signature of the QActive_armX() function contains one more `interval` parameter. The `interval` parameter allows you to specify the interval of the periodic timeout. If the `interval` is zero, the time event is one-shot.
5. It is no longer necessary to define the **QPN environment variable** to build the QP-nano examples. All directories and files referenced by example projects are **relative** to the project folder. This change reflects the fact that most development tools add source files to the project using relative paths.
6. The QP-nano @ref exa folder has been reorganized to reduce the repetitions and contains all currently available QP-nano examples. The folder includes four categories of examples: @ref exa_native "native QP-nano examples" ("bare-metal") and @ref exa_os "examples for big operating systems" (Windows and Linux). The examples folder has been expanded to contain all currently available QP-nano examples, many of them are new in this release. (**NOTE**: the currently available examples are now documented in the QP-nano Reference Manual. Each example sub-directory contains a README link to the corresponding page in the online documentation)
7. A new 3rd_party folder created to contain the Third-Party code used in the QP-nano ports and examples, such as MCU register files, low-level startup code, device drivers, etc. The 3rd_party folder avoids the need to repeat such code in every project. Also, the separation of the Third-Party components helps to clearly indicate code that comes from various sources, and to which Quantum Leaps, LLC expressly makes **no claims of ownership**. The Third-Party software components included in this "3rd_party" folder are licensed under a variety of different licensing terms that are defined by the respective owners of this software and are spelled out in the README.txt or LICENSE.txt files included in the respective sub-folders.
8. This release also comes with the much expanded online QP-nano Reference Manual, which is cross-linked with the ports and examples.
Changes in detail:
1. Renamed the "Vanilla" scheduler to the @ref comp_qv "QV-nano cooperative kernel" for symmetry with the @ref comp_qk "QK-nano preemptive kernel". Renamed QF_onIdle() callback to QV_onIdle().
2. Removed class ::QFsm (which is now deprecated). Legacy state machines coded in the "QFsm-style" will continue to work, but will use the ::QHsm implementation internally. There is no longer any efficiency advantage in using the "QFsm-style" state machines.
3. Updated @ref exa_arm-cm "ARM Cortex-M examples" and provided new examples for NXP mbed-LPC1768, and STM32 NUCLEO-L053R8, and NUCLEO-L152RE boards. All examples now use the latest CMSIS (V4.3.0). All ARM Cortex-M exampels are provided for the ARM-KEIL, GNU-ARM, and IAR-ARM toolsets.
4. Added the native @ref arm7-9 "port" and @ref exa_arm7-9 "examples" to the @ref arm7-9 "classic ARM7/9" with AT91SAM7S-EK board and the IAR-ARM toolset.
5. Added the native @ref avr "port" and @ref exa_avr "examples" to the AVR (AVRmega) with GNU-AVR and IAR-AVR toolsets. The @ref exa_avr "examples" are provided for the Arduino-UNO board.
6. Added the native @ref msp430 "port" and @ref exa_msp430 "examples" to MSP430 with TI CCS-430 and IAR-430 toolsets. The @ref exa_msp430 "examples" are provided for the MSP430 LauchPad boards (the MSP-EXP430G2 and MSP-EXP430F5529LP for the "classic" MSP430 and "extened" MSP430X, respectively).
7. Updated @ref win32-qv "port to Win32-QV" (Windows with cooperative "Vanilla" scheduler, previously known as Win32-1T). Modified the port to apply a "fudge factor" in over-sizing QP-nano event queues and event pools, to minimize the risk of overflowing queues/pools due to non-deterministic Windows behavior.
8. Renamed the POSIX port to @ref posix-qv "POSIX-QV" (POSIX with cooperative "Vanilla" scheduler). Modified the port to apply a "fudge factor" in over-sizing QP-nano event queues and event pools, to minimize the risk of overflowing queues/pools due to non-deterministic behavior under POSIX.
@section qpn_5_3_0 Version 5.3.0, 2014-04-18
This release adds the "transition to history" (deep history) feature to
both QHsm and QMsm state machines and their subclasses. This QP-nano
release matches the new QM modeling tool Version 3.1.0, which now
supports the "transition to history" connector and the corresponding
code generation for transitions to history.
@note QP-nano 5.3.0 breaks backwards-compatibility with QP-nano
applications developed for QP-nano 4.x and 5.x. However, the update to
QP-nano 5.3.0 typically requires only to add #include and
#include "qassert.h" to the qpn_port.h header file in the application
directory. Any QM models created for the previous QP-nano versions
remain fully compatible with QP-nano 5.3.0, but you need to re-generate
the code with QM 3.1.0.
This release comes with new and updated QDKs for MSP430. Specifically,
new QDKs have been added for the MSP-EXP430G2 LaunchPad as well as the
MSP-EXP420F5529LP LauchPad. Also, the QDKs for MSP430 with the TI Code
Composer Studio are now part of the baseline QP-nano distribution.
This release also goes several steps towards compliance with the new
MISRA-C:2012 rules. For example, unused tag declarations have been
removed (MISRA-C:2012 Rule 2.4), the C99 standard Boolean data type in
has been added instead of uint8_t for stricter type
analysis, and the C99 data types uint_fast8_t and uint_fast16_t are used
instead of the non-standard uint_t.
Finally, this QP-nano release brings deep changes in the source code
comments and the doxygen documentation generated from the source code.
All comments have now more consistent structure, and every function is
now documented in the implementation file (.c file), whereas the
interface (.h files) contain only the brief descriptions of the
functions. This re-structuring of documentation is performed as part of
the validation and verification effort that has begun to provide a
certification package for QP-nano for safety standards, such as IEC
61508 and ISO 62304 (FDA 510(k)).
Changes in detail:
1. Moved detailed documentation of functions from the header files (.h)
to implementation files (.c).
2. Added macros: Q_TRAN_HIST(), QM_TRAN_HIST(), and QM_TRAN_EP(), to
"qepn.h"
3. Added attributes entryAction and initAction to the QMState struct in
"qepn.h" (needed for transition to history).
4. Changed return type to bool in virtual functions QMsmVtbl.post() and
QMsmVtbl.postISR() as well as the implementations: QActive_postX_(), and
QActive_postXISR_().
5. In qepn.h, changed the QState return type from action/state handler
functions to uint_fast8_t.
6. In qfn.h, changed the type of QActive attributes prio, head, tail,
and nUsed to uint_fast8_t.
7. In qfn.h, changed the type of of QTimeEvtCtr, as well of the tickRate
argument in QF_tickXISR(), QActive_armX(), and QActive_disarmX() to
uint_fast8_t.
8. Changed the return type from QK_schedPrio_() (priority) as well as
the p argument in QK_sched_() to uint_fast8_t
9. Added new QDKs-nano/IAR for MSP-EXP430G2 LaunchPad
10. Added new QDKs-nano/IAR for MSP-EXP420F5529LP LauchPad LaunchPad
11. Added new QDKs-nano/CCS for MSP-EXP430G2 LaunchPad
12. Added new QDKs-nano/CCS for MSP-EXP420F5529LP LauchPad LaunchPad
@section qpn_5_2_0 Version 5.2.0, 2013-12-30
This release matches the new QM 3.0.0, for which it provides model
examples based on the new QMsm/QMActive classes. This, in turn
demonstrates the new state machine code generation that QM3 was
specifically designed to do.
This release also provides consistent API for late-binding ("virtual"
functions) introduced in QP-nano 5.0.0, as opposed to using regular
linking (early-binding) for direct function calls, such as
QHsm_dispatch(). A clearly separated API compatibility layer is
provided, whereas you can configure a level of backwards compatibility
by means of the #QP_API_Version macro. This facilitates migrating
existing QP applications to the newer API.
An cyclomatic complexity (McCabe V(G)) analysis of this Version has been
performed and the maximum V(G) complexity per function has been reduced
to 15 by breaking up the QHsm_dispatch_() function. The code metrics
report, including cyclomatic complexity by function as well as other
standard code metrics (e.g., lines of code), is now included in the
"QP-nano Reference Manual", see
https://www.state-machine.com/qpn/metrics.html
Finally, this release demonstrates safer stack allocation and safer
exception handlers in all ARM Cortex-M examples. The techniques are
described in the Embedded.com article "Are We Shooting Ourselves in the
Foot with Stack Overflow?".
Changes in detail:
1. In file qepn.h renamed the implementation functions, such as
QHsm_init() and QHsm_dispatch() to QHsm_init_() and QHsm_dispatch_()
(note the underscore, which means that the functions should not be
called directly by the application code). The only correct way of
calling the functions is through the macros QMSM_INIT() and
QMSM_DISPATCH(), respectively. The latter macros implement late-binding
("virtual" functions in C).
2. In file qfn.h renamed the implementation functions, such as
QActive_postX() and QActive_postXISR() to QActive_postX_(), and
QActive_postXISR_, respectively (note the underscore, which means that
the functions should not be called directly by the application code).
The only correct way of calling the functions is through the macros
QACTIVE_POST(), QACTIVE_POST_X(), QACTIVE_POST_ISR() and
QACTIVE_POST_X_ISR(). The latter macros implement late-binding
("virtual" functions in C).
3. for backwards compatibility, in files qepn.h and qfn.h defined "API
Compatibility Layer", which is controlled by the macro #QP_API_VERSION.
For example, specifying QP_API_VERSION=500 chooses API compatible with
QP Version 5.0.0 or newer, but excludes APIs that became deprecated in
the earlier versions. If the macro #QP_API_Version is not defined by the
user (typically on the command line for the compiler), the default value
of 0 is assumed. This default means maximum backwards compatibility
(from Version 0.0.0). On the other hand, higher values of
#QP_API_Version mean less backwards compatibility. For example
QP_API_VERSION=9999 will specify compatibility only with the latest
Version of QP-nano. The API Compatibility Layer for QP_API_Version < 500
provides macros: QHsm_init(), QHsm_dispatch(), QActive_post() and
QActive_postISR(). These macros resolve to QMSM_INIT() and QMSM_DISPATCH(),
QACTIVE_POST() and QACTIVE_POST_ISR() respectively, so that calls based
on the older API also use late-binging.
4. In file qepn.c, broken up the function QHsm_dispatch() into two
functions QHsm_dispatch_() and QHsm_tran_(). This has reduced the
cyclomatic complexity from 25 for the original function, to 11 and 15
for QHsm_dispatch_() and QHsm_tran_(), respectively.
5. Updated all examples for ARM Cortex-M to use safer stack allocation
and safer exception handlers in all ARM Cortex-M examples, as described
in the Embedded.com article "Are We Shooting Ourselves in the Foot with
Stack Overflow?".
@section qpn_5_1_1 Version 5.1.1, 2013-10-15
@note QP-nano 5.1.1 remains backwards-compatible with the existing
QP-nano 4.x applications, except QP-nano 5.1.x requires changing the
interrupt priority setting in the existing ARM Cortex-M applications.
Specifically, you need to set the interrupt priorities equal or lower
than QF_AWARE_ISR_CMSIS_PRI constant provided in the qfn_port.h
header file.
The main purpose of this milestone QP-nano release is to enable the QM
modeling tool to generate a new type of state machine code (requires QM
Version 3.0.0, which is still in development as of this writing).
This new type of state machine implementation in QP-nano 5 is based on
the new QMsm class, which takes advantage of the QM tool as an advanced
"state machine compiler". QM can perform optimizations that were not
possible with the C preprocessor alone. Specifically, the QM can easily
determine the LCA (Least-Common-Ancestor) state for every transition and
it can generate the complete transition-sequences (sequences of
exit/entry/initial actions) at code-generation time. The resulting code
can be still highly human-readable, but it will no longer be
human-maintainable. The lab tests indicate that the new "housekeeping"
code for executing hierarchical state machines can be about twice as
fast as the previous code based on the QHsm class. Additionally, the new
code requires less run-time support (smaller event processor) and uses
70% less of stack space in the call to the QMsm_dispatch() operation
than QHsm_dispatch().
The next big feature introduced in QP-nano 5 is polymorphism ("virtual"
functions) for basic operations, such as state machine init() and
dispatch() and active object post(), and postISR() operations. Making
theses functions "virtual" means that all these operations can be
re-defined in sub-classes of state machines and active objects. This, in
turn, allows a single application to use a mix of state machine classes
derived from the new QMsm base class with state machines derived from
the QHsm base class, each one using a different state machine
implementation strategy. Additionally, the virtual post() operation
could be very useful for implementing various Proxy active objects
(e.g., for active object event posting across networks).
Another big feature introduced in QP-nano 5 are the multiple,
independent system clock tick rates for time events. The number of
system tick rates can be now configured in the QP-nano ports. For
example, a digital watch can use a "fast" clock tick rate of 100Hz and a
"slow" clock tick rate of only 1Hz. These clock tick rates can be
managed independently, so for example, the fast clock tick rate can be
shut down in the absence of time events assigned to this rate. This
feature allows the applications to implement sophisticated power-saving
policies.
As yet another important feature, QP-nano adds a new "extended" API for
non-asserting event allocation and posting. This feature is intended for
situations, where an application is hammered with external events that
at times arrive too fast for processing, but that can be ignored under
the overload conditions. In those cases firing an assertion inside the
framework is undesirable. The non-asserting API allows a designer to
request a safety-margin when allocating or posting an event. The event
is not allocated/posted if the safety margin cannot be satisfied at the
time of the call. On the other hand, the safety margin allows the
application to still use the regular (asserting) event allocation and
posting, because the event pools and event queues are guaranteed to
maintain a minimal margin for safe operation.
Finally, QP-nano 5.1.0 never completely disables interrupts in the ARM
Cortex-M3/M4 cores, even inside the critical sections. On Cortex-M3/M4
(ARMv7-M architectures), the QP port disables interrupts selectively
using the BASEPRI register. (NOTE: The BASEPRI register is not
implemented in the ARMv6-M architecture (Cortex-M0/M0+), so
Cortex-M0/M0+ need to use the PRIMASK register to disable interrupts
globally).
This new policy of disabling interrupts divides interrupts into
"kernel-unaware" interrupts, which are never disabled, and
"kernel-aware" interrupts, which are disabled in the QP critical
sections. Only "kernel-aware" interrupts are allowed to call QP
services. "Kernel-unaware" interrupts are *NOT* allowed to call any QP
services and they can communicate with QP only by triggering a
"kernel-aware" interrupt (which can post or publish events).
As mentioned above, all QP ports to ARM Cortex-M included in the QP
5.1.x Baseline Code provide the constant QF_AWARE_ISR_CMSIS_PRI, which
must be used to offset the "kernel-aware" interrupt priorities.
All example projects for ARM Cortex-M included in the QP-nano 5.1.x
Baseline Code demonstrate the recommended way of assigning interrupt
priorities in your applications. The initialization consist of two steps:
1. you enumerate the "kernel-unaware" and "kernel-aware" interrupt
priorities (whereas you offset the "kernel-aware" priorities by the
constant QF_AWARE_ISR_CMSIS_PRI) and
2. you assign the priorities to *ALL* interrupts by calling the
NVIC_SetPriority() CMSIS function.
****
NOTE: Leaving the interrupt priority at the default value of zero
(the highest priority) is most likely incorrect, because the
"kernel-unaware" interrupts cannot call any QP services.
****
For more information, please read the short Application Note "Setting
ARM Cortex-M Interrupt Priorities in QP 5.1" available at:
https://www.state-machine.com/arm/AN_ARM-Cortex-M_Interrupt-Priorities.pdf.
The following list details the changes:
1. Added the new QMsm "class" to qepn.h. Changed the inheritance tree by
deriving QHsm and QFsm from the QMsm base class. Added virtual table
structures for QMsm, QHsm, and QFsm (polymorphism).
- added macro QMSM_INIT() to polymorphically call the state
machine initialization implementation in the QMsm base class and
all subclasses.
- added macro QMSM_DISPATCH() to polymorphically call the state
machine event dispatching implementation in the QMsm base class
and all subclasses.
2. Added the new "QMActive" "class" to qfn.h. Extended the inheritance
tree to derive QMActive from QActive. Added virtual table structures for
QMActive and QActvie (polymorphism).
- added macro QACTIVE_POST() to polymorphically call the direct
event posting to an active object.
- added macro QACTIVE_POST_ISR() to polymorphically call the
postISR (posting from interrupts) to an active object.
3. Added the multiple system clock tick rates feature in qfn.h:
- added new configuration macro QF_MAX_TICK_RATE, which specifies
the number of clock tick rates. This macro is to be defined in
the QF ports (in the qpn_port.h header file). If the macro is
undefined, the default value is 1 (one clock tick rate).
- renamed and re-implemented the QF_tickISR() function as the
"extended" QF_tickXISR() function with the argument 'tickRate' for
processing time events allocated to different clock rates. The
application must call QF_tickXISR(0), QF_tickXISR(1), ... at the
specified tick rates from ISRs or *tasks*.
- renamed and re-implemented the internal function QTimeEvt_arm_()
to a public function QActive_armX() for arming time events
initialized with the "extended" constructor. The QActive_armX()
function is the new recommended API for arming time events, both
one-shot and periodic.
- re-implemented QActive_disarm().
- extended QF_timerSetX_ to an array of [QF_MAX_TICK_RATE], so that
every rate can be checked independently.
4. Added the new non-asserting API to qf.h:
- added functions QActive_postX() and QActive_postXISR() to post an
event to the given active object. The functions do not post the
event if the target event queue has less free slots than the
specified margin. The functions assert if the margin is zero and
the event can't be posted.
5. Changed the structure of the ARM Cortex-M ports
- renamed the sub-directory for ARM Cortex-M ports and examples
from "arm-cortex" to "arm-cm". This is done to avoid confusion
with other ARM Cortex variants, such as Cortex-A/R, which very
different from Cortex-M.
- removed the CMSIS (Cortex Microcontroller Software Interface
Standard) directories from the Cortex-M examples and moved it to
the common location in the %QPN%/ports/arm-cm/cmsis/ directory.
Upgraded the CMSIS to the latest Version 3.20.
- added the ARM Cortex-M ports and examples with Keil/ARM MDK to
the QP Baseline Code.
- upgraded ARM Cortex-M ports with IAR to the latest IAR EWARM 6.60
- upgraded ARM Cortex-M ports with Sourcery CodeBench to the latest
Version 2013.05-53.
9. Added the requested simple "Blinky" example for Windows and ARM
Cortex-M (with the GNU, IAR, and Keil toolsets).
- Added "Getting Started with QP-nano" guide based on the Blinky
example.
10. Modified the application examples with PC-Lint
(qpn/examples/arm-cm/gnu/dpp-qk_ek-lm3s811-lint and
qpn/examples/arm-cm/iar/dpp-qk_ek-lm3s811-lint). Updated lint files for
the latest PC-Lint
11. Ported all state pattern examples to Win32/MinGW. That way, all
these examples can be run and modified directly on Windows, without
going back to DOS.
12. Updated the Doxygen documentation (QP-nano Reference Manual)
- updated the QP-nano tutorial
- updated and added documentation and code samples
- added search box and tree-view panel to the HTML documentation
@section qpn_4_5_04 Version 4.5.04, 2013-02-09
The main purpose of this release is adding support for the ARM Cortex-M4F
processors with the hardware Floating-Point Unit (FPU). The QP-nano ports
to Cortex-M4F take full advantage of the "lazy stacking" feature of the
FPU registers, and by doing so offer the most efficient preemptive
multitasking on this processor.
Changes in detail:
1. Added ports and examples for ARM Cortex-M4F with the EK-LM4F120XL
board (Stellaris Launchpad).
2. Added the macro QF_LOG2(), which can be re-implemented in the QP-nano
ports, if the CPU supports special instructions, such as CLZ (count leading
zeros in Cortex-M3/M4). If the macro is not defined in the QP port, the
default implementation uses a lookup table.
3. Updated all ARM Cortex-M ports and examples to the latest IAR EWARM
6.50 and Sourcery CodeBench 2012.09-85.
4. Updated App Notes "QP and ARM Cortex-M with IAR" and "QP and ARM
Cortex-M with GNU".
5. Updated the PC-Lint support files (`lib-qpn.lnt`, `au-misra2.lnt`)
to the latest PC-Lint 9.00j.
6. Updated the Application Note: "QP-nano MISRA-C:2004 Compliance Matrix".
7. Spell-checked the comments in all QP-nano source files and removed
several typos.
8. Removed the Qt ports and examples from the QP-nano Baseline Code and
@note QP-nano Version 4.5.04 preserves full compatibility with QM 2.2.03
and all existing QDKs for QP-nano 4.5.xx.
@section qpn_4_5_03 Version 4.5.03, 2012-11-29
This release changes the directory structure of QP-nano examples
for various operating systems, such as POSIX (Linux, BSD, etc.),
Win32 (Windows), Qt, etc. The OS examples are moved from the
exampels/80x86/ directory one level up to examples/.
@section qpn_4_5_02 Version 4.5.02, 2012-08-17
The main purpose of this release is providing QM models in most
examples and better, more comprehensive support for (rapid)
prototyping of embedded QP applications on the desktop with the
Win32 API and with Qt. Among others, this release adds a complete
toolkit for creating realistic embedded front panels with pure
Win32-GUI API and free Visual C++ Express and ResEdit. An extensive
Application Note "QP and Win32" is included in this release.
This QP relase adds QM models, created with the new QM 2.2.01,
to most of the examples. The code generated by this new QM version
complies with MISRA-C:2004 rules.
This release adds the variable QF_timerSet_ and bookkeeping
around it, so that the state of all timeouts in the system can
be determined quickly and efficiently. This feature is for power-
sensitive applications, where the system clock tick interrupt
needs to be turned off. One of the criteria to entering such a
sleep mode is that all timeout events are disarmed, that is,
when (QF_timerSet_ == (uint8_t)0).
Changes in detail:
1. Added QF_timerSet_ declaration to qfn.h and setting/clearing
this bitmask into qfn.c and qfn_init.c. This feature is controled
by the configuration macro Q_TIMERSET.
2. Modified QP-nano port to Win32 and used the free Visual C++ Express
2010 with Platform SDK rather than Visual C++ Pro 2008. Provided a
completely revised App Note "QP and Win32".
3. Renamed the port directory qt_1t/ to qt/.
4. Added QM models to most examples and used the automatically
generated code from the models instead of the hand-written code.
5. Added .ui files to the Qt examples for generating UIs
graphically with the Qt Designer tool. Revised and updated the
App Note "QP and Qt".
6. Removed definition of the macro QF_FSM_ACTIVE from qpn_port.h
files in /examples/80x86/watcom/dpp and
/examples/80x86/watcom/game. This configuration conflicted
with the actual definition of the active objects, which used
*hierarchical* state machines, not the "flat" state machines.
@section qpn_4_5_01 Version 4.5.01, 2012-06-14
The main purpose of this minor release is providing improved
MISRA-compliant state machine implementation. Specifically, a new
macro Q_UNHANDLED() has been added for a situation when a guard
condition evaluates to FALSE, but the state model does not prescribe
the explicit [else] case for this guard. In this case, the state
handler can return Q_UNHANDLED(), which will cause the QEP event
processor to propagate the event to the superstate, which is what
UML semantics prescribes.
NOTE: These change to the QEP-nano event processor is completely
backwards-compatible. All state hander functions coded the old
way will continue to handle the guard conditions correctly and
in accordance with the UML specification. The new Q_UNHANDLED()
macro is necessary only for MISRA-compliant state handler coding,
which will be applied in the upcoming release of the QM modeling
and code generation tool.
Changes in detail:
1. Added macro Q_UNHANDLED() and return value Q_RET_UNHANDLED in
qepn.h.
2. Modified qepn.c to handle the Q_RET_UNHANDLED return value.
3. Updated the QP-nano MISRA-C:2004 compliance matrix to
include the new MISRA-compliant way of coding guard conditions.
4. Updated the IAR ARM compiler used in the ARM Cortex-M examples
to the latest Version IAR EWARM 6.40.
5. Modified the Qt port not to define the QPApp::onClockTick()
slot, but instead to allow defining this slot in the BSP of the
application.
@section qpn_4_5_00 Version 4.5.00, 2012-05-30
The main pupose of this relase is to improve host-based development of
QP-nano applications, which is critical for Test-Driven Development (TDD).
Among others, this release provides integration between QP-nano and the
popular Qt GUI framework, which allows developers to easily build host-
based simulations of the embedded systems with the realistic user
interfaces.
This realase also simplifies implementing transitions to history, which
is a preparation to providing this feature in the QM modeling tool.
Changes in detail:
1. Renamed the event class from QEvent to QEvt to avoid a name conflict
with the Qt framework.
NOTE: To minimize impact of this change on the existing QP-nano ports
and applications, the name QEvent is provided as well, but this can be
suppressed by defining the configuration macro Q_NQEVENT in qep_port.h.
2. Added return value to QF_run() to allow transfer of the exit
status to the destop operating systems.
NOTE: This modification haves impact on most QP-nano ports, because
the QF_run() function must now return a int16_t value.
3. Added member 'temp' to the QHsm and QFsm base classes to prevent
clobbering the current state (the 'state' member) during transitons.
This change allows keeping the current state unchanged during the
entire transition chain, which in turn allows easy and generic access
to the state information to store the state history in the exit
actions from states. Additional bonus of this re-design is the
opportunity of testing for stable state configuration in assertions
added to the qepn.c file.
4. Added the QHsm_state() and QFsm_state() accessor macros.
5. Modified the "Transition to History" pattern implementation to
use the simplified technique of obtaining the current state in the
exit action from the superstate rather than all the exit actions from
the substates. Modified the "State-Local Storage" (SLS) pattern as
well, because it was using the transition to history constructs.
6. Modified the QP-nano port to Win32 (both the MinGW and VC2008).
7. Modified the QP-nano port to POSIX.
8. Added QP port to Qt (Qt with one thread) and two example
applications (DPP and PELICAN crossing).
9. Added GNU compiler option -pthread to QP ports for POSIX with
P-threads, including QP ports and examples for Linux and Mac OS X.
@section qpn_4_4_00 Version 4.4.00, 2012-03-03
The main pupose of this relase is MISRA-C:2004 compliance, strong-type
checking compliance, update of PC-Lint option files and tests, and
general cleanup.
1. For commonality with the QP/C and QP/C++ frameworks renamed macros
QF_INT_LOCK/QF_INT_UNLOCK to QF_INT_DISABLE/QF_INT_ENABLE, respectively.
Also renamed macros QF_INT_KEY_TYPE/QF_ISR_LOCK/QF_ISR_UNLOCK to
QF_ISR_STAT_TYPE/QF_ISR_DISABLE/QF_ISR_RESTORE, respectively.
NOTE: This modifications have impact on most QP-nano ports. However,
the qfn.h header file contains definitions of the new macros in terms
of the old ones. This provies backwards comatibility of the existing
QP-nano ports.
2. Added the PC-Lint option files std.lnt and lib-qpn.lnt to the
qcn/include/ directory.
3. Cleaned the whole QP-nano code from lint comments. All PC-Lint options
have been moved to PC-Lint option files.
4. Modified QP-nano assertion macro Q_DEFINE_THIS_MODULE() to avoid
using the # operator (MISRA rule 19.13). This macro now requires the
argument enclosed in doble quotes "".
NOTE: This modification has impact on some QP-nano ports.
4. Added typedefs for char_t, int_t, float32_t, and float64_t to
event.h header file for compliance with MISRA-C:2004 rules 6.1 and 6.3.
5. Added macros Q_STATE_CAST() and Q_ACTIVE_CAST() to qep.h to
encapsulate deviation from MISRA-C rule 11.4.
6. Added macro Q_UINT2PTR_CAST() to encapsulate casting unsigned
integers to pointers, which deviates from MISRA-C rule 11.3. This
macro has been added for *application-level* code.
7. Updated ARM Cortex-M examples with the latest CMSIS v3.0, which
complies with more MISRA-C:2004 rules.
8. Added PELICAN examples for MISRA-C:2004 compliant applications (for
IAR-ARM and GNU-ARM).
9. Added testing of PC-Lint option files against the MISRA-C Exemplar
Suite.
10. Updated ARM-Cortex-M3 port with GNU to the latest Sourcery
CodeBench 2011.09-60.
11. Added documentation to QP-nano distribution in the directory
qpn/doc/, with the following Application notes: "QP-nano MISRA-C:2004
Compliance Matrix" and "Quantum Leaps Coding Standard",
@section qpn_4_3_00 Version 4.3.00, 2011-10-31
1. This release changes the partitioning of the QK-nano scheduler.
Specifically, the QK-nano scheduler is now divided between two
functions QK_schedPrio_() and QK_sched_(), to calculate the highest-
priority task ready to run and to perform scheduling, respectively.
The function QK_schedPrio_() is useful to determine if scheduling
is even necessary.
2. Reduced the interrupt latency of the QK-nano kernel by breaking up
the critical section in the QK_sched_() into two pieces, just after
setting QK_currPrio_.
3. Modified the ARM Cortex-M port qkn_port.s to take advantage of the
new structure of the QK-nano scheduler. To reduce code duplications,
the QK-nano port file qkn_port.s has been placed in the directories:
qpn/ports/arm-cortex/qk/gnu/ for the GNU compiler and
qpn/ports/arm-cortex/qk/iar/ for the IAR compiler, respectively.
4. Moved the Win32 and POSIX emulation of QP-nano from the directory
qpn/emulation/ to qpn/ports/win32/ and qpn/ports/posix/, respectively.
5. Renamed the function QF_tick() to QF_tickISR() to clearly notify
the user that this function is callable from ISR only. For backwards
compatibility, the macro QF_tick() is defined to QF_tickISR().
6. Modified QF_tickISR(), QActive_postISR(), QActive_post(), and
QK_sched_() to use stack-based pointer to QActiveCB, which avoids
re-computation of the pointer on-the-fly in the loop. According to the
feature request #3403079, this significantly speeds up the code for
8-bit PIC micros.
7. Upgraded the examples for ARM Cortex with IAR EWARM to the
latest IAR EWARM Version 6.30.
8. Upgraded the examples for ARM Cortex with GNU (CodeSourcery) to the
latest Sourcery CodeBench 2011.07-60.
@section qpn_4_2_04 Version 4.2.04, 2011-09-24
The main pupose of this relase is to provide a bug fix for the QK port
to ARM Cortex processors. The bug fix addresses a very rare and
undocumented behavior of late-arrival of an interrupt while entering
the PendSV exception. In this case the PENDSVSET bit in the NVIC-ICSR
register is *not* cleared when finally PendSV is entered, so the
PendSV exception is entered in a *different* state when it is entered
via the late-arrival mechanism versus the normal activation of the
exception through tail-chaining. The consequence of this undocumented
and inconsistent hardware behavior, PendSV could be re-entered again
before the SVCall exception cleans up the stack. The bug fix is
implemented in the qk_port.s file (in QP-nano this file is replicated
in every example for QK-nano) and consists of clearing the PENDSVSET
bit programmatically inside PendSV_Handler.
@section qpc_4_2_02 Version 4.2.02, 2011-09-08
The main pupose of this relase is to repackage the default QP-nano
distribution to contain the single root directory qpn/ in the
archive. That way, unziping the archive will produce only one
directory (qpn/), which can be then changed by the user.
@section qpn_4_2_01 Version 4.2.01, 2011-08-13
1. Modified file qassert.h to add assertion macros #Q_ASSERT_ID,
#Q_REQUIRE_ID, #Q_ENSURE_ID, #Q_INVARIANT_ID, and #Q_ERROR_ID,
which are better suited for unit testig, because they avoid the
volatility of line numbers for indentifying assertions.
2. Modified the make files and project files to use the environment
variable QPN instead of relying on the relative path to the QP-nano
framework.
3. Added QP-nano examples for Mac OS X on 80x86.
4. Upgraded the examples for ARM Cortex with IAR EWARM to the
latest IAR EWARM Version 6.20.
5. Upgraded the examples for MSP430 with IAR EW430 to the
latest IAR EW430 Version 5.30.
@section qpn_4_1_07 Version 4.1.07, 2011-02-28
The goal of this release is to improve the ease of experimenting with
QP-nano on the desktop. This release adds support for Windows (Win32)
and Linux to the QP-nano baseline code. Two most popular compilers for
Windows are supported: Microsoft Visual Studio and MinGW (GNU). The
support for Linux includes pre-built examples and makefiles compatible
with Eclipse.
The changes in detail are:
1. Added sub-directory qpn/emulation with emulation code for Windows
(win32) and POSIX (Linux, Mac OS X, etc.).
2. Added Win32 examples for Visual C++ 2008 (examples/80x86/win32/
vc2008/dpp and examples/80x86/win32/vc2008/qhsmtst). Visual Studio
soultions are provides for all build configurations.
3. Added Win32 examples for MinGW (examples/80x86/win32/mingw/dpp
and examples/80x86/win32/mingw/qhsmtst). Eclipse-compatible makefiles
are provided for all build configurations. NOTE: the Makefiles assume
that the MinGW/bin directory is added to the PATH.
4. Fixed a bug in file qfn.c, function QActive_postISR(). For special
rare combination of configuration macros the assertion was checked
before declaring an automatic variable QF_ISR_KEY_TYPE key. This
declaration has been moved to the top of the function.
5. Upgraded the examples for ARM Cortex with CodeSourcery to the
latest Sourcery G++ 2011.02-2.
@section qpn_4_1_06 Version 4.1.06, 2011-01-07
1. Made cosmetic improvements to the example QM model of the
"Fly 'n' Shoot" game.
2. Made improvements in make.bat files for building the examples for
DOS/Open Watcom to run better in DosBox on Linux.
3. Upgraded the examples for ARM Cortex with IAR to the latest
IAR EWARM Version 6.10.
4. Upgraded the examples for ARM Cortex with CodeSourcery to the
latest Sourcery G++ 2010.09-66.
@section qpn_4_1_05 Version 4.1.05 (Product) Nov 01, 2010
This release is adds examples for the QM (QP Modeler) graphical modeling
and code generation tool. The examples are based on the "Fly 'n' Shoot"
game described in the QP-nano Tutorial and in Chapter 1 of the PSiCC2 book.
Specifically, the directory qpn/examples/80x86/watcom/game-qm/
contains the "Fly 'n' Shoot" game model file "game.qm". This model, when
opened in the QM tool contains all state machine diagrams and generates
code into the subdirectory qm_code/. This code can then be built and
executed on any 80x86 machine (newer versions of Windows or Linux require
the DOSbox application, see http://www.dosbox.com).
The directory qpn/examples/arm-cortex/iar/game-ev-lm3s811-qm/
contains the Version of the game for the EV-LM3S811 ARM Cortex-M3 board.
This directory contains the model file "game.qm", which is actually
identical as the model in the DOS version. The LM3S811 Version needs to
be compiled with the IAR compiler and executed on the EV-LM3S811 board.
Additionally, the QP-nano baseline code has been slighlty modified for
better conformance to the MISRA C 2004 rules and the latest PC-Lint 9.x.
@section qpn_4_1_04 Version 4.1.04, 2010-03-16
This release is adds compatibility of all examples for DOS with the DOSBox
emulator (http://www.dosbox.com/) that recreates a MS-DOS compatible
environment on all versions of Windows, including 64-bit Windows that don't
run 16-bit DOS applications anymore.
Also, this release includes QP ports and examples for EV-LM3S811 board with
the GNU-based Code Sourcery G++ toolset. Support for Sourcery G++ provides
a very cost-effective option for developing QP applications for ARM Cortex
MCUs.
Finally, this release improves the Cortex Microcontroller Software Interface
Standard (CMSIS) for the whole family of the Stellaris LM3Sxxx MCUs. The
improvement extends the CMSIS from Sandstorm to Fury, DustDevil, and Tempest
Stellaris families.
@section qpn_4_1_03 Version 4.1.03, 2010-01-21
This release is concerned with the ARM Cortex ports and examples.
Specifically, this release contains the following improvements:
1. Unified source code for ARM Cortex-M3 and the new ARM Cortex-M0 cores,
including the code for the preemptive QK kernel.
2. Compliance with the Cortex Microcontroller Software Interface Standard
(CMSIS) in all ARM Cortex examples.
3. Backward-compatible support for the new LM3S811 EVAL Rev C board with
different OLED display than previous revisions. (NOTE: The OSRAM 96x16x1 OLED
used in REV A-B boards has been replaced RITEK 96x16x1 OLED used in Rev C.)
In the process of making the examples CMSIS-compliant, the dependency on the
Luminary Micro driver library (driverlib.a) has been completely removed.
Additionally, the screen saver of the "Fly 'n' Shoot" game has been improved
to periodically switch off the power of the OLED display, which better
protects the display from burn-in. The affected file is tunnel.c.
Finally, this release introduces the QP_Version macro, which identifies the QP
version. Otherwise, this maintenance release does not change the QP/C API in
any way, so the release has NO IMPACT on the QP/C applications except for the
ARM Cortex ports and applications.
@section qpn_4_1_02 Version 4.1.02, 2010-01-14
The purpose of this minor maintenance release is the change in the directory
structure for the ARM Cortex ports and examples. As new ARM Cortex cores are
becoming available, the old port name "cortex-m3" could be misleading, because
it actually applies to wider range of ARM Cortex cores. Consequently, all ARM
Cortex ports and examples are hosted in the directory tree called
"arm-cortex".
This maintenance release does not change the QP-nano API in any way, so the
release has NO IMPACT on the QP-nano applications except for the ARM Cortex
ports and applications.
@section qpn_4_1_01 Version 4.1.01, 2009-11-05
The main purpose of this release is to replace the Turbo C++ 1.01 toolset
with the Open Watcom C/C++ toolset, because Turbo C++ 1.01 is no longer
available for a free download. In contrast, Open Watcom is distributed under
an OSI-certified open source license, which permits free commercial and
non-commercial use. Open Watcom can be downloaded from www.openwatcom.org.
All 80x86 examples (vanilla and QK-nano) for Turbo C++ 1.01 have been replaced
with examples for Open Watcom. The make.bat scripts are provided to build the
examples.
In the process of converting the examples to Open Watcom a new SLS example
have been added to the standard QP-nano distribution. The SLS example located
in <qpn>/examples/80x86/watcom/sls/ shows the QP-nano implemenation of the
new State-Local Storage state design pattern.
@section qpn_4_1_00 Version 4.1.00, 2009-10-09
The main purpose of this release is to fix a bug in event posting, which
could cause corruption of the event signal. Such corruption could occur when
an event was posted to an empty event queue, in which case it was written
directly to the internal event stored in the state machine, bypassing the
ring-buffer. However, the signal of the internal event could also be changed
by the QEP-nano event processor during execution of transitions.
The bug fix is to always pass events through the ring buffer and never
overwrite the internal event during event posting (both from the task
level and from the ISR level). The update of the ring buffer always
occurs within a critical section and is safe from interruptions.
This bug fix also allows posting of events from the top-most initial
transitions of active objects during the initialization phase. Previously,
the execution of the top-most initial transition corrupted the signal of
the internal event.
The bug fix enables also self-posting of events from entry/exit actions
and internal initial transitions. Again, the QEP event processor corrupted
the internal signal.
This release also replaces the static variables 'p' (priority) and 'a'
(active object pointer) with automatic variables. This change results in
more efficient code, because the frequently used variables can be kept in
registers and do not need to be read/written from/to memory by each use.
Additionally, this release updates the QP-nano ARM Cortex-M3 examples for
the EK-LM3S811 board to the latest IAR EWARM 5.40. Due to the acquisition
of Liminary Micro by Texas Instruments the directory IAR structure for the
examples and drivers has changed and the QP-nano examples had to be changed
accordingly.
Finally, this release fixes a bug in the "Fly 'n' Shoot" game example for
QP-nano, which caused an assertion if the Ship was moved to the very top
of the Tunnel. This was due to the y-coordinate of the ship explosion
becomoming negative.
NOTE: This release does not change the QP-nano API, but all event queues
are effectively shortened by one event. Also it is no longer possible to
declare an active object without a ring buffer (zero-sized queue), because
the internal event no longer counts towards the queue depth.
The main changes in QP v4.1.00 with respect to the earlier versions are
as follows:
- modified functions QActive_post(), QActive_postISR(), and QF_run() in qfn.c
to always use the ring buffer and not to count the internal event as part
of the queue (in the assertions).
- modified qfn.c to replace static variables 'p' and 'a' with automatic
variables.
- modified function QK_schedule_() in qkn.c to always use the ring buffer,
as described above.
- modified module qkn.c to to replace static variables 'p' and 'l_act' with
automatic variables.
- modified various examples to eliminate zero-sized queues and extend event
queues by one event.
- modified the ARM Cortex-M3 examples for the new IAR EWARM 5.40.
- modified the ship.c and tunnel.c files in the "Fly 'n' Shoot" game
example to fix the aforementioned bug.
@section qpn_4_0_04 Version 4.0.04, 2009-04-09
The maintenance release provides a fix for the compile-time assertions,
which did not work correctly for the GNU compiler family. Also, the ARM
Cortex-M3 examples have been recompiled with the newer IAR EWARM v5.30.
This maintenance release does not change the QP-nano API in any way, so the
release has NO IMPACT on the QP-nano applications.
The main changes in QP v4.0.04 with respect to earlier Version are as follows:
- in qassert.h file the #Q_ASSERT_COMPILE macro has been modified to render
a negative array dimension when the asserted condition is not TRUE.
@section qpn_4_0_03 Version 4.0.03, 2008-08-06
The main purpose of this release is to "future-proof" the QK-nano preemptive
kernel. The release 4.0.03 strictly preserves the semantics of QK_currPrio_
variable, which was violated by the previous QK mutex implementation.
The mutex locking now uses a different variable QK_ceilingPrio_, which
represents the ceiling-priority locked by the mutex. When the mutex is
configured (the macro #QK_MUTEX is defined), the QK-nano scheduler
performs an additional check to make sure that only tasks with priorities
above the ceiling can run. This additional overhead is not present when
#QK_MUTEX is not defined.
This maintenance release does not change the QP-nano API in any way, so the
release has NO IMPACT on the QP-nano applications.
The main changes in QP v4.0.03 with respect to earlier Version are as follows:
- in qkn.c file, changed priority-ceiling mutex implementation to use
the QK_ceilingPrio_ instead of QK_currPrio_. Also added testing priority
against the QK_ceilingPrio_, when the macro QK_MUTEX is defined.
@section qpn_4_0_02 Version 4.0.02, 2008-08-06
This maintenace release is made to allow posting events from any active object
to any active object from the top-most initial transtions.
This maintenance release does not change the QP-nano API in any way, so the
release has NO IMPACT on the QP-nano applications.
The main changes in QP v4.0.02 with respect to earlier Version are as follows:
- modified function QF_run() in qfn.c to first loop over all active objects
and initialize their priority attribute based on their location in the
QF_active[] array. The second for-loop triggers only the initial transitions,
but now all priorities are initialized, so active objects can post events to
each others from the initial transitions.
- modified function QF_run() in qkn.c in identical way as in qfn.c described
above.
@section qpn_4_0_01 Version 4.0.01, 2008-06-08
This maintenace release is made to allow compiling QP-nano with the GNU
compiler for AVR (WinAVR). Specifically, some changes were necessary to
accomodate the non-standard way of hanlding constant data objects allocated
in ROM (PROGMEM) in the GNU compiler for AVR.
This maintenance release does not change the QP-nano API in any way, so the
release has NO IMPACT on the QP-nano applications.
The main changes in QP v4.0.01 with respect to earlier Version are as follows:
- eliminated QF_pCB_ variable from qfn.c and qkn.c. This variable was used to
point to the constant active object control block (QActiveCB) in ROM. The GNU
compliler for AVR could not handle such pointer correctly without
contaminating the code with non-portable and non-standard extensions.
- added Doxygen comments to the qep.h header file.
- in qepn.c file, broken up expressions of the form if (t == path[iq]) ...
into (s = path[iq]; if (t == s) ...). This was done to accommodate the
ImageCraft ICCM8C compiler for PSoC.
@section qpn_4_0_00 Version 4.0.00, 2008-04-07
This milestone release is made for the book /ref PSiCC2. The book describes in
great detail this new release. The older "QP-nano Programmer's Manual" is now
phased out and is replaced with this hyper-lirenked
/ref main_page "QP-nano Reference Manual", which provides very detailed,
easily searchable reference to the software. The book /ref PSiCC2 provies
in-depth discussion of the relevant concepts as well as the design study of
QP v4.0, including QP-nano v4.0 in Chapter 12.
The main changes in QP v4.0 with respect to earlier versions are as follows:
- the coding techniques for hierarchical state machines (HSMs) and the simpler
finite state machines (FSMs) have changed. While the changes are quite simple,
the backward compatibility with QEP-nano 3.x has been broken, meaning that
some manual changes to the state machines implemented with earlier versions
are necessary. Please refer to the "QP-nano Tutorial" Section /ref coding_hsm
for more information about coding state machines with QEP 4.x.
- The main change is the signature of a state-handler function, which now
returns simply a byte. This return type (typedef'ed as QState) is the
status of the event-handling that the state handler conveys to the QEP
event processor.
- The macro #Q_TRAN() must now always follow the return statement.
- The new macro #Q_SUPER() designates the superstate of the given state.
Again, this macro must follow the return statement.
- Then two new macros #Q_HANDLED() and #Q_IGNORED() have been added to
return the status of event handled and event ignored, respectively.
- all callback functions are now consistently called /c #XXX_onYYY():
- Q_assert_handler() is now Q_onAssert()
- QF_start() is now QF_onStartup()
- QF_cleanup() is now QF_onCleanup()
- all callback functions are now consistently called /c XXX_onYYY():
- Q_assert_handler() is now Q_onAssert()
- QF_start() is now QF_onStartup()
- QF_cleanup() is now QF_onCleanup()
- enumerating global active object priorities is no longer necessary.
- the methods of posting events have changed:
- QF_post(prio, sig, par) is now void QActive_post(me, sig, par)
- QF_postISR(prio, sig, par) is now void QActive_postISR(me, sig, par)
- the global variable QF_activeNum has been eliminated
- instead the constant #QF_MAX_ACTIVE must correspond
to the exact number of active objects in the application.
- the QEP-nano event processor now works identically as the full-Version QEP.
Specifically, the signal of the current event is not used to notify the event
processor that a transition has taken place. This saves a few bytes of code
for every usage of #Q_TRAN().
- all QF-nano and QK-nano functions have been modified to use static variables
instead of stack variables wherever possible. This saves a few bytes of stack
for the "vanilla" kernel. In QK-nano the savings can be more substantial.
- the QP-nano event queues now decrement the head and tail counters. This
leads to wrap-around at zero, which is easier (faster) to test than any other
wrap-around point.
- all examples in the standard QP-nano distribution have been cleaned up and
updated to the latest QP-nano API changes.
*/
Finally, this release improves the comments in the QF_stop() function. The comments now make it very clear that after calling QF_stop() the application must terminate and cannot continue. In particular, QF_stop() is **not** intended to be followed by a call to QF_init() to "resurrect" the application. The previous comments apparently were confusing and some developers attempted to "restart" a running application, which led to system crashes.
================================================
FILE: doxygen/img/img.htm
================================================
QP built-in images
================================================
FILE: doxygen/lint.dox
================================================
/*! @page lint PC-Lint
The QP-nano framework comes with extensive support for automatic rule checking by means of PC-Lint, which is designed not just for proving compliance of the Q/CP framework code, but more importantly, to aid in checking compliance of the application-level code. Any organization engaged in designing safety-related embedded software could benefit from the unprecedented quality infrastructure built around the QP-nano framework.
@sa ports_lint
*/
================================================
FILE: doxygen/macros.h
================================================
/*!
* @file
* @ingroup qepn qfn qkn qvn
* macros for porting QP-nano, and command-line macros
*/
/*! The preprocessor switch to disable checking assertions */
/**
* @description
* When defined, Q_NASSERT disables the following macros #Q_ASSERT,
* #Q_REQUIRE, #Q_ENSURE, #Q_INVARIANT, #Q_ERROR as well as
* #Q_ASSERT_ID, #Q_REQUIRE_ID, #Q_ENSURE_ID, #Q_INVARIANT_ID, and
* #Q_ERROR_ID do NOT evaluate the test condition passed as the
* argument to these macros.
*
* @note One notable exception is the macro #Q_ALLEGE, that still
* evaluates the test condition, but does not report assertion
* failures when the switch #Q_NASSERT is defined.
*/
#define Q_NASSERT
/*! @deprecated macro to enable keeping track of QF time event usage;
* instead use: #QF_TIMEEVT_USAGE */
#define Q_TIMERSET
/*! This macro enables calling the QK-nano context-switch callback
* QK_onContextSw() */
#define QK_ON_CONTEXT_SW
/*! Macro that should be defined (typically on the compiler's command line)
in the Win32-GUI applications that use the @ref win32-qv port.
*/
#define WIN32_GUI
================================================
FILE: doxygen/main.dox
================================================
/*! @mainpage About QP-nano™
@image html qpn_banner.jpg
@section ab_new What's new?
To check what's new in QP-nano, please see @ref history "QP-nano Revision History".
@attention
The QP-nano framework is being __phased out__ and is not recommended for new product development.
@section ab_about What is it?
QP-nano™ (Quantum Platform Nano) is an ultra-lightweight Real-Time Embedded Framework (RTEF) for building responsive and modular real-time embedded applications as systems of asynchronous event-driven active objects (concurrent @ref sm "state machines"). The QP-nano™ RTEF is a member of a larger family consisting of QP-nano, QP/C, and QP/C++ frameworks, which are all strictly quality controlled, thoroughly documented, and available under @ref licensing "dual licensing model".
@note
The QP-nano™ framework is intended for **low-end** 8- and 16-bit microcontrollers such as AVRmega, MSP430, or 8051 with very limited RAM on board (less then 1KB). If your MCU has more than 1KB of RAM, you should consider the QP/C™ framework instead of QP-nano™.
@attention
To use QP-nano™ effectively, you need to understand the key concepts that underline the architecture of the framework and your applications based on the framework.
@htmlonly
@endhtmlonly
@section ab_goals What does it do?
The main goals of the QP-nano™ framework are:
- to provide a reusable **architecture** based on active objects (actors), which is _safer_ and more extensible than the venerable "superloop" commonly used on low-end 8- and 16-bit microcontrollers.
- to provide a simple-to-use coding techniques for @ref sm "hierarchical state machines", with which to implement the behavior of active objects.
- to provide efficient and thread-safe event-driven mechanisms for active objects to communicate, such as direct event passing.
- to provide event-driven timing services (time events).
- to provide a selection of built-in real-time kernels to run the QP applications, such as the cooperative @ref qvn "QV-nano kernel" and the preemptive non-blocking @ref qkn "QK-nano kernel".
- to provide portability layer and ready-to-use emulations on the desktop operating systems such as @ref posix-qv "Linux" and @ref win32-qv "Windows".
- to provide a target for modeling and automatic code generation from the QM modeling tool.
@section ab_special What's special about it?
The QP-nano™ Real-Time Embedded Framework (RTEF) is a unique offering on the embedded software market. It provides a modern, reusable **architecture** of embedded applications, which combines object-orientation with the particular model of concurrency, known as active objects (concurrent @ref sm "state machines"). This architecture is generally **safer** and better structured than the venerable "superloop + spaghetti-code" commonly used on low-end 8- and 16-bit microcontrollers.
@subsection lightweight Ultra-Lightweight
The most unique characteristic of the QP-nano™ framework is its **tiny footprint**, especially in RAM. In this respect, QP-nano™ requires far less resources than even the smallest conventional Real-Time Operating System (RTOS) kernel. In fact, it has been designed to run on microcontrollers, where you cannot fit any traditional kernel. At the same time, QP-nano™ gives you a much higher level of abstraction than a conventional RTOS. With QP-nano™, you work at the level of active objects, state machines and events, as opposed to "superloop" commonly used on low-end 8- and 16-bit microcontrollers.
@note
If you can program your MCU in ANSI-C, you probably can fit in QP-nano™. For example, the article UML Statecharts at $10.99 describes a complete QP-nano™ application (PEdestrian LIght CONtroled (PELICAN) crossing) implemented in a 8051 MCU with 256 bytes of RAM.
@subsection oop Object Orientation
Even though it is written in @ref misra "MISRA-compliant" ANSI-C, QP-nano™ is fundamentally an **object-oriented** framework, which means that the framework itself and your applications derived from the framework are fundamentally composed of classes and only classes can have @ref sm "state machines" associated with them.
@note
If you program in C and object-oriented programming is new to you, please refer to the Application Note "Object-Oriented Programming in C", which describes how you can implement the concepts of _classes_, _inheritance_, and _polymorphism_ to portable ANSI-C.
@htmlonly
Application Note: Object-Oriented Programming in C
@endhtmlonly
@subsection hsms Hierarchical State Machines
The behavior of active objects is specified in QP-nano™ by means of
hierarchical state machines (UML statecharts). The frameworks support manual coding of UML state machines in C or C++ as well as fully automatic code generation by means of the free graphical QM™ modeling tool.
@remarks
State machines can be an incredibly powerful technique, but they require an event-driven **infrastructure** (framework) that provides, at a minimum: a run-to-completion (RTC) execution context for each state machine, queuing of events, and event-based timing services. This is really the pivotal point. Without an event-driven framewok (like QP-nano), state machines are like cars without an infrastructure of roads.
@subsection kernels Built-in Kernels
All QP-nano™ framework is designed to run on @ref exa_native "low-end 8- and 16-bit single-chip microcontrollers", replacing the venerable "superloop". The framework contains two built-in real-time kernels: the cooperative @ref qvn "QV-nano kernel" and the _preemptive_ non-blocking @ref qkn "QK-nano kernel". @ref ports_native "Native QP ports" and ready-to-use @ref exa_native "examples" are provided for selected @ref exa_ref_mcu "CPU families".
@subsection emul Windows/Linux Emulation
QP-nano™ can also be emulated on @ref ports_os "desktop OSes" (such as Windows and Linux), which allows you to develop and test large portions of your deeply embedded code on the desktop.
@subsection popular Popularity & Maturity
With over 15 years of continuous development and 60,000 downloads a year, the QP™ RTEF family is the most mature and popular such solution on the embedded software market.
The QP™ frameworks are used in millions of products worldwide in aerospace, medical devices, consumer electronics, wired and wireless telecommunications, industrial automation, transportation, robotics, and many more.
@subsection psicc2 Book
The book, Practical UML Statecharts in C/C++, 2nd Edition provides a detailed design study of the QP frameworks and explains all the related concepts.
@image html PSiCC2-3D.jpg "Practical UML Statecharts in C/C++, 2nd Edition"
@section licensing How is it licensed?
QP-nano™ is licensed under the increasingly popular dual licensing model, in which both the open source software distribution mechanism and traditional closed source software distribution models are combined.
@note If your company has a policy forbidding open source in your product, all QP frameworks can be licensed commercially, in which case you don't use any open source license and you do not violate your policy.
@subsection open-source Open Source Projects
If you are developing and distributing open source applications under the GNU General Public License (GPL), as published by the Free Software Foundation, then you are free to use the Quantum Leaps software under the GPL version 3 of the License, or (at your option) any later version. Please note that GPL requires that all modifications to the original code as well as your application code (Derivative Works as defined in the Copyright Law) must also be released under the terms of the GPL open source license.
@subsection closed-source Closed Source Projects
If you are developing and distributing traditional closed source applications, you can purchase one of Quantum Leaps commercial licenses, which are specifically designed for users interested in retaining the proprietary status of their code. All Quantum Leaps commercial licenses expressly supersede the GPL open source license. This means that when you license Quantum Leaps software under a commercial license, you specifically do not use the software under the open source license and therefore you are not subject to any of its terms.
@section support How to get help?
Please post any **technical questions** to the Free Support Forum hosted on SourceForge.net. Posts to this forum benefit the whole community and are typically answered the same day.
Direct **Commercial Support** is available to the commercial licensees. Every commercial license includes one year of Technical Support for the licensed software. The support term can be extended annually.
Training and consulting services are also available from Quantum Leaps. Please refer to the Contact web-page for more information.
@section contact Contact Information
- Quantum Leaps Web site: state-machine.com
- Quantum Leaps licensing: state-machine.com/licensing
- QP/QM on SourceForge.net: sourceforge.net/projects/qpc
- QP/QM on GitHub: github.com/QuantumLeaps
- e-mail: info@state-machine.com
@image html logo_ql_TM.jpg
@next{gs}
*/
================================================
FILE: doxygen/make.bat
================================================
@echo off
:: ==========================================================================
:: Product: batch script for generating Doxygen documentation
:: Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
::
:: SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
::
:: This software is dual-licensed under the terms of the open source GNU
:: General Public License version 3 (or any later version), or alternatively,
:: under the terms of one of the closed source Quantum Leaps commercial
:: licenses.
::
:: The terms of the open source GNU General Public License version 3
:: can be found at:
::
:: The terms of the closed source Quantum Leaps commercial licenses
:: can be found at:
::
:: Redistributions in source code must retain this top-level comment block.
:: Plagiarizing this software to sidestep the license obligations is illegal.
::
:: Contact information:
::
::
:: ==========================================================================
@setlocal
@echo usage:
@echo make
@echo make -CHM
@echo make ...
:: Doxygen tool (adjust to your system) ......................................
@set DOXYGEN=doxygen
:: HTML Help tool (needed only with the -CHM option, (adjust to your system) .
@set HHC="C:\tools\HTML Help Workshop\hhc.exe"
:: Simple complexity metrics tool (adjust to your system) ...................
@set LIZARD=lizard
:: Generate metrics.dox file...
@set METRICS_INP=..\include ..\src -x ..\src\qs\*
@set METRICS_OUT=metrics.dox
@echo /** @page metrics Code Metrics > %METRICS_OUT%
@echo.>> %METRICS_OUT%
@echo @code{cpp} >> %METRICS_OUT%
@echo Code Metrics for QP-nano >> %METRICS_OUT%
%LIZARD% -m -L500 -a10 -C20 -V %METRICS_INP% >> %METRICS_OUT%
@echo @endcode >> %METRICS_OUT%
@echo */ >> %METRICS_OUT%
:: Generate Doxygen Documentation...
if "%1"=="-CHM" (
@echo Generating HTML...
%DOXYGEN% Doxyfile-CHM
@echo Adding custom images...
xcopy preview.js tmp\
xcopy img tmp\img\
@echo img\img.htm >> tmp\index.hhp
@echo Generating CHM...
%HHC% tmp\index.hhp
@echo.
@echo Cleanup...
@rmdir /S /Q tmp
@echo CHM file generated
) else (
@echo.
@echo Cleanup...
rmdir /S /Q ..\html
@echo Adding custom images...
xcopy preview.js ..\html\
xcopy img ..\html\img\
copy images\favicon.ico ..\html
@echo Generating HTML...
%DOXYGEN% Doxyfile%1
@qclean ..\html
)
@endlocal
================================================
FILE: doxygen/modules.dox
================================================
/*! @defgroup qepn QEP-nano
@brief
Hierarchical Event Processor
QEP-nano is a universal, UML-compliant event processor that enables developers to code UML state machines in highly readable ANSI-C, in which every state machine element is mapped to code precisely, unambiguously, and exactly once (traceability). QEP fully supports hierarchical state nesting, which is the fundamental mechanism for reusing behavior across many states instead of repeating the same actions and transitions over and over again.
*/
/*!
@defgroup qfn QF-nano
@brief
Active Object (Actor) Framework
QF-nano is a portable, event-driven, real-time framework for execution of active objects (concurrent state machines) specifically designed for real-time embedded (RTE) systems.
*/
/*!
@defgroup qkn QK-nano
@brief
Preemptive Non-Blocking Kernel
QK is a tiny **preemptive**, priority-based, non-blocking kernel designed specifically for executing active objects. QK meets all the requirement of the Rate Monotonic Scheduling (a.k.a. Rate Monotonic Analysis — RMA) and can be used in hard real-time systems.
*/
/*!
@defgroup qvn QV-nano
@brief
Cooperative Run-to-Completion Kernel
QV-nano is a simple **cooperative** kernel (previously called "Vanilla" kernel). This kernel executes active objects one at a time, with priority-based scheduling performed before processing of each event. Due to naturally short duration of event processing in state machines, the simple QV kernel is often adequate for many real-time systems.
*/
/*! @dir ../include
Platform-independent QP-nano API
@note
The QP-nano include directory needs to be added to the compiler's include path in the applications using QP-nano.
*/
/*! @dir ../source
Platform-independent QP-nano implementation
Files from this directory need to be added to the project, to build the QP-nano framework from source code.
@attention
Not all QP-nano source files should be added to every project. For example, QP-nano ports to the preemptive QK-nano kernel should **not** contain the file qvn.c and conversely, QP-nano ports to the cooperative QV-nano kernel should not contain the files qkn.c.
@note
The QP-nano source directory needs to be added to the compiler's include path in the applications using QP-nano, because QP-nano is built from sources.
*/
================================================
FILE: doxygen/ports.dox
================================================
/*! @page ports Ports
@section ports_gen General Comments
The QP-nano framework can be easily adapted to various operating systems, processor architectures, and compilers. Adapting the QP-nano software is called porting and the QP-nano framework has been designed from the ground up to make porting easy.
The QP-nano distribution contains many QP-nano ports, which are organized into the three categories:
- @subpage ports_native "Native Ports" adapt QP-nano to run on bare-metal processors "natively", using one of the built-in kernels (@ref comp_qv "QV" or @ref comp_qk "QK")
- @subpage ports_os "3rd-Party OS Ports" adapt QP-nano to run on top of a 3rd-Party Operating System (OS), such as Windows or Linux.
@section ports_code Port Code Structure
Starting with QP-nano release 5.4.0, **all** available ports are bundled into the QP-nano download, as opposed to being distributed as separate QP Development Kits (QDKs). The main benefit is of this approach is that it greatly reduces chances of mistakes in combining the mainline QP-nano code with various QDKs. The downside is that the QP-nano distribution becomes quite large and that ports cannot be added or updated independently from the QP-nano baseline code.
All ports are located in sub-directories of the ports @ref qpn_files "top-level folder", with the hierarchical organization outlined below:
ports
arm-cm — Native ports for ARM-Cortex-M (bare-metal) A
qk — Port to the @ref comp_qk "preemptive QK kernel"
A **Native Ports** are located in sub-directories named after the CPU architecture, such as arm-cm for ARM Cortex-M. Under that directory, the sub-directories qk and qv contain ports for the @ref comp_qk "QK" and @ref comp_qv "QV" kernels, respectively.
B **Ports for 3rd-party OS** are located in sub-directories named after the OS, such as win32-qv for the Win32-QV (Windows with QV-type scheduler).
@note
Because the QP distribution contains *all* ports, the number of sub-directories and files in the ports folder may seem daunting. However, knowing the structure of the ports folder, you can simply **delete** the sub-directories that are not interesting to you.
@next{ports_native}
*/
================================================
FILE: doxygen/ports_arm-cm.dox
================================================
/*##########################################################################*/
/*! @page arm-cm ARM Cortex-M
@tableofcontents
This section describes the QP-nano™ port to the ARM Cortex-M processor family (Cortex M0/M0+/M3/M4). Three main implementation options are covered: the @subpage arm-cm_qv "cooperative, priority-based QV-nano kernel" and the @subpage arm-cm_qk "preemptive run-to-completion QK-nano kernel". Additionally, the use of the VFP (floating point coprocessor) in the M4F processor is explained as well. This document assumes QP-nano version 5.9.x or higher.
@note
To focus the discussion, this section references the **GNU-ARM toolchain**. However, the general implementation strategy applies equally to all toolchains for ARM Cortex-M, such as **ARM-KEIL** and **IAR EWARM**, which are all provided as well. The QP code downloads contain also examples for other boards, such as STM32 Nucleo, NXP mbed-1768, SilLabs Gecko and others.
@section arm-cm_files Directories and Files
The QP ports to ARM Cortex-M are available in the standard QP distribution. Specifically, the ARM Cortex-M ports are placed in the following directories:
@section arm-cm_int Interrupts in the QP-nano Ports to ARM Cortex-M
The QP-nano framework, like any real-time kernel, needs to disable interrupts in order to access critical sections of code and re-enable interrupts when done. This section describes the general policy that in the ARM Cortex-M ports of all built-in real time kernels in QP, such as QV-nano and QK-nano.
@subsection arm-cm_kernel-aware "Kernel-Aware" and "Kernel-Unaware" Interrupts
The QP ports to ARM Cortex-M3/M4 **never completely disables interrupts**, even inside the critical sections. On Cortex-M3/M4 (ARMv7-M architecture), the QP port disables interrupts **selectively** using the BASEPRI register. This policy divides interrupts into "kernel-unaware" interrupts, which are never disabled, and "kernel-aware" interrupts, which are disabled in the QP critical sections.
@note
The BASEPRI register is not implemented in the ARMv6-M architecture (Cortex-M0/M0+), so Cortex-M0/M0+ need to use the PRIMASK register to disable interrupts globally. In other words, in Cortex-M0/M0+ ports, all interrupts are "kernel-aware".
@attention
Only "kernel-aware" interrupts are allowed to call QP services. "Kernel-unaware" interrupts are not allowed to call any QP services and they can communicate with QP only by triggering a "kernel-aware" interrupt (which can post or publish events).
As illustrated in the figures below, the number of interrupt priority bits actually available is implementation dependent, meaning that the various ARM Cortex-M silicon vendors can provide different number of priority bits, varying from just 3 bits (which is the minimum for ARMv7-M architecture) up to 8 bits. For example, the TI Tiva-C microcontrollers implement only 3 priority bits (see figure below).
@image html arm-cm_int3bit.png "Kernel-aware and Kernel-unaware interrupts with 3 priority bits
On the other hand, the STM32 MCUs implement 4 priority bits (see figure below). The CMSIS standard provides the macro __NVIC_PRIO_BITS, which specifies the number of NVIC priority bits defined in a given ARM Cortex-M implementation.
@image html arm-cm_int4bit.png "Kernel-aware and Kernel-unaware interrupts with 4 priority bits
Another important fact to note is that the ARM Cortex-M core stores the interrupt priority values in the *most significant bits* of its eight bit interrupt priority registers inside the NVIC (Nested Vectored Interrupt Controller). For example, if an implementation of a ARM Cortex-M microcontroller only implements three priority bits, then these three bits are shifted to occupy bits five, six and seven respectively. The unimplemented bits can be written as zero or one and always read as zero.
And finally, the NVIC uses an inverted priority numbering scheme for interrupts, in which priority zero (0) is the highest possible priority (highest urgency) and larger priority numbers denote actually lower-priority interrupts. So for example, interrupt of priority 2 can preempt an interrupt with priority 3, but interrupt of priority 3 cannot preempt interrupt of priority 3. The default value of priority of all interrupts out of reset is zero (0).
@note
Starting with QP 5.9.x, the QF_init() call sets interrupt priority of all IRQs to the "kernel aware" value QF_BASEPRI. Still, it is highly recommended to set the priority of all interrupts used by an application **explicitly**.
@attention
Some 3rd-party libraries (e.g., STM32Cube) change the interrupt priorities and sometimes priority grouping internally and unexpectedly, so care must be taken to change the priorities back to the appropriate values right before running the application.
The CMSIS provides the function @c NVIC_SetPriority() which you should use to set priority of every interrupt.
@note
The priority scheme passed to `NVIC_SetPriority()` is different again than the values stored in the NVIC registers, as shown in the figures above as "CMSIS priorities"
@subsection arm-cm_int-assign Assigning Interrupt Priorities
The @ref exa_arm-cm "example projects" included in the QP distribution the recommended way of assigning interrupt priorities in your applications. The initialization consist of two steps: (1) you enumerate the "kernel-unaware" and "kernel-aware" interrupt priorities, and (2) you assign the priorities by calling the @c NVIC_SetPriority() CMSIS function. The following snippet of code illustrates these steps with the explanation section following immediately after the code.
@anchor arm-cm_int-assign-code
Listing: Assigning the interrupt priorities (see file bsp.c in the example projects)
@code{c}
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
[1] enum KernelUnawareISRs { /* see NOTE0 */
/* ... */
[2] MAX_KERNEL_UNAWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-unaware" interrupts can't overlap "kernel-aware" interrupts */
[3] Q_ASSERT_COMPILE(MAX_KERNEL_UNAWARE_CMSIS_PRI <= QF_AWARE_ISR_CMSIS_PRI);
[4] enum KernelAwareISRs {
[5] GPIOPORTA_PRI = QF_AWARE_ISR_CMSIS_PRI, /* see NOTE00 */
SYSTICK_PRIO,
/* ... */
[6] MAX_KERNEL_AWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-aware" interrupts should not overlap the PendSV priority */
[7] Q_ASSERT_COMPILE(MAX_KERNEL_AWARE_CMSIS_PRI <= (0xFF>>(8-__NVIC_PRIO_BITS)));
~ ~ ~
[8] void QF_onStartup(void) {
/* set up the SysTick timer to fire at BSP_TICKS_PER_SEC rate */
SysTick_Config(ROM_SysCtlClockGet() / BSP_TICKS_PER_SEC);
/* assing all priority bits for preemption-prio. and none to sub-prio. */
[9] NVIC_SetPriorityGrouping(0U);
/* set priorities of ALL ISRs used in the system, see NOTE00
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
[10] NVIC_SetPriority(SysTick_IRQn, SYSTICK_PRIO);
[11] NVIC_SetPriority(GPIOPortA_IRQn, GPIOPORTA_PRIO);
~ ~ ~
/* enable IRQs... */
[12] NVIC_EnableIRQ(GPIOPortA_IRQn);
}
@endcode
1
The enumeration @c KernelUnawareISRs lists the priority numbers for the "kernel-unaware" interrupts. These priorities start with zero (highest possible). The priorities are suitable as the argument for the @c NVC_SetPriority() CMSIS function.
> NOTE: The NVIC allows you to assign the same priority level to multiple interrupts, so you can have more ISRs than priority levels running as "kernel-unaware" or "kernel-aware" interrupts.
2
The last value in the enumeration MAX_KERNEL_UNAWARE_CMSIS_PRI keeps track of the maximum priority used for a "kernel-unaware" interrupt.
3
The compile-time assertion ensures that the "kernel-unaware" interrupt priorities do not overlap the "kernel-aware" interrupts, which start at QF_AWARE_ISR_CMSIS_PRI.
4
The enumeration KernelAwareISRs lists the priority numbers for the "kernel-aware" interrupts.
5
The "kernel-aware" interrupt priorities start with the QF_AWARE_ISR_CMSIS_PRI offset, which is provided in the qf_port.h header file.
6
The last value in the enumeration MAX_KERNEL_AWARE_CMSIS_PRI keeps track of the maximum priority used for a "kernel-aware" interrupt.
7
The compile-time assertion ensures that the "kernel-aware" interrupt priorities do not overlap the lowest priority level reserved for the PendSV exception.
8
The QF_onStartup() callback function is where you set up the interrupts.
9
This call to the CMIS function @c NVIC_SetPriorityGrouping() assigns all the priority bits to be preempt priority bits, leaving no priority bits as subpriority bits to preserve the direct relationship between the interrupt priorities and the ISR preemption rules. This is the default configuration out of reset for the ARM Cortex-M3/M4 cores, but it can be changed by some vendor-supplied startup code. To avoid any surprises, the call to NVIC_SetPriorityGrouping(0U) is recommended.
10-11
The interrupt priories fall all interrupts ("kernel-unaware" and "kernel-aware" alike) are set explicitly by calls to the CMSIS function @c NVIC_SetPriority().
12
All used IRQ interrupts need to be explicitly enabled by calling the CMSIS function.
@subsection arm-cm_int-fpu Interrupts and the FPU (Cortex-M4F)
The QP ports described in this section support also the ARM Cortex-M4F. Compared to all other members of the Cortex-M family, these cores includes the single precision variant of the ARMv7-M Floating-Point Unit (Fpv4-SP). The hardware FPU implementation adds an extra floating-point register bank consisting of S0-S31 and some other FPU registers. This FPU register set represents additional context that need to be preserved across interrupts and thread switching (e.g., in the preemptive QK-nano kernel).
The ARM VFP has a very interesting feature called **lazy stacking** [@ref ARM-AN298]. This feature avoids an increase of interrupt latency by skipping the stacking of floating-point registers, if not required, that is:
- if the interrupt handler does not use the FPU, or
- if the interrupted program does not use the FPU.
If the interrupt handler has to use the FPU and the interrupted context has also previously used by the FPU, then the stacking of floating-point registers takes place at the point in the program where the interrupt handler first uses the FPU. The lazy stacking feature is programmable and by default it is turned ON.
@note
All built-in kernels in QP are designed to take advantage of the lazy stacking feature [@ref ARM-AN298].
@section arm-cm_ref References
@anchor ARM-AN298
- **[ARM AN298]** ARM Application Note 298 "Cortex-M4(F) Lazy Stacking and Context Switching", ARM 2012
@anchor ARM-EPM-064408
- **[ARM-EPM-064408]** "ARM Processor Cortex-M7 (AT610) and Cortex-M7 with FPU (AT611) Software Developers Errata Notice"
@anchor Reminder
- **[Reminder]** "Reminder State Pattern"
@next{arm-cm_qv}
*/
/*##########################################################################*/
/*! @page arm-cm_qv Cooperative QV-nano Kernel
@tableofcontents
The non-preemptive, cooperative QV-nano kernel executes active objects one at a time, with priority-based scheduling performed after run-to-completion (RTC) processing of each event. Due to naturally short duration of event processing in state machines, the simple QV-nano kernel is often adequate for many real-time systems.
@remarks
In the QV-nano port, the only components requiring platform-specific porting are QF-nano and QV-nano itself. The other two components: QEP and QS require merely recompilation and will not be discussed here. With the QV-nano port you're not using the QK-nano kernel. The QV-nano port to ARM Cortex-M is located in the folder /ports/arm-cm/qv/.
@section arm-cm_qv-synopsis Synopsis of the QV-nano Port on ARM Cortex-M
The cooperative QV-nano kernel works essentially as the traditional foreground-background system (a.k.a. "superloop") in that all active objects are executed in the main loop and interrupts always return back to the point of preemption. To avoid race conditions between the main loop and the interrupts, QV briefly disables interrupts.
1. The ARM Cortex-M processor executes application code (the main loop) in the Privileged Thread mode, which is exactly the mode entered out of reset.
2. The exceptions (including all interrupts) are always processed in the Privileged Handler mode.
3. QV-nano uses only the Main Stack Pointer. The Process Stack Pointer is not used and is not initialized.
4. ARM Cortex-M enters interrupt context without disabling interrupts (without setting the PRIMASK bit or the BASEPRI register). Generally, you should not disable interrupts inside your ISRs. In particular, the QP services QF_tickXISR(), QACTIVE_POST_ISR() should be called with **interrupts enabled**, to avoid nesting of critical sections.
> NOTE: If you don't wish an interrupt to be preempted by another interrupt, you can always prioritize that interrupt in the NVIC to a higher level (use a lower numerical value of priority).
5. The `QF_init()` function calls the function `QV_init()` to set the interrupt priority of all IRQs available in the MCU to the safe value of @ref QF_BASEPRI "QF_BASEPRI" (for ARM-v7 architecture).
@section arm-cm_qv-qf_port The qf_port.h Header File
The QF header file for the ARM Cortex-M port is located in `/ports/arm-cm/qv/gnu/qf_port.h`. This file specifies the interrupt disabling policy (QF critical section) as well as the configuration constants for QF (see Chapter 8 in [PSiCC2]).
@note
The ARM Cortex-M allows you to use the simplest "unconditional interrupt disabling" policy (see Section 7.3.2 in [PSiCC2]), because ARM Cortex-M is equipped with the standard nested vectored interrupt controller (NVIC) and generally runs ISRs with interrupts enabled (so the body of an ISR is not a critical section).
The following listing shows the `qfn_port.h` header file for ARM Cortex-M with the GNU-ARM toolchain. Other toolchains use slightly different conditional compilation macros to select the Cortex-M variants, but implement the same policies.
@anchor arm-cm_qf_port_h-code
Listing: The qfn_port.h header file for ARM Cortex-M
@code{c}
/* QF interrupt disable/enable and log2()... */
[1] if (__ARM_ARCH == 6) /* Cortex-M0/M0+/M1 ?, see NOTE1 */
/* Cortex-M0/M0+/M1(v6-M, v6S-M) interrupt disabling policy, see NOTE2 */
[2] #define QF_INT_DISABLE() __asm volatile ("cpsid i")
[3] #define QF_INT_ENABLE() __asm volatile ("cpsie i")
/* QF-aware ISR priority for CMSIS function NVIC_SetPriority(), NOTE1 */
[4] #define QF_AWARE_ISR_CMSIS_PRI 0
/* macro to put the CPU to sleep inside QV_onIdle() */
[5] #define QV_CPU_SLEEP() do { \
[6] __asm volatile ("wfi"); \
[7] QF_INT_ENABLE(); \
} while (0)
[8] #else /* Cortex-M3/M4, see NOTE2 */
/* Cortex-M3/M4 alternative interrupt disabling with PRIMASK */
[9] #define QF_PRIMASK_DISABLE() __asm volatile ("cpsid i")
[10] #define QF_PRIMASK_ENABLE() __asm volatile ("cpsie i")
/* Cortex-M3/M4 interrupt disabling policy */
[11] #define QF_INT_DISABLE() QF_SET_BASEPRI(QF_BASEPRI)
[12] #define QF_INT_ENABLE() QF_SET_BASEPRI(0U)
/* BASEPRI threshold for "QF-aware" interrupts, see NOTE2 */
[13] #define QF_BASEPRI 0x3F
/* QF-aware ISR priority for CMSIS function NVIC_SetPriority(), NOTE3 */
[14] #define QF_AWARE_ISR_CMSIS_PRI (QF_BASEPRI >> (8 - __NVIC_PRIO_BITS))
/* macro to put the CPU to sleep inside QV_onIdle() */
[15] #define QV_CPU_SLEEP() do { \
[16] QF_PRIMASK_DISABLE(); \
[17] QF_INT_ENABLE(); \
[18] __asm volatile ("wfi"); \
[19] QF_PRIMASK_ENABLE(); \
} while (0)
/* macro for setting the BASEPRI register */
[20] #define QF_SET_BASEPRI(basepri_) __asm volatile (\
"msr BASEPRI,%0" :: "r" (basepri_) : )
/* initialization of the QV kernel for Cortex-M3/M4/M7 */
[21] #define QV_INIT() QV_init()
void QV_init(void);
#endif
/* interrupt nesting policy for ISR level (ISRs can nest) */
[22] #define QF_ISR_NEST
[23] #include /* Exact-width types. WG14/N843 C99 Standard */
[24] #include /* Boolean type. WG14/N843 C99 Standard */
#include "qepn.h" /* QEP-nano platform-independent public interface */
#include "qfn.h" /* QF-nano platform-independent public interface */
#include "qvn.h" /* QV-nano cooperative kernel interface */
@endcode
3
As described in the previous @ref arm-cm_int "Section", the interrupt disabling policy for the ARMv6-M architecture (Cortex-M0/M0+) is different than the policy for the ARMv7-M. In GNU-ARM, the macro `__ARM_ARCH` is defined as 6 for the ARMv6-M architecture (Cortex-M0/M0+), and 7 for ARMv7-M (Cortex-M3/M4/M4F).
> NOTE: The `__ARM_ARCH` macro is specific to the GNU-ARM compiler. Other compilers for ARM Cortex-M provide different macros to detect the CPU type.
4-5
For the ARMv6-M architecture, the interrupt disabling policy uses the PRIMASK register to disable interrupts globally. The @c QF_INT_DISABLE() macro resolves in this case to the inline assembly instruction "CPSD i", which sets the PRIMASK. The @c QF_INT_ENABLE() macro resolves to the inline assembly instruction "CPSE i", which clears the PRIMASK.
6
The #QF_CRIT_STAT_TYPE is NOT defined, meaning that the critical section uses the simple policy of "unconditional interrupt disablin".
> NOTE: The "unconditional interrupt disabling" policy precludes nesting of critical sections, but this is not needed for ARM Cortex-M, because this CPU never disables interrupts, even when handling exceptions/interrupts.
7
The QF_CRIT_ENTRY() enters a critical section. Interrupts are disabled by setting the PRIMASK register.
8
The QF_CRIT_EXIT() macro leaves the critical section. Interrupts are unconditionally re-enabled by clearing the PRIMASK register.
9
For the ARMv6-M architecture, the `QF_AWARE_ISR_CMSIS_PRI` priority level is defined as zero, meaning that all interrupts are "kernel-aware", because all interrupt priorities are disabled by the kernel.
10
The `QF_LOG2()` macro is defined as a call to the function `QF_qlog2()` ("quick log-base-2 logarithm"). This function is coded in hand-optimized assembly, which always takes only 14 CPU cycles to execute (see also label [23]).
> NOTE: ARM Cortex-M0/M0+ does NOT implement the `CLZ` instruction. Therefore the log-base-2 calculation cannot be accelerated in hardware, as it is for ARM Cortex-M3 and higher.
11
For the ARMv7-M (Cortex-M3/M4/M4F) architecture...
12
The `QF_PRIMASK_DISABLE()` macro resolves to the inline assembly instruction `CPSD i`, which sets the PRIMASK.
13
The `QF_PRIMASK_ENABLE()` macro resolves to the inline assembly instruction `CPSE i`, which clears the PRIMASK.
14
Interrupts are disabled by setting the BASEPRI register to the value defined in the `QF_BASEPRI` macro (see label [19]). This setting of the BASEPRI instruction `msr BASEPRI,...` is surrounded by setting and clearing the PRIMASK register, as a workaround a hardware problem in ARM Cortex-M7 core r0p1:
> NOTE: The selective disabling of "QF-aware" interrupts with the BASEPRI register has a problem on ARM Cortex-M7 core r0p1 (see [@ref ARM-EPM-064408], Erratum 837070). The workaround recommended by ARM is to surround `MSR BASEPRI,...` with the `CPSID i`/`CPSIE i` pair, which is implemented in the QF_INT_DISABLE() macro. This workaround works also for Cortex-M3/M4 cores.
15
The `QF_INT_ENABLE()` macro sets the BASEPRI register to zero, which disables BASEPRI interrupt masking.
> NOTE: this method can never disable interrupt of priority 0 (highest).
16
The #QF_CRIT_STAT_TYPE is NOT defined, meaning that the critical section uses the simple policy of "unconditional interrupt disabling".
> NOTE: The "unconditional interrupt disabling" policy precludes nesting of critical sections, but this is not needed for ARM Cortex-M, because this CPU never disables interrupts, even when handling exceptions/interrupts.
17
The QF_CRIT_ENTRY() enters a critical section. Interrupts are disabled with the macro `QF_INT_DISABLE()` defined at label [12].
18
The QF_CRIT_EXIT() macro leaves the critical section. Interrupts are unconditionally re-enabled with the macro `QF_INT_ENABLE()` defined at label [13].
19
@anchor QF_BASEPRI
The `QF_BASEPRI` value is defined such that it is the lowest priority for the minimum number of 3 priority-bits that the ARM7-M architecture must provide. This partitions the interrupts as "kernel-unaware" and "kernel-aware" interrupts, as shown in section @ref arm-cm_int-assign.
20
For the ARMv7-M architecture, the `QF_AWARE_ISR_CMSIS_PRI` priority level suitable for the CMSIS function `NVIC_SetPriority()` is determined by the `QF_BASEPRI` value.
21
The macro `QF_LOG2()` is defined to take advantage of the CLZ instruction (Count Leading Zeroes), which is available in the ARMv7-M architecture.
> NOTE: The `__builtin_cls()` intrinsic function is specific to the GNU-ARM compiler. Other compilers for ARM Cortex-M use different function names for this intrinsic function.
22
The macro @c QF_CRIT_EXIT_NOP() provides the protection against merging two critical sections occurring back-to-back in the QP code.
23
For ARMv6 architecture, the prototype of the quick, hand-optimized log-base-2 function is provided (see also label [10]).
@section arm-cm_qv_port_h The qv_port.h Header File
The QV header file for the ARM Cortex-M port is located in /ports/arm-cm/qv/gnu/qv_port.h. This file provides the macro QV_CPU_SLEEP(), which specifies how to enter the CPU sleep mode safely in the cooperative QV kernel (see also Section 4.7) and [Samek 07]).
@note
To avoid race conditions between interrupts waking up active objects and going to sleep, the cooperative QV kernel calls the QV_CPU_SLEEP() callback with interrupts disabled.
@anchor arm-cm_qv_port_h-code
Listing: The qv_port.h header file for ARM Cortex-M
@code{c}
#ifdef ARM_ARCH_V6M /* Cortex-M0/M0+/M1 ? */
[1] #define QV_CPU_SLEEP() do { \
__asm volatile ("wfi"); \
QF_INT_ENABLE(); \
} while (0)
#else /* Cortex-M3/M4/M4F */
[2] #define QV_CPU_SLEEP() do { \
QF_PRIMASK_DISABLE(); \
QF_INT_ENABLE(); \
__asm volatile ("wfi"); \
QF_RIMASK_ENABLE(); \
} while (0)
#endif
[3] #define QV_INIT() QV_init()
void QV_init();
#include "qv.h" /* QV platform-independent public interface */
@endcode
1
For the ARMv6-M architecture, the macro `QV_CPU_SLEEP()` stops the CPU with the WFI instruction (Wait For Interrupt). After the CPU is woken up by an interrupt, interrupts are re-enabled with the PRIMASK.
2
For the ARMv7-M architecture, the macro `QV_CPU_SLEEP()` first disables interrupts by setting the PRIMASK, then clears the BASEPRI to enable all "kernel-aware" interrupts and only then stops the CPU with the WFI instruction (Wait For Interrupt). After the CPU is woken up by an interrupt, interrupts are re-enabled with the PRIMASK. This sequence is necessary, because the ARM Cortex-M3/M4/M7 cores cannot be woken up by any interrupt blocked by the BASEPRI register.
2
The macro `QV_INIT()` is defined as a call to the `QV_init()` function, which means that this function will be called from `QF_init()`. The `QV_init()` function initializes all available IRQ priorities in the MCU to the safe value of @ref QF_BASEPRI "QF_BASEPRI".
@section arm-cm_qv_port_c The qv_port.c Implementation File
The QV implementation file for the ARM Cortex-M port is located in /ports/arm-cm/qv/gnu/qf_port.c. This file defines the function @c QV_init(), which for the ARMv7-M architecture sets the interrupt priorities of all IRQs to the safe value `QF_BASEPRI`.
@anchor arm-cm_qv_port_c-code
Listing: The qv_port.c header file for ARM Cortex-M
@code{c}
#include "qf_port.h"
[1] #if (__ARM_ARCH != 6) /* NOT Cortex-M0/M0+/M1 ? */
#define SCnSCB_ICTR ((uint32_t volatile *)0xE000E004)
#define SCB_SYSPRI ((uint32_t volatile *)0xE000ED14)
#define NVIC_IP ((uint32_t volatile *)0xE000E400)
void QV_init(void) {
uint32_t n;
/* set exception priorities to QF_BASEPRI...
* SCB_SYSPRI1: Usage-fault, Bus-fault, Memory-fault
*/
[2] SCB_SYSPRI[1] |= (QF_BASEPRI << 16) | (QF_BASEPRI << 8) | QF_BASEPRI;
/* SCB_SYSPRI2: SVCall */
[3] SCB_SYSPRI[2] |= (QF_BASEPRI << 24);
/* SCB_SYSPRI3: SysTick, PendSV, Debug */
[4] SCB_SYSPRI[3] |= (QF_BASEPRI << 24) | (QF_BASEPRI << 16) | QF_BASEPRI;
/* set all implemented IRQ priories to QF_BASEPRI... */
[5] n = 8 + (*SCnSCB_ICTR << 3); /* # interrupt priority registers */
do {
--n;
[6] NVIC_IP[n] = (QF_BASEPRI << 24) | (QF_BASEPRI << 16)
| (QF_BASEPRI << 8) | QF_BASEPRI;
} while (n != 0);
}
#endif /* NOT Cortex-M0/M0+/M1 */
@endcode
1
For the ARMv7-M architecture (Cortex-M3/M4)...
2
The exception priorities for User-Fault, Bus-Fault, and Mem-Fault are set to the value QF_BASEPRI.
3
The exception priority for SVCCall is set to the value QF_BASEPRI.
4
The exception priority for SysTick, PendSV, and Debug is set to the value QF_BASEPRI.
5
The number of implemented IRQs is read from the @c SCnSCB_ICTR register
6
The interrupt priority of all implemented IRQs is set to the safe value QF_BASEPRI in a loop.
@section arm-cm_qv-isr Writing ISRs for QV
The ARM Cortex-M CPU is designed to use regular C functions as exception and interrupt service routines (ISRs).
@note
The ARM EABI (Embedded Application Binary Interface) requires the stack be 8-byte aligned, whereas some compilers guarantee only 4-byte alignment. For that reason, some compilers (e.g., GNU-ARM) provide a way to designate ISR functions as interrupts. For example, the GNU-ARM compiler provides the __attribute__((__interrupt__)) designation that will guarantee the 8-byte stack alignment.
Typically, ISRs are application-specific (with the main purpose to produce events for active objects). Therefore, ISRs are not part of the generic QP port, but rather part of the BSP (Board Support Package).
The following listing shows an example of the SysTick_Handler() ISR (from the DPP example application). This ISR calls the QF_TICK_X() macro to perform QF time-event management.
@anchor arm-cm_qv-isr-code
Listing: An ISR header for QV
@code{c}
void SysTick_Handler(void) __attribute__((__interrupt__));
void SysTick_Handler(void) {
~ ~ ~
QF_TICK_X(0U, &l_SysTick_Handler); /* process all armed time events */
}
@endcode
@note
The QP port to ARM Cortex-M complies with the CMSIS standard, which dictates the names of all exception handlers and IRQ handlers.
@section arm-cm_qv-fpu Using the FPU in the QV-nano Port (Cortex-M4F)
If you have the Cortex-M4F CPU and your application uses the hardware FPU, it should be enabled because it is turned off out of reset. The CMSIS-compliant way of turning the FPU on looks as follows:
@verbatim
SCB->CPACR |= (0xFU << 20);
@endverbatim
@note
The FPU must be enabled before executing any floating point instruction. An attempt to execute a floating point instruction will fault if the FPU is not enabled.
Depending on whether or not you use the FPU in your ISRs, the QV port allows you to configure the FPU in various ways, as described in the following sub-sections.
@subsection arm-cm_qv-fpu_noisr FPU NOT used in the ISRs
If you use the FPU only at the thread-level (inside active objects) and none of your ISRs use the FPU, you can setup the FPU not to use the automatic state preservation and not to use the lazy stacking feature as follows:
@verbatim
FPU->FPCCR &= ~((1U << FPU_FPCCR_ASPEN_Pos) | (1U << FPU_FPCCR_LSPEN_Pos));
@endverbatim
With this setting, the Cortex-M4F processor handles the ISRs in the exact-same way as Cortex-M0-M3, that is, only the standard interrupt frame with R0-R3,R12,LR,PC,xPSR is used. This scheme is the fastest and incurs no additional CPU cycles to save and restore the FPU registers.
@note
This FPU setting will lead to FPU errors, if any of the ISRs indeed starts to use the FPU
@subsection arm-cm_qv-fpu_isr FPU used in the ISRs
If you use the FPU both at the thread-level (inside active objects) and in any of your ISRs as well, you should setup the FPU to use the automatic state preservation and the lazy stacking feature as follows:
@verbatim
FPU->FPCCR |= (1U << FPU_FPCCR_ASPEN_Pos) | (1U << FPU_FPCCR_LSPEN_Pos);
@endverbatim
This will enable the lazy stacking feature of the Cortex-M4F processor [@ref ARM-AN298]. The the "automatic state saving" and "lazy stacking" are enabled by default, so you typically don't need to change these settings.
@note
As described in the ARM Application Note "Cortex-M4(F) Lazy Stacking and Context Switching" [@ref ARM-AN298], the FPU automatic state saving requires more stack plus additional CPU time to save the FPU registers, but only when the FPU is actually used.
@section arm-cm_qv-idle QV Idle Processing Customization in QV_onIdle()
When no events are available, the non-preemptive QV kernel invokes the platform-specific callback function QV_onIdle(), which you can use to save CPU power, or perform any other "idle" processing (such as Quantum Spy software trace output).
@note
The idle callback QV_onIdle() must be invoked with interrupts disabled, because the idle condition can be changed by any interrupt that posts events to event queues. QV_onIdle() must internally enable interrupts, ideally atomically with putting the CPU to the power-saving mode (see also [Samek 07] and Chapter 7 in [PSiCC2]).
Because QV_onIdle() must enable interrupts internally, the signature of the function depends on the interrupt locking policy. In case of the simple "unconditional interrupt locking and unlocking" policy, which is used in this ARM Cortex-M port, the QV_onIdle() takes no parameters. Listing 6 shows an example implementation of QV_onIdle() for the TM4C MCU. Other ARM Cortex-M embedded microcontrollers (e.g., NXP’s LPC1114/1343) handle the power-saving mode very similarly.
@anchor arm-cm_qv_onidle-code
Listing: QV_onIdle() for ARM Cortex-M
@code{c}
[1] void QV_onIdle(void) { /* entered with interrupts DISABLED, see NOTE01 */
~ ~ ~
[2] #if defined NDEBUG
/* Put the CPU and peripherals to the low-power mode */
[3] QV_CPU_SLEEP(); /* atomically go to sleep and enable interrupts */
#else
[4] QF_INT_ENABLE(); /* just enable interrupts */
#endif
}
@endcode
1
The cooperative QV kernel calls the QV_onIdle() callback with interrupts disabled, to avoid race condition with interrupts that can post events to active objects and thus invalidate the idle condition.
2
The sleep mode is used only in the non-debug configuration, because sleep mode stops CPU clock, which can interfere with debugging.
3
The macro QV_CPU_SLEEP() is used to put the CPU to the low-power sleep mode safely. The macro QV_CPU_SLEEP() is defined in the qv_port.h header file for the QV kernel and depends on the interrupt disabling policy used.
4
When a sleep mode is not used, the QV_onIdle() callback simply re-enables interrupts.
The preemptive, run-to-completion (RTC) QK-nano kernel breaks entirely with the endless-loop structure of the thread routines and instead uses threads structured as one-shot, discrete, run-to-completion functions, very much like ISRs [PSiCC2, Chapter 10]. In fact, the QK-nano kernel views interrupts very much like threads of a "super-high" priority, except that interrupts are prioritized in hardware by the interrupt controller, whereas threads are prioritized in software by the RTC kernel.
@note
The preemptive QK-nano kernel uses only one stack for all threads (see the next section), but the stack must be bigger than in the non-preemptive QV kernel. You need to adjust the size of this stack to be large enough for your application.
As a fully preemptive multithreading kernel, QK-nano must ensure that at all times the CPU executes the highest-priority thread (active object) that is ready to run. Fortunately, only two scenarios can lead to readying a higher-priority thread:
1
When a lower-priority thread posts an event to a higher-priority thread, the kernel must immediately suspend the execution of the lower-priority thread and start the higher-priority thread. This type of preemption is called synchronous preemption because it happens synchronously with posting an event to the thread's event queue.
> NOTE: The stack usage shown in the bottom panel displays stack growing down (towards lower addresses), as it is the case in ARM Cortex-M.
@anchor arm-cm_qk-synch-fig
@image html qk_synch.gif "Synchronous Preemption in QK"
2
When an interrupt posts an event to a higher-priority thread than the interrupted thread, upon completion of the ISR the kernel must start execution of the higher-priority thread instead of resuming the lower-priority thread. This type of preemption is called asynchronous preemption because it can happen asynchronously, any time interrupts are not explicitly disabled.
> NOTE: The stack usage during asynchronous preemption on ARM Cortex-M is slightly simplified in the diagram below. A more detailed stack usage diagram is discussed later in the section explaining the @ref "Detailed stack allocation in QK-nano for ARM Cortex-M".
@anchor arm-cm_qk-asynch-fig
@image html qk_asynch.gif "Synchronous Preemption in QK"
@note
A traditional RTOS kernel does not distinguish between the synchronous and asynchronous preemptions and makes all preemptions look like the more stack-intensive asynchronous preemptions. In contrast, a RTC kernel can implement synchronous preemption as a simple function call (to QK_activate_()), which is much more efficient than a full context-switch.
@section arm-cm_qk-synopsis Synopsis of the QK-nano Port on ARM Cortex-M
The ARM Cortex-M architecture is designed primarily for the traditional real-time kernels that use multiple per-thread stacks. This section explains how the run-to-completion preemptive QK-nano kernel works on ARM Cortex-M.
1. The ARM Cortex-M processor executes the QK-nano application code (active objects) in the Privileged Thread mode, which is exactly the mode entered out of reset. The exceptions (including all interrupts) are always processed in the Privileged Handler mode.
2. QK-nano uses only the Main Stack Pointer (QK-nano is a single stack kernel). The Process Stack Pointer is not used and is not initialized.
3. ARM Cortex-M enters interrupt context without disabling interrupts (without setting the PRIMASK bit or the BASEPRI register). Generally, you should not disable interrupts inside your ISRs. In particular, the QP services QF_PUBLISH(), QF_TICK_X(), and QACTIVE_POST() should be called with interrupts enabled, to avoid nesting of critical sections. (NOTE: If you don’t wish an interrupt to be preempted by another interrupt, you can always prioritize that interrupt in the NVIC to a higher level -- use a lower numerical value of priority).
4. The QK-nano port uses the PendSV exception (number 14) and the NMI exception (number 2) to perform asynchronous preemption and return to the preempted thread, respectively (see Chapter 10 in [PSiCC2]). The startup code must initialize the Interrupt Vector Table with the addresses of @c PendSV_Handler() and @c NMI_Handler() exception handlers.
5. The QF_init() function calls the function QK_init() to set the priority of the PendSV exception to the lowest level in the whole system (0xFF). The function QK_init() additionally sets the interrupt priority of all IRQs available in the MCU to the safe value of @c QF_BASEPRI (for ARM-v7 architecture).
6. It is strongly recommended that you do not assign the lowest priority (0xFF) to any interrupt in your application. With 3 MSB-bits of priority, this leaves the following 7 priority levels for you (listed from the lowest to the highest urgency): 0xC0, 0xA0, 0x80, 0x60, 0x40, 0x20, and 0x00 (the highest priority).
7. Before returning, every "kernel aware" ISR must check whether an active object has been activated that has a higher priority than the currently running active object. If this is the case, the ISR must set the PensSV pending flag in the NVIC. All this is accomplished in the macro QK_ISR_EXIT(), which must be called just before exiting every ISRs.
8. In ARM Cortex-M the whole prioritization of interrupts, including the PendSV exception, is performed entirely by the NVIC. Because the PendSV has the lowest priority in the system, the NVIC tail-chains to the PendSV exception only after exiting the last nested interrupt.
9. The pushing of the 8 registers comprising the ARM Cortex-M interrupt stack frame upon entry to NMI exception is wasteful in a single-stack kernel, but is necessary to perform full interrupt return to the preempted context through the NMI's return.
@subsection arm-cm_qk-preempt Preemption Scenarios in QK-nano on ARM Cortex-M
@anchor arm-cm_qk-arm-cm-fig
@image html qk_arm-cm.gif "Several preemption scenarios in QK"
0
The timeline begins with the QK-nano executing the idle loop.
1
At some point an interrupt occurs and the CPU immediately suspends the idle loop, pushes the interrupt stack frame to the Main Stack and starts executing the ISR.
2
The ISR performs its work, and in QK-nano always must call the QK_ISR_EXIT() macro, which calls the QK-nano scheduler to determine if there is a higher-priority AO to run. If so, the macro sets the pending flag for the PendSV exception in the NVIC. The priority of the PendSV exception is configured to be the lowest of all exceptions, so the ISR continues executing and PendSV exception remains pending. At the ISR return, the ARM Cortex-M CPU performs tail-chaining to the pending PendSV exception.
3
The PendSV exception discovers whether there is a higher-priority thread to run then the preempted one (by calling QK_schedPrio_()) and if so, to to synthesize an exception stack frame to return to the QK-nano scheduler (QK_sched_()) to run this new thread.
> NOTE: The QK-nano scheduler must run in the thread context, while PendSV executes in the exception context. The change of the context is accomplished by returning from the PendSV exception directly to the QK-nano scheduler.
To return directly to the QK-nano scheduler, PendSV synthesizes an exception stack frame, which contains the exception return address set to QK_sched_(). The QK-nano scheduler discovers that the Low-priority thread is ready to run (the ISR has posted event to this thread). The QK-nano scheduler enables interrupts and launches the Low-priority thread, which is simply a C-function call in QK. The Low-priority thread (active object) starts running.
4
Some time later a low-priority interrupt occurs. The Low-priority thread is suspended and the CPU pushes the interrupt stack frame to the Main Stack and starts executing the ISR.
5
Before the Low-priority ISR completes, it too gets preempted by a High-priority ISR. The CPU pushes another interrupt stack frame and starts executing the High-priority ISR.
6
The High-priority ISR sets the pending flag for the PendSV exception by means of the QK_ISR_EXIT() macro. When the High-priority ISR returns, the NVIC does not tail-chain to the PendSV exception, because a higher-priority ISR than PendSV is still active. The NVIC performs an exception return to the preempted Low-priority interrupt, which finally completes.
7
Upon the exit from the Low-priority ISR, it too sets the pending flag for the PendSV exception by means of the QK_ISR_EXIT() macro. The PendSV is already pended from the High-priority interrupt, so pending is again is redundant, but it is not an error. At the ISR return, the ARM Cortex-M CPU performs tail-chaining to the pending PendSV exception.
8
The PendSV exception synthesizes an interrupt stack frame to return to the QK-nano scheduler. The QK-nano scheduler detects that the High-priority thread is ready to run and launches the High-priority thread (normal C-function call). The High-priority thread runs to completion and returns to the scheduler.
9
The QK-nano scheduler does not find any more higher-priority threads to execute and needs to return to the preempted thread. The only way to restore the interrupted context in ARM Cortex-M is through the interrupt return, but the thread is executing outside of the interrupt context (in fact, threads are executing in the Privileged Thread mode). The thread enters the Handler mode by pending the NMI exception.
> NOTE: The NMI exception is pended while interrupts are still disabled. This is not a problem, because NMI cannot be masked by disabling interrupts, so runs without any problems.
10
The only job of the NMI exception is to discard its own interrupt stack frame, re-enable interrupts, and return using the interrupt stack frame that has been on the stack from the moment of thread preemption.
11
The Low-priority thread, which has been preempted all that time, resumes and finally runs to completion and returns to the QK-nano scheduler. The QK-nano scheduler does not find any more threads to launch and causes the NMI exception to return to the preempted thread.
12
The NMI exception discards its own interrupt stack frame and returns using the interrupt stack frame from the preempted thread context
@section arm-cm_qk-qf_port The qf_port.h Header File
The QF header file for the ARM Cortex-M port is located in /ports/arm-cm/qk/gnu/qf_port.h. This file is almost identical to the @ref arm-cm_qv-qf_port "QV port", except the header file in the QK-nano port includes `qk_port.h` header file instead of `qv_porth`.
@section arm-cm_qk-qk_port The qk_port.h Header File
You configure and customize QK-nano through the header file qk_port.h, which is located in the QP ports directory /ports/arm-cm/qk/gnu/. The most important function of qk_port.h is specifying interrupt entry and exit.
@note
As any preemptive kernel, QK-nano needs to be notified about entering the interrupt context and about exiting an interrupt context in order to perform a context switch, if necessary.
@anchor arm-cm_qk_port-code
Listing: qk_port.h header file for ARM Cortex-M
@code{c}
/* determination if the code executes in the ISR context */
[1] #define QK_ISR_CONTEXT_() (QK_get_IPSR() != (uint32_t)0)
__attribute__((always_inline))
[2] static inline uint32_t QK_get_IPSR(void) {
uint32_t regIPSR;
__asm volatile ("mrs %0,ipsr" : "=r" (regIPSR));
return regIPSR;
}
/* QK-nano interrupt entry and exit */
[3] #define QK_ISR_ENTRY() ((void)0)
[4] #define QK_ISR_EXIT() do { \
[5] QF_INT_DISABLE(); \
[6] if (QK_sched_() != (uint_fast8_t)0) { \
[7] (*Q_UINT2PTR_CAST(uint32_t, 0xE000ED04U) = (uint32_t)(1U << 28)); \
} \
[8] QF_INT_ENABLE(); \
} while (0)
/* initialization of the QK-nano kernel */
[9] #define QK_INIT() QK_init()
void QK_init(void);
#include "qk.h" /* QK-nano platform-independent public interface */
@endcode
1
The macro @c QK_ISR_CONTEXT() returns true when the code executes in the ISR context and false otherwise. The macro takes advantage of the ARM Cortex-M register IPSR, which is non-zero when the CPU executes an exception (or interrupt) and is zero when the CPU is executing thread code.
> NOTE: QK-nano needs to distinguish between ISR and thread contexts, because threads need to perform synchronous context switch (when a higher-priority thread becomes ready to run), while ISRs should not do that.
2
The inline function @c QK_get_IPSR() obtains the IPSR register and returns it to the caller. This function is defined explicitly for the GNU-ARM toolchain, but many other toolchains provide this function as an intrinsic, built-in facility.
3
The @c QK_ISR_ENTRY() macro notifies QK-nano about entering an ISR. The macro is empty, because the determination of the ISR vs thread context is performed independently in the @c QK_ISR_CONTEXT() macro (see above).
4
The @c QK_ISR_EXIT() macro notifies QK-nano about exiting an ISR.
5
Interrupts are disabled before calling QK-nano scheduler.
6
The QK-nano scheduler is called to find out whether an active object of a higher priority than the current one needs activation. The @c QK_sched_() function returns non zero value if this is the case.
7
If asynchronous preemption becomes necessary, the code sets the PENDSV Pend bit(28) in the ICSR register (Interrupt Control and State Register). The register is mapped at address 0xE000ED04 in all ARM Cortex-M cores.
8
The interrupts are re-enabled after they have been disabled in step [5].
> NOTE: Because the priority of the PendSV exception is the lowest of all interrupts, it is actually triggered only after all nested interrupts exit. The PendSV exception is then entered through the efficient **tail-chaining** process, which eliminates the restoring and re-entering the interrupt context.
@section arm-cm_qk-qk_impl QK-nano Port Implementation for ARM Cortex-M
The QK-nano port to ARM Cortex-M requires coding the PendSV and NMI exceptions in assembly. This ARM Cortex-M-specific code, as well as QK-nano initialization (@c QK_init()) is located in the file ports/arm-cm/qk/gnu/qk_port.c
@note
The single assembly module `qk_port.s` contains common code for all Cortex-M variants (Architecture v6M and v7M) as well as options with and without the VFP. The CPU variants are distinguished by conditional compilation, when necessary.
@subsection arm-cm_qk_port-asm_init QK_init() Implementation
Listing: QK_init function in qk_port.s assembly file
@code{c}
/*****************************************************************************
* The QK_init() function sets the priority of PendSV to 0xFF (lowest urgency).
* For Cortex-M3/4/7, it also sets priorities of all other exceptions and IRQs
* to the safe value. All this is performed in a nestable critical section.
*****************************************************************************/
.section .text.QK_init
.global QK_init
.type QK_init, %function
[1] QK_init:
[2] MRS r0,PRIMASK /* store the state of the PRIMASK in r0 */
[3] MOV r12,r0 /* r12 := PRIMASK */
[4] CPSID i /* PRIMASK := 1 */
[5] .if __ARM_ARCH == 6 /* Cortex-M0/M0+/M1 (v6-M, v6S-M)? */
[6] LDR r3,=0xE000ED18 /* System Handler Priority Register */
[7] LDR r2,[r3,#8] /* r2 := SYSPRI3 */
[8] MOVS r0,#0xFF
[9] LSLS r0,r0,#16
[10] ORRS r2,r1
[11] STR r2,[r3,#8] /* SYSPRI3 := r2, PendSV <- 0xFF */
[12] .else /* M3/M4 */
/* NOTE:
* On Cortex-M3/M4/.., this QK-nano port disables interrupts by means of the
* BASEPRI register. However, this method cannot disable interrupt
* priority zero, which is the default for all interrupts out of reset.
* The following code changes the SysTick priority and all IRQ priorities
* to the safe value QF_BASEPRI, wich the QF critical section can disable.
* This avoids breaching of the QF critical sections in case the
* application programmer forgets to explicitly set priorities of all
* "kernel aware" interrupts.
*/
/* set all priority bytes to QF_BASEPRI in r1 */
[13] MOVS r1,#QF_BASEPRI
LSLS r1,r1,#8
ORRS r1,r1,#QF_BASEPRI
LSLS r1,r1,#8
ORRS r1,r1,#QF_BASEPRI
LSLS r1,r1,#8
ORRS r1,r1,#QF_BASEPRI
LDR r3,=0xE000ED18 /* System Handler Priority Register */
LDR r2,[r3] /* r2 := SYSPRI1 */
ORRS r2,r1 /* r2 |= "all values to QF_BASEPRI" */
[14] STR r2,[r3] /* SYSPRI1 |= r2, Use-fault/Bus-fault/Mem-fault*/
LDR r2,[r3,#4] /* r2 := SYSPRI2 */
ORRS r2,r1 /* r2 |= "all values to QF_BASEPRI" */
[16] STR r2,[r3,#4] /* SYSPRI2 := r2, SVCall */
LDR r2,[r3,#8] /* r2 := SYSPRI3 */
ORRS r1,r1,#(0xFF << 16) /* r1 |= 0xFF for PendSV */
ORRS r2,r1
[17] STR r2,[r3,#8] /* SYSPRI3 |= r2, SysTick/PendSV/Debug */
/* set again all prioriy bytes to QF_BASEPRI in r1 */
[18] MOVS r1,#QF_BASEPRI
LSLS r1,r1,#8
ORRS r1,r1,#QF_BASEPRI
LSLS r1,r1,#8
ORRS r1,r1,#QF_BASEPRI
LSLS r1,r1,#8
ORRS r1,r1,#QF_BASEPRI
[19] LDR r3,=0xE000E004 /* Interrupt Controller Type Register */
LDR r3,[r3] /* r3 := INTLINESUM */
LSLS r3,r3,#3
[20] ADDS r3,r3,#8 /* r3 == number of NVIC_PRIO registers */
/* loop over all implemented NVIC_PRIO registers for IRQs... */
QK_init_irq:
SUBS r3,r3,#1
LDR r2,=0xE000E400 /* NVIC_PRI0 register */
[21] STR r1,[r2,r3,LSL #2] /* NVIC_PRI0[r3] := r1 */
CMP r3,#0
BNE QK_init_irq
.endif /* M3/M4 */
[22] MOV r0,r12 /* r0 := original PRIMASK */
[23] MSR PRIMASK,r0 /* PRIMASK := r0 */
[24] BX lr
.size QK_init, . - QK_init
@endcode
1
The QK_init() function initializes the exception priorities of PendSV and NMI as well as interrupt priorities of all IRQs available in a given MCU (for Cortex-M3/4/7).
2
The PRIMASK register is retreived into r0.
3
The PRIMASK value is stored in the high-register r12.
4
Interrupts are disabled by setting the PRIMASK.
5
For the ARMv6-M architecture...
6
The address of the NVIC System Handler Priority Register 0 is loaded into r3
7
The contents of the NVIC System Handler Priority Register 2 (note the offset of 8) is loaded into r2.
8-9
The mask value of 0xFF0000 is synthesized in r2.
10
The mask is then applied to set the priority byte PRI_14 to 0xFF without changing other priority bytes in this register.
11
The contents of r2 is stored in the NVIC System Handler Priority Register 2 (note the offset of 8).
12
For the ARMv7-M architecture...
13
The priority value QF_BASEPRI is all bytes of the register r1.
14
The exception priorities for User-Fault, Bus-Fault, and Mem-Fault are set to the value QF_BASEPRI.
16
The exception priority for SVCCall is set to the value QF_BASEPRI.
17
The exception priority for SysTick, PendSV, and Debug is set to the value QF_BASEPRI.
18
The priority value QF_BASEPRI is all bytes of the register r1 again.
19
The value of Interrupt Controller Type Register is loaded into r3
20
The number of implemented IRQs is loaded into r3
21
The interrupt priority of all implemented IRQs is set to the safe value QF_BASEPRI in a loop.
22
The original value of PRIMASK is restored form the high-register r12
23
The PRIMASK register is restored to its original value
14
The function QK_init returns to the caller.
@subsection arm-cm_qk_port-asm_pendsv PendSV_Handler() Implementation
Listing: PendSV_Handler function in qk_port.s assembly file
@code{c}
.section .text.PendSV_Handler
.global PendSV_Handler /* CMSIS-compliant exception name */
.type PendSV_Handler, %function
[1] PendSV_Handler:
/* Prepare some constants in registers before entering critical section */
[2] LDR r3,=0xE000ED04 /* Interrupt Control and State Register */
[3] MOVS r1,#1
[4] LSLS r1,r1,#27 /* r0 := (1 << 27) (UNPENDSVSET bit) */
/* <<<<<<<<<<<<<<<<<<<<<<< CRITICAL SECTION BEGIN <<<<<<<<<<<<<<<<<<<<< */
.if __ARM_ARCH == 6 /* Cortex-M0/M0+/M1 (v6-M, v6S-M)? */
[6] CPSID i /* disable interrupts (set PRIMASK) */
.else /* M3/M4 */
.ifdef __FPU_PRESENT /* if VFP available... */
[7] PUSH {r0,lr} /* ... push EXC_RETURN plus stack-aligner */
.endif /* VFP */
[8] MOVS r0,#QF_BASEPRI
[9] CPSID i /* selectively disable interrutps with BASEPRI */
[10] MSR BASEPRI,r0 /* apply the workaround the Cortex-M7 erraturm */
[11] CPSIE i /* 837070, see ARM-EPM-064408. */
.endif /* M3/M4 */
/* The PendSV exception handler can be preempted by an interrupt,
* which might pend PendSV exception again. The following write to
* ICSR[27] un-pends any such spurious instance of PendSV.
*/
[12] STR r1,[r3] /* ICSR[27] := 1 (unpend PendSV) */
/* The QK-nano activator must be called in a Thread mode, while this code
* executes in the Handler mode of the PendSV exception. The switch
* to the Thread mode is accomplished by returning from PendSV using
* a fabricated exception stack frame, where the return address is
* QK_activate_().
*
* NOTE: the QK-nano activator is called with interrupts DISABLED and also
* returns with interrupts DISABLED.
*/
[13] LSRS r3,r1,#3 /* r3 := (r1 >> 3), set the T bit (new xpsr) */
[14] LDR r2,=QK_activate_ /* address of QK_activate_ */
[15] SUBS r2,r2,#1 /* align Thumb-address at halfword (new pc) */
[16] LDR r1,=Thread_ret /* return address after the call (new lr) */
[17] SUB sp,sp,#8*4 /* reserve space for exception stack frame */
[18] ADD r0,sp,#5*4 /* r0 := 5 registers below the top of stack */
[19] STM r0!,{r1-r3} /* save xpsr,pc,lr */
[20] MOVS r0,#6
[21] MVNS r0,r0 /* r0 := ~6 == 0xFFFFFFF9 */
[22] BX r0 /* exception-return to the QK-nano activator */
.size PendSV_Handler, . - PendSV_Handler
/*
* Thread_ret is a helper function executed when the QXK activator returns.
*
* NOTE: Thread_ret does not execute in the PendSV context!
* NOTE: Thread_ret executes entirely with interrupts DISABLED.
*/
.section .text.Thread_ret
.type Thread_ret, %function
[23] Thread_ret:
/* After the QK-nano activator returns, we need to resume the preempted
* thread. However, this must be accomplished by a return-from-exception,
* while we are still in the thread context. The switch to the exception
* context is accomplished by triggering the NMI exception.
*/
/* before triggering the NMI exception, make sure that the
* VFP stack frame will NOT be used...
*/
.ifdef __FPU_PRESENT /* if VFP available... */
[24] MRS r0,CONTROL /* r0 := CONTROL */
[25] BICS r0,r0,#4 /* r0 := r0 & ~4 (FPCA bit) */
[26] MSR CONTROL,r0 /* CONTROL := r0 (clear CONTROL[2] FPCA bit) */
[27] ISB /* ISB after MSR CONTROL (ARM AN321,Sect.4.16)*/
.endif /* VFP available */
/* trigger NMI to return to preempted thread...
* NOTE: The NMI exception is triggered with nterrupts DISABLED
*/
[28] LDR r0,=0xE000ED04 /* Interrupt Control and State Register */
[29] LSLS r1,r1,#31 /* r1 := (1 << 31) (NMI bit) */
[30] MOVS r1,#1
[31] STR r1,[r0] /* ICSR[31] := 1 (pend NMI) */
[32] B . /* wait for preemption by NMI */
.size Thread_ret, . - Thread_ret
@endcode
1
`PendSV_Handler` is a CMSIS-complinat name of the PendSV exception handler. The `PendSV_Handler` exception is always entered via tail-chaining from the last nested interrupt.
2-4
Before interrupts are disabled, the following constants are loaded into registers: address of ICSR into r3 and (1<<27) into r1.
For the ARMv6-M architecture (Cortex-M0/M0+)...
6
Interrupts are globally disabled by setting PRIMASK (see Section 3)
Otherwise, for the ARMv7-M architecture (Cortex-M3/4/7) and when the `_FPU_PRESENT` macro is defined...
> NOTE: The symbol `__FPU_PRESENT` must be defined on the command-line to the GNU-ARM assembler if you intend to use the FPU on the Cortex-M4F cores.
7
The lr register (EXC_RETURN) is pushed to the stack along with r0, to keep the stack aligned at 8-byte boundary.
> NOTE: In the presence of the FPU (Cortex-M4F), the EXC_RETURN[4] bit carries the information about the stack frame format used, whereas EXC_RETURN[4] ==0 means that the stack contains room for the S0-S15 and FPSCR registers in addition to the usual R0-R3,R12,LR,PC,xPSR registers. This information must be preserved, in order to properly return from the exception at the end.
8
For the ARMv7-M architecture (Cortex-M3/M4), interrupts are selectively disabled by setting the BASEPRI register.
> NOTE: The value moved to BASEPRI must be identical to the QF_BASEPRI macro defined in `qf_port.h`.
9
Before setting the BASEPRI register, interrupts are disabled with the PRIMASK register, which is the recommended workaround for the Cortex-M7 r0p1 hardware bug, as described in the ARM Ltd. [@ref ARM-EPM-064408], Erratum 837070.
10
The BASEPRI register is set to the @c QF_BASEPRI value.
11
After setting the BASEPRI register, interrupts are re-anabed with the PRIMASK register, which is the recommended workaround for the Cortex-M7 r0p1 hardware bug, as described in the ARM Ltd. [@ref ARM-EPM-064408], Erratum 837070.
12
The PendSV exception is **explicitly** un-pended.
> NOTE: The PendSV exception handler can be preempted by an interrupt, which might pend PendSV exception again. This would trigger PendSV incorrectly again immediately after calling QK-nano activator.
The following code [13-22] fabricates an exception stack frame, to perform an exception-return to the QK-nano activator without destroying the original exception stack frame of the PendSV exception. This is necessary to preserve the context of the preempted code.
13
The value (1 << 24) is synthesized in r3 from the value (1 << 27) already available in r1. This value is going to be stacked and later restored to xPSR register (only the T bit set).
14
The address of the QK-nano activator function @c QK_activate_ is loaded into r2. This will be pushed to the stack as the PC register value.
15
The address of the QK-nano activator function @c QK_activate_ in r2 is adjusted to be half-word aligned instead of being an odd THUMB address.
> NOTE: This is necessary, because the value will be loaded directly to the PC, which cannot accept odd values.
16
The address of the Thread_ret function is loaded into r1. This will be pushed to the stack as the lr register value.
> NOTE: The address of the @c Thread_ret label must be a THUMB address, that is, the least-significant bit of this address must be set (this address must be odd number). This is essential for the correct return of the QK-nano scheduler with setting the THUMB bit in the PSR. Without the LS-bit set, the ARM Cortex-M CPU will clear the T bit in the PSR and cause the Hard Fault. The GNU-ARM assembler/linker will synthesize the correct THUMB address of the svc_ret label only if this label is declared with the `.type Thread_ret , %function` attribute (see step [23]).
16
The stack pointer is adjusted to leave room for 8 registers.
18
The top of stack, adjusted by 5 registers, (r0, r1, r2, r3, and r12) is stored to r0.
19
The values of xpsr, pc, and lr prepared in r3, r2, and r1, respectively, are pushed on the top of stack (now in r0). This operation completes the synthesis of the exception stack frame. After this step the stack looks as follows:
Hi memory
(optionally S0-S15, FPSCR), if EXC_RETURN[4]==0
xPSR
pc (interrupt return address)
lr
r12
r3
r2
r1
r0
EXC_RETURN (pushed in step [7] if FPU is present)
old SP --> "aligner" (pushed in step [7] if FPU is present)
xPSR == 0x01000000
PC == QK_activate_
lr == Thread_ret
r12 don't care
r3 don't care
r2 don't care
r1 don't care
SP --> r0 don't care
Low memory
20-21
The special exception-return value 0xFFFFFFF9 is synthesized in r0 (two instructions are used to make the code compatible with Cortex-M0, which has no barrel shifter).
> NOTE: the r0 register is used instead of lr because the Cortex-M0 instruction set cannot manipulate the higher-registers (r9-r15).
> NOTE: The exception-return value is consistent with the synthesized stack-frame with the lr[4] bit set to 1, which means that the FPU registers are not included in this stack frame.
22
PendSV exception returns using the special value of the r0 register of 0xFFFFFFF9 (return to Privileged Thread mode using the Main Stack pointer). The synthesized stack frame causes actually a function call to QK_sched_ function in C.
> NOTE: The return from the PendSV exception just executed switches the ARM Cortex-M core to the Privileged Thread mode. The QK_sched_ function internally re-enables interrupts before launching any thread, so the threads always run in the Thread mode with interrupts enabled and can be preempted by interrupts of any priority.
> NOTE: In the presence of the FPU, the exception-return to the QK-nano scheduler does not change any of the FPU status bit, such as CONTROL.FPCA or LSPACT.
23
The @c Thread_ret function is the place, where the QK-nano activator `QK_activate_()` returns to, because this return address is pushed to the stack in step [16]. Please note that the address of the @c Thread_ret label must be a THUMB address.
24-27
If the FPU is present, the read-modify-write code clears the CONTROL[2] bit [2]. This bit, called CONTROL.FPCA (Floating Point Active), would cause generating the FPU-type stack frame, which you want to avoid in this case (because the NMI exception will certainly not use the FPU).
> NOTE: Clearing the CONTROL.FPCA bit occurs with interrupts disabled, so it is protected from a context switch.
28-31
The asynchronous NMI exception is triggered by setting ICSR[31]. The job of this exception is to put the CPU into the exception mode and correctly return to the thread level.
32
This endless loop should not be reached, because the NMI exception should preempt the code immediately after step [31]
@subsection arm-cm_qk_port-asm_nmi NMI_Handler() Implementation
Listing: NMI_Handler function in qk_port.s assembly file
@code{c}
.section .text.NMI_Handler
.global NMI_Handler
.type NMI_Handler, %function
[1] NMI_Handler:
[2] ADD sp,sp,#(8*4) /* remove one 8-register exception frame */
.if __ARM_ARCH == 6 /* Cortex-M0/M0+/M1 (v6-M, v6S-M)? */
[3] CPSIE i /* enable interrupts (clear PRIMASK) */
[4] BX lr /* return to the preempted thread */
.else /* M3/M4 */
[5] MOVS r0,#0
[6] MSR BASEPRI,r0 /* enable interrupts (clear BASEPRI) */
.ifdef __FPU_PRESENT /* if VFP available... */
[7] POP {r0,pc} /* pop stack "aligner" and EXC_RETURN to PC */
.else /* no VFP */
[8] BX lr /* return to the preempted thread */
.endif /* VFP available */
.endif /* M3/M4 */
.size NMI_Handler, . - NMI_Handler
@endcode
1
The @c NMI_Handler is the CMSIS-compliant name of the NMI exception handler. This exception is triggered after returning from the QK-nano activator in step [31] of the previous listing. The job of NMI is to discard its own stack frame and cause the exception-return to the original preempted thread context. The stack contents just after entering NMI is shown below:
Hi memory
(optionally S0-S15, FPSCR), if EXC_RETURN[4]==0
xPSR
pc (interrupt return address)
lr
r12
r3
r2
r1
r0
old SP --> EXC_RETURN (pushed in PendSV [7] if FPU is present)
"aligner" (pushed in PendSV [7] if FPU is present)
xPSR don't care
PC don't care
lr don't care
r12 don't care
r3 don't care
r2 don't care
r1 don't care
SP --> r0 don't care
Low memory
2
The stack pointer is adjusted to un-stack the 8 registers of the interrupt stack frame corresponding to the NMI exception itself. This moves the stack pointer from the "old SP" to "SP" in the picture above, which "uncovers" the original exception stack frame left by the PendSV exception.
3
For ARMv6-M, interrupts are enabled by clearing the PRIMASK.
4
For ARMv6-M, The NMI exception returns to the preempted thread using the standard EXC_RETURN, which is in lr.
5-6
For the ARMv7-M, interrupts are enabled by writing 0 into the BASEPRI register.
7
If the FPU is used, the EXC_RETURN and the "stack aligner" saved in PendSV step [7] are popped from the stack into r0 and pc, respectively. Updating the pc causes the return from PendSV.
8
Otherwise, NMI returns to the preempted thread using the standard EXC_RETURN, which is in lr.
@anchor qk_stack-detail
@image html qk_stack-detail.gif "Detailed stack allocation in QK-nano for ARM Cortex-M"
@section arm-cm_qk-isr Writing ISRs for QK
The ARM Cortex-M CPU is designed to use regular C functions as exception and interrupt service routines (ISRs).
@note
The ARM EABI (Embedded Application Binary Interface) requires the stack be 8-byte aligned, whereas some compilers guarantee only 4-byte alignment. For that reason, some compilers (e.g., GNU-ARM) provide a way to designate ISR functions as interrupts. For example, the GNU-ARM compiler provides the `__attribute__((__interrupt__))` designation that will guarantee the 8-byte stack alignment.
Typically, ISRs are application-specific (with the main purpose to produce events for active objects). Therefore, ISRs are not part of the generic QP port, but rather part of the BSP (Board Support Package).
The following listing shows an example of the SysTick_Handler() ISR (from the DPP example application). This ISR calls the QF_TICK_X() macro to perform QF time-event management.
@anchor arm-cm_qk-isr-code
Listing: An ISR header for QK
@code{c}
void SysTick_Handler(void) __attribute__((__interrupt__));
void SysTick_Handler(void) {
~ ~ ~
[1] QK_ISR_ENTRY(); /* inform QK-nano about entering an ISR */
~ ~ ~
QF_TICK_X(0U, &l_SysTick_Handler); /* process all armed time events */
~ ~ ~
[2] QK_ISR_EXIT(); /* inform QK-nano about exiting an ISR */
}
@endcode
1
Every ISR for QK-nano must call @c QK_ISR_ENTRY() before calling any QP API
2
Every ISR for QK-nano must call @c QK_ISR_EXIT() right before exiting to let the QK-nano kernel schedule an asynchronous preemption, if necessary.
@note
The QK-nano port to ARM Cortex-M complies with the requirement of the ARM-EABI to preserve stack pointer alignment at **8-byte boundary**. Also, all QP examples for ARM Cortex-M comply with the CMSIS naming convention for all exception handlers and IRQ handlers.
@section arm-cm_qk-fpu Using the FPU in the QK-nano Port (Cortex-M4F)
If you have the Cortex-M4F CPU and your application uses the hardware FPU, it should be enabled because it is turned off out of reset. The CMSIS-compliant way of turning the FPU on looks as follows:
@verbatim
SCB->CPACR |= (0xFU << 20);
@endverbatim
@note
The FPU must be enabled before executing any floating point instruction. An attempt to execute a floating point instruction will fault if the FPU is not enabled.
Depending on wheter or not you use the FPU in your ISRs, the "Vanilla" QP port allows you to configure the FPU in various ways, as described in the following sub-sections.
@subsection arm-cm_qk-fpu_1thread FPU used in ONE thread only and not in any ISR
If you use the FPU only at a single thread (active object) and none of your ISRs use the FPU, you can setup the FPU not to use the automatic state preservation and not to use the lazy stacking feature as follows:
@verbatim
FPU->FPCCR &= ~((1U << FPU_FPCCR_ASPEN_Pos) | (1U << FPU_FPCCR_LSPEN_Pos));
@endverbatim
With this setting, the Cortex-M4F processor handles the ISRs in the exact-same way as Cortex-M0-M3, that is, only the standard interrupt frame with R0-R3,R12,LR,PC,xPSR is used. This scheme is the fastest and incurs no additional CPU cycles to save and restore the FPU registers.
@note
This FPU setting will lead to FPU errors, if more than one thread or any of the ISRs indeed start to use the FPU
@subsection arm-cm_qk-fpu_nthreadd FPU used in more than one thread only or the ISR
If you use the FPU in more than one of the threads (active objects) or in any of your ISRs, you should setup the FPU to use the automatic state preservation and the lazy stacking feature as follows:
FPU->FPCCR |= (1U << FPU_FPCCR_ASPEN_Pos) | (1U << FPU_FPCCR_LSPEN_Pos);
This is actually the default setting of the hardware FPU and is recommended for the QK-nano port, because it is safer in view of code evolution. Future changes to the application can easily introduce FPU use in multiple active objects, which would be unsafe if the FPU context was not preserved automatically.
@note
As described in the ARM Application Note "Cortex-M4(F) Lazy Stacking and Context Switching" [@ref ARM-AN298], the FPU automatic state saving requires more stack plus additional CPU time to save the FPU registers, but only when the FPU is actually used.
@section arm-cm_qk-idle QK-nano Idle Processing Customization in QK_onIdle()
QK-nano can very easily detect the situation when no events are available, in which case QK-nano calls the `QK_onIdle()` callback. You can use `QK_onIdle()` to suspended the CPU to save power, if your CPU supports such a power-saving mode. Please note that `QK_onIdle()` is called repetitively from an endless loop, which is the QK-nano idle-thread. The `QK_onIdle()` callback is called with interrupts **enabled** (which is in contrast to the @ref arm-cm_qv-idle "QV_onIdle() callback" used in the non-preemptive configuration).
The THUMB-2 instruction set used exclusively in ARM Cortex-M provides a special instruction WFI (Wait-for-Interrupt) for stopping the CPU clock, as described in the "ARMv7-M Reference Manual" [ARM 06a]. The following listing shows the `QK_onIdle()` callback that puts ARM Cortex-M into a low-power mode.
@anchor arm-cm_qk_onidle-code
Listing: QV_onIdle() for ARM Cortex-M
@code{c}
[1] void QK_onIdle(void) {
~ ~ ~
[2] #if defined NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular Cortex-M3 MCU.
*/
[3] __WFI(); /* Wait-For-Interrupt */
#endif
}
@endcode
1
The preemptive QK-nano kernel calls the `QK_onIdle()` callback with interrupts enabled.
2
The sleep mode is used only in the non-debug configuration, because sleep mode stops CPU clock, which can interfere with debugging.
3
The `WFI` instruction is generated using inline assembly.
@section arm-cm_qk-testing Testing QK-nano Preemption Scenarios
The `bsp.c` file included in the examples/arm-cm/dpp_ek-tm4c123gxl/qk directory contains special instrumentation (an ISR designed for testing) for convenient testing of @ref arm-cm_qk-arm-cm-fig "various preemption scenarios in QK".
The technique described in this section will allow you to trigger an interrupt at any machine instruction and observe the preemption it causes. The interrupt used for the testing purposes is the GPIOA interrupt (INTID == 0). The ISR for this interrupt is shown below:
@code{c}
void GPIOPortA_IRQHandler(void) {
QK_ISR_ENTRY(); /* inform QK-nano about entering an ISR */
QACTIVE_POST(AO_Table, Q_NEW(QEvt, MAX_PUB_SIG), /* for testing... */
&l_GPIOPortA_IRQHandler);
QK_ISR_EXIT(); /* inform QK-nano about exiting an ISR */
}
@endcode
`GPIOPortA_IRQHandler()`, as all interrupts in the system, invokes the macros QK_ISR_ENTRY() and QK_ISR_EXIT(), and also posts an event to the Table active object, which has higher priority than any of the Philo active object.
The figure below hows how to trigger the GPIOA interrupt from the CCS debugger. From the debugger you need to first open the register window and select NVIC registers from the drop-down list (see right-bottom corner of Figure 6).You scroll to the NVIC_SW_TRIG register, which denotes the Software Trigger Interrupt Register in the NVIC. This write-only register is useful for software-triggering various interrupts by writing various masks to it. To trigger the GPIOA interrupt you need to write 0x00 to the NVIC_SW_TRIG by clicking on this field, entering the value, and pressing the Enter key.
@image html arm-cm_qk_test-ccs.png "Triggering the GPIOA interrupt from Eclipse debugger"
The general testing strategy is to break into the application at an interesting place for preemption, set breakpoints to verify which path through the code is taken, and trigger the GPIO interrupt. Next, you need to free-run the code (don’t use single stepping) so that the NVIC can perform prioritization. You observe the order in which the breakpoints are hit. This procedure will become clearer after a few examples.
@subsection arm-cm_qk-test-isr Interrupt Nesting Test
The first interesting test is verifying the correct tail-chaining to the PendSV exception after the interrupt nesting occurs, as shown in @ref arm-cm_qk-synch-fig "Synchronous Preemption in QK". To test this scenario, you place a breakpoint inside the `GPIOPortA_IRQHandler()` and also inside the `SysTick_Handler()` ISR. When the breakpoint is hit, you remove the original breakpoint and place another breakpoint at the very next machine instruction (use the Disassembly window) and also another breakpoint on the first instruction of the `QK_PendSV` handler. Next you trigger the PIOINT0 interrupt per the instructions given in the previous section. You hit the Run button.
The pass criteria of this test are as follows:
1. The first breakpoint hit is the one inside the `GPIOPortA_IRQHandler()` function, which means that GPIO ISR preempted the SysTick ISR.
2. The second breakpoint hit is the one in the `SysTick_Handler()`, which means that the SysTick ISR continues after the PIOINT0 ISR completes.
3. The last breakpoint hit is the one in `PendSV_Handler()` exception handler, which means that the PendSV exception is tail-chained only after all interrupts are processed. You need to remove all breakpoints before proceeding to the next test.
@subsection arm-cm_qk-test-thread Thread Preemption Test
The next interesting test is verifying that threads can preempt each other. You set a breakpoint anywhere in the Philosopher state machine code. You run the application until the breakpoint is hit. After this happens, you remove the original breakpoint and place another breakpoint at the very next machine instruction (use the Disassembly window). You also place a breakpoint inside the `GPIOPortA_IRQHandler()` interrupt handler and on the first instruction of the `PendSV_Handler()` handler. Next you trigger the GPIOA interrupt per the instructions given in the previous section. You hit the Run button.
The pass criteria of this test are as follows:
1. The first breakpoint hit is the one inside the `GPIOPortA_IRQHandler()` function, which means that GPIO ISR preempted the Philo thread.
2. The second breakpoint hit is the one in `PendSV_Handler()` exception handler, which means that the PendSV exception is activated before the control returns to the preempted Philosopher thread.
3. After hitting the breakpoint in `PendSV_Handler()`, you single step into `QK_activate_()`. You verify that the activator invokes a state handler from the Table state machine. This proves that the Table thread preempts the Philo thread.
4. After this you free-run the application and verify that the next breakpoint hit is the one inside the Philosopher state machine. This validates that the preempted thread continues executing only after the preempting thread (the Table state machine) completes.
@subsection arm-cm_qk-test-fpu Testing the FPU (Cortex-M4F)
In order to test the FPU, the Board Support Package (BSP) for the Cortex-M4F EK-TM4C123GXL board uses the FPU in the following contexts:
- In the idle loop via the `QK_onIdle()` callback (QP priority 0)
- In the thread level via the `BSP_random()` function called from all five Philo active objects (QP priorities 1-5).
- In the thread level via the `BSP_displayPhiloStat()` function called from the Table active object (QP priorty 6)
- In the ISR level via the `SysTick_Handler()` ISR (priority above all threads)
To test the FPU, you could step through the code in the debugger and verify that the expected FPU-type exception stack frame is used and that the FPU registers are saved and restored by the "lazy stacking feature" when the FPU is actually used.
Next, you can selectively comment out the FPU code at various levels of priority and verify that the QK-nano context switching works as expected with both types of exception stak frames (with and without the FPU).
@subsection arm-cm_qk-test-other Other Tests
Other interesting tests that you can perform include changing priority of the GPIOA interrupt to be lower than the priority of SysTick to verify that the PendSV is still activated only after all interrupts complete.
In yet another test you could post an event to Philosopher active object rather than Table active object from the `GPIOPortA_IRQHandler()` function to verify that the QK-nano activator will not preempt the Philosopher thread by itself. Rather the next event will be queued and the Philosopher thread will process the queued event only after completing the current event processing.
*/
================================================
FILE: doxygen/ports_native.dox
================================================
/*##########################################################################*/
/*! @page ports_native Native (Bare-Metal) Ports
- @subpage lint (generic C compiler)
- @subpage arm-cm (Cortex-M0/M0+/M3/M4/M4F)
- @ref arm-cm_qv (ARM-KEIL, GNU-ARM, IAR-ARM, TI-CCS toolsets)
- @ref arm-cm_qk (ARM-KEIL, GNU-ARM, IAR-ARM, TI-CCS toolsets)
- @subpage arm7-9 ("classic" ARM)
- @ref arm7-9_qk (GNU-ARM, IAR-ARM toolsets)
- @ref arm7-9_qv (GNU-ARM, IAR-ARM toolsets)
- @subpage avr (megaAVR)
- @ref avr_qk (GNU-AVR, IAR-AVR toolsets)
- @ref avr_qv (GNU-AVR, IAR-AVR toolsets)
- @subpage msp430 ("classic" MSP430 and "extended" MSP430X)
- @ref msp430_qv (CCS, IAR toolsets)
- @ref msp430_qk (CCS, IAR toolsets)
*/
/*##########################################################################*/
/*! @page lint PC-Lint-Plus
@tableofcontents
The QP-nano distribution contains a "port" to PC-Lint-Plus static analysis tool from Gimpel Software, which is a static analysis tool for C and C++ with one of the longest track records and best value of the money in the industry. The "PC-Lint-Plus port" allows you to statically analyze the QP-nano source code and facilitates static analysis of your **application code** based on QP-nano.
The QP-nano "port" to PC-Lint-Plus is located in the directory qpn/ports/lint-plus and includes also lint configuration files, as well as an example of "linting" application code in the directory qpn/examples/arm-cm/dpp_ek-tm4c123gxl/lint-plus. The following listing describes the most important files in these three directories.
@code{.x}
qpn\ - QP-nano installation directory
|
| +-ports/ - QP-nano ports directory
| | +-lint-plus/ - QP-nano "port" to PC-Lint-Plus
| | | +-qkn/ - QP-nano port with the QK-nano kernel
| | | +-qvn/ - QP-nano port with the QV-nano kernel
| | | +-au-ds.lnt - Dan Saks recommendations
| | | +-au-misra3.lnt - MISRA-C:2012 compliance checks
| | | +-au-misra3-amd1.lnt - MISRA-C:2012-Amendment-1 additional checks
| | | +-qpn.lnt - PC-Lint-Plus options for QP-nano applications
| | | +-std.lnt - Standard PC-Lint-Plus settings recommended by Quantum Leaps
| | | +-lin.bat - Batch file to invoke PC-Lint-Plus to run analysis of QP-nano code
| | | +-options.lnt - PC/Lint-Plus options for "linting" QP-nano source code
| | | +-lint_qfn.log - PC/Lint-Plus output for the QEP/QF-nano components of QP-nano
| | | +-lint_qvn.log - PC/Lint-Plus output for the QV-nano component of QP-nano
| | | +-lint_qkn.log - PC/Lint-Plus output for the QK-nano component of QP-nano
| | | +-qpn_conf.h - QP-nano config file for a "generic C compiler"
| | | +-stdbool.h - Standard Boolean type and constants for a "generic C compiler"
| | | +-stdint.h - Standard exact-width integers for a "generic C compiler"
| |
| +-examples\ - QP-nano examples directory (application)
| | +-arm-cm\ - QP-nano examples for ARM Cortex-M
| | | +-dpp_ek-tm4c123gxl\ - DPP example on the EK-TM4C123GLX board
| | | | +-lint-plus\ - directory for linting the application
| | | | | +-lin.bat - Batch to run PC-Lint-Plus analysis of application code
| | | | | +-options.lnt - PC-Lint-Plus options for "linting" of application code
@endcode
@section lint_qpn Linting the QP-nano Source Code
The directory qpn/ports/lint-plus (see listing above) contains also the **lin.bat** batch file for "linting" the QP-nano source code. The `lin.bat` batch file invokes PC-Lint-Plus and generates the lint output files. As shown in the listing above, the lint output is collected into four text files `lint_qfn.log`, lint_qkn.log`, and `lint_qvn.log`, for QEP/QF-nano, QK-nano, and QV-nano components of the QP-nano framework, respectively.
@note
In order to execute the `lin.bat` file on your system, you might need to adjust the symbol `PCLP_DIR` at the top of the batch file, to the PC-Lint-Plus installation directory on your computer.
According to the PC-Lint-Plus guidelines, the `lin.bat` uses two option files: the `qpn.lnt` configuration file discussed before and the `options.lnt` configuration file that covers all deviations from the MISRA-C rules **within the QP-nano source code**. These deviations are intentionally localized to QP-nano code and are independent from your **application-level** code. In other words, a MISRA-C deviation present in the QP-nano code does **not** mean that such deviation is somehow allowed or its detection is somehow suppressed in the **application-level** code. This is because the the `options.lnt` configuration file for internals of QP-nano is **not** used to "lint" the application-level code.
@section lint_app Linting QP-nano Application Code
The QP-nano baseline code contains an example of MISRA-C compliance checking with PC-Lint-Plus: the DPP example for the EK-TM4C123GLX Cortex-M4F board, located in the directory qpn/examples/arm-cm/dpp_ek-tm4c123gxl/lint-plus. The PC-Lint-Plus analysis is very simple and requires invoking the **lin.bat** file.
@note
In order to execute the **lin.bat** file on your system, you might need to adjust the symbol `PCLP_DIR` at the top of the batch file, to the PC-Lint-Plus installation directory on your computer. You
The `lint-plus` subdirectory contains also the `options.lnt` with the PC-Lint-Plus options specific to linting the application. Here, you might include linting options for your specific compiler, as described in the "PC-Lint-Plus Manual", Chapter 2 "Installation and Configuration".
@section lint_options Structure of PC-Lint-Plus Options for QP-nano
PC-Lint-Plus has several places where it reads its currently valid options:
- From special PC-Lint-Plus option files (usually called `*.lnt`)
- From the command line
- From within the special lint-comments in the source code modules (not recommended)
The QP-nano source code and example application code has been "linted" only by means of the first alternative (option files) with possibility of adding options via command line. The third alternative--lint comments--is not used and Quantum Leaps does not recommend this alternative.
@note
The QP-nano source code is completely free of lint comments, which are viewed as a contamination of the source code.
The structure of the PC-Lint-Plus option files used for "linting" QP-nano follows exactly the Gimpel Software guidelines for configuring PC-Lint-Plus (See Section 2 "Configuration" in the *PC-Lint-Plus Manual*). The design and grouping of the lint options also reflects the fact that static code analysis of a software framework, such as QP-nano, has really two major aspects. First, the source code of the framework itself has to be analyzed. But even more important and helpful to the users of the framework is providing the infrastructure to effectively analyze the application-level code based on the framework. With this in mind, the PC-Lint-Plus options for static analysis of QP-nano are divided into two groups, located in directories qpn/include and qpn/ports/lint. These two groups are for analyzing QP-nano **applications** and QP-nano **source code**, respectively.
As shown in the PC-Lint-Plus "port" files description, the directory qpn/include, contains the PC-Lint-Plus options for "linting" the application code along with all platform-independent QP-nano header files required by the applications. This collocation of lint options with header files simplifies "linting", because specifying just `-iqpn/include` include directory to PC-Lint-Plus accomplishes both inclusion of QP-nano header files and PC-Lint-Plus options.
Note that the `qpn/include` directory contains all PC-Lint-Plus option files used in "linting" the code, including the standard MISRA-C:2012 `au-misr3.lnt` option file as well as Dan Saks' recommendations `au-ds.lnt`, which are copied from the PC-Lint-Plus distribution. This design freezes the lint options for which the compliance has been checked.
@subsection lint_std_lnt The std.lnt option file
According to the Gimpel Software *PC-Lint-Plus Configuration Guidelines*, the file `qpn/ports/lint-plus/std.lnt` file, contains the top-level options, which Quantum Leaps recommends for all projects. These options include the formatting of the PC-Lint-Plus messages and making two passes to perform better cross-module analysis. However, the most important option is `-restore_at_end`, which has the effect of surrounding each source file with options `-save` and `-restore`. This precaution prevents options from "bleeding" from one file to another.
Top-level option file std.lnt
@include std.lnt
@subsection lint_qpn_lnt The qpn.lnt option file
The most important file for "linting" QP-nano applications is the **qpn.lnt** option file. This file handles all deviations from the MISRA-C:2012 rules, which might arise at the application-level code from the use of the QP-nano framework. In other words, the **qpn.lnt** option file allows completely clean "linting" of the application-level code, as long as the application code does not violate any of the MISRA-C:2012 rules.
At the same time, the **qpn.lnt** option file has been very carefully designed not to suppress any MISRA-C:2012 rule checking outside the very specific context of the QP-nano API. In other words, the qpn.lnt option file still supports 100% of the MISRA-C:2012 rule checks that PC-Lint-Plus is capable of performing.
@remarks
For example, for reasons explained in Section 5.10 of the "QP-nano MISRA Compliance Matrix", QP-nano extensively uses function-like macros, which deviates from the MISRA-C:2012 advisory Rule 4.9 and which PC-Lint-Plus checks with the warning 9026. However, instead of suppressing this warning globally (with the -e9096 directive), the qpn.lnt option file suppresses warning 9096 only for the specific QP function-like macros that are visible to the application level. So specifically, the qpn.lnt file contains directives `-esym(9026, Q_TRAN, Q_SUPER, ...)`, which suppresses the warning only for the specified macros, but does not disable checking of any other macros in the application-level code.
@next{arm-cm}
*/
/*##########################################################################*/
/*! @page arm-cm ARM Cortex-M
@image html under_construction.jpg
@section arm7-9_qk Preemptive QK Kernel
@includelineno ports/arm-sm/qk/iar/qkn_port.s
@next{arm7-9}
*/
/*##########################################################################*/
/*! @page arm7-9 ARM7/ARM9
@image html under_construction.jpg
@section arm7-9_qk Preemptive QK Kernel
@includelineno ports/arm7-9/qk/iar/qkn_port.s
@section arm7-9_qv Cooperative QV Kernel
@next{msp430}
*/
/*##########################################################################*/
/*! @page msp430 MSP430
@image html under_construction.jpg
@section msp430_qk Preemptive QK Kernel
@section msp430_qv Cooperative QV Kernel
@next{avr}
*/
/*##########################################################################*/
/*! @page avr AVR
@image html under_construction.jpg
@section avr_qk Preemptive QK Kernel
@section avr_qv Cooperative QV Kernel
*/
================================================
FILE: doxygen/ports_os.dox
================================================
/*##########################################################################*/
/*! @page ports_os Ports to Third-Party OS
- @subpage posix-qv (Linux, embedded-Linux, BSD, etc.)
- @subpage win32-qv (Windows with QV)
*/
/*##########################################################################*/
/*! @page posix-qv POSIX-QV
@image html under_construction.jpg
@sa
@ref exa_posix-qv "Examples for POSIX-QV"
*/
/*##########################################################################*/
/*! @page win32-qv Win32-QV
@image html under_construction.jpg
@sa
@ref exa_win32-qv "Examples for Win32-QV"
*/
================================================
FILE: doxygen/preview.js
================================================
/* Image preview script
* powered by jQuery (http://www.jquery.com)
* written by Alen Grakalic (http://cssglobe.com)
* for more info visit
* http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
*/
this.imagePreview = function(){
// you might want to adjust to get the right result
horOffset = -100;
verOffset = 0;
/* END CONFIG */
$("a.preview").hover(function(e){
this.t = this.title;
this.title = "";
var c = (this.t != "") ? " " + this.t : "";
$("body").append("
"+ c +"
");
$("#preview")
.css("top",(e.pageY - verOffset) + "px")
.css("left",(e.pageX + horOffset) + "px")
.fadeIn("fast");
},
function(){
this.title = this.t;
$("#preview").remove();
});
$("a.preview").mousemove(function(e){
$("#preview")
.css("top",(e.pageY - verOffset) + "px")
.css("left",(e.pageX + horOffset) + "px");
});
};
// starting the script on page load
$(document).ready(function(){
imagePreview();
});
================================================
FILE: doxygen/rsm.bat
================================================
@echo off
:: ==========================================================================
:: Product: QP-nano script for running MSquared Resource Standard Metrics (RSM)
:: Last Updated for Version: 5.2.0
:: Date of the Last Update: Dec 20, 2013
::
:: Q u a n t u m L e a P s
:: ---------------------------
:: innovating embedded systems
::
:: Copyright (C) 2002-2013 Quantum Leaps, LLC. All rights reserved.
::
:: This program is open source software: you can redistribute it and/or
:: modify it under the terms of the GNU General Public License as published
:: by the Free Software Foundation, either version 3 of the License, or
:: (at your option) any later version.
::
:: Alternatively, this program may be distributed and modified under the
:: terms of Quantum Leaps commercial licenses, which expressly supersede
:: the GNU General Public License and are specifically designed for
:: licensees interested in retaining the proprietary status of their code.
::
:: This program is distributed in the hope that it will be useful,
:: but WITHOUT ANY WARRANTY; without even the implied warranty of
:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
:: GNU General Public License for more details.
::
:: You should have received a copy of the GNU General Public License
:: along with this program. If not, see .
::
:: Contact information:
:: Quantum Leaps Web sites: http://www.quantum-leaps.com
:: http://www.state-machine.com
:: e-mail: info@quantum-leaps.com
:: ==========================================================================
setlocal
set RCMHOME="C:\tools\MSquared\M2 RSM"
set RSM_OUTPUT=qpn_metrics.txt
set RSM_INPUT=..\include\*.h ..\source\*.h ..\source\*.c
%RCMHOME%\rsm.exe -fd -n -xNOCOMMAND -xNOCONFIG -u"File cfg rsm_qpn.cfg" %RSM_INPUT% > %RSM_OUTPUT%
endlocal
================================================
FILE: doxygen/rsm_qpn.cfg
================================================
# ==========================================================================
# Product: Configuration file for MSquared Resource Standard Metrics (RSM)
# Last Updated for Version: 5.2.0
# Date of the Last Update: Dec 20, 2013
#
# Q u a n t u m L e a P s
# ---------------------------
# innovating embedded systems
#
# Copyright (C) 2002-2013 Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# Quantum Leaps Web sites: http://www.quantum-leaps.com
# http://www.state-machine.com
# e-mail: info@quantum-leaps.com
# ==========================================================================
####################################################################
# RSM Operational Configuration ####################################
# Company Specific Header
# This line will appear at the top of all reports
# Typical uses include copyrights, security and project markings
# You must specify both a text version for text and csv reports
# and an HTML version.
Report Header Active : No
Report Header Text Line : Standard Metrics Report
Report Header HTML Line : Standard Metrics Report
# Enable user defined configuration files.
# The file rsm.cfg is read from the location of the rsm.lic file.
# This file can enable this option to allow users to override the
# operational configuration of RSM. This option is enabled by the
# end user with the -u "File cfg path\file" option
Enable user defined configuration files : Yes
# Windows 9x and DOS are case insensitive file systems.
# Files like foo.c and foo.C are seen as C source files.
# If *.C files are C++ files under these operating systems
# or you are operating on NT or UNIX set this option to
# case sensitivity equal to Yes.
Source file names are case sensitive : No
# Show a progress indicator when processing files and
# code differentials.
Show progress indicator : Yes
Detailed Progress Showing File Names : Yes
# Number of files which comprise a status marker when
# status is indicated during lengthy operations.
Progress status interval number of files: 10
# Show file dates when displaying file metrics.
Show file date and size : No
# RSM will process only files with the following extensions.
# The user may add to this list, but RSM is designed to process
# only the C, C++, C# and Java languages.
Validate file extensions for processing : Yes
# Specify the extensions for each type of supported language.
# Files extensions are separated by commas and are case sensitive
# if case sensitivity is specified in this file (comma separated,no spaces).
C File Extensions : c
C Header File Extensions : h
C++ File Extensions : cc,cpp,cxx,h,hh,H,hxx
C++ Header File Extensions : h,hh,H,hxx
C# File Extensions : cs
Java File Extensions : java
# Other files are not officially supported by RSM
# but lines will be counted as LOC
Other File Extensions :
# When analyzing *.h files, treat header files as
# both C and C++. If you use separate extensions for C++ and
# C header files, then set this option to No.
Treat C headers as C++ : Yes
# RSM will not process files when the path/file name contains
# a pattern in the pattern list (comma separated,no spaces).
Pattern Filter Active : No
Pattern Filter : .designer.c
# RSM Code skip strings allow the RSM parser to skip
# processing of all code between the start and stop
# tokens. This is useful for machine generated code.
# Code tokens are unique in the could base and if
# found on a code line the rsm processing will be effected.
# Start and stop tokens must match within a file and
# cannot span files. A token cannot contain spaces and
# must be alphnumeric and can contain the underscore.
# Quality skip tokens turn off just quality notice checking.
# i.e. // RSM_IGNORE_BEGIN
# some code ....
# // RSM_IGNORE_END
RSM Code Skip Start Token : RSM_IGNORE_BEGIN
RSM Code Skip End Token : RSM_IGNORE_END
RSM Code Quality Skip Start Token : RSM_IGNORE_QUALITY_BEGIN
RSM Code Quality Skip End Token : RSM_IGNORE_QUALITY_END
Activate RSM code skip tokens : Yes
# RSM will not process files in local directories when this
# flag is set. This will prevent recursive descent into
# these directories (comma separated,no spaces).
Do not process these local directories : No
Local directory names not processed : test,sccs,cvs,rcs,svn
# Names in reports include file, namespace or package, class
# and function names. These names can get quite long and will
# extend beyond the report right margin. This setting will
# wrap the name to the report right margin.
Wrap long names in reports : Yes
####################################################################
# RSM Configuration for Baseline Metrics Differentials #############
# The following path location specifies where work files
# are to be created. The path must be a location with write
# permissions. RSM will create work files in the current
# directory if no path is specified.
Work file location path :
# When processing code line differentials, ignore
# blank line changes in the code.
Ignore code differential blank lines : Yes
# When processing code line differentials, ignore
# blanks and tab changes in the code.
Ignore code differential white space : Yes
# Maximum number of lines in a file when using Longest Common Sequence
# differential algorithm. This value establishes the line to line
# comparison matrix size. This value has been set to the maximum allowed
# under 32 bit operating systems. It is not advised to make this value >
# than 10000. If you have a machine with very low physical memory you may
# want to use a value of 6000 to 7000 where 10000 should be a maximum.
# When file lengths exceed the matrix limits, the file is segmented to fit
# the matrix size.
Maximum LCS file size, number of lines : 10000
# Code differential metrics determine lines that are
# different in the current baseline compared to the
# older baseline. This metric can include
# lines that are removed from the current baseline.
Add removed older lines as modified : No
# When showing differential details for each file
# using the switch -ws
Show equal lines : Yes
Show lines removed from older file : Yes
Show lines added (mod) to newer file : Yes
# The following parameter, when set to Yes will cause
# the files stored into work files to be relative to the
# location specified by the -w"create top_dir", baseline
# top directory.
Relative Work Files : Yes
# User defined productivity values for determining works
# rates for baseline metric differentials.
Work Seconds per Hour : 3600
Work Hours per Shift : 8
Work Shifts per Day : 1
Work Days per Week : 5
Work Hours per Man Day : 8
Work Hours per Man Week : 40
Work Hours per Man Month : 160
Work Hours per Man Year : 1960
#####################################################################
# Function point conversion factors for LOC metrics
#
Header File Function Points per LOC : 0
Header File Function Points per eLOC : 0
Header File Function Points per lLOC : 0
C File Function Points per LOC : 128
C File Function Points per eLOC : 128
C File Function Points per lLOC : 128
C++ File Function Points per LOC : 53
C++ File Function Points per eLOC : 53
C++ File Function Points per lLOC : 53
Java File Function Points per LOC : 53
Java File Function Points per eLOC : 53
Java File Function Points per lLOC : 53
C# File Function Points per LOC : 53
C# File Function Points per eLOC : 53
C# File Function Points per lLOC : 53
Other File Function Points per LOC : 0
Other File Function Points per eLOC : 0
Other File Function Points per lLOC : 0
####################################################################
# RSM Configuration for cyclomatic complexity ######################
#
# McCabe Cyclomatic Complexity includes the following constructs in
# the calculation.
# function call + if + inline if + while + for + foreach
# case + goto + logical or + Logical and
#
# You may tailor the cyclomatic complexity calculation to meet your
# specific requirements.
Include 'function call' in cyclomatic complexity: Yes
Include 'while' in cyclomatic complexity : Yes
Include 'for' in cyclomatic complexity : Yes
Include 'switch' in cyclomatic complexity : No
Include 'case' in cyclomatic complexity : Yes
Include 'if' in cyclomatic complexity : Yes
Include 'else' in cyclomatic complexity : No
Include '?' inlined if in cyclomatic complexity : Yes
Include 'goto' in cyclomatic complexity : Yes
Include '||' or 'or' in cyclomatic complexity : Yes
Include '&&' or 'and' in cyclomatic complexity : Yes
####################################################################
# RSM Quality Notices Configuration ################################
# User Defined Quality Notices UDQN
# Specify the file name which contains the UDQN definitions
# See this provided example for a tutorial on UDQN.
RSM user defined quality notice file : rsm_udqn.cfg
# Re-order the quality notice format so that if a line number
# is emitted, the line number precedes the notice number. This
# option enables code editors to parse the notice line.
Reorder notice, line in quality notices : No
# RSM Quality Notices For Code Style ###################################
# Quality Notice No. 1
# Emit a quality notice when the physical line length
# is greater than the specified number of characters.
Quality Notice 1 : Yes
Maximum Line Length : 80
# Quality Notice No. 2
# Emit a quality notice when the function name length
# is greater than the specified number of characters.
Quality Notice 2 : Yes
Maximum Function Name Length : 32
# Quality Notice No. 21
# Emit a quality notice when a file does not contain
# the specified key string.
Quality Notice 21 : No
RSM KEY String :
# RSM Quality Notices For Stability and Maintainability ################
# Quality Notice No. 3
# Emit a quality notice when ellipsis '...' are identified
# within a functions parameter list thus enabling variable
# arguments.
Quality Notice 3 : Yes
# Quality Notice No. 4
# Emit a quality notice if there exists an assignment
# operator '=' within a logical 'if' condition.
Quality Notice 4 : Yes
# Quality Notice No. 5
# Emit a quality notice if there exists an assignment
# operator '=' within a logical 'while' condition.
Quality Notice 5 : Yes
# Quality Notice No. 6
# Emit a quality notice when a pre-decrement operator '--'
# is identified within the code.
Quality Notice 6 : No
# Quality Notice No. 7
# Emit a quality notice when a pre-increment operator '++'
# is identified within the code.
Quality Notice 7 : No
# Quality Notice No. 8
# Emit a quality notice when the 'realloc' function
# is identified within the code.
Quality Notice 8 : Yes
# Quality Notice No. 9
# Emit a quality notice when the 'goto' function
# is identified within the code.
Quality Notice 9 : Yes
# Quality Notice No. 10
# Emit a quality notice when the Non-ANSI function
# prototype is identified within the code.
Quality Notice 10 : Yes
# Quality Notice No. 11
# Emit a quality notice when open and closed brackets
# '[ ]' are not balance within a file.
Quality Notice 11 : Yes
# Quality Notice No. 12
# Emit a quality notice when open and closed parenthesis
# '()' are not balance within a file.
Quality Notice 12 : Yes
# Quality Notice No. 13
# Emit a quality notice when a 'switch' statement does
# not have a 'default' condition.
Quality Notice 13 : Yes
# Quality Notice No. 14
# Emit a quality notice when there are more 'case' conditions
# than 'break' statements or 'fall through' comments.
Use default in case/break comparison : Yes
Quality Notice 14 : Yes
# Quality Notice No. 15
# Emit a quality notice when a friend class
# is identified within the code.
Quality Notice 15 : Yes
# Quality Notice No. 22
# Emit a quality notice when each if, else, for
# or while is not bound by scope.
Quality Notice 22 : Yes
# Quality Notice No. 23
# Emit a quality notice when the '?' or the implied
# if-then-else construct has been identified.
Quality Notice 23 : Yes
# Quality Notice No. 24
# Emit a quality notice when an ANSI C++ keyword
# is identified within a *.c or a *.h file.
Quality Notice 24 : Yes
# Quality Notice No. 26
# Emit a quality notice when a void * is identified
# within a source file.
Quality Notice 26 : No
# Quality Notice No. 27
# Emit a quality notice when the number of function
# return points is greater than the specified maximum.
Quality Notice 27 : Yes
Maximum functional return points : 1
Count goto as a function return point : Yes
# Quality Notice No. 28
# Emit a quality notice when the cyclomatic complexity
# of a function exceeds the specified maximum.
Quality Notice 28 : Yes
Maximum functional cyclomatic complexity: 10
# Quality Notice No. 29
# Emit a quality notice when the number of function
# input parameters exceeds the specified maximum.
Quality Notice 29 : Yes
Maximum functional interface complexity : 6
# Quality Notice No. 49
# Emit a quality notice when function parameters
# are blank or not specified, thus requiring void.
Quality Notice 49 : Yes
# Quality Notice No. 30
# Emit a quality notice when a TAB character is identified
# within the source code. Indentation with TAB will create
# editor and device dependent formatting.
Quality Notice 30 : Yes
# Quality Notice No. 32
# Emit a quality notice when 'using namespace'
# has been identified in a C++ source file.
Quality Notice 32 : Yes
# Quality Notice No. 33
# Emit a quality notice when a class/struct definition
# is identified within a function definition.
Quality Notice 33 : Yes
# Quality Notice No. 34
# Emit a quality notice when a class definition
# contains a pointer to a data item.
Quality Notice 34 : Yes
# Quality Notice No. 35
# Emit a quality notice when a class definition
# contains public data.
Quality Notice 35 : Yes
# Reference Quality Notice No. 35
# Ignore public data for specific types of data
Ignore public event data : Yes
Ignore public const data : Yes
Ignore public delegate data : Yes
# Quality Notice No. 36
# Emit a quality notice when a class definition
# contains protected data.
Quality Notice 36 : Yes
# Quality Notice No. 37
# Emit a quality notice when a base class, with virtual
# functions, does not contain a virtual destructor.
Quality Notice 37 : Yes
# Quality Notice No. 38
# Emit a quality notice when exception handling is
# present within a function.
Quality Notice 38 : Yes
# Quality Notice No. 39
# Emit a quality notice when the number of class/struct methods
# exceed the specified maximum (public, protected and private).
Quality Notice 39 : Yes
Maximum number of methods per class : 100
# Quality Notice No. 40
# Emit a quality notice when the depth of the inheritance
# tree exceeds the specified maximum value.
Quality Notice 40 : Yes
Maximum depth of inheritance tree : 4
# Quality Notice No. 41
# Emit a quality notice when the number of direct derived
# classes exceeds the specified maximum value.
Quality Notice 41 : Yes
Maximum number of derived child classes : 10
# Quality Notice No. 42
# Emit a quality notice when the multiple inheritance
# has been identified.
Quality Notice 42 : Yes
# Quality Notice No. 43
# Emit a quality notice when the keyword 'continue'
# has been identified.
Quality Notice 43 : Yes
# Quality Notice No. 44
# Emit a quality notice when the keyword 'break'
# has been identified outside a 'switch' logic
# control structure.
Quality Notice 44 : Yes
# Quality Notice No. 45
# Emit a quality notice when a file does not
# have equal counts of new and delete.
Quality Notice 45 : Yes
# Quality Notice No. 50
# Emit a quality notice when a variable is assigned
# to a literal number and not a symbolic constant.
Quality Notice 50 : No
Include zero (0) as literal assignment : No
# Quality Notice No. 55
# Emit a quality notice when the depth of scope
# exceeds the specified maximum value. This condition
# indicates complex logic and/or a maintenance concern.
Quality Notice 55 : Yes
Maximum depth of scope : 6
# Quality Notice No. 56
# Emit a quality notice when sequential breaks are
# identified without a respective case statement.
Quality Notice 56 : Yes
# RSM Quality Notices for Functional/Struct and Class Content ##########
# Minimum LOC for content analysis for blank lines
# comments, and white space.
Min. Function LOC for content analysis : 5
Min. Class/Struct LOC content analysis : 10
# Quality Notice No. 16
# Emit a quality notice when function, struct, class
# or interface white space percentage is less than
# the specified minimum.
Quality Notice 16 : Yes
Minimum Function Whitespace Percent : 10.00
# Quality Notice No. 17
# Emit a quality notice when function comment line
# percentage is less than the specified minimum.
Quality Notice 17 : No
Minimum Function Comment Line Percent : 10.00
# Quality Notice No. 18
# Emit a quality notice when the eLOC within a
# function exceeds the specified maximum.
Quality Notice 18 : Yes
Maximum Function eLOC : 200
# Quality Notice No. 48
# Emit a quality notice when the lLOC within a
# function does not meet the specified minimum.
# This notice serves to find nop functions.
Quality Notice 48 : Yes
Minimum Function lLOC : 0
# Quality Notice No. 31
# Emit a quality notice when class/struct comment line
# percentage is less than the specified minimum.
Quality Notice 31 : Yes
Minimum Class/Struct Comment Percent : 10.00
# Quality Notice No. 46
# Emit a quality notice when function, struct, class
# or interface blank line percentage is less than the
# specified minimum.
Quality Notice 46 : No
Minimum Function Blank Line Percent : 10.00
# Quality Notice No. 51
# Emit a quality notice when a function
# does not have a preceding comment.
Quality Notice 51 : Yes
# Quality Notice No. 52
# Emit a quality notice when a class
# does not have a preceding comment.
Quality Notice 52 : Yes
# Quality Notice No. 53
# Emit a quality notice when a struct
# does not have a preceding comment.
Quality Notice 53 : Yes
# Quality Notice No. 54
# Emit a quality notice when a interface
# does not have a preceding comment.
Quality Notice 54 : Yes
# RSM Quality Notices for File Content #
# Quality Notice No. 19
# Emit a quality notice when file white space
# percentage is less than the specified minimum.
# Consider setting Notice 30 to No.
Quality Notice 19 : Yes
Minimum File Whitespace Percent : 10.00
A TAB is equivalent to n space : 2
# Quality Notice No. 20
# Emit a quality notice when file comment line
# percentage is less than the specified minimum.
Quality Notice 20 : Yes
Minimum File Comment Line Percent : 10.00
# Quality Notice No. 47
# Emit a quality notice when file blank line
# percentage is less than the specified minimum.
Quality Notice 47 : No
Minimum File Blank Line Percent : 10.00
# Quality Notice No. 57
# Emit a quality notice when RSM skip lines conditions
# are met by a matching token.
Quality Notice 57 : No
# Quality Notice No. 58
# Emit a quality notice when RSM skip quality notice conditions
# are met by a matching token.
Quality Notice 58 : No
# RSM Quality Notices Miscellaneous ####################################
# Quality Notice No. 25
# Deprecated in Version 6.70
# See settings under language extensions.
####################################################################
# Code Listing Report Configuration ################################
# The following parameters setup source code printing.
# These values become the default settings.
Printed Line Length : 80
Printed Page Length : 55
Printed Left Margin : 5
Printed Top Margin : 1
Printed Page Header : RSM Code Listing
Page breaks in code print format : No
####################################################################
# HTML Report and Color Configuration ##############################
# The following parameters setup HTML report output. The hyperlinks
# for source code can be either absolute or relative.
Relative HTML Links : No
# The following color parameters modify the HTML report
# output. Colors can be specified as Hex or Name.
# Blank color parameters will result to the browser default.
HTML RSM Color : #0000FF
HTML Date Color : #0000FF
HTML Text Color : #000000
HTML VLink Color : #660099
HTML Link Color : #0000EE
HTML Background Color : #F8F8F8
HTML Error Color : #FF0000
HTML Line Color : #003399
HTML Old File Differential Color : #CC0033
HTML New File Differential Color : #336666
HTML File Name Color : #0000FF
HTML Function Color : #0000FF
HTML Function Parameter Color : #006600
HTML Template Color : #006699
HTML Macro Color : #33CCFF
HTML Class Color : #663300
HTML Inheritance Color : #FF3300
HTML Struct Color : #990000
HTML Notice Color : #CC0000
HTML Header Color : #993300
HTML New Code Differential Color : #3366CC
HTML Removed Code Differential Color : #FF0000
HTML Modified Code Differential Color : #993300
HTML Equal Code Differential Color : #00CC00
HTML Total Color : #993300
HTML Inheritance Depth Color : #333300
HTML Inheritance Child Color : #CC6600
####################################################################
# end of rsm.cfg
================================================
FILE: doxygen/snippets/qepn_qhist.c
================================================
typedef struct {
QHsm super; /* inherit QHsm */
QStateHandler hist_doorClosed; /* history of doorClosed */
} ToastOven;
/*..........................................................*/
static QState ToastOven_doorClosed(ToastOven * const me) {
QState status_;
switch (Q_SIG(me)) {
~ ~ ~
case Q_EXIT_SIG: {
me->hist_doorClosed = QHsm_state(&me->super);
status_ = Q_HANDLED();
break;
}
}
return status_;
}
/*..........................................................*/
static QState ToastOven_doorOpen(ToastOven * const me) {
QState status_;
switch (Q_SIG(me)) {
~ ~ ~
case CLOSE_SIG: {
status_ = Q_TRAN_HIST(hist_doorClosed); /*<== */
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
================================================
FILE: doxygen/snippets/qepn_qhsm.c
================================================
typedef struct {
QHsm super; /* inherits QHsm */
double operand1;
double operand2;
char display[DISP_WIDTH + 1];
uint8_t len;
uint8_t opKey;
} Calc;
================================================
FILE: doxygen/snippets/qepn_qhsm_ctor.c
================================================
void Alarm_ctor(Alarm * const me) {
QHsm_ctor(&me->super, Q_STATE_CAST(&Alarm_initial));
}
================================================
FILE: doxygen/snippets/qepn_qhsm_use.c
================================================
#include "qpn.h" /* QP-nano */
#include "calc.h" /* Application interface */
Q_DEFINE_THIS_FILE
static Calc l_calc; /* an instance of Calc HSM */
int main() {
Calc_ctor(&l_calc); /* Calc HSM "constructor" invokes QHsm_ctor() */
QHSM_INIT(&l_calc.super); /* trigger initial transition, late biniding */
for (;;) { /* event loop */
. . .
/* wait for the next event and assign it to the current event */
QSIG(&l_calc) = ...
QPAR(&l_calc) = ...
QHSM_DISPATCH(&l_calc.super); /* dispatch the event, late binding */
}
return 0;
}
================================================
FILE: doxygen/snippets/qepn_qinit.c
================================================
/*..........................................................................*/
void Pelican_ctor(Pelican * const me) {
QActive_ctor(me, Q_STATE_CAST(&Pelican_initial));
}
/* HSM definition ----------------------------------------------------------*/
QState Pelican_initial(Pelican * const me) { /* the initial pseudo-state */
return Q_TRAN(&Pelican_operational);
}
/*..........................................................................*/
QState Pelican_operational(Pelican * const me) { /* a regular state handler */
QState status_;
switch (Q_SIG(me)) {
case Q_ENTRY_SIG: {
BSP_signalCars(CARS_RED);
BSP_signalPeds(PEDS_DONT_WALK);
status_ = Q_HANDLED();
break;
}
case Q_INIT_SIG: {
status_ = Q_TRAN(&Pelican_carsEnabled); /* regular transition */
break;
}
case OFF_SIG: {
status_ = Q_TRAN(&Pelican_offline); /* regular transition */
break;
}
default: {
status_ = Q_SUPER(&QHsm_top); /* the superstate */
break;
}
}
return status_;
}
================================================
FILE: doxygen/snippets/qepn_qtran.c
================================================
/* HSM definition ----------------------------------------------------------*/
QState Pelican_carsGreenNoPed(Pelican * const me) {
QState status_;
switch (Q_SIG(me)) {
case Q_ENTRY_SIG: {
BSP_showState(me->super.prio, "carsGreenNoPed");
status_ = Q_HANDLED();
break;
}
case PEDS_WAITING_SIG: {
status_ = Q_TRAN(&Pelican_carsGreenPedWait);
break;
}
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Pelican_carsGreenInt);
break;
}
default: {
status_ = Q_SUPER(&Pelican_carsGreen);
break;
}
}
return status_;
}
/*..........................................................................*/
QState Pelican_carsGreenPedWait(Pelican * const me) {
QState status_;
switch (Q_SIG(me)) {
case Q_ENTRY_SIG: {
BSP_showState(me->super.prio, "carsGreenPedWait");
status_ = Q_HANDLED();
break;
}
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Pelican_carsYellow);
break;
}
default: {
status_ = Q_SUPER(&Pelican_carsGreen);
break;
}
}
return status_;
}
================================================
FILE: doxygen/snippets/qfn_armx.c
================================================
/* when #QF_TIMEEVT_PERIODIC is NOT defined... */
QState Pelican_carsGreen(Pelican * const me) {
QState status_;
switch (Q_SIG(me)) {
case Q_ENTRY_SIG: {
/* arm timer (one-shot) at tick rate 0 */
QActive_armX(&me->super, 0U,
CARS_GREEN_MIN_TOUT);
BSP_signalCars(CARS_GREEN);
status_ = Q_HANDLED();
break;
}
case Q_EXIT_SIG: {
QActive_disarm(&me->super)
status_ = Q_HANDLED();
break;
}
case Q_INIT_SIG: {
status_ = Q_TRAN(&Pelican_carsGreenNoPed);
break;
}
default: {
status_ = Q_SUPER(&Pelican_carsEnabled);
break;
}
}
return status_;
}
/* when #QF_TIMEEVT_PERIODIC is defined... */
QState Pelican_carsGreen(Pelican * const me) {
QState status_;
switch (Q_SIG(me)) {
case Q_ENTRY_SIG: {
/* arm timer (one-shot) at tick rate 0 */
QActive_armX(&me->super, 0U,
CARS_GREEN_MIN_TOUT, 0U);
BSP_signalCars(CARS_GREEN);
status_ = Q_HANDLED();
break;
}
case Q_EXIT_SIG: {
QActive_disarm(&me->super)
status_ = Q_HANDLED();
break;
}
case Q_INIT_SIG: {
status_ = Q_TRAN(&Pelican_carsGreenNoPed);
break;
}
default: {
status_ = Q_SUPER(&Pelican_carsEnabled);
break;
}
}
return status_;
}
================================================
FILE: doxygen/snippets/qfn_main.c
================================================
#include "qpn.h" /* QP-nano API */
#include "bsp.h" /* Board Support Package (BSP) */
#include "pelican.h" /* Application interface */
/*..........................................................................*/
static QEvt l_pelicanQueue[2];
static QEvt l_pedQueue[1];
/* QF_active[] array defines all active object control blocks --------------*/
QActiveCB const Q_ROM QF_active[] = {
{ (QActive *)0, (QEvt *)0, 0 },
{ (QActive *)&AO_Pelican, l_pelicanQueue, Q_DIM(l_pelicanQueue) },
{ (QActive *)&AO_Ped, l_pedQueue, Q_DIM(l_pedQueue) }
};
/*..........................................................................*/
int_t main (void) {
Pelican_ctor(); /* instantiate the Pelican AO */
Ped_ctor(); /* instantiate the Ped AO */
QF_init(Q_DIM(QF_active)); /* initialize the QF-nano framework */
BSP_init(); /* initialize the Board Support Package */
return QF_run(); /* transfer control to QF-nano */
}
================================================
FILE: doxygen/snippets/qfn_post.c
================================================
/* event posting from the interrupt context (QACTIVE_POST_ISR()) ... */
#pragma vector=TIMER0_A0_VECTOR
__interrupt void TIMER0_A0_ISR(void) {
QK_ISR_ENTRY(); /* infrom QK-nano about entering an ISR */
QF_tickXISR(0U); /* process time events for rate 0 */
/* post TIME_TICK events to all interested active objects... */
QACTIVE_POST_ISR((QActive *)&AO_Tunnel, TIME_TICK_SIG, 0U);
QACTIVE_POST_ISR((QActive *)&AO_Ship, TIME_TICK_SIG, 0U);
QACTIVE_POST_ISR((QActive *)&AO_Missile, TIME_TICK_SIG, 0U);
QK_ISR_EXIT(); /* infrom QK-nano about exiting an ISR */
}
/* event posting from the task context (QACTIVE_POST())... */
static QState Ship_flying(Ship * const me) {
QState status_;
switch (Q_SIG(me)) {
case TIME_TICK_SIG: {
. . .
if ((me->score % 10) == 0) { /* is the score "round"? */
QACTIVE_POST((QActive *)&AO_Tunnel,
SCORE_SIG, me->score); /* signal and parameter */
}
status_ = Q_HANDLED();
break;
}
. . .
}
return status_;
}
================================================
FILE: doxygen/snippets/qfn_postx.c
================================================
/* "extended" event posting from the interrupt context (QACTIVE_POST_X_ISR) */
void SysTick_Handler(void) {
. . .
if (!QACTIVE_POST_X_ISR((QActive *)&AO_Cruncher,
5U, /* margin of free slots in the queue */
ECHO_SIG, 0U)) /* signal and parameter */
{
/* event posting failed... */
}
}
/* "extended" event posting from the task context (QACTIVE_POST_X())... */
static QState Ship_flying(Ship * const me) {
QState status_;
switch (Q_SIG(me)) {
case TIME_TICK_SIG: {
. . .
if ((me->score % 10) == 0) { /* is the score "round"? */
if (!QACTIVE_POST_X((QActive *)&AO_Tunnel,
4U, /* margin of free slots in the queue */
SCORE_SIG, me->score)) /* signal and parameter */
{
/* event posting failed... */
}
}
status_ = Q_HANDLED();
break;
}
. . .
}
return status_;
}
================================================
FILE: doxygen/snippets/qfn_qactive.c
================================================
/* PEdestrian Light CONtrolled (PELICAN) crossing active object */
typedef struct {
QActive super; /* inherits QActive */
uint8_t pedFlashCtr; /* pedestrian flash counter */
} Pelican;
/* the ctor */
void Pelican_ctor(Pelican * const me, uint8_t timeout) {
/* call the superclass' ctor... */
QActive_ctor(&me->super, Q_STATE_CAST(&Pelican_initial));
. . . /* initialize the added attributes */
}
================================================
FILE: doxygen/snippets/qfn_tickx.c
================================================
/* system clock tick ISR for MSP430 from TI (cooperative QV-nano kernel) */
#pragma vector = TIMERA0_VECTOR
__interrupt void timerA_ISR(void) {
__low_power_mode_off_on_exit();
QF_tickXISR(0U); /* handle all armed time events at tick rate 0 */
}
/* system clock tick ISR for MSP430 from TI (preemptive QK-nano kernel) */
#pragma vector = TIMERA0_VECTOR
__interrupt void timerA_ISR(void) {
QK_ISR_ENTRY(); /* inform QK-nano about entering the ISR */
QF_tickXISR(0U); /* handle all armed time events at tick rate 0 */
QK_ISR_EXIT(); /* inform QK-nano about exiting the ISR */
}
================================================
FILE: doxygen/snippets/qkn_lock.c
================================================
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
uint32_t rnd;
QSchedStatus lockStat; /* <=== QK-nano scheduler lock status */
lockStat = QK_schedLock(N_PHILO); /* <=== lock scheduler up to N_PHILO prio */
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
rnd = l_rnd * (3U*7U*11U*13U*23U);
l_rnd = rnd; /* set for the next time */
QK_schedUnlock(lockStat); /* <=== unlock the scheduler */
return (rnd >> 8);
}
================================================
FILE: doxygen/snippets/qkn_oncontextsw.c
================================================
#ifdef QK_ON_CONTEXT_SW
/* NOTE: the context-switch callback is called with interrupts DISABLED */
void QK_onContextSw(uint_fast8_t prev, uint_fast8_t next) {
(void)prev;
if (next != (uint_fast8_t)0) {
//_impure_ptr = &reentrant[next];
}
}
#endif /* QK_ON_CONTEXT_SW */
================================================
FILE: doxygen/struct.dox
================================================
/*! @page struct Structure and Features
@tableofcontents
@section files Directories and Files
The following annotated directory tree lists the top-level directories provided in the standard QP-nano distribution.
qpn/
3rd_party/ — Third-Party code used in the QP-nano @ref ports "ports" and @ref exa "examples"
examples/ — @ref exa "QP-nano Examples"
ports/ — @ref ports "QP-nano Ports"
include/ — Platform-independent QP-nano API (see @ref ../include "include")
src/ — Platform-independent QP-nano source code (see @ref ../src "src")
@note
The standard QP-nano distribution contains many @ref exa "Example Projects", which are specifically designed to help you learn to use QP-nano and to serve you as starting points for your own projects.
@section comp Components of QP-nano
The QP-nano active object framework is comprised of the following components:
@image html qpn_components.jpg "Components of the QP-nano Framework"
@subsection comp_qep QEP-nano Hierarchical Event Processor
QEP-nano is a universal, UML-compliant event processor that enables developers to code UML state machines in highly readable ANSI-C, in which every state machine element is mapped to code precisely, unambiguously, and exactly once (traceability). QEP-nano fully supports hierarchical state nesting, which is the fundamental mechanism for reusing behavior across many states instead of repeating the same actions and transitions over and over again. (See also @ref qepn).
@subsection comp_qf QF-nano Active-Object Framework
QF-nano is a portable, event-driven, active-object (actor) framework for execution of **active objects** (concurrent state machines) specifically designed for real-time embedded (RTE) systems. (See also @ref qfn).
@subsection comp_qv QV-nano Cooperative Kernel
QV-nano is a simple **cooperative** kernel (previously called "Vanilla" kernel). This kernel executes active objects one at a time, with priority-based scheduling performed before processing of each event. Due to naturally short duration of event processing in state machines, the simple QV kernel is often adequate for many real-time systems. (See also @ref qvn).
@subsection comp_qk QK-nano Preemptive Kernel
QK-nano is a tiny **preemptive**, priority-based, non-blocking, real-time kernel designed specifically for executing active objects. QK-nano meets all the requirement of the Rate Monotonic Scheduling (a.k.a. Rate Monotonic Analysis — RMA) and can be used in hard real-time systems. (See also @ref qkn).
@section classes Classes in QP-nano
The figure below shows the main classes comprising the QP-nano framework and their relation to the application-level code, such as the @ref game example application.
@image html qpn_classes.gif "Main Classes in the QP-nano Framework"
0 The ::QEvt class represents events, possibly with a parameter (the existence of event parameter is configured by the macro #Q_PARAM_SIZE).
1 The abstract ::QHsm class represents a Hierarchical State Machine (HSM) with full support for hierarchical nesting of states, entry/exit actions, initial transitions, and transitions to history in any composite state. This class is designed for ease of manual coding of HSMs in C, but it is also supported by the QM modeling tool. The class is abstract, meaning that it is not designed to be instantiated directly, but rather only for inheritance. The @ref game application provides an example of application-level classes deriving directly from ::QHsm (see [5]).
2 The abstract ::QActive class represents an active object that uses the ::QHsm style state machine implementation strategy. This strategy is tailored to manual coding, but it is also supported by the QM modeling tool. The @ref game application provides an example of application-level classes deriving directly from ::QActive (see [4]).
3 ::QActiveCB (QActive Control Block) represents the read-only (constant) information that the QF-nano needs to manage the active object. ::QActiveCB objects are grouped in the array ::QF_active, which typically can be placed in ROM.
4 Active Objects in the application derive from the ::QActive base class.
5 Applications can also use classes derived directly from the ::QHsm base class to represent "raw" state machines that are not active objects, because they don't have event queue and execution thread. Such "raw" state machines are typically used as "Orthogonal Components".
@section sm State Machines
The behavior of each active object in QP-nano is specified by means of a hierarchical state machine (UML statechart), which is the most effective and elegant technique of describing event-driven behavior. The most important innovation of UML state machines over classical finite state machines (FSMs) is the hierarchical state nesting. The value of state nesting lies in avoiding repetitions, which are inevitable in the traditional "flat" FSM formalism and are the main reason for the "state-transition explosion" in FSMs. The semantics of state nesting allow substates to define only the differences of behavior from the superstates, thus promoting sharing and reusing behavior.
@htmlonly
Application Note: A Crash Course in UML State Machines
@endhtmlonly
The Quantum Leaps Application Note A Crash Course in UML State Machines introduces the main state machine concepts backed up by examples.
@note
The hallmark of the QP-nano implementation of UML state machines is **traceability**, which is direct, precise, and unambiguous mapping of every state machine element to human-readable, portable, MISRA-compliant C code. Preserving the traceability from requirements through design to code is essential for mission-critical systems, such as medical devices or avionic systems.
@section coding Coding Standard
The QP-nano framework has been developed in strict adherence to the documented Quantum Leaps Coding Standard.
@htmlonly
Application Note: Quantum Leaps C/C++ Coding Standard
@endhtmlonly
@section misra MISRA Compliance
The QP-nano framework complies with most of the Motor Industry Software Reliability Association (MISRA) MISRA-C:2004 rules.
@endhtmlonly
All deviations are carefully limited into very specific contexts and are documented with the Application Note: QP-nano MISRA-C:2004 Compliance Matrix.
@note
MISRA and MISRA C are registered trademarks of MIRA Ltd, held on behalf of the MISRA Consortium.
The MISRA guidelines place great emphasis on the use of static code analysts tools to check compliance with the MISRA-C language subset. To this end, QP-nano comes with an extensive support for automatic rule checking with @ref lint "PC-Lint". The QP frameworks go even beyond MISRA, by complying with the strict type checking of PC-Lint.
@section pc-lint PC-Lint Support
The QP-nano framework comes with extensive support for automatic rule checking by means of PC-Lint, which is designed not just for proving compliance of the QP-nano framework code, but more importantly, to aid in checking compliance of the application-level code. Any organization engaged in designing safety-related embedded software could benefit from the unprecedented quality infrastructure built around the QP-nano framework.
@sa @ref lint "Lint Port"
*/
/*##########################################################################*/
/*! @dir ../include
Platform-independent QP-nano API
@note
The QP-nano include directory needs to be added to the compiler's include path in the applications using QP-nano.
*/
/*##########################################################################*/
/*! @dir ../src
Platform-independent QP-nano source code
Files from this directory need to be added to the project, to build the QP-nano framework from source code.
@note
The QP-nano src directory needs to be added to the compiler's include path in the applications that build QP-nano framework from sources (as opposed to using QP as a pre-built library).
*/
/*##########################################################################*/
/*! @dir ../src/qfn
Platform-independent implementation of the @ref qepn and @ref qfn components.
@note
Typically, files in this directory need to be added to the application build, but some QP ports might not need all the files in this directory. For example, a QP port to a 3rd-party RTOS kernel might be using a message queue of the RTOS instead of the native QP event queue, in which case the file qf_actq.c would not be needed and should be excluded from the build.
*/
/*##########################################################################*/
/*! @dir ../src/qvn
Platform-independent implementation of the @ref qvn built-in kernel.
@attention
Files in this directory need to be included in the QP application build only if the application uses the @ref qvn kernel.
*/
/*##########################################################################*/
/*! @dir ../src/qkn
Platform-independent implementation of the @ref qkn built-in kernel.
@attention
Files in this directory need to be included in the QP application build only if the application uses the @ref qkn kernel.
*/
================================================
FILE: examples/README.url
================================================
[InternetShortcut]
URL=http://www.state-machine.com/qpn/exa.html
IconFile=http://www.state-machine.com/qp.ico
================================================
FILE: examples/arm-cm/README.url
================================================
[InternetShortcut]
URL=http://www.state-machine.com/qpn/exa_arm-cm.html
IconFile=http://www.state-machine.com/qp.ico
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/README.txt
================================================
About this Example
==================
This directory contains a QP example application for the
EFM32-SLSTK3401A board (Pearl Gecko Starter Kit). This directory
contains portable code that should compile with any C compiler for
ARM Cortex-M.
The sub-directories contain code and project files, which are specific
to the particular ARM toolchains, such as ARM (MDK-ARM), GNU, and IAR.
Please refer to the README files in the sub-directories for specific
instructions how to use and customize the example to your needs.
Support Code for EFM32-SLSTK3401A Board
=======================================
The directory qpc\3rd_party\efm32pg1b contains the CMSIS-compliant
device code for the EFM32PG1B200F256GM48 MCU. Please see the README.txt
file in this folder for more details.
Win32-QV Emulation
==================
The sub-directory win32-qv provides the emulation of the example
on Windows GUI (with the cooperative QV scheduler). This sub-directory
contains the Makefile for the MinGW toolset and Visual Studio solution
file (game-gui.sln) for Visual C++.
The Win32-QV emulation uses exactly the same code as the embedded board and
differ only in the Board Support Package (bsp.c). This example demonstrates
the "dual targeting" development approach, where most of the embedded code
is developed on the desktop machine (Windows), but is intended for a deeply
embedded target (EFM32-SLSTK3401A here).
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/README.url
================================================
[InternetShortcut]
URL=http://www.state-machine.com/qpn/arm-cm_blinky_ek-tm4c123gxl.html
IconFile=http://www.state-machine.com/qp.ico
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/blinky.c
================================================
/*****************************************************************************
* Product: Simple Blinky example
* Last updated for version 5.4.0
* Last updated on 2015-05-18
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, www.state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "blinky.h"
#include "bsp.h"
//Q_DEFINE_THIS_FILE
/*..........................................................................*/
typedef struct BlinkyTag { /* the Blinky active object */
QActive super; /* inherit QActive */
} Blinky;
/* hierarchical state machine ... */
static QState Blinky_initial(Blinky * const me);
static QState Blinky_off (Blinky * const me);
static QState Blinky_on (Blinky * const me);
/* Global objects ----------------------------------------------------------*/
Blinky AO_Blinky; /* the single instance of the Blinky AO */
/*..........................................................................*/
void Blinky_ctor(void) {
Blinky * const me = &AO_Blinky;
QActive_ctor(&me->super, Q_STATE_CAST(&Blinky_initial));
}
/* HSM definition ----------------------------------------------------------*/
QState Blinky_initial(Blinky * const me) {
QActive_armX((QActive *)me, 0U,
BSP_TICKS_PER_SEC/2U, BSP_TICKS_PER_SEC/2U);
return Q_TRAN(&Blinky_off);
}
/*..........................................................................*/
QState Blinky_off(Blinky * const me) {
QState status;
switch (Q_SIG(me)) {
case Q_ENTRY_SIG: {
BSP_ledOff();
status = Q_HANDLED();
break;
}
case Q_TIMEOUT_SIG: {
status = Q_TRAN(&Blinky_on);
break;
}
default: {
status = Q_SUPER(&QHsm_top);
break;
}
}
return status;
}
/*..........................................................................*/
QState Blinky_on(Blinky * const me) {
QState status;
switch (Q_SIG(me)) {
case Q_ENTRY_SIG: {
BSP_ledOn();
status = Q_HANDLED();
break;
}
case Q_TIMEOUT_SIG: {
status = Q_TRAN(&Blinky_off);
break;
}
default: {
status = Q_SUPER(&QHsm_top);
break;
}
}
return status;
}
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/blinky.h
================================================
/*****************************************************************************
* Product: simple "Blinky" example
* Last updated for version 5.4.0
* Last updated on 2015-05-18
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, www.state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef BLINKY_H
#define BLINKY_H
enum BlinkySignals {
DUMMY_SIG = Q_USER_SIG,
MAX_PUB_SIG, /* the last published signal */
TIMEOUT_SIG,
MAX_SIG /* the last signal */
};
void Blinky_ctor(void);
extern struct BlinkyTag AO_Blinky;
#endif /* BLINKY_H */
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/bsp.h
================================================
/*****************************************************************************
* Product: Simple Blinky example
* Last updated for version 5.4.0
* Last updated on 2015-05-18
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, www.state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef BSP_H
#define BSP_H
#define BSP_TICKS_PER_SEC 100U
void BSP_init(void);
void BSP_ledOff(void);
void BSP_ledOn(void);
#endif /* BSP_H */
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/main.c
================================================
/*****************************************************************************
* Product: "Blinky" example
* Last Updated for Version: 5.8.0
* Date of the Last Update: 2016-04-05
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h" /* QP-nano API */
#include "bsp.h" /* Board Support Package */
#include "blinky.h" /* Application interface */
/* Local-scope objects -----------------------------------------------------*/
static QEvt l_blinkyQSto[10]; /* Event queue storage for Blinky */
/* QF_active[] array defines all active object control blocks --------------*/
QActiveCB const Q_ROM QF_active[] = {
{ (QActive *)0, (QEvt *)0, 0U },
{ (QActive *)&AO_Blinky, l_blinkyQSto, Q_DIM(l_blinkyQSto) }
};
/*..........................................................................*/
int main(void) {
Blinky_ctor(); /* instantiate all Blinky AO */
QF_init(Q_DIM(QF_active)); /* initialize the QF-nano framework */
BSP_init(); /* initialize the Board Support Package */
return QF_run(); /* transfer control to QF-nano */
}
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qk/armclang/README.txt
================================================
About this Example
==================
This example demonstrates how to use the uVision IDE together with
the MDK-ARM toolchain.
uVision Project File
====================
The MDK-ARM uVision project file provided with this example uses
relative paths to the QP framework location (includes, port, and
libraries. These relative paths must be modified when the project
is moved to different relative location.
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the
command-line options for the ARM assembler (see the Asm tab in
the "Options for Target" dialog box in uVision). Specifically,
you should define symbols: Stack_Size=xxx Heap_Size=yyy, where
xxx represents a numerical value of stack size and yyy the
numerical value of the heap size (for most embedded projects
yyy should be 0, as the using the heap is not recommended).
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\efm32pg1b\arm\startup_efm32pg1b.s
The file startup_efm32pg1b.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qk/armclang/blinky-qk.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj; *.o*.lib*.txt; *.h; *.inc*.plm*.cpp000blinky-dbg0x4ARM-ADS120000001110016553500079668.\dbg\11101101000011111110010130111111111111101011001003Segger\JL2CM3.dll0DLGUARM/0JL2CM3-U440060969 -O207 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO7 -FD20000000 -FC8000 -FN1 -FF0GECKOP2.FLM -FS00 -FL040000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10UL2CM3UL2CM3(-O207 -S0 -C0 -FO7 -FN1 -FC8000 -FD20000000 -FF0GECKOP2 -FL020000 -FS00 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)0DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E2006F4 -O4622 -S4 -FO61120x200002000200x40000001000010000000000000000000blinky-rel0x4ARM-ADS120000001110016553500079668.\rel\11101101000011111110010030111111111111101011001003Segger\JL2CM3.dll0JL2CM3-U440060969 -O207 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO7 -FD20000000 -FC8000 -FN1 -FF0GECKOP2.FLM -FS00 -FL020000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)0DLGUARM/0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E10259B -O4622 -S4 -FO610UL2CM3-O207 -S0 -C0 -FO7 -FN1 -FC8000 -FD20000000 -FF0GECKOP2 -FL020000 -FS00 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)120x200002000200x40000001000010000000000000000000Applicatioin1000111000..\bsp.cbsp.c00121000..\..\blinky.cblinky.c00131000..\..\main.cmain.c00145000..\..\blinky.hblinky.h00151000..\..\..\..\..\include\qstamp.cqstamp.c00efm32pg1b1000261000..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.cem_cmu.c00271000..\..\..\..\..\3rd_party\efm32pg1b\em_emu.cem_emu.c00281000..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.cem_gpio.c00291000..\..\..\..\..\3rd_party\efm32pg1b\em_int.cem_int.c002101000..\..\..\..\..\3rd_party\efm32pg1b\em_rtcc.cem_rtcc.c002111000..\..\..\..\..\3rd_party\efm32pg1b\em_system.cem_system.c002121000..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.csystem_efm32pg1b.c002132000..\..\..\..\..\3rd_party\efm32pg1b\arm\startup_efm32pg1b.sstartup_efm32pg1b.s00QP10003141000..\..\..\..\..\src\qfn\qepn.cqepn.c003151000..\..\..\..\..\src\qfn\qfn.cqfn.c003161000..\..\..\..\..\src\qkn\qkn.cqkn.c00QP_port10004175000..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqfn_port.h004181000..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.cqkn_port.c00
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qk/armclang/blinky-qk.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwareblinky-dbg0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1EFM32PG1B200F256GM48Silicon LabsSiliconLabs.EFM32PG1B_DFP.5.5.0https://www.silabs.com/documents/public/cmsis-packs/IRAM(0x20000000,0x00008000) IROM(0x00000000,0x00020000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC8000 -FN1 -FF0GECKOP2 -FS00 -FL020000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM))0$$Device:EFM32PG1B200F256GM48$Device\EFM32PG1B\Include\em_device.h$$Device:EFM32PG1B200F256GM48$SVD\EFM32PG1B\EFM32PG1B200F256GM48.svd0000001.\dbg\blinky-qk10011.\dbg\10000000010cmd /c "del .\dbg\qstamp.o"000010fromelf --bin --output .\dbg\blinky-qk.bin .\dbg\blinky-qk.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140961BIN\UL2CM3.DLL"" ()0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x2000000x00x010x00x010x00x010x00x010x00x2000010x00x000x00x000x00x000x00x000x200000000x800000x00x007001000003011003300000EFM32PG1B200F256GM48=1 __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\efm32pg1b1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cblinky.c1..\..\blinky.cmain.c1..\..\main.cblinky.h5..\..\blinky.hqstamp.c1..\..\..\..\..\include\qstamp.cefm32pg1bem_cmu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.cem_emu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_emu.cem_gpio.c1..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.cem_int.c1..\..\..\..\..\3rd_party\efm32pg1b\em_int.cem_rtcc.c1..\..\..\..\..\3rd_party\efm32pg1b\em_rtcc.cem_system.c1..\..\..\..\..\3rd_party\efm32pg1b\em_system.csystem_efm32pg1b.c1..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.cstartup_efm32pg1b.s2..\..\..\..\..\3rd_party\efm32pg1b\arm\startup_efm32pg1b.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.cblinky-rel0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1EFM32PG1B200F256GM48Silicon LabsSiliconLabs.EFM32PG1B_DFP.5.5.0https://www.silabs.com/documents/public/cmsis-packs/IRAM(0x20000000,0x00008000) IROM(0x00000000,0x00020000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC8000 -FN1 -FF0GECKOP2 -FS00 -FL020000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM))0$$Device:EFM32PG1B200F256GM48$Device\EFM32PG1B\Include\em_device.h$$Device:EFM32PG1B200F256GM48$SVD\EFM32PG1B\EFM32PG1B200F256GM48.svd0000001.\rel\blinky-qk10000.\rel\10000000010cmd /c "del .\rel\qstamp.o"000010fromelf --bin --output .\rel\blinky-qk.bin .\rel\blinky-qk.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140961BIN\UL2CM3.DLL"" ()0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x2000000x00x010x00x010x00x010x00x010x00x2000010x00x000x00x000x00x000x00x000x200000000x800000x00x007001000003011003300000NDEBUG EFM32PG1B200F256GM48=1 __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\efm32pg1b1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000blinky-qk.sct--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cblinky.c1..\..\blinky.cmain.c1..\..\main.cblinky.h5..\..\blinky.hqstamp.c1..\..\..\..\..\include\qstamp.cefm32pg1bem_cmu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.cem_emu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_emu.cem_gpio.c1..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.cem_int.c1..\..\..\..\..\3rd_party\efm32pg1b\em_int.cem_rtcc.c1..\..\..\..\..\3rd_party\efm32pg1b\em_rtcc.cem_system.c1..\..\..\..\..\3rd_party\efm32pg1b\em_system.csystem_efm32pg1b.c1..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.cstartup_efm32pg1b.s2..\..\..\..\..\3rd_party\efm32pg1b\arm\startup_efm32pg1b.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.c
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qk/bsp.c
================================================
/*****************************************************************************
* Product: "Blinky" on EFM32-SLSTK3401A board, preemptive QK kernel
* Last Updated for Version: 5.6.5
* Date of the Last Update: 2016-06-02
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "blinky.h"
#include "bsp.h"
#include "em_device.h" /* the device specific header (SiLabs) */
#include "em_cmu.h" /* Clock Management Unit (SiLabs) */
#include "em_gpio.h" /* GPIO (SiLabs) */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
enum KernelUnawareISRs { /* see NOTE00 */
/* ... */
MAX_KERNEL_UNAWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-unaware" interrupts can't overlap "kernel-aware" interrupts */
Q_ASSERT_COMPILE(MAX_KERNEL_UNAWARE_CMSIS_PRI <= QF_AWARE_ISR_CMSIS_PRI);
enum KernelAwareISRs {
SYSTICK_PRIO = QF_AWARE_ISR_CMSIS_PRI, /* see NOTE00 */
/* ... */
MAX_KERNEL_AWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-aware" interrupts should not overlap the PendSV priority */
Q_ASSERT_COMPILE(MAX_KERNEL_AWARE_CMSIS_PRI <= (0xFF >>(8-__NVIC_PRIO_BITS)));
/* ISRs defined in this BSP ------------------------------------------------*/
void SysTick_Handler(void);
/* Local-scope objects -----------------------------------------------------*/
#define LED_PORT gpioPortF
#define LED0_PIN 4
#define LED1_PIN 5
#define PB_PORT gpioPortF
#define PB0_PIN 6
#define PB1_PIN 7
/* ISRs used in this project ===============================================*/
void SysTick_Handler(void) {
QK_ISR_ENTRY(); /* inform QK about entering an ISR */
QF_tickXISR(0U); /* process time events for rate 0 */
QK_ISR_EXIT(); /* inform QK about exiting an ISR */
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* NOTE: SystemInit() already called from the startup code
* but SystemCoreClock needs to be updated
*/
SystemCoreClockUpdate();
/* configure the FPU usage by choosing one of the options... */
#if 1
/* OPTION 1:
* Use the automatic FPU state preservation and the FPU lazy stacking.
*
* NOTE:
* Use the following setting when FPU is used in more than one task or
* in any ISRs. This setting is the safest and recommended, but requires
* extra stack space and CPU cycles.
*/
FPU->FPCCR |= (1U << FPU_FPCCR_ASPEN_Pos) | (1U << FPU_FPCCR_LSPEN_Pos);
#else
/* OPTION 2:
* Do NOT to use the automatic FPU state preservation and
* do NOT to use the FPU lazy stacking.
*
* NOTE:
* Use the following setting when FPU is used in ONE task only and not
* in any ISR. This setting is very efficient, but if more than one task
* (or ISR) start using the FPU, this can lead to corruption of the
* FPU registers. This option should be used with CAUTION.
*/
FPU->FPCCR &= ~((1U << FPU_FPCCR_ASPEN_Pos)
| (1U << FPU_FPCCR_LSPEN_Pos));
#endif
/* enable clock for to the peripherals used by this application... */
CMU_ClockEnable(cmuClock_HFPER, true);
CMU_ClockEnable(cmuClock_GPIO, true);
CMU_ClockEnable(cmuClock_HFPER, true);
CMU_ClockEnable(cmuClock_GPIO, true);
/* configure the LEDs */
GPIO_PinModeSet(LED_PORT, LED0_PIN, gpioModePushPull, 0);
GPIO_PinModeSet(LED_PORT, LED1_PIN, gpioModePushPull, 0);
GPIO_PinOutClear(LED_PORT, LED0_PIN);
GPIO_PinOutClear(LED_PORT, LED1_PIN);
/* configure the Buttons */
GPIO_PinModeSet(PB_PORT, PB0_PIN, gpioModeInputPull, 1);
GPIO_PinModeSet(PB_PORT, PB1_PIN, gpioModeInputPull, 1);
}
/*..........................................................................*/
void BSP_ledOff(void) {
//GPIO_PinOutClear(LED_PORT, LED0_PIN);
GPIO->P[LED_PORT].DOUT &= ~(1U << LED0_PIN);
}
/*..........................................................................*/
void BSP_ledOn(void) {
/* exercise the FPU with some floating point computations */
float volatile x = 3.1415926F;
x = x + 2.7182818F;
//GPIO_PinOutSet(LED0_PORT, LED0_PIN);
GPIO->P[LED_PORT].DOUT |= (1U << LED0_PIN);
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set up the SysTick timer to fire at BSP_TICKS_PER_SEC rate */
SysTick_Config(SystemCoreClock / BSP_TICKS_PER_SEC);
/* assing all priority bits for preemption-prio. and none to sub-prio. */
NVIC_SetPriorityGrouping(0U);
/* set priorities of ALL ISRs used in the system, see NOTE00
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
NVIC_SetPriority(SysTick_IRQn, SYSTICK_PRIO);
/* ... */
/* enable IRQs... */
}
/*..........................................................................*/
void QK_onIdle(void) {
/* toggle LED1 on and then off, see NOTE01 */
QF_INT_DISABLE();
GPIO->P[LED_PORT].DOUT |= (1U << LED1_PIN);
GPIO->P[LED_PORT].DOUT &= ~(1U << LED1_PIN);
QF_INT_ENABLE();
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular Cortex-M3 MCU.
*/
__WFI(); /* Wait-For-Interrupt */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int loc) {
/*
* NOTE: add here your application-specific error handling
*/
(void)module;
(void)loc;
#ifndef NDEBUG
/* light up both LEDs */
GPIO->P[LED_PORT].DOUT |= ((1U << LED0_PIN) | (1U << LED1_PIN));
/* for debugging, hang on in an endless loop until PB1 is pressed... */
while ((GPIO->P[PB_PORT].DIN & (1U << PB1_PIN)) != 0) {
}
#endif
NVIC_SystemReset();
}
/*****************************************************************************
* NOTE00:
* The QF_AWARE_ISR_CMSIS_PRI constant from the QF port specifies the highest
* ISR priority that is disabled by the QF framework. The value is suitable
* for the NVIC_SetPriority() CMSIS function.
*
* Only ISRs prioritized at or below the QF_AWARE_ISR_CMSIS_PRI level (i.e.,
* with the numerical values of priorities equal or higher than
* QF_AWARE_ISR_CMSIS_PRI) are allowed to call any QF services. These ISRs
* are "QF-aware".
*
* Conversely, any ISRs prioritized above the QF_AWARE_ISR_CMSIS_PRI priority
* level (i.e., with the numerical values of priorities less than
* QF_AWARE_ISR_CMSIS_PRI) are never disabled and are not aware of the kernel.
* Such "QF-unaware" ISRs cannot call any QF services. The only mechanism
* by which a "QF-unaware" ISR can communicate with the QF framework is by
* triggering a "QF-aware" ISR, which can post/publish events.
*
* NOTE01:
* One of the LEDs is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qk/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano on EMF32-SLSTK3401A, QK-nano kernel, GNU-ARM
# Last Updated for Version: 6.5.0
# Date of the Last Update: 2019-04-15
#
# Q u a n t u m L e a P s
# ------------------------
# Modern Embedded Software
#
# Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# https://www.state-machine.com
# mailto:info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := blinky-qk
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/arm-cm/qk/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qkn \
$(QP_PORT_DIR) \
$(QPN)/3rd_party/efm32pg1b \
$(QPN)/3rd_party/efm32pg1b/gnu
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR) \
-I$(QPN)/3rd_party/CMSIS/Include \
-I$(QPN)/3rd_party/efm32pg1b
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
blinky.c \
bsp.c \
main.c \
startup_efm32pg1b.c \
system_efm32pg1b.c \
em_cmu.c \
em_emu.c \
em_gpio.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qepn.c \
qfn.c \
qkn.c \
qkn_port.c
QP_ASMS :=
LIB_DIRS :=
LIBS :=
# defines
DEFINES := -DEFM32PG1B200F256GM48=1
# ARM CPU, ARCH, FPU, and Float-ABI types...
# ARM_CPU: [cortex-m0 | cortex-m0plus | cortex-m1 | cortex-m3 | cortex-m4]
# ARM_ARCH: [6 | 7] (NOTE: must match ARM_CPU!)
# ARM_FPU: [ | vfp]
# FLOAT_ABI: [ | soft | softfp | hard]
#
ARM_CPU := -mcpu=cortex-m4
ARM_ARCH := 7 # NOTE: must match the ARM_CPU!
ARM_FPU := -mfpu=vfp
FLOAT_ABI := -mfloat-abi=softfp
#-----------------------------------------------------------------------------
# GNU-ARM toolset (NOTE: You need to adjust to your machine)
# see https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
#
ifeq ($(GNU_ARM),)
GNU_ARM := $(QTOOLS)/gnu_arm-none-eabi
endif
# make sure that the GNU-ARM toolset exists...
ifeq ("$(wildcard $(GNU_ARM))","")
$(error GNU_ARM toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_ARM)/bin/arm-none-eabi-gcc
CPP := $(GNU_ARM)/bin/arm-none-eabi-g++
AS := $(GNU_ARM)/bin/arm-none-eabi-as
LINK := $(GNU_ARM)/bin/arm-none-eabi-g++
BIN := $(GNU_ARM)/bin/arm-none-eabi-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M
#
# combine all the soruces...
C_SRCS += $(QP_SRCS)
ASM_SRCS += $(QP_ASMS)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS = $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration ..........................................
BIN_DIR := dbg
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O $(INCLUDES) $(DEFINES)
CPPFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES)
endif # ......................................................................
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
-specs=nosys.specs -specs=nano.specs \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_BIN := $(BIN_DIR)/$(OUTPUT).bin
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_BIN)
#all: $(TARGET_ELF)
$(TARGET_BIN): $(TARGET_ELF)
$(BIN) -O binary $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(CC) $(CFLAGS) $(QPN)/include/qstamp.c -o $(BIN_DIR)/qstamp.o
$(LINK) $(LINKFLAGS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.bin \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qk/gnu/README.txt
================================================
About this Example
==================
This example can be built from the command prompt with the provided
Makefile. The example can also be imported as a Makefile-based
project into Eclipse-based IDEs.
The Makefile
============
The provided Makefile should be easy to adapt for your own projects.
It contains two build configurations: Debug (default) and Release.
Also, the Makefile has been specifically designed to work as an external
Makefile with the Eclipse CDT.
The various build configurations are built as follows:
make
make CONF=rel
make clean
make CONF=rel clean
***
NOTE:
The installation folder of the GNU-ARM toolset on YOUR machine needs
to be adjusted in the provided Makefile, by editing the symbol: GNU_ARM.
As described in the comment for this symbol, the GNU-ARM toolset is taken
from: http://gnutoolchains.com/arm-eabi
It is highly recommened to use the same GNU-ARM distribution, especially
for ARM Cortex-M4F projects, due to the support for the hardware FPU
(float-abi=hard).
***
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the GCC linker
script (.ld file), which provides a template of the recommended GCC linker
script for QP applications.
Startup Code
============
The startup code for the EFM32PG1B200F256GM48 MCU used in this project
is located in the "3rd_party" folder in the following location:
qpc\3rd_party\efm32pg1b\gnu\startup_efm32pg1b.c
The file startup_efm32pg1b.c provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qk/gnu/blinky-qk.ld
================================================
/*****************************************************************************
* Product: Linker script for EFM32-SLSTK3401A, GNU-ARM linker
* Last Updated for Version: 5.9.8
* Date of the Last Update: 2017-09-13
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* http://www.state-machine.com
* mailto:info@state-machine.com
*****************************************************************************/
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(Reset_Handler) /* entry Point */
MEMORY { /* memory map of Pearl Gecko EFM32PG1B200F256GM48 */
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 256K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
}
/* The size of the stack used by the application. NOTE: you need to adjust */
STACK_SIZE = 1024;
/* The size of the heap used by the application. NOTE: you need to adjust */
HEAP_SIZE = 0;
SECTIONS {
.isr_vector : { /* the vector table goes FIRST into ROM */
KEEP(*(.isr_vector)) /* vector table */
. = ALIGN(4);
} >ROM
.text : { /* code and constants */
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} >ROM
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >ROM
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >ROM
.fini_array : {
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array*))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >ROM
_etext = .; /* global symbols at end of code */
.stack : {
__stack_start__ = .;
. = . + STACK_SIZE;
. = ALIGN(4);
__stack_end__ = .;
} >RAM
.data : AT (_etext) {
__data_load = LOADADDR (.data);
__data_start = .;
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
__data_end__ = .;
_edata = __data_end__;
} >RAM
.bss : {
__bss_start__ = .;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = .;
} >RAM
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >RAM
__exidx_end = .;
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );
PROVIDE ( __end__ = _ebss );
.heap : {
__heap_start__ = .;
. = . + HEAP_SIZE;
. = ALIGN(4);
__heap_end__ = .;
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ : {
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
}
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qk/gnu/flash.bat
================================================
::============================================================================
:: Batch file to program the flash of EFM32-SLSTK3401A board
::
:: NOTE: requires the J-Link commander (JLink.exe) from SEGGER, see:
:: https://www.segger.com/j-link-commander.html
::
setlocal
@echo off
@echo Load a given binary file to the flash of EFM32-SLSTK3401A
@echo usage: flash bin-file
@echo example: flash dbg\blinky-qk.bin
::----------------------------------------------------------------------------
:: NOTE: Adjust the following symbol to the location of the
:: JLink utility on your machine
::
if [%JLINK%] EQU [] set JLINK=%QTOOLS%\..\JLink
if not exist "%JLINK%\JLink.exe" (
@echo The JLink tool not found. Please adjust flash.bat
@goto end
)
if ["%~1"]==[""] (
@echo The binary file missing
@goto end
)
if not exist %~s1 (
@echo The binary file '%1' does not exist
@goto end
)
:: generate the Jlink command file depending on the first parameter %1
@echo si 1 >flash.jlink
@echo speed 4000 >>flash.jlink
@echo r >>flash.jlink
@echo h >>flash.jlink
@echo loadbin %1, 0 >>flash.jlink
@echo exit >>flash.jlink
@echo on
%JLINK%\JLink.exe -device EFM32PG1B200F256GM48 flash.jlink
@echo off
@del flash.jlink
:end
endlocal
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qk/iar/README.txt
================================================
About this Example
==================
This example demonstrates how to use the IAR EWARM IDE to build
a QP application.
IAR Project File
----------------
The IAR EWARM project file provided with this example uses relative paths
to the QP/C framework location (includes, port, and libraries. These
relative paths must be modified when the project is moved to different
relative location.
Stack Size and Heap Size
------------------------
In this project, the size of the C stack and heap are determined in
the linker script blinky-qk.icf (see the next section).
Linker Script
-------------
The IAR linker script provides a template of the recommended linker script
for QP applications. This file needs to be customized to set the
application-specific sizes of the Stack and Heap. This file can be edited
from the IAR EWARM IDE via the Project Options/Linker settings.
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\efm32pg1b\iar\startup_efm32pg1b.s
The file startup_efm32pg1b.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qk/iar/blinky-qk.ewd
================================================
3DebugARM1C-SPY22811ARMSIM_ID2111CADI_ID2011CMSISDAP_ID2411GDBSERVER_ID2011IJET_ID2811JLINK_ID21611LMIFTDI_ID2211PEMICRO_ID2311STLINK_ID2411THIRDPARTY_ID2011TIFET_ID2111XDS100_ID2611$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseARM0C-SPY22810ARMSIM_ID2110CADI_ID2010CMSISDAP_ID2410GDBSERVER_ID2010IJET_ID2810JLINK_ID21610LMIFTDI_ID2210PEMICRO_ID2310STLINK_ID2410THIRDPARTY_ID2010TIFET_ID2110XDS100_ID2610$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qk/iar/blinky-qk.ewp
================================================
3DebugARM1General32811ICCARM23411AARM21011OBJCOPY0111CUSTOM30BICOMP0BUILDACTION1cmd /c "if exist $OBJ_DIR$\qstamp.o del $OBJ_DIR$\qstamp.o"ILINK02011IARCHIVE0011BILINK0Coder0ReleaseARM0General32810ICCARM23410AARM21010OBJCOPY0110CUSTOM30BICOMP0BUILDACTION1cmd /c "if exist $OBJ_DIR$\qstamp.o del $OBJ_DIR$\qstamp.o"ILINK02010IARCHIVE0010BILINK0Coder0Application$PROJ_DIR$\..\..\blinky.c$PROJ_DIR$\..\..\blinky.h$PROJ_DIR$\..\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\main.c$PROJ_DIR$\..\..\..\..\..\include\qstamp.cefm32pg1b$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_assert.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_emu.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_system.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\iar\startup_efm32pg1b.s$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.cQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qkn\qkn.cQP_port$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qk\iar\qkn_port.c
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qk/iar/blinky-qk.eww
================================================
$WS_DIR$\blinky-qk.ewp
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qk/iar/blinky-qk.icf
================================================
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0003FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 1024;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place at start of RAM_region {block CSTACK };
place in RAM_region { readwrite, block HEAP };
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qpn_conf.h
================================================
/*****************************************************************************
* Product: QP-nano configuration for the Blinky example
* Last Updated for Version: 5.6.2
* Date of the Last Update: 2016-04-05
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef QPN_CONF_H
#define QPN_CONF_H
#define Q_PARAM_SIZE 4U
#define QF_MAX_TICK_RATE 1U
#define QF_TIMEEVT_CTR_SIZE 2U
#define QF_TIMEEVT_PERIODIC
#endif /* QPN_CONF_H */
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qv/armclang/README.txt
================================================
About this Example
==================
This example demonstrates how to use the uVision IDE together with
the MDK-ARM toolchain.
uVision Project File
====================
The MDK-ARM uVision project file provided with this example uses
relative paths to the QP framework location (includes, port, and
libraries. These relative paths must be modified when the project
is moved to different relative location.
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the
command-line options for the ARM assembler (see the Asm tab in
the "Options for Target" dialog box in uVision). Specifically,
you should define symbols: Stack_Size=xxx Heap_Size=yyy, where
xxx represents a numerical value of stack size and yyy the
numerical value of the heap size (for most embedded projects
yyy should be 0, as the using the heap is not recommended).
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\efm32pg1b\arm\startup_efm32pg1b.s
The file startup_efm32pg1b.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qv/armclang/blinky-qv.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj; *.o*.lib*.txt; *.h; *.inc*.plm*.cpp000blinky-dbg0x4ARM-ADS120000001110016553500079668.\dbg\11101101000011111110010130111111111111101011001003Segger\JL2CM3.dll0DLGUARM/0JL2CM3-U440060969 -O207 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO7 -FD20000000 -FC8000 -FN1 -FF0GECKOP2.FLM -FS00 -FL040000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10UL2CM3UL2CM3(-O207 -S0 -C0 -FO7 -FN1 -FC8000 -FD20000000 -FF0GECKOP2 -FL020000 -FS00 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)0DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E2006F4 -O4622 -S4 -FO61120x200002000200x40000001000010000000000000000000blinky-rel0x4ARM-ADS120000001110016553500079668.\rel\11101101000011111110010030111111111111101011001003Segger\JL2CM3.dll0JL2CM3-U440060969 -O207 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO7 -FD20000000 -FC8000 -FN1 -FF0GECKOP2.FLM -FS00 -FL020000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)0DLGUARM/0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E10259B -O4622 -S4 -FO610UL2CM3-O207 -S0 -C0 -FO7 -FN1 -FC8000 -FD20000000 -FF0GECKOP2 -FL020000 -FS00 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)120x200002000200x40000001000010000000000000000000Applicatioin0000111000..\bsp.cbsp.c00121000..\..\blinky.cblinky.c00131000..\..\main.cmain.c00145000..\..\blinky.hblinky.h00151000..\..\..\..\..\include\qstamp.cqstamp.c00efm32pg1b1000261000..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.cem_cmu.c00271000..\..\..\..\..\3rd_party\efm32pg1b\em_emu.cem_emu.c00281000..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.cem_gpio.c00291000..\..\..\..\..\3rd_party\efm32pg1b\em_int.cem_int.c002101000..\..\..\..\..\3rd_party\efm32pg1b\em_rtcc.cem_rtcc.c002111000..\..\..\..\..\3rd_party\efm32pg1b\em_system.cem_system.c002121000..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.csystem_efm32pg1b.c002132000..\..\..\..\..\3rd_party\efm32pg1b\arm\startup_efm32pg1b.sstartup_efm32pg1b.s00QP10003141000..\..\..\..\..\src\qfn\qepn.cqepn.c003151000..\..\..\..\..\src\qfn\qfn.cqfn.c003161000..\..\..\..\..\src\qvn\qvn.cqvn.c00QP_port10004175000..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqfn_port.h004181000..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.cqvn_port.c00
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qv/armclang/blinky-qv.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwareblinky-dbg0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1EFM32PG1B200F256GM48Silicon LabsSiliconLabs.EFM32PG1B_DFP.5.5.0https://www.silabs.com/documents/public/cmsis-packs/IRAM(0x20000000,0x00008000) IROM(0x00000000,0x00020000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC8000 -FN1 -FF0GECKOP2 -FS00 -FL020000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM))0$$Device:EFM32PG1B200F256GM48$Device\EFM32PG1B\Include\em_device.h$$Device:EFM32PG1B200F256GM48$SVD\EFM32PG1B\EFM32PG1B200F256GM48.svd0000001.\dbg\blinky-qv10011.\dbg\10000000010cmd /c "del .\dbg\qstamp.o"000010fromelf --bin --output .\dbg\blinky-qv.bin .\dbg\blinky-qv.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140961BIN\UL2CM3.DLL"" ()0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x2000000x00x010x00x010x00x010x00x010x00x2000010x00x000x00x000x00x000x00x000x200000000x800000x00x007001000003011003300000EFM32PG1B200F256GM48=1 __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\efm32pg1b1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cblinky.c1..\..\blinky.cmain.c1..\..\main.cblinky.h5..\..\blinky.hqstamp.c1..\..\..\..\..\include\qstamp.cefm32pg1bem_cmu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.cem_emu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_emu.cem_gpio.c1..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.cem_int.c1..\..\..\..\..\3rd_party\efm32pg1b\em_int.cem_rtcc.c1..\..\..\..\..\3rd_party\efm32pg1b\em_rtcc.cem_system.c1..\..\..\..\..\3rd_party\efm32pg1b\em_system.csystem_efm32pg1b.c1..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.cstartup_efm32pg1b.s2..\..\..\..\..\3rd_party\efm32pg1b\arm\startup_efm32pg1b.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.cblinky-rel0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1EFM32PG1B200F256GM48Silicon LabsSiliconLabs.EFM32PG1B_DFP.5.5.0https://www.silabs.com/documents/public/cmsis-packs/IRAM(0x20000000,0x00008000) IROM(0x00000000,0x00020000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC8000 -FN1 -FF0GECKOP2 -FS00 -FL020000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM))0$$Device:EFM32PG1B200F256GM48$Device\EFM32PG1B\Include\em_device.h$$Device:EFM32PG1B200F256GM48$SVD\EFM32PG1B\EFM32PG1B200F256GM48.svd0000001.\rel\blinky-qv10000.\rel\10000000010cmd /c "del .\rel\qstamp.o"000010fromelf --bin --output .\rel\blinky-qv.bin .\rel\blinky-qv.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140961BIN\UL2CM3.DLL"" ()0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x2000000x00x010x00x010x00x010x00x010x00x2000010x00x000x00x000x00x000x00x000x200000000x800000x00x007001000003011003300000NDEBUG EFM32PG1B200F256GM48=1 __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\efm32pg1b1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000blinky-qv.sct--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cblinky.c1..\..\blinky.cmain.c1..\..\main.cblinky.h5..\..\blinky.hqstamp.c1..\..\..\..\..\include\qstamp.cefm32pg1bem_cmu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.cem_emu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_emu.cem_gpio.c1..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.cem_int.c1..\..\..\..\..\3rd_party\efm32pg1b\em_int.cem_rtcc.c1..\..\..\..\..\3rd_party\efm32pg1b\em_rtcc.cem_system.c1..\..\..\..\..\3rd_party\efm32pg1b\em_system.csystem_efm32pg1b.c1..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.cstartup_efm32pg1b.s2..\..\..\..\..\3rd_party\efm32pg1b\arm\startup_efm32pg1b.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.c
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qv/bsp.c
================================================
/*****************************************************************************
* Product: "Blinky" on EFM32-SLSTK3401A board, cooperative QV kernel
* Last Updated for Version: 5.6.5
* Date of the Last Update: 2016-06-02
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "blinky.h"
#include "bsp.h"
#include "em_device.h" /* the device specific header (SiLabs) */
#include "em_cmu.h" /* Clock Management Unit (SiLabs) */
#include "em_gpio.h" /* GPIO (SiLabs) */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
enum KernelUnawareISRs { /* see NOTE00 */
/* ... */
MAX_KERNEL_UNAWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-unaware" interrupts can't overlap "kernel-aware" interrupts */
Q_ASSERT_COMPILE(MAX_KERNEL_UNAWARE_CMSIS_PRI <= QF_AWARE_ISR_CMSIS_PRI);
enum KernelAwareISRs {
SYSTICK_PRIO = QF_AWARE_ISR_CMSIS_PRI, /* see NOTE00 */
/* ... */
MAX_KERNEL_AWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-aware" interrupts should not overlap the PendSV priority */
Q_ASSERT_COMPILE(MAX_KERNEL_AWARE_CMSIS_PRI <= (0xFF >>(8-__NVIC_PRIO_BITS)));
/* ISRs defined in this BSP ------------------------------------------------*/
void SysTick_Handler(void);
/* Local-scope objects -----------------------------------------------------*/
#define LED_PORT gpioPortF
#define LED0_PIN 4
#define LED1_PIN 5
#define PB_PORT gpioPortF
#define PB0_PIN 6
#define PB1_PIN 7
/* ISRs used in this project ===============================================*/
void SysTick_Handler(void) {
QF_tickXISR(0U); /* process time events for rate 0 */
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* NOTE: SystemInit() already called from the startup code
* but SystemCoreClock needs to be updated
*/
SystemCoreClockUpdate();
/* configure the FPU usage by choosing one of the options...
*
* Do NOT to use the automatic FPU state preservation and
* do NOT to use the FPU lazy stacking.
*
* NOTE:
* Use the following setting when FPU is used only by active objects
* and NOT in any ISR. This setting is very efficient, but if any ISRs
* start using the FPU, this can lead to corruption of the FPU registers.
*/
FPU->FPCCR &= ~((1U << FPU_FPCCR_ASPEN_Pos) | (1U << FPU_FPCCR_LSPEN_Pos));
/* enable clock for to the peripherals used by this application... */
CMU_ClockEnable(cmuClock_HFPER, true);
CMU_ClockEnable(cmuClock_GPIO, true);
CMU_ClockEnable(cmuClock_HFPER, true);
CMU_ClockEnable(cmuClock_GPIO, true);
/* configure the LEDs */
GPIO_PinModeSet(LED_PORT, LED0_PIN, gpioModePushPull, 0);
GPIO_PinModeSet(LED_PORT, LED1_PIN, gpioModePushPull, 0);
GPIO_PinOutClear(LED_PORT, LED0_PIN);
GPIO_PinOutClear(LED_PORT, LED1_PIN);
/* configure the Buttons */
GPIO_PinModeSet(PB_PORT, PB0_PIN, gpioModeInputPull, 1);
GPIO_PinModeSet(PB_PORT, PB1_PIN, gpioModeInputPull, 1);
}
/*..........................................................................*/
void BSP_ledOff(void) {
//GPIO_PinOutClear(LED_PORT, LED0_PIN);
GPIO->P[LED_PORT].DOUT &= ~(1U << LED0_PIN);
}
/*..........................................................................*/
void BSP_ledOn(void) {
/* exercise the FPU with some floating point computations */
float volatile x = 3.1415926F;
x = x + 2.7182818F;
//GPIO_PinOutSet(LED0_PORT, LED0_PIN);
GPIO->P[LED_PORT].DOUT |= (1U << LED0_PIN);
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set up the SysTick timer to fire at BSP_TICKS_PER_SEC rate */
SysTick_Config(SystemCoreClock / BSP_TICKS_PER_SEC);
/* assing all priority bits for preemption-prio. and none to sub-prio. */
NVIC_SetPriorityGrouping(0U);
/* set priorities of ALL ISRs used in the system, see NOTE00
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
NVIC_SetPriority(SysTick_IRQn, SYSTICK_PRIO);
/* ... */
/* enable IRQs... */
}
/*..........................................................................*/
void QV_onIdle(void) { /* CATION: called with interrupts DISABLED, NOTE01 */
/* toggle LED1 on and then off, see NOTE02 */
GPIO_PinOutSet(LED_PORT, LED1_PIN);
//GPIO->P[LED_PORT].DOUT |= (1U << LED1_PIN);
GPIO_PinOutClear(LED_PORT, LED1_PIN);
//GPIO->P[LED_PORT].DOUT &= ~(1U << LED1_PIN);
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular Cortex-M MCU.
*/
QV_CPU_SLEEP(); /* atomically go to sleep and enable interrupts */
#else
QF_INT_ENABLE(); /* just enable interrupts */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int loc) {
/*
* NOTE: add here your application-specific error handling
*/
(void)module;
(void)loc;
#ifndef NDEBUG
/* light up both LEDs */
GPIO->P[LED_PORT].DOUT |= ((1U << LED0_PIN) | (1U << LED1_PIN));
/* for debugging, hang on in an endless loop until PB1 is pressed... */
while ((GPIO->P[PB_PORT].DIN & (1U << PB1_PIN)) != 0) {
}
#endif
NVIC_SystemReset();
}
/*****************************************************************************
* NOTE00:
* The QF_AWARE_ISR_CMSIS_PRI constant from the QF port specifies the highest
* ISR priority that is disabled by the QF framework. The value is suitable
* for the NVIC_SetPriority() CMSIS function.
*
* Only ISRs prioritized at or below the QF_AWARE_ISR_CMSIS_PRI level (i.e.,
* with the numerical values of priorities equal or higher than
* QF_AWARE_ISR_CMSIS_PRI) are allowed to call any QF services. These ISRs
* are "QF-aware".
*
* Conversely, any ISRs prioritized above the QF_AWARE_ISR_CMSIS_PRI priority
* level (i.e., with the numerical values of priorities less than
* QF_AWARE_ISR_CMSIS_PRI) are never disabled and are not aware of the kernel.
* Such "QF-unaware" ISRs cannot call any QF services. The only mechanism
* by which a "QF-unaware" ISR can communicate with the QF framework is by
* triggering a "QF-aware" ISR, which can post/publish events.
*
* NOTE01:
* The QV_onIdle() callback is called with interrupts disabled, because the
* determination of the idle condition might change by any interrupt posting
* an event. QV_onIdle() must internally enable interrupts, ideally
* atomically with putting the CPU to the power-saving mode.
*
* NOTE02:
* One of the LEDs is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qv/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano on EMF32-SLSTK3401A, QV-nano kernel, GNU-ARM
# Last Updated for Version: 6.5.0
# Date of the Last Update: 2019-04-15
#
# Q u a n t u m L e a P s
# ------------------------
# Modern Embedded Software
#
# Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# https://www.state-machine.com
# mailto:info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := blinky-qv
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/arm-cm/qv/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qvn \
$(QP_PORT_DIR) \
$(QPN)/3rd_party/efm32pg1b \
$(QPN)/3rd_party/efm32pg1b/gnu
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR) \
-I$(QPN)/3rd_party/CMSIS/Include \
-I$(QPN)/3rd_party/efm32pg1b
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
blinky.c \
bsp.c \
main.c \
startup_efm32pg1b.c \
system_efm32pg1b.c \
em_cmu.c \
em_emu.c \
em_gpio.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qepn.c \
qfn.c \
qvn.c \
qvn_port.c
QP_ASMS := \
LIB_DIRS :=
LIBS :=
# defines
DEFINES := -DEFM32PG1B200F256GM48=1
# ARM CPU, ARCH, FPU, and Float-ABI types...
# ARM_CPU: [cortex-m0 | cortex-m0plus | cortex-m1 | cortex-m3 | cortex-m4]
# ARM_ARCH: [6 | 7] (NOTE: must match ARM_CPU!)
# ARM_FPU: [ | vfp]
# FLOAT_ABI: [ | soft | softfp | hard]
#
ARM_CPU := -mcpu=cortex-m4
ARM_ARCH := 7 # NOTE: must match the ARM_CPU!
ARM_FPU := -mfpu=vfp
FLOAT_ABI := -mfloat-abi=softfp
#-----------------------------------------------------------------------------
# GNU-ARM toolset (NOTE: You need to adjust to your machine)
# see https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
#
ifeq ($(GNU_ARM),)
GNU_ARM := $(QTOOLS)/gnu_arm-none-eabi
endif
# make sure that the GNU-ARM toolset exists...
ifeq ("$(wildcard $(GNU_ARM))","")
$(error GNU_ARM toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_ARM)/bin/arm-none-eabi-gcc
CPP := $(GNU_ARM)/bin/arm-none-eabi-g++
AS := $(GNU_ARM)/bin/arm-none-eabi-as
LINK := $(GNU_ARM)/bin/arm-none-eabi-g++
BIN := $(GNU_ARM)/bin/arm-none-eabi-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M
#
# combine all the soruces...
C_SRCS += $(QP_SRCS)
ASM_SRCS += $(QP_ASMS)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS = $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration ..........................................
BIN_DIR := dbg
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O $(INCLUDES) $(DEFINES)
CPPFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES)
endif # ......................................................................
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
-specs=nosys.specs -specs=nano.specs \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_BIN := $(BIN_DIR)/$(OUTPUT).bin
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_BIN)
#all: $(TARGET_ELF)
$(TARGET_BIN): $(TARGET_ELF)
$(BIN) -O binary $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(CC) $(CFLAGS) $(QPN)/include/qstamp.c -o $(BIN_DIR)/qstamp.o
$(LINK) $(LINKFLAGS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.bin \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qv/gnu/README.txt
================================================
About this Example
==================
This example can be built from the command prompt with the provided
Makefile. The example can also be imported as a Makefile-based
project into Eclipse-based IDEs.
The Makefile
============
The provided Makefile should be easy to adapt for your own projects.
It contains two build configurations: Debug (default) and Release.
Also, the Makefile has been specifically designed to work as an external
Makefile with the Eclipse CDT.
The various build configurations are built as follows:
make
make CONF=rel
make clean
make CONF=rel clean
***
NOTE:
The installation folder of the GNU-ARM toolset on YOUR machine needs
to be adjusted in the provided Makefile, by editing the symbol: GNU_ARM.
As described in the comment for this symbol, the GNU-ARM toolset is taken
from: http://gnutoolchains.com/arm-eabi
It is highly recommened to use the same GNU-ARM distribution, especially
for ARM Cortex-M4F projects, due to the support for the hardware FPU
(float-abi=hard).
***
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the GCC linker
script (.ld file), which provides a template of the recommended GCC linker
script for QP applications.
Startup Code
============
The startup code for the EFM32PG1B200F256GM48 MCU used in this project
is located in the "3rd_party" folder in the following location:
qpc\3rd_party\efm32pg1b\gnu\startup_efm32pg1b.c
The file startup_efm32pg1b.c provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qv/gnu/blinky-qv.ld
================================================
/*****************************************************************************
* Product: Linker script for EFM32-SLSTK3401A, GNU-ARM linker
* Last Updated for Version: 5.9.8
* Date of the Last Update: 2017-09-13
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* http://www.state-machine.com
* mailto:info@state-machine.com
*****************************************************************************/
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(Reset_Handler) /* entry Point */
MEMORY { /* memory map of Pearl Gecko EFM32PG1B200F256GM48 */
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 256K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
}
/* The size of the stack used by the application. NOTE: you need to adjust */
STACK_SIZE = 1024;
/* The size of the heap used by the application. NOTE: you need to adjust */
HEAP_SIZE = 0;
SECTIONS {
.isr_vector : { /* the vector table goes FIRST into ROM */
KEEP(*(.isr_vector)) /* vector table */
. = ALIGN(4);
} >ROM
.text : { /* code and constants */
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} >ROM
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >ROM
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >ROM
.fini_array : {
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array*))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >ROM
_etext = .; /* global symbols at end of code */
.stack : {
__stack_start__ = .;
. = . + STACK_SIZE;
. = ALIGN(4);
__stack_end__ = .;
} >RAM
.data : AT (_etext) {
__data_load = LOADADDR (.data);
__data_start = .;
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
__data_end__ = .;
_edata = __data_end__;
} >RAM
.bss : {
__bss_start__ = .;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = .;
} >RAM
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >RAM
__exidx_end = .;
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );
PROVIDE ( __end__ = _ebss );
.heap : {
__heap_start__ = .;
. = . + HEAP_SIZE;
. = ALIGN(4);
__heap_end__ = .;
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ : {
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
}
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qv/gnu/flash.bat
================================================
::============================================================================
:: Batch file to program the flash of EFM32-SLSTK3401A board
::
:: NOTE: requires the J-Link commander (JLink.exe) from SEGGER, see:
:: https://www.segger.com/j-link-commander.html
::
setlocal
@echo off
@echo Load a given binary file to the flash of EFM32-SLSTK3401A
@echo usage: flash bin-file
@echo example: flash dbg\blinky-qk.bin
::----------------------------------------------------------------------------
:: NOTE: Adjust the following symbol to the location of the
:: JLink utility on your machine
::
if [%JLINK%] EQU [] set JLINK=%QTOOLS%\..\JLink
if not exist "%JLINK%\JLink.exe" (
@echo The JLink tool not found. Please adjust flash.bat
@goto end
)
if ["%~1"]==[""] (
@echo The binary file missing
@goto end
)
if not exist %~s1 (
@echo The binary file '%1' does not exist
@goto end
)
:: generate the Jlink command file depending on the first parameter %1
@echo si 1 >flash.jlink
@echo speed 4000 >>flash.jlink
@echo r >>flash.jlink
@echo h >>flash.jlink
@echo loadbin %1, 0 >>flash.jlink
@echo exit >>flash.jlink
@echo on
%JLINK%\JLink.exe -device EFM32PG1B200F256GM48 flash.jlink
@echo off
@del flash.jlink
:end
endlocal
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qv/iar/README.txt
================================================
About this Example
==================
This example demonstrates how to use the IAR EWARM IDE to build
a QP application.
IAR Project File
----------------
The IAR EWARM project file provided with this example uses relative paths
to the QP/C framework location (includes, port, and libraries. These
relative paths must be modified when the project is moved to different
relative location.
Stack Size and Heap Size
------------------------
In this project, the size of the C stack and heap are determined in
the linker script blinky-qk.icf (see the next section).
Linker Script
-------------
The IAR linker script provides a template of the recommended linker script
for QP applications. This file needs to be customized to set the
application-specific sizes of the Stack and Heap. This file can be edited
from the IAR EWARM IDE via the Project Options/Linker settings.
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\efm32pg1b\iar\startup_efm32pg1b.s
The file startup_efm32pg1b.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qv/iar/blinky-qv.ewd
================================================
3DebugARM1C-SPY22811ARMSIM_ID2111CADI_ID2011CMSISDAP_ID2411GDBSERVER_ID2011IJET_ID2811JLINK_ID21611LMIFTDI_ID2211PEMICRO_ID2311STLINK_ID2411THIRDPARTY_ID2011TIFET_ID2111XDS100_ID2611$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseARM0C-SPY22810ARMSIM_ID2110CADI_ID2010CMSISDAP_ID2410GDBSERVER_ID2010IJET_ID2810JLINK_ID21610LMIFTDI_ID2210PEMICRO_ID2310STLINK_ID2410THIRDPARTY_ID2010TIFET_ID2110XDS100_ID2610$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qv/iar/blinky-qv.ewp
================================================
3DebugARM1General32811ICCARM23411AARM21011OBJCOPY0111CUSTOM30BICOMP0BUILDACTION1cmd /c "if exist $OBJ_DIR$\qstamp.o del $OBJ_DIR$\qstamp.o"ILINK02011IARCHIVE0011BILINK0Coder0ReleaseARM0General32810ICCARM23410AARM21010OBJCOPY0110CUSTOM30BICOMP0BUILDACTION1cmd /c "if exist $OBJ_DIR$\qstamp.o del $OBJ_DIR$\qstamp.o"ILINK02010IARCHIVE0010BILINK0Coder0Application$PROJ_DIR$\..\..\blinky.c$PROJ_DIR$\..\..\blinky.h$PROJ_DIR$\..\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\main.c$PROJ_DIR$\..\..\..\..\..\include\qstamp.cefm32pg1b$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_assert.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_emu.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_system.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\iar\startup_efm32pg1b.s$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.cQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qvn\qvn.cQP_port$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qv\iar\qvn_port.c
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qv/iar/blinky-qv.eww
================================================
$WS_DIR$\blinky-qv.ewp
================================================
FILE: examples/arm-cm/blinky_efm32-slstk3401a/qv/iar/blinky-qv.icf
================================================
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0003FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 1024;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place at start of RAM_region {block CSTACK };
place in RAM_region { readwrite, block HEAP };
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/README.txt
================================================
About this Example
==================
This directory contains the simple "Blinky" QP-nano example application for
the EK-TM4C123GXL board (TivaC LauchPad). This directory contains portable
code that should compile with any C compiler.
The sub-directories contain the Board Support Packages (BSPs) for the
preemptive QK-nano kernel (sub-directory qk), the cooperative QV kernel
(sub-directory qv), and the Win32-QV emulation (Windows).
The native kernels (QK-nano and QV-nano) further provide code and project
files for the particular ARM toolchains, such as ARM (MDK-ARM), GNU, and IAR.
Please refer to the README files in the sub-directories for instructions
how to use and customize the example to your needs.
Support Code for EK-TM4C123GXL Board
====================================
The directory qpn\3rd_party\ek-tm4c123gxl contains the CMSIS-compliant
device code for the TM4C123GH6PM MCU. Please see the README.txt file in
this folder for more details.
Win32 Emulation
===============
The sub-directory win32-qv provides the emulation of the example on Windows
as a console application. The sub-directory contains the Makefile for the
MinGW toolset and a Visual Studio solution file (blinky.sln) for Visual C++.
The Win32 emulation uses exactly the same code as the embedded board and
differs only in the Board Support Package (bsp.c). This example demonstrates
the "dual targeting" development approach, where most of the embedded code
is developed on the desktop machine (Windows), but is intended for a deeply
embedded target (TivaC LauchPad here).
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/README.url
================================================
[InternetShortcut]
URL=http://www.state-machine.com/qpn/arm-cm_blinky_ek-tm4c123gxl.html
IconFile=http://www.state-machine.com/qp.ico
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/blinky.c
================================================
/*****************************************************************************
* Product: Simple Blinky example
* Last updated for version 5.4.0
* Last updated on 2015-05-18
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, www.state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "blinky.h"
#include "bsp.h"
//Q_DEFINE_THIS_FILE
/*..........................................................................*/
typedef struct BlinkyTag { /* the Blinky active object */
QActive super; /* inherit QActive */
} Blinky;
/* hierarchical state machine ... */
static QState Blinky_initial(Blinky * const me);
static QState Blinky_off (Blinky * const me);
static QState Blinky_on (Blinky * const me);
/* Global objects ----------------------------------------------------------*/
Blinky AO_Blinky; /* the single instance of the Blinky AO */
/*..........................................................................*/
void Blinky_ctor(void) {
Blinky * const me = &AO_Blinky;
QActive_ctor(&me->super, Q_STATE_CAST(&Blinky_initial));
}
/* HSM definition ----------------------------------------------------------*/
QState Blinky_initial(Blinky * const me) {
QActive_armX((QActive *)me, 0U,
BSP_TICKS_PER_SEC/2U, BSP_TICKS_PER_SEC/2U);
return Q_TRAN(&Blinky_off);
}
/*..........................................................................*/
QState Blinky_off(Blinky * const me) {
QState status;
switch (Q_SIG(me)) {
case Q_ENTRY_SIG: {
BSP_ledOff();
status = Q_HANDLED();
break;
}
case Q_TIMEOUT_SIG: {
status = Q_TRAN(&Blinky_on);
break;
}
default: {
status = Q_SUPER(&QHsm_top);
break;
}
}
return status;
}
/*..........................................................................*/
QState Blinky_on(Blinky * const me) {
QState status;
switch (Q_SIG(me)) {
case Q_ENTRY_SIG: {
BSP_ledOn();
status = Q_HANDLED();
break;
}
case Q_TIMEOUT_SIG: {
status = Q_TRAN(&Blinky_off);
break;
}
default: {
status = Q_SUPER(&QHsm_top);
break;
}
}
return status;
}
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/blinky.h
================================================
/*****************************************************************************
* Product: simple "Blinky" example
* Last updated for version 5.4.0
* Last updated on 2015-05-18
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, www.state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef BLINKY_H
#define BLINKY_H
enum BlinkySignals {
DUMMY_SIG = Q_USER_SIG,
MAX_PUB_SIG, /* the last published signal */
TIMEOUT_SIG,
MAX_SIG /* the last signal */
};
void Blinky_ctor(void);
extern struct BlinkyTag AO_Blinky;
#endif /* BLINKY_H */
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/bsp.h
================================================
/*****************************************************************************
* Product: Simple Blinky example
* Last updated for version 5.4.0
* Last updated on 2015-05-18
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, www.state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef BSP_H
#define BSP_H
#define BSP_TICKS_PER_SEC 100U
void BSP_init(void);
void BSP_ledOff(void);
void BSP_ledOn(void);
#endif /* BSP_H */
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/main.c
================================================
/*****************************************************************************
* Product: "Blinky" example
* Last Updated for Version: 5.8.0
* Date of the Last Update: 2016-11-06
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h" /* QP-nano API */
#include "bsp.h" /* Board Support Package */
#include "blinky.h" /* Application interface */
/* Local-scope objects -----------------------------------------------------*/
static QEvt l_blinkyQSto[10]; /* Event queue storage for Blinky */
/* QF_active[] array defines all active object control blocks --------------*/
QActiveCB const Q_ROM QF_active[] = {
{ (QActive *)0, (QEvt *)0, 0U },
{ (QActive *)&AO_Blinky, l_blinkyQSto, Q_DIM(l_blinkyQSto) }
};
/*..........................................................................*/
int main(void) {
Blinky_ctor(); /* instantiate all Blinky AO */
QF_init(Q_DIM(QF_active)); /* initialize the QF-nano framework */
BSP_init(); /* initialize the Board Support Package */
return QF_run(); /* transfer control to QF-nano */
}
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qk/arm/README.txt
================================================
About this Example
==================
This example demonstrates how to use the uVision IDE together with
the MDK-ARM toolchain.
***
NOTE: This example requires installing the following Software Pack
in the Keil uVision: Keil::TM4C_DFP.
***
uVision Project File
====================
The MDK-ARM uVision project file provided with this example uses
relative paths to the QP framework location (includes, port, and
libraries. These relative paths must be modified when the project
is moved to different relative location.
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the
command-line options for the ARM assembler (see the Asm tab in
the "Options for Target" dialog box in uVision). Specifically,
you should define symbols: Stack_Size=xxx Heap_Size=yyy, where
xxx represents a numerical value of stack size and yyy the
numerical value of the heap size (for most embedded projects
yyy should be 0, as the using the heap is not recommended).
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.s
The file startup_TM4C123GH6PM.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qk/arm/blinky-qk.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj; *.o*.lib*.txt; *.h; *.inc*.plm*.cpp000blinky-dbg0x4ARM-ADS120000001110016553500079668.\dbg\11101101000011111110010140111111111111101011001008BIN\lmidk-agdi.dll0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10UL2CM3UL2CM3(-O207 -S0 -C0 -FO7 -FN1 -FC1000 -FD20000000 -FF0TM4C123_256 -FL040000 -FS00 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM)0DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E2006F4 -O4622 -S4 -FO61120x200002000200x40000001000010000000000000000000blinky-rel0x4ARM-ADS120000001110016553500079668.\rel\11101101000011111110010040111111111011101011001003BIN\lmidk-agdi.dll0DLGUARMÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÈ`»
´ª¤ô 0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E10259B -O4622 -S4 -FO610UL2CM3-O207 -S0 -C0 -FO7 -FN1 -FC1000 -FD20000000 -FF0TM4C123_256 -FL040000 -FS00 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM)120x200002000200x40000001000010000000000000000000Applicatioin1000111000..\bsp.cbsp.c00121000..\..\blinky.cblinky.c00131000..\..\main.cmain.c00145000..\..\blinky.hblinky.h00ek-tm4c123gxl1000251000..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.csystem_TM4C123GH6PM.c00265000..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hTM4C123GH6PM.h00272000..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sstartup_TM4C123GH6PM.s00285000..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hgpio.h00295000..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hrom.h002105000..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsysctl.h002115000..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hsystem_TM4C123GH6PM.h00QP10003121000..\..\..\..\..\src\qfn\qepn.cqepn.c003131000..\..\..\..\..\src\qfn\qfn.cqfn.c003141000..\..\..\..\..\src\qkn\qkn.cqkn.c00QP_port10004151000..\..\..\..\..\ports\arm-cm\qk\arm\qkn_port.cqkn_port.c00
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qk/arm/blinky-qk.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwareblinky-dbg0x4ARM-ADS5060750::V5.06 update 6 (build 750)::ARMCC0TM4C123GH6PMTexas InstrumentsKeil.TM4C_DFP.1.1.0http://www.keil.com/pack/IROM(0x00000000,0x040000) IRAM(0x20000000,0x008000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C123_256 -FS00 -FL040000 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM))0$$Device:TM4C123GH6PM$Device\Include\TM4C123\TM4C123.h$$Device:TM4C123GH6PM$SVD\TM4C123\TM4C123GH6PM.svd0000001.\dbg\blinky-qk10011.\dbg\10000000000000010fromelf --bin --output .\dbg\blinky-qk.bin .\dbg\blinky-qk.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x4000000x00x010x00x010x00x010x00x010x00x4000010x00x000x00x000x00x000x00x000x200000000x800000x00x001001000002010000000000__FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\arm;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\ek-tm4c123gxl1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cblinky.c1..\..\blinky.cmain.c1..\..\main.cblinky.h5..\..\blinky.hek-tm4c123gxlsystem_TM4C123GH6PM.c1..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.cTM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hstartup_TM4C123GH6PM.s2..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sgpio.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hrom.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hsysctl.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsystem_TM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP_portqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\arm\qkn_port.cblinky-rel0x4ARM-ADS0TM4C123GH6PMTexas InstrumentsKeil.TM4C_DFP.1.1.0http://www.keil.com/pack/IROM(0x00000000,0x040000) IRAM(0x20000000,0x008000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C123_256 -FS00 -FL040000 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM))0$$Device:TM4C123GH6PM$Device\Include\TM4C123\TM4C123.h$$Device:TM4C123GH6PM$SVD\TM4C123\TM4C123GH6PM.svd0000001.\rel\blinky-qk10000.\rel\10000000000000010fromelf --bin --output .\rel\blinky-qk.bin .\rel\blinky-qk.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x4000000x00x010x00x010x00x010x00x010x00x4000010x00x000x00x000x00x000x00x000x200000000x800000x00x004001000002010000000000NDEBUG __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\arm;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\ek-tm4c123gxl1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000blinky-qk.sct--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cblinky.c1..\..\blinky.cmain.c1..\..\main.cblinky.h5..\..\blinky.hek-tm4c123gxlsystem_TM4C123GH6PM.c1..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.cTM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hstartup_TM4C123GH6PM.s2..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sgpio.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hrom.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hsysctl.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsystem_TM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP_portqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\arm\qkn_port.c
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qk/armclang/README.txt
================================================
About this Example
==================
This example demonstrates how to use the uVision IDE together with
the MDK-ARM toolchain.
***
NOTE: This example requires installing the following Software Pack
in the Keil uVision: Keil::TM4C_DFP.
***
uVision Project File
====================
The MDK-ARM uVision project file provided with this example uses
relative paths to the QP framework location (includes, port, and
libraries. These relative paths must be modified when the project
is moved to different relative location.
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the
command-line options for the ARM assembler (see the Asm tab in
the "Options for Target" dialog box in uVision). Specifically,
you should define symbols: Stack_Size=xxx Heap_Size=yyy, where
xxx represents a numerical value of stack size and yyy the
numerical value of the heap size (for most embedded projects
yyy should be 0, as the using the heap is not recommended).
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.s
The file startup_TM4C123GH6PM.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qk/armclang/blinky-qk.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj; *.o*.lib*.txt; *.h; *.inc*.plm*.cpp000blinky-dbg0x4ARM-ADS120000001110016553500079668.\dbg\11101101000011111110010140111111111111101011001008BIN\lmidk-agdi.dll0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10UL2CM3UL2CM3(-O207 -S0 -C0 -FO7 -FN1 -FC1000 -FD20000000 -FF0TM4C123_256 -FL040000 -FS00 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM)0DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E2006F4 -O4622 -S4 -FO61120x200002000200x40000001000010000000000000000000blinky-rel0x4ARM-ADS120000001110016553500079668.\rel\11101101000011111110010040111111111011101011001008BIN\lmidk-agdi.dll0DLGUARMÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÈ`»
´ª¤ô 0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E10259B -O4622 -S4 -FO610UL2CM3-O207 -S0 -C0 -FO7 -FN1 -FC1000 -FD20000000 -FF0TM4C123_256 -FL040000 -FS00 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM)120x200002000200x40000001000010000000000000000000Applicatioin1000111000..\bsp.cbsp.c00121000..\..\blinky.cblinky.c00131000..\..\main.cmain.c00145000..\..\blinky.hblinky.h00ek-tm4c123gxl1000255000..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hTM4C123GH6PM.h00262000..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sstartup_TM4C123GH6PM.s00275000..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hgpio.h00285000..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hrom.h00295000..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsysctl.h002105000..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hsystem_TM4C123GH6PM.h002111000..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.csystem_TM4C123GH6PM.c00QP10003121000..\..\..\..\..\src\qfn\qepn.cqepn.c003131000..\..\..\..\..\src\qfn\qfn.cqfn.c003141000..\..\..\..\..\src\qkn\qkn.cqkn.c00QP_port10004155000..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqfn_port.h004161000..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.cqkn_port.c00
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qk/armclang/blinky-qk.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwareblinky-dbg0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1TM4C123GH6PMTexas InstrumentsKeil.TM4C_DFP.1.1.0http://www.keil.com/pack/IROM(0x00000000,0x040000) IRAM(0x20000000,0x008000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C123_256 -FS00 -FL040000 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM))0$$Device:TM4C123GH6PM$Device\Include\TM4C123\TM4C123.h$$Device:TM4C123GH6PM$SVD\TM4C123\TM4C123GH6PM.svd0000001.\dbg\blinky-qk10011.\dbg\10000000000000010fromelf --bin --output .\dbg\blinky-qk.bin .\dbg\blinky-qk.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x4000000x00x010x00x010x00x010x00x010x00x4000010x00x000x00x000x00x000x00x000x200000000x800000x00x007001000003010003300000__FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\ek-tm4c123gxl1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cblinky.c1..\..\blinky.cmain.c1..\..\main.cblinky.h5..\..\blinky.hek-tm4c123gxlTM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hstartup_TM4C123GH6PM.s2..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sgpio.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hrom.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hsysctl.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsystem_TM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hsystem_TM4C123GH6PM.c1..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.cQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.cblinky-rel0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1TM4C123GH6PMTexas InstrumentsKeil.TM4C_DFP.1.1.0http://www.keil.com/pack/IROM(0x00000000,0x040000) IRAM(0x20000000,0x008000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C123_256 -FS00 -FL040000 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM))0$$Device:TM4C123GH6PM$Device\Include\TM4C123\TM4C123.h$$Device:TM4C123GH6PM$SVD\TM4C123\TM4C123GH6PM.svd0000001.\rel\blinky-qk10000.\rel\10000000000000010fromelf --bin --output .\rel\blinky-qk.bin .\rel\blinky-qk.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x4000000x00x010x00x010x00x010x00x010x00x4000010x00x000x00x000x00x000x00x000x200000000x800000x00x007001000003010003300000NDEBUG __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\ek-tm4c123gxl1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000blinky-qk.sct--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cblinky.c1..\..\blinky.cmain.c1..\..\main.cblinky.h5..\..\blinky.hek-tm4c123gxlTM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hstartup_TM4C123GH6PM.s2..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sgpio.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hrom.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hsysctl.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsystem_TM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hsystem_TM4C123GH6PM.c1..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.cQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.c
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qk/bsp.c
================================================
/*****************************************************************************
* Product: "Blinky" on EK-TM4C123GXL board, preemptive QK kernel
* Last Updated for Version: 5.5.1
* Date of the Last Update: 2015-10-05
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "blinky.h"
#include "bsp.h"
#include "TM4C123GH6PM.h" /* the device specific header (TI) */
#include "rom.h" /* the built-in ROM functions (TI) */
#include "sysctl.h" /* system control driver (TI) */
#include "gpio.h" /* GPIO driver (TI) */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
enum KernelUnawareISRs { /* see NOTE00 */
/* ... */
MAX_KERNEL_UNAWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-unaware" interrupts can't overlap "kernel-aware" interrupts */
Q_ASSERT_COMPILE(MAX_KERNEL_UNAWARE_CMSIS_PRI <= QF_AWARE_ISR_CMSIS_PRI);
enum KernelAwareISRs {
SYSTICK_PRIO = QF_AWARE_ISR_CMSIS_PRI, /* see NOTE00 */
/* ... */
MAX_KERNEL_AWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-aware" interrupts should not overlap the PendSV priority */
Q_ASSERT_COMPILE(MAX_KERNEL_AWARE_CMSIS_PRI <= (0xFF >>(8-__NVIC_PRIO_BITS)));
/* ISRs defined in this BSP ------------------------------------------------*/
void SysTick_Handler(void);
void GPIOPortA_IRQHandler(void);
/* Local-scope objects -----------------------------------------------------*/
#define LED_RED (1U << 1)
#define LED_GREEN (1U << 3)
#define LED_BLUE (1U << 2)
#define BTN_SW1 (1U << 4)
#define BTN_SW2 (1U << 0)
/* ISRs used in this project ===============================================*/
void SysTick_Handler(void) {
QK_ISR_ENTRY(); /* inform QK about entering an ISR */
QF_tickXISR(0U); /* process time events for rate 0 */
QK_ISR_EXIT(); /* inform QK about exiting an ISR */
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* NOTE: SystemInit() already called from the startup code
* but SystemCoreClock needs to be updated
*/
SystemCoreClockUpdate();
/* configure the FPU usage by choosing one of the options... */
#if 1
/* OPTION 1:
* Use the automatic FPU state preservation and the FPU lazy stacking.
*
* NOTE:
* Use the following setting when FPU is used in more than one task or
* in any ISRs. This setting is the safest and recommended, but requires
* extra stack space and CPU cycles.
*/
FPU->FPCCR |= (1U << FPU_FPCCR_ASPEN_Pos) | (1U << FPU_FPCCR_LSPEN_Pos);
#else
/* OPTION 2:
* Do NOT to use the automatic FPU state preservation and
* do NOT to use the FPU lazy stacking.
*
* NOTE:
* Use the following setting when FPU is used in ONE task only and not
* in any ISR. This setting is very efficient, but if more than one task
* (or ISR) start using the FPU, this can lead to corruption of the
* FPU registers. This option should be used with CAUTION.
*/
FPU->FPCCR &= ~((1U << FPU_FPCCR_ASPEN_Pos)
| (1U << FPU_FPCCR_LSPEN_Pos));
#endif
/* enable clock for to the peripherals used by this application... */
SYSCTL->RCGCGPIO |= (1U << 5); /* enable Run mode for GPIOF */
/* configure the LEDs and push buttons */
GPIOF->DIR |= (LED_RED | LED_GREEN | LED_BLUE);/* set direction: output */
GPIOF->DEN |= (LED_RED | LED_GREEN | LED_BLUE); /* digital enable */
GPIOF->DATA_Bits[LED_RED] = 0U; /* turn the LED off */
GPIOF->DATA_Bits[LED_GREEN] = 0U; /* turn the LED off */
GPIOF->DATA_Bits[LED_BLUE] = 0U; /* turn the LED off */
/* configure the Buttons */
GPIOF->DIR &= ~(BTN_SW1 | BTN_SW2); /* set direction: input */
ROM_GPIOPadConfigSet(GPIOF_BASE, (BTN_SW1 | BTN_SW2),
GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
}
/*..........................................................................*/
void BSP_ledOff(void) {
GPIOF->DATA_Bits[LED_GREEN] = 0U;
}
/*..........................................................................*/
void BSP_ledOn(void) {
/* exercise the FPU with some floating point computations */
float volatile x = 3.1415926F;
x = x + 2.7182818F;
GPIOF->DATA_Bits[LED_GREEN] = 0xFFU;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set up the SysTick timer to fire at BSP_TICKS_PER_SEC rate */
SysTick_Config(SystemCoreClock / BSP_TICKS_PER_SEC);
/* assing all priority bits for preemption-prio. and none to sub-prio. */
NVIC_SetPriorityGrouping(0U);
/* set priorities of ALL ISRs used in the system, see NOTE00
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
NVIC_SetPriority(SysTick_IRQn, SYSTICK_PRIO);
/* ... */
/* enable IRQs... */
}
/*..........................................................................*/
void QK_onIdle(void) {
/* toggle LED2 on and then off, see NOTE01 */
QF_INT_DISABLE();
GPIOF->DATA_Bits[LED_BLUE] = 0xFFU;
GPIOF->DATA_Bits[LED_BLUE] = 0x00U;
QF_INT_ENABLE();
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular Cortex-M3 MCU.
*/
__WFI(); /* Wait-For-Interrupt */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int loc) {
/*
* NOTE: add here your application-specific error handling
*/
(void)module;
(void)loc;
NVIC_SystemReset();
}
/*****************************************************************************
* NOTE00:
* The QF_AWARE_ISR_CMSIS_PRI constant from the QF port specifies the highest
* ISR priority that is disabled by the QF framework. The value is suitable
* for the NVIC_SetPriority() CMSIS function.
*
* Only ISRs prioritized at or below the QF_AWARE_ISR_CMSIS_PRI level (i.e.,
* with the numerical values of priorities equal or higher than
* QF_AWARE_ISR_CMSIS_PRI) are allowed to call any QF services. These ISRs
* are "QF-aware".
*
* Conversely, any ISRs prioritized above the QF_AWARE_ISR_CMSIS_PRI priority
* level (i.e., with the numerical values of priorities less than
* QF_AWARE_ISR_CMSIS_PRI) are never disabled and are not aware of the kernel.
* Such "QF-unaware" ISRs cannot call any QF services. The only mechanism
* by which a "QF-unaware" ISR can communicate with the QF framework is by
* triggering a "QF-aware" ISR, which can post/publish events.
*
* NOTE01:
* One of the LEDs is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qk/gnu/.ccsproject
================================================
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qk/gnu/.cproject
================================================
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qk/gnu/.project
================================================
blinky-qkorg.eclipse.cdt.managedbuilder.core.genmakebuilderorg.eclipse.cdt.managedbuilder.core.ScannerConfigBuilderfull,incremental,com.ti.ccstudio.core.ccsNatureorg.eclipse.cdt.core.cnatureorg.eclipse.cdt.managedbuilder.core.managedBuildNatureorg.eclipse.cdt.core.ccnatureorg.eclipse.cdt.managedbuilder.core.ScannerConfigNatureQK-nano2PARENT-5-PROJECT_LOC/src/qknQP-nano2PARENT-5-PROJECT_LOC/src/qfnQP_port2PARENT-5-PROJECT_LOC/ports/arm-cm/qk/gnuTM4C123GH6PM.h1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/TM4C123GH6PM.hblinky.c1PARENT-2-PROJECT_LOC/blinky.cblinky.h1PARENT-2-PROJECT_LOC/blinky.hbsp.c1PARENT-1-PROJECT_LOC/bsp.cbsp.h1PARENT-2-PROJECT_LOC/bsp.hgpio.h1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/gpio.hmain.c1PARENT-2-PROJECT_LOC/main.cqstamp.c1PARENT-5-PROJECT_LOC/include/qstamp.crom.h1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/rom.hstartup_TM4C123GH6PM.c1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/gnu/startup_TM4C123GH6PM.csysctl.h1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/sysctl.hsystem_TM4C123GH6PM.c1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/system_TM4C123GH6PM.csystem_TM4C123GH6PM.h1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/system_TM4C123GH6PM.h
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qk/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano on EK-TM4C123GXL, QK-nano, GNU-ARM
# Last Updated for Version: 6.5.0
# Date of the Last Update: 2019-04-15
#
# Q u a n t u m L e a P s
# ------------------------
# Modern Embedded Software
#
# Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# https://www.state-machine.com
# mailto:info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := blinky-qk
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/arm-cm/qk/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qkn \
$(QP_PORT_DIR) \
$(QPN)/3rd_party/ek-tm4c123gxl \
$(QPN)/3rd_party/ek-tm4c123gxl/gnu
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR) \
-I$(QPN)/3rd_party/CMSIS/Include \
-I$(QPN)/3rd_party/ek-tm4c123gxl
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
blinky.c \
bsp.c \
main.c \
system_TM4C123GH6PM.c \
startup_TM4C123GH6PM.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qepn.c \
qfn.c \
qkn.c \
qkn_port.c
QP_ASMS :=
LIB_DIRS :=
LIBS :=
# defines
DEFINES := -DTARGET_IS_TM4C123_RB1
# ARM CPU, ARCH, FPU, and Float-ABI types...
# ARM_CPU: [cortex-m0 | cortex-m0plus | cortex-m1 | cortex-m3 | cortex-m4]
# ARM_ARCH: [6 | 7] (NOTE: must match ARM_CPU!)
# ARM_FPU: [ | vfp]
# FLOAT_ABI: [ | soft | softfp | hard]
#
ARM_CPU := -mcpu=cortex-m4
ARM_ARCH := 7 # NOTE: must match the ARM_CPU!
ARM_FPU := -mfpu=vfp
FLOAT_ABI := -mfloat-abi=softfp
#-----------------------------------------------------------------------------
# GNU-ARM toolset (NOTE: You need to adjust to your machine)
# see https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
#
ifeq ($(GNU_ARM),)
GNU_ARM := $(QTOOLS)/gnu_arm-none-eabi
endif
# make sure that the GNU-ARM toolset exists...
ifeq ("$(wildcard $(GNU_ARM))","")
$(error GNU_ARM toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_ARM)/bin/arm-none-eabi-gcc
CPP := $(GNU_ARM)/bin/arm-none-eabi-g++
AS := $(GNU_ARM)/bin/arm-none-eabi-as
LINK := $(GNU_ARM)/bin/arm-none-eabi-g++
BIN := $(GNU_ARM)/bin/arm-none-eabi-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M
#
# combine all the soruces...
C_SRCS += $(QP_SRCS)
ASM_SRCS += $(QP_ASMS)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS = $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration ..........................................
BIN_DIR := dbg
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O $(INCLUDES) $(DEFINES)
CPPFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES)
endif # ......................................................................
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
-specs=nosys.specs -specs=nano.specs \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_BIN := $(BIN_DIR)/$(OUTPUT).bin
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_BIN)
#all: $(TARGET_ELF)
$(TARGET_BIN): $(TARGET_ELF)
$(BIN) -O binary $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(CC) $(CFLAGS) $(QPN)/include/qstamp.c -o $(BIN_DIR)/qstamp.o
$(LINK) $(LINKFLAGS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.bin \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qk/gnu/README.txt
================================================
About this Example
==================
This example can be built in two different ways:
- from the command prompt with the provided Makefile.
- from the TI Code Composer Studio with the provided CCS project.
The Makefile
============
The provided Makefile should be easy to adapt for your own projects.
It contains three build configurations: Debug (default), Release, and
Spy.
Also, the Makefile has been specifically designed to work as an external
Makefile with the Eclipse CDT.
The various build configurations are built as follows:
make
make CONF=rel
make CONF=spy
make clean
make CONF=rel clean
make CONF=spy clean
***
NOTE:
The installation folder of the GNU-ARM toolset on YOUR machine needs
to be adjusted in the provided Makefile, by editing the symbol: GNU_ARM.
As described in the comment for this symbol, the GNU-ARM toolset is taken
from: http://gnutoolchains.com/arm-eabi
It is highly recommened to use the same GNU-ARM distribution, especially
for ARM Cortex-M4F projects, due to the support for the hardware FPU
(float-abi=hard).
***
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the GCC linker
script (.ld file), which provides a template of the recommended GCC linker
script for QP applications.
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\gcc\startup_TM4C123GH6PM.c
The file startup_TM4C123GH6PM.c provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qk/gnu/blinky-qk.ld
================================================
/*****************************************************************************
* Product: Linker script for EK-TM4C123GXL, GNU-ARM linker
* Last Updated for Version: 5.9.8
* Date of the Last Update: 2017-09-13
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* Web : http://www.state-machine.com
* Email: info@state-machine.com
*****************************************************************************/
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(Reset_Handler) /* entry Point */
MEMORY { /* memory map of Tiva TM4C123GH6PM */
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 256K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
}
/* The size of the stack used by the application. NOTE: you need to adjust */
STACK_SIZE = 1024;
/* The size of the heap used by the application. NOTE: you need to adjust */
HEAP_SIZE = 0;
SECTIONS {
.isr_vector : { /* the vector table goes FIRST into ROM */
KEEP(*(.isr_vector)) /* vector table */
. = ALIGN(4);
} >ROM
.text : { /* code and constants */
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} >ROM
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >ROM
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >ROM
.fini_array : {
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array*))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >ROM
_etext = .; /* global symbols at end of code */
.stack : {
__stack_start__ = .;
. = . + STACK_SIZE;
. = ALIGN(4);
__stack_end__ = .;
} >RAM
.data : AT (_etext) {
__data_load = LOADADDR (.data);
__data_start = .;
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
__data_end__ = .;
_edata = __data_end__;
} >RAM
.bss : {
__bss_start__ = .;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = .;
} >RAM
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >RAM
__exidx_end = .;
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );
PROVIDE ( __end__ = _ebss );
.heap : {
__heap_start__ = .;
. = . + HEAP_SIZE;
. = ALIGN(4);
__heap_end__ = .;
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ : {
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
}
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qk/gnu/flash.bat
================================================
::============================================================================
:: Batch file to program the flash of EK-TM4C123GXL
::
:: NOTE: requires the LMFlash programmer (included in QTools for Windows)
::
@echo off
setlocal
@echo Load a given binary file to the flash of EK-TM4C123GXL
@echo usage: flash binary-file
@echo example: flash dbg\blinky-qk.bin
::----------------------------------------------------------------------------
:: NOTE: The following symbol LMFLASH assumes that LMFlash.exe can
:: be found on the PATH. You might need to adjust this symbol to the
:: location of the LMFlash utility on your machine
::
set LMFLASH=LMFlash.exe
if ["%~1"]==[""] (
@echo The binary file missing
@goto end
)
if not exist %~s1 (
@echo The binary file '%1' does not exist
@goto end
)
%LMFLASH% -q ek-tm4c123gxl -e -v -r %1
:end
endlocal
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qk/iar/README.txt
================================================
About this Example
==================
This example demonstrates how to use the IAR EWARM IDE to build
a QP application.
IAR Project File
----------------
The IAR EWARM project file provided with this example uses relative paths
to the QP/C framework location (includes, port, and libraries. These
relative paths must be modified when the project is moved to different
relative location.
Stack Size and Heap Size
------------------------
In this project, the size of the C stack and heap are determined in
the linker script blinky-qk.icf (see the next section).
Linker Script
-------------
The IAR linker script provides a template of the recommended linker script
for QP applications. This file needs to be customized to set the
application-specific sizes of the Stack and Heap. This file can be edited
from the IAR EWARM IDE via the Project Options/Linker settings.
Startup Code
------------
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\iar\startup_TM4C123GH6PM.s
The file startup_TM4C123GH6PM.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qk/iar/blinky-qk.ewd
================================================
3DebugARM1C-SPY22811ARMSIM_ID2111CADI_ID2011CMSISDAP_ID2411GDBSERVER_ID2011IJET_ID2811JLINK_ID21611LMIFTDI_ID2211PEMICRO_ID2311STLINK_ID2411THIRDPARTY_ID2011TIFET_ID2111XDS100_ID2611$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseARM0C-SPY22810ARMSIM_ID2110CADI_ID2010CMSISDAP_ID2410GDBSERVER_ID2010IJET_ID2810JLINK_ID21610LMIFTDI_ID2210PEMICRO_ID2310STLINK_ID2410THIRDPARTY_ID2010TIFET_ID2110XDS100_ID2610$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qk/iar/blinky-qk.ewp
================================================
3DebugARM1General32811ICCARM23411AARM21011OBJCOPY0111CUSTOM30BICOMP0BUILDACTION1ILINK02011IARCHIVE0011BILINK0Coder0ReleaseARM0General32810ICCARM23410AARM21010OBJCOPY0110CUSTOM30BICOMP0BUILDACTION1ILINK02010IARCHIVE0010BILINK0Coder0Application$PROJ_DIR$\..\..\blinky.c$PROJ_DIR$\..\..\blinky.h$PROJ_DIR$\..\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\main.cek-tm4c123gxl$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\iar\startup_TM4C123GH6PM.s$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.c$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.h$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qkn\qkn.cQP_port$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qk\iar\qkn_port.c
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qk/iar/blinky-qk.eww
================================================
$WS_DIR$\blinky-qk.ewp
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qk/iar/blinky-qk.icf
================================================
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0003FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 1024;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place at start of RAM_region {block CSTACK };
place in RAM_region { readwrite, block HEAP };
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qpn_conf.h
================================================
/*****************************************************************************
* Product: QP-nano configuration for the Blinky example
* Last Updated for Version: 5.6.2
* Date of the Last Update: 2016-04-05
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef QPN_CONF_H
#define QPN_CONF_H
#define Q_PARAM_SIZE 4U
#define QF_MAX_TICK_RATE 1U
#define QF_TIMEEVT_CTR_SIZE 2U
#define QF_TIMEEVT_PERIODIC
#endif /* QPN_CONF_H */
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qv/arm/README.txt
================================================
About this Example
==================
This example demonstrates how to use the uVision IDE together with
the MDK-ARM toolchain.
***
NOTE: This example requires installing the following Software Pack
in the Keil uVision: Keil::TM4C_DFP.
***
uVision Project File
====================
The MDK-ARM uVision project file provided with this example uses
relative paths to the QP framework location (includes, port, and
libraries. These relative paths must be modified when the project
is moved to different relative location.
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the
command-line options for the ARM assembler (see the Asm tab in
the "Options for Target" dialog box in uVision). Specifically,
you should define symbols: Stack_Size=xxx Heap_Size=yyy, where
xxx represents a numerical value of stack size and yyy the
numerical value of the heap size (for most embedded projects
yyy should be 0, as the using the heap is not recommended).
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.s
The file startup_TM4C123GH6PM.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qv/arm/blinky-qv.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj*.lib*.txt; *.h; *.inc*.plm*.cpp000blinky-dbg0x4ARM-ADS120000001110016553500079668.\dbg\11101101000011111110010140111111111111101011008BIN\lmidk-agdi.dll0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10UL2CM3UL2CM3(-O207 -S0 -C0 -FO7 -FN1 -FC1000 -FD20000000 -FF0TM4C123_256 -FL040000 -FS00 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM)0DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E2006F4 -O4622 -S4 -FO61120x200002000200x4000000100001000000000000000000blinky-rel0x4ARM-ADS120000001110016553500079668.\rel\11101101000011111110010040111111111011101011003BIN\lmidk-agdi.dll0DLGUARMÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÈ`»
´ª¤ô 0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E10259B -O4622 -S4 -FO610UL2CM3-O207 -S0 -C0 -FO7 -FN1 -FC1000 -FD20000000 -FF0TM4C123_256 -FL040000 -FS00 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM)120x200002000200x4000000100001000000000000000000Applicatioin1000111000..\bsp.cbsp.c00121000..\..\blinky.cblinky.c00131000..\..\main.cmain.c00145000..\..\blinky.hblinky.h00ek-tm4c123gxl1000251000..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.csystem_TM4C123GH6PM.c00265000..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hTM4C123GH6PM.h00272000..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sstartup_TM4C123GH6PM.s00285000..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hgpio.h00295000..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hrom.h002105000..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsysctl.h002115000..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hsystem_TM4C123GH6PM.h00QP10003121000..\..\..\..\..\src\qfn\qepn.cqepn.c003131000..\..\..\..\..\src\qfn\qfn.cqfn.c003141000..\..\..\..\..\src\qvn\qvn.cqvn.c00QP_port10004151000..\..\..\..\..\ports\arm-cm\qv\arm\qvn_port.cqvn_port.c00
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qv/arm/blinky-qv.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwareblinky-dbg0x4ARM-ADS5060020::V5.06 (build 20)::ARMCCTM4C123GH6PMTexas InstrumentsKeil.TM4C_DFP.1.1.0http://www.keil.com/pack/IROM(0x00000000,0x040000) IRAM(0x20000000,0x008000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C123_256 -FS00 -FL040000 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM))0$$Device:TM4C123GH6PM$Device\Include\TM4C123\TM4C123.h$$Device:TM4C123GH6PM$SVD\TM4C123\TM4C123GH6PM.svd0000001.\dbg\blinky-qv10011.\dbg\10000000000000010fromelf --bin --output .\dbg\blinky-qv.bin .\dbg\blinky-qv.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M4"000110020080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x4000000x00x010x00x010x00x010x00x010x00x4000010x00x000x00x000x00x000x00x000x200000000x800000x00x0010010000020100000000__FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\arm;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\ek-tm4c123gxl100000010Stack_Size=1024 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cblinky.c1..\..\blinky.cmain.c1..\..\main.cblinky.h5..\..\blinky.hek-tm4c123gxlsystem_TM4C123GH6PM.c1..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.cTM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hstartup_TM4C123GH6PM.s2..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sgpio.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hrom.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hsysctl.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsystem_TM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cQP_portqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\arm\qvn_port.cblinky-rel0x4ARM-ADSTM4C123GH6PMTexas InstrumentsKeil.TM4C_DFP.1.1.0http://www.keil.com/pack/IROM(0x00000000,0x040000) IRAM(0x20000000,0x008000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C123_256 -FS00 -FL040000 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM))0$$Device:TM4C123GH6PM$Device\Include\TM4C123\TM4C123.h$$Device:TM4C123GH6PM$SVD\TM4C123\TM4C123GH6PM.svd0000001.\rel\blinky-qv10000.\rel\10000000000000010fromelf --bin --output .\rel\blinky-qv.bin .\rel\blinky-qv.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M4"000110020080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x4000000x00x010x00x010x00x010x00x010x00x4000010x00x000x00x000x00x000x00x000x200000000x800000x00x0040010000020100000000NDEBUG __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\arm;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\ek-tm4c123gxl100000010Stack_Size=1024 Heap_Size=01000100x000000000x20000000blinky-qv.sct--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cblinky.c1..\..\blinky.cmain.c1..\..\main.cblinky.h5..\..\blinky.hek-tm4c123gxlsystem_TM4C123GH6PM.c1..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.cTM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hstartup_TM4C123GH6PM.s2..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sgpio.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hrom.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hsysctl.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsystem_TM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cQP_portqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\arm\qvn_port.c
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qv/armclang/README.txt
================================================
About this Example
==================
This example demonstrates how to use the uVision IDE together with
the MDK-ARM toolchain.
***
NOTE: This example requires installing the following Software Pack
in the Keil uVision: Keil::TM4C_DFP.
***
uVision Project File
====================
The MDK-ARM uVision project file provided with this example uses
relative paths to the QP framework location (includes, port, and
libraries. These relative paths must be modified when the project
is moved to different relative location.
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the
command-line options for the ARM assembler (see the Asm tab in
the "Options for Target" dialog box in uVision). Specifically,
you should define symbols: Stack_Size=xxx Heap_Size=yyy, where
xxx represents a numerical value of stack size and yyy the
numerical value of the heap size (for most embedded projects
yyy should be 0, as the using the heap is not recommended).
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.s
The file startup_TM4C123GH6PM.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qv/armclang/blinky-qv.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj*.lib*.txt; *.h; *.inc*.plm*.cpp000blinky-dbg0x4ARM-ADS120000001110016553500079668.\dbg\11101101000011111110010140111111111111101011001008BIN\lmidk-agdi.dll0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10UL2CM3UL2CM3(-O207 -S0 -C0 -FO7 -FN1 -FC1000 -FD20000000 -FF0TM4C123_256 -FL040000 -FS00 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM)0DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E2006F4 -O4622 -S4 -FO61120x200002000200x40000001000010000000000000000000blinky-rel0x4ARM-ADS120000001110016553500079668.\rel\11101101000011111110010040111111111011101011001003BIN\lmidk-agdi.dll0DLGUARMÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÈ`»
´ª¤ô 0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E10259B -O4622 -S4 -FO610UL2CM3-O207 -S0 -C0 -FO7 -FN1 -FC1000 -FD20000000 -FF0TM4C123_256 -FL040000 -FS00 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM)120x200002000200x40000001000010000000000000000000Applicatioin1000111000..\bsp.cbsp.c00121000..\..\blinky.cblinky.c00131000..\..\main.cmain.c00145000..\..\blinky.hblinky.h00ek-tm4c123gxl1000251000..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.csystem_TM4C123GH6PM.c00265000..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hTM4C123GH6PM.h00272000..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sstartup_TM4C123GH6PM.s00285000..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hgpio.h00295000..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hrom.h002105000..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsysctl.h002115000..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hsystem_TM4C123GH6PM.h00QP10003121000..\..\..\..\..\src\qfn\qepn.cqepn.c003131000..\..\..\..\..\src\qfn\qfn.cqfn.c003141000..\..\..\..\..\src\qvn\qvn.cqvn.c00QP_port10004151000..\..\..\..\..\ports\arm-cm\qv\arm\qvn_port.cqvn_port.c00
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qv/armclang/blinky-qv.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwareblinky-dbg0x4ARM-ADS5060020::V5.06 (build 20)::ARMCC0TM4C123GH6PMTexas InstrumentsKeil.TM4C_DFP.1.1.0http://www.keil.com/pack/IROM(0x00000000,0x040000) IRAM(0x20000000,0x008000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C123_256 -FS00 -FL040000 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM))0$$Device:TM4C123GH6PM$Device\Include\TM4C123\TM4C123.h$$Device:TM4C123GH6PM$SVD\TM4C123\TM4C123GH6PM.svd0000001.\dbg\blinky-qv10011.\dbg\10000000000000010fromelf --bin --output .\dbg\blinky-qv.bin .\dbg\blinky-qv.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x4000000x00x010x00x010x00x010x00x010x00x4000010x00x000x00x000x00x000x00x000x200000000x800000x00x001001000002010000000000__FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\arm;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\ek-tm4c123gxl1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cblinky.c1..\..\blinky.cmain.c1..\..\main.cblinky.h5..\..\blinky.hek-tm4c123gxlsystem_TM4C123GH6PM.c1..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.cTM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hstartup_TM4C123GH6PM.s2..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sgpio.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hrom.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hsysctl.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsystem_TM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cQP_portqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\arm\qvn_port.cblinky-rel0x4ARM-ADS0TM4C123GH6PMTexas InstrumentsKeil.TM4C_DFP.1.1.0http://www.keil.com/pack/IROM(0x00000000,0x040000) IRAM(0x20000000,0x008000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C123_256 -FS00 -FL040000 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM))0$$Device:TM4C123GH6PM$Device\Include\TM4C123\TM4C123.h$$Device:TM4C123GH6PM$SVD\TM4C123\TM4C123GH6PM.svd0000001.\rel\blinky-qv10000.\rel\10000000000000010fromelf --bin --output .\rel\blinky-qv.bin .\rel\blinky-qv.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x4000000x00x010x00x010x00x010x00x010x00x4000010x00x000x00x000x00x000x00x000x200000000x800000x00x004001000002010000000000NDEBUG __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\arm;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\ek-tm4c123gxl1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000blinky-qv.sct--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cblinky.c1..\..\blinky.cmain.c1..\..\main.cblinky.h5..\..\blinky.hek-tm4c123gxlsystem_TM4C123GH6PM.c1..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.cTM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hstartup_TM4C123GH6PM.s2..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sgpio.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hrom.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hsysctl.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsystem_TM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cQP_portqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\arm\qvn_port.c
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qv/bsp.c
================================================
/*****************************************************************************
* Product: "Blinky" on EK-TM4C123GXL board, cooperative QV kernel
* Last Updated for Version: 5.5.1
* Date of the Last Update: 2015-10-05
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "blinky.h"
#include "bsp.h"
#include "TM4C123GH6PM.h" /* the device specific header (TI) */
#include "rom.h" /* the built-in ROM functions (TI) */
#include "sysctl.h" /* system control driver (TI) */
#include "gpio.h" /* GPIO driver (TI) */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
enum KernelUnawareISRs { /* see NOTE00 */
/* ... */
MAX_KERNEL_UNAWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-unaware" interrupts can't overlap "kernel-aware" interrupts */
Q_ASSERT_COMPILE(MAX_KERNEL_UNAWARE_CMSIS_PRI <= QF_AWARE_ISR_CMSIS_PRI);
enum KernelAwareISRs {
SYSTICK_PRIO = QF_AWARE_ISR_CMSIS_PRI, /* see NOTE00 */
/* ... */
MAX_KERNEL_AWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-aware" interrupts should not overlap the PendSV priority */
Q_ASSERT_COMPILE(MAX_KERNEL_AWARE_CMSIS_PRI <= (0xFF >>(8-__NVIC_PRIO_BITS)));
/* ISRs defined in this BSP ------------------------------------------------*/
void SysTick_Handler(void);
void GPIOPortA_IRQHandler(void);
/* Local-scope objects -----------------------------------------------------*/
#define LED_RED (1U << 1)
#define LED_GREEN (1U << 3)
#define LED_BLUE (1U << 2)
#define BTN_SW1 (1U << 4)
#define BTN_SW2 (1U << 0)
/* ISRs used in this project ===============================================*/
void SysTick_Handler(void) {
QF_tickXISR(0U); /* process time events for rate 0 */
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* NOTE: SystemInit() already called from the startup code
* but SystemCoreClock needs to be updated
*/
SystemCoreClockUpdate();
/*
* Do NOT to use the automatic FPU state preservation and
* do NOT to use the FPU lazy stacking.
*
* NOTE:
* Use the following setting when FPU is used at the task-level only and
* NOT in any ISR. This setting is very efficient, but if ISRs start using
* the FPU, this can lead to corruption of the FPU registers.
*/
FPU->FPCCR &= ~((1U << FPU_FPCCR_ASPEN_Pos)
| (1U << FPU_FPCCR_LSPEN_Pos));
/* enable clock for to the peripherals used by this application... */
SYSCTL->RCGCGPIO |= (1U << 5); /* enable Run mode for GPIOF */
/* configure the LEDs and push buttons */
GPIOF->DIR |= (LED_RED | LED_GREEN | LED_BLUE);/* set direction: output */
GPIOF->DEN |= (LED_RED | LED_GREEN | LED_BLUE); /* digital enable */
GPIOF->DATA_Bits[LED_RED] = 0U; /* turn the LED off */
GPIOF->DATA_Bits[LED_GREEN] = 0U; /* turn the LED off */
GPIOF->DATA_Bits[LED_BLUE] = 0U; /* turn the LED off */
/* configure the Buttons */
GPIOF->DIR &= ~(BTN_SW1 | BTN_SW2); /* set direction: input */
ROM_GPIOPadConfigSet(GPIOF_BASE, (BTN_SW1 | BTN_SW2),
GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
}
/*..........................................................................*/
void BSP_ledOff(void) {
GPIOF->DATA_Bits[LED_GREEN] = 0U;
}
/*..........................................................................*/
void BSP_ledOn(void) {
/* exercise the FPU with some floating point computations */
float volatile x = 3.1415926F;
x = x + 2.7182818F;
GPIOF->DATA_Bits[LED_GREEN] = 0xFFU;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set up the SysTick timer to fire at BSP_TICKS_PER_SEC rate */
SysTick_Config(SystemCoreClock / BSP_TICKS_PER_SEC);
/* assing all priority bits for preemption-prio. and none to sub-prio. */
NVIC_SetPriorityGrouping(0U);
/* set priorities of ALL ISRs used in the system, see NOTE00
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
NVIC_SetPriority(SysTick_IRQn, SYSTICK_PRIO);
/* ... */
/* enable IRQs... */
}
/*..........................................................................*/
void QV_onIdle(void) { /* CATION: called with interrupts DISABLED, NOTE01 */
/* toggle LED2 on and then off, see NOTE02 */
GPIOF->DATA_Bits[LED_BLUE] = 0xFFU;
GPIOF->DATA_Bits[LED_BLUE] = 0x00U;
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular Cortex-M MCU.
*/
QV_CPU_SLEEP(); /* atomically go to sleep and enable interrupts */
#else
QF_INT_ENABLE(); /* just enable interrupts */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int loc) {
/*
* NOTE: add here your application-specific error handling
*/
(void)module;
(void)loc;
NVIC_SystemReset();
}
/*****************************************************************************
* NOTE00:
* The QF_AWARE_ISR_CMSIS_PRI constant from the QF port specifies the highest
* ISR priority that is disabled by the QF framework. The value is suitable
* for the NVIC_SetPriority() CMSIS function.
*
* Only ISRs prioritized at or below the QF_AWARE_ISR_CMSIS_PRI level (i.e.,
* with the numerical values of priorities equal or higher than
* QF_AWARE_ISR_CMSIS_PRI) are allowed to call any QF services. These ISRs
* are "QF-aware".
*
* Conversely, any ISRs prioritized above the QF_AWARE_ISR_CMSIS_PRI priority
* level (i.e., with the numerical values of priorities less than
* QF_AWARE_ISR_CMSIS_PRI) are never disabled and are not aware of the kernel.
* Such "QF-unaware" ISRs cannot call any QF services. The only mechanism
* by which a "QF-unaware" ISR can communicate with the QF framework is by
* triggering a "QF-aware" ISR, which can post/publish events.
*
* NOTE01:
* The QV_onIdle() callback is called with interrupts disabled, because the
* determination of the idle condition might change by any interrupt posting
* an event. QV_onIdle() must internally enable interrupts, ideally
* atomically with putting the CPU to the power-saving mode.
*
* NOTE02:
* One of the LEDs is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qv/gnu/.ccsproject
================================================
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qv/gnu/.cproject
================================================
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qv/gnu/.project
================================================
blinky-qvorg.eclipse.cdt.managedbuilder.core.genmakebuilderorg.eclipse.cdt.managedbuilder.core.ScannerConfigBuilderfull,incremental,com.ti.ccstudio.core.ccsNatureorg.eclipse.cdt.core.cnatureorg.eclipse.cdt.managedbuilder.core.managedBuildNatureorg.eclipse.cdt.core.ccnatureorg.eclipse.cdt.managedbuilder.core.ScannerConfigNatureqv-nano2PARENT-5-PROJECT_LOC/src/qvnQP-nano2PARENT-5-PROJECT_LOC/src/qfnQP_port2PARENT-5-PROJECT_LOC/ports/arm-cm/qv/gnuTM4C123GH6PM.h1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/TM4C123GH6PM.hblinky.c1PARENT-2-PROJECT_LOC/blinky.cblinky.h1PARENT-2-PROJECT_LOC/blinky.hbsp.c1PARENT-1-PROJECT_LOC/bsp.cbsp.h1PARENT-2-PROJECT_LOC/bsp.hgpio.h1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/gpio.hmain.c1PARENT-2-PROJECT_LOC/main.cqstamp.c1PARENT-5-PROJECT_LOC/include/qstamp.crom.h1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/rom.hstartup_TM4C123GH6PM.c1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/gnu/startup_TM4C123GH6PM.csysctl.h1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/sysctl.hsystem_TM4C123GH6PM.c1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/system_TM4C123GH6PM.csystem_TM4C123GH6PM.h1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/system_TM4C123GH6PM.h
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qv/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano on EK-TM4C123GXL, QV-nano, GNU-ARM
# Last Updated for Version: 6.5.0
# Date of the Last Update: 2019-04-15
#
# Q u a n t u m L e a P s
# ------------------------
# Modern Embedded Software
#
# Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# https://www.state-machine.com
# mailto:info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := blinky-qv
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/arm-cm/qv/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qvn \
$(QP_PORT_DIR) \
$(QPN)/3rd_party/ek-tm4c123gxl \
$(QPN)/3rd_party/ek-tm4c123gxl/gnu
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR) \
-I$(QPN)/3rd_party/CMSIS/Include \
-I$(QPN)/3rd_party/ek-tm4c123gxl
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
blinky.c \
bsp.c \
main.c \
system_TM4C123GH6PM.c \
startup_TM4C123GH6PM.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qepn.c \
qfn.c \
qvn.c \
qvn_port.c
QP_ASMS :=
LIB_DIRS :=
LIBS :=
# defines
DEFINES :=
# ARM CPU, ARCH, FPU, and Float-ABI types...
# ARM_CPU: [cortex-m0 | cortex-m0plus | cortex-m1 | cortex-m3 | cortex-m4]
# ARM_ARCH: [6 | 7] (NOTE: must match ARM_CPU!)
# ARM_FPU: [ | vfp]
# FLOAT_ABI: [ | soft | softfp | hard]
#
ARM_CPU := -mcpu=cortex-m4
ARM_ARCH := 7 # NOTE: must match the ARM_CPU!
ARM_FPU := -mfpu=vfp
FLOAT_ABI := -mfloat-abi=softfp
#-----------------------------------------------------------------------------
# GNU-ARM toolset (NOTE: You need to adjust to your machine)
# see https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
#
ifeq ($(GNU_ARM),)
GNU_ARM := $(QTOOLS)/gnu_arm-none-eabi
endif
# make sure that the GNU-ARM toolset exists...
ifeq ("$(wildcard $(GNU_ARM))","")
$(error GNU_ARM toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_ARM)/bin/arm-none-eabi-gcc
CPP := $(GNU_ARM)/bin/arm-none-eabi-g++
AS := $(GNU_ARM)/bin/arm-none-eabi-as
LINK := $(GNU_ARM)/bin/arm-none-eabi-g++
BIN := $(GNU_ARM)/bin/arm-none-eabi-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M
#
# combine all the soruces...
C_SRCS += $(QP_SRCS)
ASM_SRCS += $(QP_ASMS)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS = $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration ..........................................
BIN_DIR := dbg
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O $(INCLUDES) $(DEFINES)
CPPFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES)
endif # ......................................................................
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
-specs=nosys.specs -specs=nano.specs \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_BIN := $(BIN_DIR)/$(OUTPUT).bin
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_BIN)
#all: $(TARGET_ELF)
$(TARGET_BIN): $(TARGET_ELF)
$(BIN) -O binary $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(CC) $(CFLAGS) $(QPN)/include/qstamp.c -o $(BIN_DIR)/qstamp.o
$(LINK) $(LINKFLAGS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.bin \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qv/gnu/README.txt
================================================
About this Example
==================
This example can be built in two different ways:
- from the command prompt with the provided Makefile.
- from the TI Code Composer Studio with the provided CCS project.
The Makefile
============
The provided Makefile should be easy to adapt for your own projects.
It contains three build configurations: Debug (default), Release, and
Spy.
Also, the Makefile has been specifically designed to work as an external
Makefile with the Eclipse CDT.
The various build configurations are built as follows:
make
make CONF=rel
make CONF=spy
make clean
make CONF=rel clean
make CONF=spy clean
***
NOTE:
The installation folder of the GNU-ARM toolset on YOUR machine needs
to be adjusted in the provided Makefile, by editing the symbol: GNU_ARM.
As described in the comment for this symbol, the GNU-ARM toolset is taken
from: http://gnutoolchains.com/arm-eabi
It is highly recommened to use the same GNU-ARM distribution, especially
for ARM Cortex-M4F projects, due to the support for the hardware FPU
(float-abi=hard).
***
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the GCC linker
script (.ld file), which provides a template of the recommended GCC linker
script for QP applications.
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\gcc\startup_TM4C123GH6PM.c
The file startup_TM4C123GH6PM.c provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qv/gnu/blinky-qv.ld
================================================
/*****************************************************************************
* Product: Linker script for EK-TM4C123GXL, GNU-ARM linker
* Last Updated for Version: 5.9.8
* Date of the Last Update: 2017-09-13
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* Web : http://www.state-machine.com
* Email: info@state-machine.com
*****************************************************************************/
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(Reset_Handler) /* entry Point */
MEMORY { /* memory map of Tiva TM4C123GH6PM */
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 256K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
}
/* The size of the stack used by the application. NOTE: you need to adjust */
STACK_SIZE = 1024;
/* The size of the heap used by the application. NOTE: you need to adjust */
HEAP_SIZE = 0;
SECTIONS {
.isr_vector : { /* the vector table goes FIRST into ROM */
KEEP(*(.isr_vector)) /* vector table */
. = ALIGN(4);
} >ROM
.text : { /* code and constants */
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} >ROM
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >ROM
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >ROM
.fini_array : {
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array*))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >ROM
_etext = .; /* global symbols at end of code */
.stack : {
__stack_start__ = .;
. = . + STACK_SIZE;
. = ALIGN(4);
__stack_end__ = .;
} >RAM
.data : AT (_etext) {
__data_load = LOADADDR (.data);
__data_start = .;
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
__data_end__ = .;
_edata = __data_end__;
} >RAM
.bss : {
__bss_start__ = .;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = .;
} >RAM
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >RAM
__exidx_end = .;
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );
PROVIDE ( __end__ = _ebss );
.heap : {
__heap_start__ = .;
. = . + HEAP_SIZE;
. = ALIGN(4);
__heap_end__ = .;
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ : {
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
}
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qv/gnu/flash.bat
================================================
::============================================================================
:: Batch file to program the flash of EK-TM4C123GXL
::
:: NOTE: requires the LMFlash programmer (included in QTools for Windows)
::
@echo off
setlocal
@echo Load a given binary file to the flash of EK-TM4C123GXL
@echo usage: flash binary-file
@echo example: flash dbg\blinky-qk.bin
::----------------------------------------------------------------------------
:: NOTE: The following symbol LMFLASH assumes that LMFlash.exe can
:: be found on the PATH. You might need to adjust this symbol to the
:: location of the LMFlash utility on your machine
::
set LMFLASH=LMFlash.exe
if ["%~1"]==[""] (
@echo The binary file missing
@goto end
)
if not exist %~s1 (
@echo The binary file '%1' does not exist
@goto end
)
%LMFLASH% -q ek-tm4c123gxl -e -v -r %1
:end
endlocal
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qv/iar/README.txt
================================================
About this Example
==================
This example demonstrates how to use the IAR EWARM IDE to build
a QP application.
IAR Project File
----------------
The IAR EWARM project file provided with this example uses relative paths
to the QP framework location (includes, port, and libraries. These
relative paths must be modified when the project is moved to different
relative location.
Stack Size and Heap Size
------------------------
In this project, the size of the C stack and heap are determined in
the linker script blinky-qk.icf (see the next section).
Linker Script
-------------
The IAR linker script provides a template of the recommended linker script
for QP applications. This file needs to be customized to set the
application-specific sizes of the Stack and Heap. This file can be edited
from the IAR EWARM IDE via the Project Options/Linker settings.
Startup Code
------------
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\iar\startup_TM4C123GH6PM.s
The file startup_TM4C123GH6PM.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qv/iar/blinky-qv.ewd
================================================
3DebugARM1C-SPY22811ARMSIM_ID2111CADI_ID2011CMSISDAP_ID2411GDBSERVER_ID2011IJET_ID2811JLINK_ID21611LMIFTDI_ID2211PEMICRO_ID2311STLINK_ID2411THIRDPARTY_ID2011TIFET_ID2111XDS100_ID2611$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseARM0C-SPY22810ARMSIM_ID2110CADI_ID2010CMSISDAP_ID2410GDBSERVER_ID2010IJET_ID2810JLINK_ID21610LMIFTDI_ID2210PEMICRO_ID2310STLINK_ID2410THIRDPARTY_ID2010TIFET_ID2110XDS100_ID2610$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qv/iar/blinky-qv.ewp
================================================
3DebugARM1General32811ICCARM23411AARM21011OBJCOPY0111CUSTOM30BICOMP0BUILDACTION1ILINK02011IARCHIVE0011BILINK0Coder0ReleaseARM0General32810ICCARM23410AARM21010OBJCOPY0110CUSTOM30BICOMP0BUILDACTION1ILINK02010IARCHIVE0010BILINK0Coder0Application$PROJ_DIR$\..\..\blinky.c$PROJ_DIR$\..\..\blinky.h$PROJ_DIR$\..\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\main.cek-tm4c123gxl$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\iar\startup_TM4C123GH6PM.s$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.c$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.h$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qvn\qvn.cQP_port$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qv\iar\qfn_port.h$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qv\iar\qvn_port.c
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qv/iar/blinky-qv.eww
================================================
$WS_DIR$\blinky-qv.ewp
================================================
FILE: examples/arm-cm/blinky_ek-tm4c123gxl/qv/iar/blinky-qv.icf
================================================
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0003FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 1024;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place at start of RAM_region {block CSTACK };
place in RAM_region { readwrite, block HEAP };
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/README.txt
================================================
About this Example
==================
This directory contains the simple DPP QP-nano example application for
the EK-TM4C123GXL board (TivaC LauchPad). This directory contains portable
code that should compile with any C compiler.
The sub-directories contain the Board Support Packages (BSPs) for the
preemptive QK-nano kernel (sub-directory qk), the cooperative QV kernel
(sub-directory qv), and the Win32-QV emulation (Windows).
The native kernels (QK-nano and QV-nano) further provide code and project
files for the particular ARM toolchains, such as ARM (MDK-ARM), GNU, and IAR.
Please refer to the README files in the sub-directories for instructions
how to use and customize the example to your needs.
Support Code for EK-TM4C123GXL Board
====================================
The directory qpn\3rd_party\ek-tm4c123gxl contains the CMSIS-compliant
device code for the TM4C123GH6PM MCU. Please see the README.txt file in
this folder for more details.
Win32 Emulation
===============
The sub-directory win32-qv provides the emulation of the example on Windows
as a GUI application. The sub-directory contains the Makefile for the
MinGW toolset and a Visual Studio solution file (dpp-gui.sln) for Visual C++.
The Win32 emulation uses exactly the same code as the embedded board and
differs only in the Board Support Package (bsp.c). This example demonstrates
the "dual targeting" development approach, where most of the embedded code
is developed on the desktop machine (Windows), but is intended for a deeply
embedded target (TivaC LauchPad here).
Lint Support
============
The sub-directory lint provides the scripts and configuration files for
running the PC-Lint static analysis tool over the application code. Please
read the README.txt file in the lint directory for more information.
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/README.url
================================================
[InternetShortcut]
URL=http://www.state-machine.com/qpn/arm-cm_dpp_efm32-slstk3401a.html
IconFile=http://www.state-machine.com/qp.ico
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/bsp.h
================================================
/*****************************************************************************
* Product: DPP example
* Last Updated for Version: 5.4.0
* Date of the Last Update: 2015-03-07
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* Web : www.state-machine.com
*
*****************************************************************************/
#ifndef BSP_H
#define BSP_H
#define BSP_TICKS_PER_SEC 100U
void BSP_init(void);
void BSP_displayPaused(uint8_t paused);
void BSP_displayPhilStat(uint8_t n, char_t const *stat);
void BSP_terminate(int16_t result);
void BSP_randomSeed(uint32_t seed); /* random seed */
uint32_t BSP_random(void); /* pseudo-random generator */
#endif /* BSP_H */
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/dpp.h
================================================
/*.$file${.::dpp.h} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: dpp.qm
* File: ${.::dpp.h}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::dpp.h} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#ifndef DPP_H
#define DPP_H
enum DPPSignals {
EAT_SIG = Q_USER_SIG, /* published by Table to let a philosopher eat */
DONE_SIG, /* published by Philosopher when done eating */
PAUSE_SIG, /* published by BSP to pause the application */
SERVE_SIG, /* published by BSP to pause the application */
TERMINATE_SIG, /* published by BSP to terminate the application */
HUNGRY_SIG, /* posted direclty to Table from hungry Philo */
MAX_SIG /* the last signal */
};
/* number of philosophers */
#define N_PHILO ((uint8_t)5)
#define PHILO_0_PRIO 1
/*.$declare${AOs::AO_Philo0} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo0;
/*.$enddecl${AOs::AO_Philo0} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo1} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo1;
/*.$enddecl${AOs::AO_Philo1} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo2} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo2;
/*.$enddecl${AOs::AO_Philo2} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo3} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo3;
/*.$enddecl${AOs::AO_Philo3} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo4} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo4;
/*.$enddecl${AOs::AO_Philo4} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Table AO_Table;
/*.$enddecl${AOs::AO_Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::Philo_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo_ctor} ......................................................*/
void Philo_ctor(void);
/*.$enddecl${AOs::Philo_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::Table_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table_ctor} ......................................................*/
void Table_ctor(void);
/*.$enddecl${AOs::Table_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#endif /* DPP_H */
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/dpp.qm
================================================
Dining Philosopher Problem example with QActiveQActive_armX(&me->super, 0U, THINK_TIME, 0U);QActive_disarmX(&me->super, 0U);Q_ERROR(); /* these events should never arrive in this state */QACTIVE_POST(&AO_Table, HUNGRY_SIG, me->super.prio);Q_ERROR(); /* this event should never arrive in this state */QActive_armX(&me->super, 0U, EAT_TIME, 0U);QActive_disarmX(&me->super, 0U);
QACTIVE_POST(QF_ACTIVE_CAST(&AO_Table), DONE_SIG, me->super.prio);Q_ERROR(); /* these events should never arrive in this state */uint8_t n;
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "thinking");
}BSP_terminate(0);Q_ERROR();uint8_t n;
for (n = 0U; n < N_PHILO; ++n) { /* give permissions to eat... */
if ((me->isHungry[n] != 0U)
&& (me->fork[LEFT(n)] == FREE)
&& (me->fork[n] == FREE))
{
QActive *philo;
me->fork[LEFT(n)] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "eating ");
}
}uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "hungry ");
m = LEFT(n);(me->fork[m] == FREE) && (me->fork[n] == FREE)me->fork[m] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
BSP_displayPhilStat(n, "eating ");elseme->isHungry[n] = 1U;uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;
m = RIGHT(n); /* check the right neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[m] == FREE)) {
me->fork[n] = USED;
me->fork[m] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}
m = LEFT(n); /* check the left neighbor */
n = LEFT(m); /* left fork of the left neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[n] == FREE)) {
me->fork[m] = USED;
me->fork[n] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}Q_ERROR();BSP_displayPaused(1U);BSP_displayPaused(0U);uint8_t n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* philo ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
me->isHungry[n] = 1U;
BSP_displayPhilStat(n, "hungry ");uint8_t n, m;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;QActive_ctor(&AO_Philo0.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo1.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo2.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo3.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo4.super, Q_STATE_CAST(&Philo_initial));
BSP_randomSeed(123U);uint8_t n;
Table *me = &AO_Table;
QActive_ctor(&me->super, Q_STATE_CAST(&Table_initial));
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
}#ifndef DPP_H
#define DPP_H
enum DPPSignals {
EAT_SIG = Q_USER_SIG, /* published by Table to let a philosopher eat */
DONE_SIG, /* published by Philosopher when done eating */
PAUSE_SIG, /* published by BSP to pause the application */
SERVE_SIG, /* published by BSP to pause the application */
TERMINATE_SIG, /* published by BSP to terminate the application */
HUNGRY_SIG, /* posted direclty to Table from hungry Philo */
MAX_SIG /* the last signal */
};
/* number of philosophers */
#define N_PHILO ((uint8_t)5)
#define PHILO_0_PRIO 1
$declare${AOs::AO_Philo0}
$declare${AOs::AO_Philo1}
$declare${AOs::AO_Philo2}
$declare${AOs::AO_Philo3}
$declare${AOs::AO_Philo4}
$declare${AOs::AO_Table}
$declare${AOs::Philo_ctor}
$declare${AOs::Table_ctor}
#endif /* DPP_H */
#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("philo")
/* Active object class -----------------------------------------------------*/
$declare${AOs::Philo}
/* Global objects ----------------------------------------------------------*/
$define${AOs::AO_Philo0}
$define${AOs::AO_Philo1}
$define${AOs::AO_Philo2}
$define${AOs::AO_Philo3}
$define${AOs::AO_Philo4}
/* Local objects -----------------------------------------------------------*/
#define THINK_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + (BSP_TICKS_PER_SEC/2U))
#define EAT_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + BSP_TICKS_PER_SEC)
/* Philo definition --------------------------------------------------------*/
$define${AOs::Philo_ctor}
$define${AOs::Philo}#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("table")
/* Active object class -----------------------------------------------------*/
$declare${AOs::Table}
/* Global objects ----------------------------------------------------------*/
$define${AOs::AO_Table}
#define RIGHT(n_) ((uint8_t)(((n_) + (N_PHILO - 1U)) % N_PHILO))
#define LEFT(n_) ((uint8_t)(((n_) + 1U) % N_PHILO))
#define FREE ((uint8_t)0)
#define USED ((uint8_t)1)
/*..........................................................................*/
$define${AOs::Table_ctor}
$define${AOs::Table}
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/main.c
================================================
/*****************************************************************************
* Product: DPP example
* Last Updated for Version: 5.8.0
* Date of the Last Update: 2016-11-06
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h" /* QP-nano */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
/*..........................................................................*/
static QEvt l_philoQueue[N_PHILO][N_PHILO];
static QEvt l_tableQueue[2];
/* QF_active[] array defines all active object control blocks --------------*/
QActiveCB const Q_ROM QF_active[] = {
{ (QActive *)0, (QEvt *)0, 0U },
{ (QActive *)&AO_Philo0, l_philoQueue[0], Q_DIM(l_philoQueue[0]) },
{ (QActive *)&AO_Philo1, l_philoQueue[1], Q_DIM(l_philoQueue[1]) },
{ (QActive *)&AO_Philo2, l_philoQueue[2], Q_DIM(l_philoQueue[2]) },
{ (QActive *)&AO_Philo3, l_philoQueue[3], Q_DIM(l_philoQueue[3]) },
{ (QActive *)&AO_Philo4, l_philoQueue[4], Q_DIM(l_philoQueue[4]) },
{ (QActive *)&AO_Table, l_tableQueue, Q_DIM(l_tableQueue) }
};
/*..........................................................................*/
int_t main() {
Philo_ctor(); /* instantiate all Philo AOs */
Table_ctor(); /* instantiate the Table AO */
QF_init(Q_DIM(QF_active)); /* initialize the QF-nano framework */
BSP_init(); /* initialize the Board Support Package */
return QF_run(); /* transfer control to QF-nano */
}
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/philo.c
================================================
/*.$file${.::philo.c} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: dpp.qm
* File: ${.::philo.c}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::philo.c} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("philo")
/* Active object class -----------------------------------------------------*/
/*.$declare${AOs::Philo} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo} ...........................................................*/
typedef struct Philo {
/* protected: */
QActive super;
} Philo;
/* protected: */
static QState Philo_initial(Philo * const me);
static QState Philo_thinking(Philo * const me);
static QState Philo_hungry(Philo * const me);
static QState Philo_eating(Philo * const me);
/*.$enddecl${AOs::Philo} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Global objects ----------------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*. Check for the minimum required QP version */
#if (QP_VERSION < 650U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpn version 6.5.0 or higher required
#endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo0} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo0} .......................................................*/
struct Philo AO_Philo0;
/*.$enddef${AOs::AO_Philo0} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo1} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo1} .......................................................*/
struct Philo AO_Philo1;
/*.$enddef${AOs::AO_Philo1} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo2} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo2} .......................................................*/
struct Philo AO_Philo2;
/*.$enddef${AOs::AO_Philo2} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo3} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo3} .......................................................*/
struct Philo AO_Philo3;
/*.$enddef${AOs::AO_Philo3} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo4} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo4} .......................................................*/
struct Philo AO_Philo4;
/*.$enddef${AOs::AO_Philo4} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Local objects -----------------------------------------------------------*/
#define THINK_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + (BSP_TICKS_PER_SEC/2U))
#define EAT_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + BSP_TICKS_PER_SEC)
/* Philo definition --------------------------------------------------------*/
/*.$define${AOs::Philo_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo_ctor} ......................................................*/
void Philo_ctor(void) {
QActive_ctor(&AO_Philo0.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo1.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo2.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo3.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo4.super, Q_STATE_CAST(&Philo_initial));
BSP_randomSeed(123U);
}
/*.$enddef${AOs::Philo_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Philo} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo} ...........................................................*/
/*.${AOs::Philo::SM} .......................................................*/
static QState Philo_initial(Philo * const me) {
/*.${AOs::Philo::SM::initial} */
return Q_TRAN(&Philo_thinking);
}
/*.${AOs::Philo::SM::thinking} .............................................*/
static QState Philo_thinking(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Philo::SM::thinking} */
case Q_ENTRY_SIG: {
QActive_armX(&me->super, 0U, THINK_TIME, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::thinking} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::thinking::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Philo_hungry);
break;
}
/*.${AOs::Philo::SM::thinking::EAT, DONE} */
case EAT_SIG: /* intentionally fall through */
case DONE_SIG: {
Q_ERROR(); /* these events should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Philo::SM::hungry} ...............................................*/
static QState Philo_hungry(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Philo::SM::hungry} */
case Q_ENTRY_SIG: {
QACTIVE_POST(&AO_Table, HUNGRY_SIG, me->super.prio);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::hungry::EAT} */
case EAT_SIG: {
status_ = Q_TRAN(&Philo_eating);
break;
}
/*.${AOs::Philo::SM::hungry::DONE} */
case DONE_SIG: {
Q_ERROR(); /* this event should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Philo::SM::eating} ...............................................*/
static QState Philo_eating(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Philo::SM::eating} */
case Q_ENTRY_SIG: {
QActive_armX(&me->super, 0U, EAT_TIME, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::eating} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
QACTIVE_POST(QF_ACTIVE_CAST(&AO_Table), DONE_SIG, me->super.prio);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::eating::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Philo_thinking);
break;
}
/*.${AOs::Philo::SM::eating::EAT, DONE} */
case EAT_SIG: /* intentionally fall through */
case DONE_SIG: {
Q_ERROR(); /* these events should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.$enddef${AOs::Philo} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qk/armclang/README.txt
================================================
About this Example
==================
This example demonstrates how to use the uVision IDE together with
the MDK-ARM toolchain.
uVision Project File
====================
The MDK-ARM uVision project file provided with this example uses
relative paths to the QP framework location (includes, port, and
libraries. These relative paths must be modified when the project
is moved to different relative location.
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the
command-line options for the ARM assembler (see the Asm tab in
the "Options for Target" dialog box in uVision). Specifically,
you should define symbols: Stack_Size=xxx Heap_Size=yyy, where
xxx represents a numerical value of stack size and yyy the
numerical value of the heap size (for most embedded projects
yyy should be 0, as the using the heap is not recommended).
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\efm32pg1b\arm\startup_efm32pg1b.s
The file startup_efm32pg1b.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qk/armclang/dpp-qk.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj; *.o*.lib*.txt; *.h; *.inc*.plm*.cpp000dpp-dbg0x4ARM-ADS120000001110016553500079668.\dbg\11101101000011111110010130111111111111101011001003Segger\JL2CM3.dll0DLGUARM/0JL2CM3-U440060969 -O207 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO7 -FD20000000 -FC8000 -FN1 -FF0GECKOP2.FLM -FS00 -FL040000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10UL2CM3UL2CM3(-O207 -S0 -C0 -FO7 -FN1 -FC8000 -FD20000000 -FF0GECKOP2 -FL020000 -FS00 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)0DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E2006F4 -O4622 -S4 -FO61120x200002000200x40000001000010000000000000000000dpp-rel0x4ARM-ADS120000001110016553500079668.\rel\11101101000011111110010030111111111111101011001003Segger\JL2CM3.dll0JL2CM3-U440060969 -O207 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO7 -FD20000000 -FC8000 -FN1 -FF0GECKOP2.FLM -FS00 -FL020000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)0DLGUARM/0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E10259B -O4622 -S4 -FO610UL2CM3-O207 -S0 -C0 -FO7 -FN1 -FC8000 -FD20000000 -FF0GECKOP2 -FL020000 -FS00 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)120x200002000200x40000001000010000000000000000000Applicatioin1000111000..\bsp.cbsp.c00121000..\..\main.cmain.c00135000..\..\dpp.hdpp.h00141000..\..\..\..\..\include\qstamp.cqstamp.c00151000..\..\philo.cphilo.c00161000..\..\table.ctable.c00efm32pg1b1000271000..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.cem_cmu.c00281000..\..\..\..\..\3rd_party\efm32pg1b\em_emu.cem_emu.c00291000..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.cem_gpio.c002101000..\..\..\..\..\3rd_party\efm32pg1b\em_int.cem_int.c002111000..\..\..\..\..\3rd_party\efm32pg1b\em_rtcc.cem_rtcc.c002121000..\..\..\..\..\3rd_party\efm32pg1b\em_system.cem_system.c002131000..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.csystem_efm32pg1b.c002142000..\..\..\..\..\3rd_party\efm32pg1b\arm\startup_efm32pg1b.sstartup_efm32pg1b.s00QP10003151000..\..\..\..\..\src\qfn\qepn.cqepn.c003161000..\..\..\..\..\src\qfn\qfn.cqfn.c003171000..\..\..\..\..\src\qkn\qkn.cqkn.c00QP_port10004185000..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqfn_port.h004191000..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.cqkn_port.c00
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qk/armclang/dpp-qk.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwaredpp-dbg0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1EFM32PG1B200F256GM48Silicon LabsSiliconLabs.EFM32PG1B_DFP.5.5.0https://www.silabs.com/documents/public/cmsis-packs/IRAM(0x20000000,0x00008000) IROM(0x00000000,0x00020000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC8000 -FN1 -FF0GECKOP2 -FS00 -FL020000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM))0$$Device:EFM32PG1B200F256GM48$Device\EFM32PG1B\Include\em_device.h$$Device:EFM32PG1B200F256GM48$SVD\EFM32PG1B\EFM32PG1B200F256GM48.svd0000001.\dbg\dpp-qk10011.\dbg\10000000010cmd /c "del .\dbg\qstamp.o"000010fromelf --bin --output .\dbg\dpp-qk.bin .\dbg\dpp-qk.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140961BIN\UL2CM3.DLL"" ()0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x2000000x00x010x00x010x00x010x00x010x00x2000010x00x000x00x000x00x000x00x000x200000000x800000x00x007001000003011003300000EFM32PG1B200F256GM48=1 __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\efm32pg1b1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cmain.c1..\..\main.cdpp.h5..\..\dpp.hqstamp.c1..\..\..\..\..\include\qstamp.cphilo.c1..\..\philo.ctable.c1..\..\table.cefm32pg1bem_cmu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.cem_emu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_emu.cem_gpio.c1..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.cem_int.c1..\..\..\..\..\3rd_party\efm32pg1b\em_int.cem_rtcc.c1..\..\..\..\..\3rd_party\efm32pg1b\em_rtcc.cem_system.c1..\..\..\..\..\3rd_party\efm32pg1b\em_system.csystem_efm32pg1b.c1..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.cstartup_efm32pg1b.s2..\..\..\..\..\3rd_party\efm32pg1b\arm\startup_efm32pg1b.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.cdpp-rel0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1EFM32PG1B200F256GM48Silicon LabsSiliconLabs.EFM32PG1B_DFP.5.5.0https://www.silabs.com/documents/public/cmsis-packs/IRAM(0x20000000,0x00008000) IROM(0x00000000,0x00020000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC8000 -FN1 -FF0GECKOP2 -FS00 -FL020000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM))0$$Device:EFM32PG1B200F256GM48$Device\EFM32PG1B\Include\em_device.h$$Device:EFM32PG1B200F256GM48$SVD\EFM32PG1B\EFM32PG1B200F256GM48.svd0000001.\rel\dpp-qk10000.\rel\10000000010cmd /c "del .\rel\qstamp.o"000010fromelf --bin --output .\rel\dpp-qk.bin .\rel\dpp-qk.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140961BIN\UL2CM3.DLL"" ()0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x2000000x00x010x00x010x00x010x00x010x00x2000010x00x000x00x000x00x000x00x000x200000000x800000x00x007001000003011003300000NDEBUG EFM32PG1B200F256GM48=1 __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\efm32pg1b1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000dpp-qk.sct--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cmain.c1..\..\main.cdpp.h5..\..\dpp.hqstamp.c1..\..\..\..\..\include\qstamp.cphilo.c1..\..\philo.ctable.c1..\..\table.cefm32pg1bem_cmu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.cem_emu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_emu.cem_gpio.c1..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.cem_int.c1..\..\..\..\..\3rd_party\efm32pg1b\em_int.cem_rtcc.c1..\..\..\..\..\3rd_party\efm32pg1b\em_rtcc.cem_system.c1..\..\..\..\..\3rd_party\efm32pg1b\em_system.csystem_efm32pg1b.c1..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.cstartup_efm32pg1b.s2..\..\..\..\..\3rd_party\efm32pg1b\arm\startup_efm32pg1b.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.c
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qk/bsp.c
================================================
/*****************************************************************************
* Product: DPP example, EFM32-SLSTK3401A board, preemptive QK kernel
* Last Updated for Version: 5.9.7
* Date of the Last Update: 2018-08-18
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "dpp.h"
#include "bsp.h"
#include "em_device.h" /* the device specific header (SiLabs) */
#include "em_cmu.h" /* Clock Management Unit (SiLabs) */
#include "em_gpio.h" /* GPIO (SiLabs) */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
enum KernelUnawareISRs { /* see NOTE00 */
/* ... */
MAX_KERNEL_UNAWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-unaware" interrupts can't overlap "kernel-aware" interrupts */
Q_ASSERT_COMPILE(MAX_KERNEL_UNAWARE_CMSIS_PRI <= QF_AWARE_ISR_CMSIS_PRI);
enum KernelAwareISRs {
GPIO_EVEN_PRIO = QF_AWARE_ISR_CMSIS_PRI, /* see NOTE00 */
SYSTICK_PRIO,
/* ... */
MAX_KERNEL_AWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-aware" interrupts should not overlap the PendSV priority */
Q_ASSERT_COMPILE(MAX_KERNEL_AWARE_CMSIS_PRI <= (0xFF >>(8-__NVIC_PRIO_BITS)));
/* ISRs defined in this BSP ------------------------------------------------*/
void SysTick_Handler(void);
void GPIO_EVEN_IRQHandler(void);
/* Local-scope objects -----------------------------------------------------*/
#define LED_PORT gpioPortF
#define LED0_PIN 4
#define LED1_PIN 5
#define PB_PORT gpioPortF
#define PB0_PIN 6
#define PB1_PIN 7
static uint32_t l_rnd; /* random seed */
/*..........................................................................*/
void SysTick_Handler(void) {
/* state of the button debouncing, see below */
static struct ButtonsDebouncing {
uint32_t depressed;
uint32_t previous;
} buttons = { ~0U, ~0U };
uint32_t current;
uint32_t tmp;
QK_ISR_ENTRY(); /* inform QK about entering an ISR */
QF_tickXISR(0U); /* process time events for rate 0 */
/* Perform the debouncing of buttons. The algorithm for debouncing
* adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
* and Michael Barr, page 71.
*/
current = ~GPIO->P[PB_PORT].DIN; /* read PB0 and BP1 */
tmp = buttons.depressed; /* save the debounced depressed buttons */
buttons.depressed |= (buttons.previous & current); /* set depressed */
buttons.depressed &= (buttons.previous | current); /* clear released */
buttons.previous = current; /* update the history */
tmp ^= buttons.depressed; /* changed debounced depressed */
if ((tmp & (1U << PB0_PIN)) != 0U) { /* debounced PB0 state changed? */
if ((buttons.depressed & (1U << PB0_PIN)) != 0U) { /* PB0 depressed?*/
QACTIVE_POST_ISR(&AO_Table, PAUSE_SIG, 0U);
}
else { /* the button is released */
QACTIVE_POST_ISR(&AO_Table, SERVE_SIG, 0U);
}
}
QK_ISR_EXIT(); /* inform QK about exiting an ISR */
}
/*..........................................................................*/
void GPIO_EVEN_IRQHandler(void) {
QK_ISR_ENTRY(); /* inform QK about entering an ISR */
QACTIVE_POST_ISR(&AO_Table, MAX_SIG, 0U);
QK_ISR_EXIT(); /* inform QK about exiting an ISR */
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* NOTE: SystemInit() already called from the startup code
* but SystemCoreClock needs to be updated
*/
SystemCoreClockUpdate();
/* configure the FPU usage by choosing one of the options... */
#if 1
/* OPTION 1:
* Use the automatic FPU state preservation and the FPU lazy stacking.
*
* NOTE:
* Use the following setting when FPU is used in more than one task or
* in any ISRs. This setting is the safest and recommended, but requires
* extra stack space and CPU cycles.
*/
FPU->FPCCR |= (1U << FPU_FPCCR_ASPEN_Pos) | (1U << FPU_FPCCR_LSPEN_Pos);
#else
/* OPTION 2:
* Do NOT to use the automatic FPU state preservation and
* do NOT to use the FPU lazy stacking.
*
* NOTE:
* Use the following setting when FPU is used in ONE task only and not
* in any ISR. This setting is very efficient, but if more than one task
* (or ISR) start using the FPU, this can lead to corruption of the
* FPU registers. This option should be used with CAUTION.
*/
FPU->FPCCR &= ~((1U << FPU_FPCCR_ASPEN_Pos) | (1U << FPU_FPCCR_LSPEN_Pos));
#endif
/* enable clock for to the peripherals used by this application... */
CMU_ClockEnable(cmuClock_HFPER, true);
CMU_ClockEnable(cmuClock_GPIO, true);
CMU_ClockEnable(cmuClock_HFPER, true);
CMU_ClockEnable(cmuClock_GPIO, true);
/* configure the LEDs */
GPIO_PinModeSet(LED_PORT, LED0_PIN, gpioModePushPull, 0);
GPIO_PinModeSet(LED_PORT, LED1_PIN, gpioModePushPull, 0);
GPIO_PinOutClear(LED_PORT, LED0_PIN);
GPIO_PinOutClear(LED_PORT, LED1_PIN);
/* configure the Buttons */
GPIO_PinModeSet(PB_PORT, PB0_PIN, gpioModeInputPull, 1);
GPIO_PinModeSet(PB_PORT, PB1_PIN, gpioModeInputPull, 1);
BSP_randomSeed(1234U);
}
/*..........................................................................*/
void BSP_displayPhilStat(uint8_t n, char const *stat) {
if (stat[0] == 'e') {
GPIO->P[LED_PORT].DOUT |= (1U << LED0_PIN);
}
else {
GPIO->P[LED_PORT].DOUT &= ~(1U << LED0_PIN);
}
}
/*..........................................................................*/
void BSP_displayPaused(uint8_t paused) {
if (paused != 0U) {
GPIO->P[LED_PORT].DOUT |= (1U << LED0_PIN);
}
else {
GPIO->P[LED_PORT].DOUT &= ~(1U << LED0_PIN);
}
}
/*..........................................................................*/
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
uint32_t rnd;
QSchedStatus lockStat; /* <=== QK scheduler lock status */
/* The flating point code is to exercise the FPU... */
float volatile x = 3.1415926F;
x = x + 2.7182818F;
lockStat = QK_schedLock(N_PHILO); /* <=== lock scheduler up to N_PHILO prio */
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
rnd = l_rnd * (3U*7U*11U*13U*23U);
l_rnd = rnd; /* set for the next time */
QK_schedUnlock(lockStat); /* <=== unlock the scheduler */
return (rnd >> 8);
}
/*..........................................................................*/
void BSP_randomSeed(uint32_t seed) {
l_rnd = seed;
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
(void)result;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set up the SysTick timer to fire at BSP_TICKS_PER_SEC rate */
SysTick_Config(SystemCoreClock / BSP_TICKS_PER_SEC);
/* assing all priority bits for preemption-prio. and none to sub-prio. */
NVIC_SetPriorityGrouping(0U);
/* set priorities of ALL ISRs used in the system, see NOTE00
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
NVIC_SetPriority(SysTick_IRQn, SYSTICK_PRIO);
NVIC_SetPriority(GPIO_EVEN_IRQn, GPIO_EVEN_PRIO);
/* ... */
/* enable IRQs... */
NVIC_EnableIRQ(GPIO_EVEN_IRQn);
}
/*..........................................................................*/
void QK_onIdle(void) {
/* toggle the User LED on and then off, see NOTE01 */
QF_INT_DISABLE();
GPIO->P[LED_PORT].DOUT |= (1U << LED1_PIN);
GPIO->P[LED_PORT].DOUT &= ~(1U << LED1_PIN);
QF_INT_ENABLE();
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular Cortex-M3 MCU.
*/
__WFI(); /* Wait-For-Interrupt */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int loc) {
/*
* NOTE: add here your application-specific error handling
*/
(void)module;
(void)loc;
#ifndef NDEBUG
/* light up both LEDs */
GPIO->P[LED_PORT].DOUT |= ((1U << LED0_PIN) | (1U << LED1_PIN));
/* for debugging, hang on in an endless loop until PB1 is pressed... */
while ((GPIO->P[PB_PORT].DIN & (1U << PB1_PIN)) != 0) {
}
#endif
NVIC_SystemReset();
}
/*****************************************************************************
* NOTE00:
* The QF_AWARE_ISR_CMSIS_PRI constant from the QF port specifies the highest
* ISR priority that is disabled by the QF framework. The value is suitable
* for the NVIC_SetPriority() CMSIS function.
*
* Only ISRs prioritized at or below the QF_AWARE_ISR_CMSIS_PRI level (i.e.,
* with the numerical values of priorities equal or higher than
* QF_AWARE_ISR_CMSIS_PRI) are allowed to call the QK_ISR_ENTRY/QK_ISR_ENTRY
* macros or any other QF/QK services. These ISRs are "QF-aware".
*
* Conversely, any ISRs prioritized above the QF_AWARE_ISR_CMSIS_PRI priority
* level (i.e., with the numerical values of priorities less than
* QF_AWARE_ISR_CMSIS_PRI) are never disabled and are not aware of the kernel.
* Such "QF-unaware" ISRs cannot call any QF/QK services. In particular they
* can NOT call the macros QK_ISR_ENTRY/QK_ISR_ENTRY. The only mechanism
* by which a "QF-unaware" ISR can communicate with the QF framework is by
* triggering a "QF-aware" ISR, which can post/publish events.
*
* NOTE01:
* The User LED is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qk/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano on EMF32-SLSTK3401A, QK-nano kernel, GNU-ARM
# Last Updated for Version: 6.5.0
# Date of the Last Update: 2019-04-15
#
# Q u a n t u m L e a P s
# ------------------------
# Modern Embedded Software
#
# Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# https://www.state-machine.com
# mailto:info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := dpp-qk
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/arm-cm/qk/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qkn \
$(QP_PORT_DIR) \
$(QPN)/3rd_party/efm32pg1b \
$(QPN)/3rd_party/efm32pg1b/gnu
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR) \
-I$(QPN)/3rd_party/CMSIS/Include \
-I$(QPN)/3rd_party/efm32pg1b
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
bsp.c \
main.c \
philo.c \
table.c \
startup_efm32pg1b.c \
system_efm32pg1b.c \
em_cmu.c \
em_emu.c \
em_gpio.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qepn.c \
qfn.c \
qkn.c \
qkn_port.c
QP_ASMS :=
LIB_DIRS :=
LIBS :=
# defines
DEFINES := -DEFM32PG1B200F256GM48=1
# ARM CPU, ARCH, FPU, and Float-ABI types...
# ARM_CPU: [cortex-m0 | cortex-m0plus | cortex-m1 | cortex-m3 | cortex-m4]
# ARM_ARCH: [6 | 7] (NOTE: must match ARM_CPU!)
# ARM_FPU: [ | vfp]
# FLOAT_ABI: [ | soft | softfp | hard]
#
ARM_CPU := -mcpu=cortex-m4
ARM_ARCH := 7 # NOTE: must match the ARM_CPU!
ARM_FPU := -mfpu=vfp
FLOAT_ABI := -mfloat-abi=softfp
#-----------------------------------------------------------------------------
# GNU-ARM toolset (NOTE: You need to adjust to your machine)
# see https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
#
ifeq ($(GNU_ARM),)
GNU_ARM := $(QTOOLS)/gnu_arm-none-eabi
endif
# make sure that the GNU-ARM toolset exists...
ifeq ("$(wildcard $(GNU_ARM))","")
$(error GNU_ARM toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_ARM)/bin/arm-none-eabi-gcc
CPP := $(GNU_ARM)/bin/arm-none-eabi-g++
AS := $(GNU_ARM)/bin/arm-none-eabi-as
LINK := $(GNU_ARM)/bin/arm-none-eabi-g++
BIN := $(GNU_ARM)/bin/arm-none-eabi-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M
#
# combine all the soruces...
C_SRCS += $(QP_SRCS)
ASM_SRCS += $(QP_ASMS)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS = $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration ..........................................
BIN_DIR := dbg
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O $(INCLUDES) $(DEFINES)
CPPFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES)
endif # ......................................................................
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
-specs=nosys.specs -specs=nano.specs \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_BIN := $(BIN_DIR)/$(OUTPUT).bin
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_BIN)
#all: $(TARGET_ELF)
$(TARGET_BIN): $(TARGET_ELF)
$(BIN) -O binary $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(CC) $(CFLAGS) $(QPN)/include/qstamp.c -o $(BIN_DIR)/qstamp.o
$(LINK) $(LINKFLAGS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.bin \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qk/gnu/README.txt
================================================
About this Example
==================
This example can be built from the command prompt with the provided
Makefile. The example can also be imported as a Makefile-based
project into Eclipse-based IDEs.
The Makefile
============
The provided Makefile should be easy to adapt for your own projects.
It contains two build configurations: Debug (default) and Release.
Also, the Makefile has been specifically designed to work as an external
Makefile with the Eclipse CDT.
The various build configurations are built as follows:
make
make CONF=rel
make clean
make CONF=rel clean
***
NOTE:
The installation folder of the GNU-ARM toolset on YOUR machine needs
to be adjusted in the provided Makefile, by editing the symbol: GNU_ARM.
As described in the comment for this symbol, the GNU-ARM toolset is taken
from: http://gnutoolchains.com/arm-eabi
It is highly recommened to use the same GNU-ARM distribution, especially
for ARM Cortex-M4F projects, due to the support for the hardware FPU
(float-abi=hard).
***
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the GCC linker
script (.ld file), which provides a template of the recommended GCC linker
script for QP applications.
Startup Code
============
The startup code for the EFM32PG1B200F256GM48 MCU used in this project
is located in the "3rd_party" folder in the following location:
qpc\3rd_party\efm32pg1b\gnu\startup_efm32pg1b.c
The file startup_efm32pg1b.c provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qk/gnu/dpp-qk.ld
================================================
/*****************************************************************************
* Product: Linker script for EFM32-SLSTK3401A, GNU-ARM linker
* Last Updated for Version: 5.9.8
* Date of the Last Update: 2017-09-13
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* http://www.state-machine.com
* mailto:info@state-machine.com
*****************************************************************************/
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(Reset_Handler) /* entry Point */
MEMORY { /* memory map of Pearl Gecko EFM32PG1B200F256GM48 */
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 256K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
}
/* The size of the stack used by the application. NOTE: you need to adjust */
STACK_SIZE = 1024;
/* The size of the heap used by the application. NOTE: you need to adjust */
HEAP_SIZE = 0;
SECTIONS {
.isr_vector : { /* the vector table goes FIRST into ROM */
KEEP(*(.isr_vector)) /* vector table */
. = ALIGN(4);
} >ROM
.text : { /* code and constants */
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} >ROM
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >ROM
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >ROM
.fini_array : {
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array*))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >ROM
_etext = .; /* global symbols at end of code */
.stack : {
__stack_start__ = .;
. = . + STACK_SIZE;
. = ALIGN(4);
__stack_end__ = .;
} >RAM
.data : AT (_etext) {
__data_load = LOADADDR (.data);
__data_start = .;
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
__data_end__ = .;
_edata = __data_end__;
} >RAM
.bss : {
__bss_start__ = .;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = .;
} >RAM
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >RAM
__exidx_end = .;
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );
PROVIDE ( __end__ = _ebss );
.heap : {
__heap_start__ = .;
. = . + HEAP_SIZE;
. = ALIGN(4);
__heap_end__ = .;
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ : {
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
}
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qk/gnu/flash.bat
================================================
::============================================================================
:: Batch file to program the flash of EFM32-SLSTK3401A board
::
:: NOTE: requires the J-Link commander (JLink.exe) from SEGGER, see:
:: https://www.segger.com/j-link-commander.html
::
setlocal
@echo off
@echo Load a given binary file to the flash of EFM32-SLSTK3401A
@echo usage: flash bin-file
@echo example: flash dbg\blinky-qk.bin
::----------------------------------------------------------------------------
:: NOTE: Adjust the following symbol to the location of the
:: JLink utility on your machine
::
if [%JLINK%] EQU [] set JLINK=%QTOOLS%\..\JLink
if not exist "%JLINK%\JLink.exe" (
@echo The JLink tool not found. Please adjust flash.bat
@goto end
)
if ["%~1"]==[""] (
@echo The binary file missing
@goto end
)
if not exist %~s1 (
@echo The binary file '%1' does not exist
@goto end
)
:: generate the Jlink command file depending on the first parameter %1
@echo si 1 >flash.jlink
@echo speed 4000 >>flash.jlink
@echo r >>flash.jlink
@echo h >>flash.jlink
@echo loadbin %1, 0 >>flash.jlink
@echo exit >>flash.jlink
@echo on
%JLINK%\JLink.exe -device EFM32PG1B200F256GM48 flash.jlink
@echo off
@del flash.jlink
:end
endlocal
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qk/iar/README.txt
================================================
About this Example
==================
This example demonstrates how to use the IAR EWARM IDE to build
a QP application.
IAR Project File
----------------
The IAR EWARM project file provided with this example uses relative paths
to the QP/C framework location (includes, port, and libraries. These
relative paths must be modified when the project is moved to different
relative location.
Stack Size and Heap Size
------------------------
In this project, the size of the C stack and heap are determined in
the linker script blinky-qk.icf (see the next section).
Linker Script
-------------
The IAR linker script provides a template of the recommended linker script
for QP applications. This file needs to be customized to set the
application-specific sizes of the Stack and Heap. This file can be edited
from the IAR EWARM IDE via the Project Options/Linker settings.
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\efm32pg1b\iar\startup_efm32pg1b.s
The file startup_efm32pg1b.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qk/iar/dpp-qk.ewd
================================================
3DebugARM1C-SPY22911ARMSIM_ID2111CADI_ID2011CMSISDAP_ID2411GDBSERVER_ID2011IJET_ID2811JLINK_ID21611LMIFTDI_ID2211PEMICRO_ID2311STLINK_ID2411THIRDPARTY_ID2011TIFET_ID2111XDS100_ID2611$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\Mbed\MbedArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\TargetAccessServer\TargetAccessServer.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseARM0C-SPY22910ARMSIM_ID2110CADI_ID2010CMSISDAP_ID2410GDBSERVER_ID2010IJET_ID2810JLINK_ID21610LMIFTDI_ID2210PEMICRO_ID2310STLINK_ID2410THIRDPARTY_ID2010TIFET_ID2110XDS100_ID2610$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\Mbed\MbedArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\TargetAccessServer\TargetAccessServer.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qk/iar/dpp-qk.ewp
================================================
3DebugARM1General33011ICCARM23411AARM21011OBJCOPY0111CUSTOM30BICOMP0BUILDACTION1cmd /c "if exist $OBJ_DIR$\qstamp.o del $OBJ_DIR$\qstamp.o"ILINK02011IARCHIVE0011BILINK0Coder0ReleaseARM0General33010ICCARM23410AARM21010OBJCOPY0110CUSTOM30BICOMP0BUILDACTION1cmd /c "if exist $OBJ_DIR$\qstamp.o del $OBJ_DIR$\qstamp.o"ILINK02010IARCHIVE0010BILINK0Coder0Application$PROJ_DIR$\..\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\dpp.h$PROJ_DIR$\..\..\main.c$PROJ_DIR$\..\..\philo.c$PROJ_DIR$\..\..\qpn_conf.h$PROJ_DIR$\..\..\..\..\..\include\qstamp.c$PROJ_DIR$\..\..\table.cefm32pg1b$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_assert.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_emu.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_system.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\iar\startup_efm32pg1b.s$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.cQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qkn\qkn.cQP_port$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qk\iar\qkn_port.c
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qk/iar/dpp-qk.eww
================================================
$WS_DIR$\dpp-qk.ewp
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qk/iar/dpp-qk.icf
================================================
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0003FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 1024;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place at start of RAM_region {block CSTACK };
place in RAM_region { readwrite, block HEAP };
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qpn_conf.h
================================================
/*****************************************************************************
* Product: QP-nano configuration for the Blinky example
* Last Updated for Version: 5.9.7
* Date of the Last Update: 2017-08-18
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef QPN_CONF_H
#define QPN_CONF_H
#define Q_PARAM_SIZE 4U
#define QF_MAX_TICK_RATE 1U
#define QF_TIMEEVT_CTR_SIZE 2U
#define QF_TIMEEVT_PERIODIC
#define QK_SCHED_LOCK
#endif /* QPN_CONF_H */
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qv/armclang/README.txt
================================================
About this Example
==================
This example demonstrates how to use the uVision IDE together with
the MDK-ARM toolchain.
uVision Project File
====================
The MDK-ARM uVision project file provided with this example uses
relative paths to the QP framework location (includes, port, and
libraries. These relative paths must be modified when the project
is moved to different relative location.
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the
command-line options for the ARM assembler (see the Asm tab in
the "Options for Target" dialog box in uVision). Specifically,
you should define symbols: Stack_Size=xxx Heap_Size=yyy, where
xxx represents a numerical value of stack size and yyy the
numerical value of the heap size (for most embedded projects
yyy should be 0, as the using the heap is not recommended).
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\efm32pg1b\arm\startup_efm32pg1b.s
The file startup_efm32pg1b.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qv/armclang/dpp-qv.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj; *.o*.lib*.txt; *.h; *.inc*.plm*.cpp000dpp-dbg0x4ARM-ADS120000001110016553500079668.\dbg\11101101000011111110010130111111111111101011001003Segger\JL2CM3.dll0DLGUARM/0JL2CM3-U440060969 -O207 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO7 -FD20000000 -FC8000 -FN1 -FF0GECKOP2.FLM -FS00 -FL040000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10UL2CM3UL2CM3(-O207 -S0 -C0 -FO7 -FN1 -FC8000 -FD20000000 -FF0GECKOP2 -FL020000 -FS00 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)0DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E2006F4 -O4622 -S4 -FO61120x200002000200x40000001000010000000000000000000dpp-rel0x4ARM-ADS120000001110016553500079668.\rel\11101101000011111110010030111111111111101011001003Segger\JL2CM3.dll0JL2CM3-U440060969 -O207 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO7 -FD20000000 -FC8000 -FN1 -FF0GECKOP2.FLM -FS00 -FL020000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)0DLGUARM/0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E10259B -O4622 -S4 -FO610UL2CM3-O207 -S0 -C0 -FO7 -FN1 -FC8000 -FD20000000 -FF0GECKOP2 -FL020000 -FS00 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)120x200002000200x40000001000010000000000000000000Applicatioin1000111000..\bsp.cbsp.c00121000..\..\main.cmain.c00135000..\..\dpp.hdpp.h00141000..\..\..\..\..\include\qstamp.cqstamp.c00151000..\..\philo.cphilo.c00161000..\..\table.ctable.c00efm32pg1b1000271000..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.cem_cmu.c00281000..\..\..\..\..\3rd_party\efm32pg1b\em_emu.cem_emu.c00291000..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.cem_gpio.c002101000..\..\..\..\..\3rd_party\efm32pg1b\em_int.cem_int.c002111000..\..\..\..\..\3rd_party\efm32pg1b\em_rtcc.cem_rtcc.c002121000..\..\..\..\..\3rd_party\efm32pg1b\em_system.cem_system.c002131000..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.csystem_efm32pg1b.c002142000..\..\..\..\..\3rd_party\efm32pg1b\arm\startup_efm32pg1b.sstartup_efm32pg1b.s00QP10003151000..\..\..\..\..\src\qfn\qepn.cqepn.c003161000..\..\..\..\..\src\qfn\qfn.cqfn.c003171000..\..\..\..\..\src\qvn\qvn.cqvn.c00QP_port10004185000..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqfn_port.h004191000..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.cqvn_port.c00
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qv/armclang/dpp-qv.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwaredpp-dbg0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1EFM32PG1B200F256GM48Silicon LabsSiliconLabs.EFM32PG1B_DFP.5.5.0https://www.silabs.com/documents/public/cmsis-packs/IRAM(0x20000000,0x00008000) IROM(0x00000000,0x00020000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC8000 -FN1 -FF0GECKOP2 -FS00 -FL020000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM))0$$Device:EFM32PG1B200F256GM48$Device\EFM32PG1B\Include\em_device.h$$Device:EFM32PG1B200F256GM48$SVD\EFM32PG1B\EFM32PG1B200F256GM48.svd0000001.\dbg\dpp-qv10011.\dbg\10000000010cmd /c "del .\dbg\qstamp.o"000010fromelf --bin --output .\dbg\dpp-qv.bin .\dbg\dpp-qv.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140961BIN\UL2CM3.DLL"" ()0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x2000000x00x010x00x010x00x010x00x010x00x2000010x00x000x00x000x00x000x00x000x200000000x800000x00x007001000003011003300000EFM32PG1B200F256GM48=1 __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\efm32pg1b1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cmain.c1..\..\main.cdpp.h5..\..\dpp.hqstamp.c1..\..\..\..\..\include\qstamp.cphilo.c1..\..\philo.ctable.c1..\..\table.cefm32pg1bem_cmu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.cem_emu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_emu.cem_gpio.c1..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.cem_int.c1..\..\..\..\..\3rd_party\efm32pg1b\em_int.cem_rtcc.c1..\..\..\..\..\3rd_party\efm32pg1b\em_rtcc.cem_system.c1..\..\..\..\..\3rd_party\efm32pg1b\em_system.csystem_efm32pg1b.c1..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.cstartup_efm32pg1b.s2..\..\..\..\..\3rd_party\efm32pg1b\arm\startup_efm32pg1b.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.cdpp-rel0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1EFM32PG1B200F256GM48Silicon LabsSiliconLabs.EFM32PG1B_DFP.5.5.0https://www.silabs.com/documents/public/cmsis-packs/IRAM(0x20000000,0x00008000) IROM(0x00000000,0x00020000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC8000 -FN1 -FF0GECKOP2 -FS00 -FL020000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM))0$$Device:EFM32PG1B200F256GM48$Device\EFM32PG1B\Include\em_device.h$$Device:EFM32PG1B200F256GM48$SVD\EFM32PG1B\EFM32PG1B200F256GM48.svd0000001.\rel\dpp-qv10000.\rel\10000000010cmd /c "del .\rel\qstamp.o"000010fromelf --bin --output .\rel\dpp-qv.bin .\rel\dpp-qv.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140961BIN\UL2CM3.DLL"" ()0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x2000000x00x010x00x010x00x010x00x010x00x2000010x00x000x00x000x00x000x00x000x200000000x800000x00x007001000003011003300000NDEBUG EFM32PG1B200F256GM48=1 __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\efm32pg1b1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000dpp-qv.sct--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cmain.c1..\..\main.cdpp.h5..\..\dpp.hqstamp.c1..\..\..\..\..\include\qstamp.cphilo.c1..\..\philo.ctable.c1..\..\table.cefm32pg1bem_cmu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.cem_emu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_emu.cem_gpio.c1..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.cem_int.c1..\..\..\..\..\3rd_party\efm32pg1b\em_int.cem_rtcc.c1..\..\..\..\..\3rd_party\efm32pg1b\em_rtcc.cem_system.c1..\..\..\..\..\3rd_party\efm32pg1b\em_system.csystem_efm32pg1b.c1..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.cstartup_efm32pg1b.s2..\..\..\..\..\3rd_party\efm32pg1b\arm\startup_efm32pg1b.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.c
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qv/bsp.c
================================================
/*****************************************************************************
* Product: DPP example, EFM32-SLSTK3401A board, cooperative QV kernel
* Last Updated for Version: 5.6.5
* Date of the Last Update: 2016-05-08
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "dpp.h"
#include "bsp.h"
#include "em_device.h" /* the device specific header (SiLabs) */
#include "em_cmu.h" /* Clock Management Unit (SiLabs) */
#include "em_gpio.h" /* GPIO (SiLabs) */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
enum KernelUnawareISRs { /* see NOTE00 */
/* ... */
MAX_KERNEL_UNAWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-unaware" interrupts can't overlap "kernel-aware" interrupts */
Q_ASSERT_COMPILE(MAX_KERNEL_UNAWARE_CMSIS_PRI <= QF_AWARE_ISR_CMSIS_PRI);
enum KernelAwareISRs {
GPIO_EVEN_PRIO = QF_AWARE_ISR_CMSIS_PRI, /* see NOTE00 */
SYSTICK_PRIO,
/* ... */
MAX_KERNEL_AWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-aware" interrupts should not overlap the PendSV priority */
Q_ASSERT_COMPILE(MAX_KERNEL_AWARE_CMSIS_PRI <= (0xFF >>(8-__NVIC_PRIO_BITS)));
/* ISRs defined in this BSP ------------------------------------------------*/
void SysTick_Handler(void);
void GPIO_EVEN_IRQHandler(void);
/* Local-scope objects -----------------------------------------------------*/
#define LED_PORT gpioPortF
#define LED0_PIN 4
#define LED1_PIN 5
#define PB_PORT gpioPortF
#define PB0_PIN 6
#define PB1_PIN 7
static uint32_t l_rnd; /* random seed */
/*..........................................................................*/
void SysTick_Handler(void) {
/* state of the button debouncing, see below */
static struct ButtonsDebouncing {
uint32_t depressed;
uint32_t previous;
} buttons = { ~0U, ~0U };
uint32_t current;
uint32_t tmp;
QF_tickXISR(0U); /* process time events for rate 0 */
/* Perform the debouncing of buttons. The algorithm for debouncing
* adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
* and Michael Barr, page 71.
*/
current = ~GPIO->P[PB_PORT].DIN; /* read PB0 and BP1 */
tmp = buttons.depressed; /* save the debounced depressed buttons */
buttons.depressed |= (buttons.previous & current); /* set depressed */
buttons.depressed &= (buttons.previous | current); /* clear released */
buttons.previous = current; /* update the history */
tmp ^= buttons.depressed; /* changed debounced depressed */
if ((tmp & (1U << PB0_PIN)) != 0U) { /* debounced PB0 state changed? */
if ((buttons.depressed & (1U << PB0_PIN)) != 0U) { /* PB0 depressed?*/
QACTIVE_POST_ISR(&AO_Table, PAUSE_SIG, 0U);
}
else { /* the button is released */
QACTIVE_POST_ISR(&AO_Table, SERVE_SIG, 0U);
}
}
}
/*..........................................................................*/
void GPIO_EVEN_IRQHandler(void) {
QACTIVE_POST_ISR(&AO_Table, MAX_SIG, 0U);
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* NOTE: SystemInit() already called from the startup code
* but SystemCoreClock needs to be updated
*/
SystemCoreClockUpdate();
/* configure the FPU usage by choosing one of the options...
*
* Do NOT to use the automatic FPU state preservation and
* do NOT to use the FPU lazy stacking.
*
* NOTE:
* Use the following setting when FPU is used only by active objects
* and NOT in any ISR. This setting is very efficient, but if any ISRs
* start using the FPU, this can lead to corruption of the FPU registers.
*/
FPU->FPCCR &= ~((1U << FPU_FPCCR_ASPEN_Pos) | (1U << FPU_FPCCR_LSPEN_Pos));
/* enable clock for to the peripherals used by this application... */
CMU_ClockEnable(cmuClock_HFPER, true);
CMU_ClockEnable(cmuClock_GPIO, true);
CMU_ClockEnable(cmuClock_HFPER, true);
CMU_ClockEnable(cmuClock_GPIO, true);
/* configure the LEDs */
GPIO_PinModeSet(LED_PORT, LED0_PIN, gpioModePushPull, 0);
GPIO_PinModeSet(LED_PORT, LED1_PIN, gpioModePushPull, 0);
GPIO_PinOutClear(LED_PORT, LED0_PIN);
GPIO_PinOutClear(LED_PORT, LED1_PIN);
/* configure the Buttons */
GPIO_PinModeSet(PB_PORT, PB0_PIN, gpioModeInputPull, 1);
GPIO_PinModeSet(PB_PORT, PB1_PIN, gpioModeInputPull, 1);
BSP_randomSeed(1234U);
}
/*..........................................................................*/
void BSP_displayPhilStat(uint8_t n, char const *stat) {
if (stat[0] == 'e') {
GPIO->P[LED_PORT].DOUT |= (1U << LED0_PIN);
}
else {
GPIO->P[LED_PORT].DOUT &= ~(1U << LED0_PIN);
}
}
/*..........................................................................*/
void BSP_displayPaused(uint8_t paused) {
if (paused != 0U) {
GPIO->P[LED_PORT].DOUT |= (1U << LED0_PIN);
}
else {
GPIO->P[LED_PORT].DOUT &= ~(1U << LED0_PIN);
}
}
/*..........................................................................*/
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
uint32_t rnd;
/* The flating point code is to exercise the FPU... */
float volatile x = 3.1415926F;
x = x + 2.7182818F;
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
rnd = l_rnd * (3U*7U*11U*13U*23U);
l_rnd = rnd;
return rnd >> 8;
}
/*..........................................................................*/
void BSP_randomSeed(uint32_t seed) {
l_rnd = seed;
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
(void)result;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set up the SysTick timer to fire at BSP_TICKS_PER_SEC rate */
SysTick_Config(SystemCoreClock / BSP_TICKS_PER_SEC);
/* assing all priority bits for preemption-prio. and none to sub-prio. */
NVIC_SetPriorityGrouping(0U);
/* set priorities of ALL ISRs used in the system, see NOTE00
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
NVIC_SetPriority(SysTick_IRQn, SYSTICK_PRIO);
NVIC_SetPriority(GPIO_EVEN_IRQn, GPIO_EVEN_PRIO);
/* ... */
/* enable IRQs... */
NVIC_EnableIRQ(GPIO_EVEN_IRQn);
}
/*..........................................................................*/
void QV_onIdle(void) { /* CATION: called with interrupts DISABLED, NOTE01 */
/* toggle LED1 on and then off, see NOTE02 */
GPIO_PinOutSet(LED_PORT, LED1_PIN);
//GPIO->P[LED_PORT].DOUT |= (1U << LED1_PIN);
GPIO_PinOutClear(LED_PORT, LED1_PIN);
//GPIO->P[LED_PORT].DOUT &= ~(1U << LED1_PIN);
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular Cortex-M MCU.
*/
QV_CPU_SLEEP(); /* atomically go to sleep and enable interrupts */
#else
QF_INT_ENABLE(); /* just enable interrupts */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int loc) {
/*
* NOTE: add here your application-specific error handling
*/
(void)module;
(void)loc;
#ifndef NDEBUG
/* light up both LEDs */
GPIO->P[LED_PORT].DOUT |= ((1U << LED0_PIN) | (1U << LED1_PIN));
/* for debugging, hang on in an endless loop until PB1 is pressed... */
while ((GPIO->P[PB_PORT].DIN & (1U << PB1_PIN)) != 0) {
}
#endif
NVIC_SystemReset();
}
/*****************************************************************************
* NOTE00:
* The QF_AWARE_ISR_CMSIS_PRI constant from the QF port specifies the highest
* ISR priority that is disabled by the QF framework. The value is suitable
* for the NVIC_SetPriority() CMSIS function.
*
* Only ISRs prioritized at or below the QF_AWARE_ISR_CMSIS_PRI level (i.e.,
* with the numerical values of priorities equal or higher than
* QF_AWARE_ISR_CMSIS_PRI) are allowed to call the QK_ISR_ENTRY/QK_ISR_ENTRY
* macros or any other QF/QK services. These ISRs are "QF-aware".
*
* Conversely, any ISRs prioritized above the QF_AWARE_ISR_CMSIS_PRI priority
* level (i.e., with the numerical values of priorities less than
* QF_AWARE_ISR_CMSIS_PRI) are never disabled and are not aware of the kernel.
* Such "QF-unaware" ISRs cannot call any QF/QK services. In particular they
* can NOT call the macros QK_ISR_ENTRY/QK_ISR_ENTRY. The only mechanism
* by which a "QF-unaware" ISR can communicate with the QF framework is by
* triggering a "QF-aware" ISR, which can post/publish events.
*
* NOTE01:
* The QV_onIdle() callback is called with interrupts disabled, because the
* determination of the idle condition might change by any interrupt posting
* an event. QV_onIdle() must internally enable interrupts, ideally
* atomically with putting the CPU to the power-saving mode.
*
* NOTE02:
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qv/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano on EMF32-SLSTK3401A, QV-nano kernel, GNU-ARM
# Last Updated for Version: 6.5.0
# Date of the Last Update: 2019-04-15
#
# Q u a n t u m L e a P s
# ------------------------
# Modern Embedded Software
#
# Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# https://www.state-machine.com
# mailto:info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := dpp-qv
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/arm-cm/qv/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qvn \
$(QP_PORT_DIR) \
$(QPN)/3rd_party/efm32pg1b \
$(QPN)/3rd_party/efm32pg1b/gnu
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR) \
-I$(QPN)/3rd_party/CMSIS/Include \
-I$(QPN)/3rd_party/efm32pg1b
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
bsp.c \
main.c \
philo.c \
table.c \
startup_efm32pg1b.c \
system_efm32pg1b.c \
em_cmu.c \
em_emu.c \
em_gpio.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qepn.c \
qfn.c \
qvn.c \
qvn_port.c
QP_ASMS := \
LIB_DIRS :=
LIBS :=
# defines
DEFINES := -DEFM32PG1B200F256GM48=1
# ARM CPU, ARCH, FPU, and Float-ABI types...
# ARM_CPU: [cortex-m0 | cortex-m0plus | cortex-m1 | cortex-m3 | cortex-m4]
# ARM_ARCH: [6 | 7] (NOTE: must match ARM_CPU!)
# ARM_FPU: [ | vfp]
# FLOAT_ABI: [ | soft | softfp | hard]
#
ARM_CPU := -mcpu=cortex-m4
ARM_ARCH := 7 # NOTE: must match the ARM_CPU!
ARM_FPU := -mfpu=vfp
FLOAT_ABI := -mfloat-abi=softfp
#-----------------------------------------------------------------------------
# GNU-ARM toolset (NOTE: You need to adjust to your machine)
# see https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
#
ifeq ($(GNU_ARM),)
GNU_ARM := $(QTOOLS)/gnu_arm-none-eabi
endif
# make sure that the GNU-ARM toolset exists...
ifeq ("$(wildcard $(GNU_ARM))","")
$(error GNU_ARM toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_ARM)/bin/arm-none-eabi-gcc
CPP := $(GNU_ARM)/bin/arm-none-eabi-g++
AS := $(GNU_ARM)/bin/arm-none-eabi-as
LINK := $(GNU_ARM)/bin/arm-none-eabi-g++
BIN := $(GNU_ARM)/bin/arm-none-eabi-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M
#
# combine all the soruces...
C_SRCS += $(QP_SRCS)
ASM_SRCS += $(QP_ASMS)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS = $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration ..........................................
BIN_DIR := dbg
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O $(INCLUDES) $(DEFINES)
CPPFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES)
endif # ......................................................................
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
-specs=nosys.specs -specs=nano.specs \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_BIN := $(BIN_DIR)/$(OUTPUT).bin
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_BIN)
#all: $(TARGET_ELF)
$(TARGET_BIN): $(TARGET_ELF)
$(BIN) -O binary $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(CC) $(CFLAGS) $(QPN)/include/qstamp.c -o $(BIN_DIR)/qstamp.o
$(LINK) $(LINKFLAGS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.bin \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qv/gnu/README.txt
================================================
About this Example
==================
This example can be built from the command prompt with the provided
Makefile. The example can also be imported as a Makefile-based
project into Eclipse-based IDEs.
The Makefile
============
The provided Makefile should be easy to adapt for your own projects.
It contains two build configurations: Debug (default) and Release.
Also, the Makefile has been specifically designed to work as an external
Makefile with the Eclipse CDT.
The various build configurations are built as follows:
make
make CONF=rel
make clean
make CONF=rel clean
***
NOTE:
The installation folder of the GNU-ARM toolset on YOUR machine needs
to be adjusted in the provided Makefile, by editing the symbol: GNU_ARM.
As described in the comment for this symbol, the GNU-ARM toolset is taken
from: http://gnutoolchains.com/arm-eabi
It is highly recommened to use the same GNU-ARM distribution, especially
for ARM Cortex-M4F projects, due to the support for the hardware FPU
(float-abi=hard).
***
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the GCC linker
script (.ld file), which provides a template of the recommended GCC linker
script for QP applications.
Startup Code
============
The startup code for the EFM32PG1B200F256GM48 MCU used in this project
is located in the "3rd_party" folder in the following location:
qpc\3rd_party\efm32pg1b\gnu\startup_efm32pg1b.c
The file startup_efm32pg1b.c provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qv/gnu/dpp-qv.ld
================================================
/*****************************************************************************
* Product: Linker script for EFM32-SLSTK3401A, GNU-ARM linker
* Last Updated for Version: 5.9.8
* Date of the Last Update: 2017-09-13
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* http://www.state-machine.com
* mailto:info@state-machine.com
*****************************************************************************/
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(Reset_Handler) /* entry Point */
MEMORY { /* memory map of Pearl Gecko EFM32PG1B200F256GM48 */
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 256K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
}
/* The size of the stack used by the application. NOTE: you need to adjust */
STACK_SIZE = 1024;
/* The size of the heap used by the application. NOTE: you need to adjust */
HEAP_SIZE = 0;
SECTIONS {
.isr_vector : { /* the vector table goes FIRST into ROM */
KEEP(*(.isr_vector)) /* vector table */
. = ALIGN(4);
} >ROM
.text : { /* code and constants */
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} >ROM
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >ROM
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >ROM
.fini_array : {
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array*))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >ROM
_etext = .; /* global symbols at end of code */
.stack : {
__stack_start__ = .;
. = . + STACK_SIZE;
. = ALIGN(4);
__stack_end__ = .;
} >RAM
.data : AT (_etext) {
__data_load = LOADADDR (.data);
__data_start = .;
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
__data_end__ = .;
_edata = __data_end__;
} >RAM
.bss : {
__bss_start__ = .;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = .;
} >RAM
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >RAM
__exidx_end = .;
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );
PROVIDE ( __end__ = _ebss );
.heap : {
__heap_start__ = .;
. = . + HEAP_SIZE;
. = ALIGN(4);
__heap_end__ = .;
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ : {
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
}
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qv/gnu/flash.bat
================================================
::============================================================================
:: Batch file to program the flash of EFM32-SLSTK3401A board
::
:: NOTE: requires the J-Link commander (JLink.exe) from SEGGER, see:
:: https://www.segger.com/j-link-commander.html
::
setlocal
@echo off
@echo Load a given binary file to the flash of EFM32-SLSTK3401A
@echo usage: flash bin-file
@echo example: flash dbg\blinky-qk.bin
::----------------------------------------------------------------------------
:: NOTE: Adjust the following symbol to the location of the
:: JLink utility on your machine
::
if [%JLINK%] EQU [] set JLINK=%QTOOLS%\..\JLink
if not exist "%JLINK%\JLink.exe" (
@echo The JLink tool not found. Please adjust flash.bat
@goto end
)
if ["%~1"]==[""] (
@echo The binary file missing
@goto end
)
if not exist %~s1 (
@echo The binary file '%1' does not exist
@goto end
)
:: generate the Jlink command file depending on the first parameter %1
@echo si 1 >flash.jlink
@echo speed 4000 >>flash.jlink
@echo r >>flash.jlink
@echo h >>flash.jlink
@echo loadbin %1, 0 >>flash.jlink
@echo exit >>flash.jlink
@echo on
%JLINK%\JLink.exe -device EFM32PG1B200F256GM48 flash.jlink
@echo off
@del flash.jlink
:end
endlocal
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qv/iar/README.txt
================================================
About this Example
==================
This example demonstrates how to use the IAR EWARM IDE to build
a QP application.
IAR Project File
----------------
The IAR EWARM project file provided with this example uses relative paths
to the QP/C framework location (includes, port, and libraries. These
relative paths must be modified when the project is moved to different
relative location.
Stack Size and Heap Size
------------------------
In this project, the size of the C stack and heap are determined in
the linker script blinky-qk.icf (see the next section).
Linker Script
-------------
The IAR linker script provides a template of the recommended linker script
for QP applications. This file needs to be customized to set the
application-specific sizes of the Stack and Heap. This file can be edited
from the IAR EWARM IDE via the Project Options/Linker settings.
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\efm32pg1b\iar\startup_efm32pg1b.s
The file startup_efm32pg1b.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qv/iar/dpp-qv.ewd
================================================
3DebugARM1C-SPY22811ARMSIM_ID2111CADI_ID2011CMSISDAP_ID2411GDBSERVER_ID2011IJET_ID2811JLINK_ID21611LMIFTDI_ID2211PEMICRO_ID2311STLINK_ID2411THIRDPARTY_ID2011TIFET_ID2111XDS100_ID2611$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseARM0C-SPY22810ARMSIM_ID2110CADI_ID2010CMSISDAP_ID2410GDBSERVER_ID2010IJET_ID2810JLINK_ID21610LMIFTDI_ID2210PEMICRO_ID2310STLINK_ID2410THIRDPARTY_ID2010TIFET_ID2110XDS100_ID2610$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qv/iar/dpp-qv.ewp
================================================
3DebugARM1General32811ICCARM23411AARM21011OBJCOPY0111CUSTOM30BICOMP0BUILDACTION1cmd /c "if exist $OBJ_DIR$\qstamp.o del $OBJ_DIR$\qstamp.o"ILINK02011IARCHIVE0011BILINK0Coder0ReleaseARM0General32810ICCARM23410AARM21010OBJCOPY0110CUSTOM30BICOMP0BUILDACTION1cmd /c "if exist $OBJ_DIR$\qstamp.o del $OBJ_DIR$\qstamp.o"ILINK02010IARCHIVE0010BILINK0Coder0Application$PROJ_DIR$\..\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\dpp.h$PROJ_DIR$\..\..\main.c$PROJ_DIR$\..\..\philo.c$PROJ_DIR$\..\..\qpn_conf.h$PROJ_DIR$\..\..\..\..\..\include\qstamp.c$PROJ_DIR$\..\..\table.cefm32pg1b$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_assert.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_emu.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_system.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\iar\startup_efm32pg1b.s$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.cQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qvn\qvn.cQP_port$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qv\iar\qfn_port.h$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qv\iar\qvn_port.c
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qv/iar/dpp-qv.eww
================================================
$WS_DIR$\dpp-qv.ewp
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/qv/iar/dpp-qv.icf
================================================
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0003FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 1024;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place at start of RAM_region {block CSTACK };
place in RAM_region { readwrite, block HEAP };
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/table.c
================================================
/*.$file${.::table.c} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: dpp.qm
* File: ${.::table.c}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::table.c} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("table")
/* Active object class -----------------------------------------------------*/
/*.$declare${AOs::Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table} ...........................................................*/
typedef struct Table {
/* protected: */
QActive super;
/* private: */
uint8_t fork[N_PHILO];
uint8_t isHungry[N_PHILO];
} Table;
/* protected: */
static QState Table_initial(Table * const me);
static QState Table_active(Table * const me);
static QState Table_serving(Table * const me);
static QState Table_paused(Table * const me);
/*.$enddecl${AOs::Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Global objects ----------------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*. Check for the minimum required QP version */
#if (QP_VERSION < 650U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpn version 6.5.0 or higher required
#endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Table} ........................................................*/
struct Table AO_Table;
/*.$enddef${AOs::AO_Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#define RIGHT(n_) ((uint8_t)(((n_) + (N_PHILO - 1U)) % N_PHILO))
#define LEFT(n_) ((uint8_t)(((n_) + 1U) % N_PHILO))
#define FREE ((uint8_t)0)
#define USED ((uint8_t)1)
/*..........................................................................*/
/*.$define${AOs::Table_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table_ctor} ......................................................*/
void Table_ctor(void) {
uint8_t n;
Table *me = &AO_Table;
QActive_ctor(&me->super, Q_STATE_CAST(&Table_initial));
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
}
}
/*.$enddef${AOs::Table_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table} ...........................................................*/
/*.${AOs::Table::SM} .......................................................*/
static QState Table_initial(Table * const me) {
/*.${AOs::Table::SM::initial} */
uint8_t n;
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "thinking");
}
return Q_TRAN(&Table_serving);
}
/*.${AOs::Table::SM::active} ...............................................*/
static QState Table_active(Table * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Table::SM::active::TERMINATE} */
case TERMINATE_SIG: {
BSP_terminate(0);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::EAT} */
case EAT_SIG: {
Q_ERROR();
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Table::SM::active::serving} ......................................*/
static QState Table_serving(Table * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Table::SM::active::serving} */
case Q_ENTRY_SIG: {
uint8_t n;
for (n = 0U; n < N_PHILO; ++n) { /* give permissions to eat... */
if ((me->isHungry[n] != 0U)
&& (me->fork[LEFT(n)] == FREE)
&& (me->fork[n] == FREE))
{
QActive *philo;
me->fork[LEFT(n)] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "eating ");
}
}
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::serving::HUNGRY} */
case HUNGRY_SIG: {
uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "hungry ");
m = LEFT(n);
/*.${AOs::Table::SM::active::serving::HUNGRY::[bothfree]} */
if ((me->fork[m] == FREE) && (me->fork[n] == FREE)) {
me->fork[m] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
BSP_displayPhilStat(n, "eating ");
status_ = Q_HANDLED();
}
/*.${AOs::Table::SM::active::serving::HUNGRY::[else]} */
else {
me->isHungry[n] = 1U;
status_ = Q_HANDLED();
}
break;
}
/*.${AOs::Table::SM::active::serving::DONE} */
case DONE_SIG: {
uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;
m = RIGHT(n); /* check the right neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[m] == FREE)) {
me->fork[n] = USED;
me->fork[m] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}
m = LEFT(n); /* check the left neighbor */
n = LEFT(m); /* left fork of the left neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[n] == FREE)) {
me->fork[m] = USED;
me->fork[n] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::serving::EAT} */
case EAT_SIG: {
Q_ERROR();
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::serving::PAUSE} */
case PAUSE_SIG: {
status_ = Q_TRAN(&Table_paused);
break;
}
default: {
status_ = Q_SUPER(&Table_active);
break;
}
}
return status_;
}
/*.${AOs::Table::SM::active::paused} .......................................*/
static QState Table_paused(Table * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Table::SM::active::paused} */
case Q_ENTRY_SIG: {
BSP_displayPaused(1U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::paused} */
case Q_EXIT_SIG: {
BSP_displayPaused(0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::paused::SERVE} */
case SERVE_SIG: {
status_ = Q_TRAN(&Table_serving);
break;
}
/*.${AOs::Table::SM::active::paused::HUNGRY} */
case HUNGRY_SIG: {
uint8_t n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* philo ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
me->isHungry[n] = 1U;
BSP_displayPhilStat(n, "hungry ");
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::paused::DONE} */
case DONE_SIG: {
uint8_t n, m;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&Table_active);
break;
}
}
return status_;
}
/*.$enddef${AOs::Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/win32-gui/bsp.c
================================================
/*****************************************************************************
* Product: "DPP" example, EFM32-SLSTK3401A, Win32-GUI
* Last Updated for Version: 6.7.0
* Date of the Last Update: 2020-01-06
*
* Q u a n t u m L e a P s
* ------------------------
* Modern Embedded Software
*
* Copyright (C) 2005-2020 Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "dpp.h"
#include "bsp.h"
#include "qwin_gui.h" /* QWIN GUI */
#include "resource.h" /* GUI resource IDs generated by the resource editior */
#include "safe_std.h" /* portable "safe" / facilities */
Q_DEFINE_THIS_FILE
/* local variables ---------------------------------------------------------*/
static HINSTANCE l_hInst; /* this application instance */
static HWND l_hWnd; /* main window handle */
static LPSTR l_cmdLine; /* the command line string */
static SegmentDisplay l_philos; /* SegmentDisplay to show Philo status */
static OwnerDrawnButton l_pauseBtn; /* owner-drawn button */
static unsigned l_rnd; /* random seed */
/* Local functions ---------------------------------------------------------*/
static LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg,
WPARAM wParam, LPARAM lParam);
/*..........................................................................*/
/* thread function for running the application main_gui() */
static DWORD WINAPI appThread(LPVOID par) {
(void)par; /* unused parameter */
return (DWORD)main_gui(); /* run the QF application */
}
/*--------------------------------------------------------------------------*/
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
LPSTR cmdLine, int iCmdShow)
{
HWND hWnd;
MSG msg;
(void)hPrevInst; /* unused parameter */
l_hInst = hInst; /* save the application instance */
l_cmdLine = cmdLine; /* save the command line string */
//AllocConsole();
/* create the main custom dialog window */
hWnd = CreateCustDialog(hInst, IDD_APPLICATION, NULL,
&WndProc, "MY_CLASS");
ShowWindow(hWnd, iCmdShow); /* show the main window */
/* enter the message loop... */
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
//FreeConsole();
BSP_terminate(0);
return msg.wParam;
}
/*..........................................................................*/
static LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg,
WPARAM wParam, LPARAM lParam)
{
switch (iMsg) {
/* Perform initialization upon cration of the main dialog window
* NOTE: Any child-windows are NOT created yet at this time, so
* the GetDlgItem() function can't be used (it will return NULL).
*/
case WM_CREATE: {
l_hWnd = hWnd; /* save the window handle */
/* initialize the owner-drawn buttons...
* NOTE: must be done *before* the first drawing of the buttons,
* so WM_INITDIALOG is too late.
*/
OwnerDrawnButton_init(&l_pauseBtn, IDC_PAUSE,
LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_BTN_UP)),
LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_BTN_DWN)),
LoadCursor(NULL, IDC_HAND));
return 0;
}
/* Perform initialization after all child windows have been created */
case WM_INITDIALOG: {
SegmentDisplay_init(&l_philos,
N_PHILO, /* N_PHILO "segments" for the Philos */
3U); /* 3 bitmaps (for thinking/hungry/eating) */
SegmentDisplay_initSegment(&l_philos, 0U, IDC_PHILO_0);
SegmentDisplay_initSegment(&l_philos, 1U, IDC_PHILO_1);
SegmentDisplay_initSegment(&l_philos, 2U, IDC_PHILO_2);
SegmentDisplay_initSegment(&l_philos, 3U, IDC_PHILO_3);
SegmentDisplay_initSegment(&l_philos, 4U, IDC_PHILO_4);
SegmentDisplay_initBitmap(&l_philos,
0U, LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_THINKING)));
SegmentDisplay_initBitmap(&l_philos,
1U, LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_HUNGRY)));
SegmentDisplay_initBitmap(&l_philos,
2U, LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_EATING)));
/* --> QP: spawn the application thread to run main_gui() */
Q_ALLEGE(CreateThread(NULL, 0, &appThread, NULL, 0, NULL)
!= (HANDLE)0);
return 0;
}
case WM_DESTROY: {
PostQuitMessage(0);
return 0;
}
/* commands from regular buttons and menus... */
case WM_COMMAND: {
SetFocus(hWnd);
switch (wParam) {
case IDOK:
case IDCANCEL: {
PostQuitMessage(0);
break;
}
}
return 0;
}
/* owner-drawn buttons... */
case WM_DRAWITEM: {
LPDRAWITEMSTRUCT pdis = (LPDRAWITEMSTRUCT)lParam;
switch (pdis->CtlID) {
case IDC_PAUSE: { /* PAUSE owner-drawn button */
switch (OwnerDrawnButton_draw(&l_pauseBtn,pdis)) {
case BTN_DEPRESSED: {
QACTIVE_POST((QActive *)&AO_Table, PAUSE_SIG, 0U);
break;
}
case BTN_RELEASED: {
QACTIVE_POST((QActive *)&AO_Table, SERVE_SIG, 0U);
break;
}
default: {
break;
}
}
break;
}
}
return 0;
}
/* mouse input... */
case WM_MOUSEWHEEL: {
return 0;
}
/* keyboard input... */
case WM_KEYDOWN: {
return 0;
}
}
return DefWindowProc(hWnd, iMsg, wParam, lParam) ;
}
/*--------------------------------------------------------------------------*/
void QF_onStartup(void) {
QF_setTickRate(BSP_TICKS_PER_SEC, 30U); /* set the desired tick rate */
}
/*..........................................................................*/
void QF_onCleanup(void) {
}
/*..........................................................................*/
void QF_onClockTickISR(void) {
QF_tickXISR(0U); /* perform the QF-nano clock tick processing */
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const * const module, int_t loc) {
char message[80];
QF_stop(); /* stop ticking */
SNPRINTF_S(message, Q_DIM(message) - 1,
"Assertion failed in module %s location %d", module, loc);
MessageBox(l_hWnd, message, "!!! ASSERTION !!!",
MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL);
PostQuitMessage(-1);
}
/*..........................................................................*/
void BSP_init(void) {
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
QF_stop();
/* cleanup all QWIN resources... */
OwnerDrawnButton_xtor(&l_pauseBtn); /* cleanup the l_pauseBtn resources */
SegmentDisplay_xtor(&l_philos); /* cleanup the l_philos resources */
/* end the main dialog */
EndDialog(l_hWnd, result);
}
/*..........................................................................*/
void BSP_displayPhilStat(uint8_t n, char const *stat) {
UINT bitmapNum = 0;
Q_REQUIRE(n < N_PHILO);
switch (stat[0]) {
case 't': bitmapNum = 0U; break;
case 'h': bitmapNum = 1U; break;
case 'e': bitmapNum = 2U; break;
default: Q_ERROR(); break;
}
/* set the "segment" # n to the bitmap # 'bitmapNum' */
SegmentDisplay_setSegment(&l_philos, (UINT)n, bitmapNum);
}
/*..........................................................................*/
void BSP_displayPaused(uint8_t paused) {
char buf[16];
LoadString(l_hInst,
(paused != 0U) ? IDS_PAUSED : IDS_RUNNING, buf, Q_DIM(buf));
SetDlgItemText(l_hWnd, IDC_PAUSED, buf);
}
/*..........................................................................*/
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
l_rnd = l_rnd * (3U*7U*11U*13U*23U);
return l_rnd >> 8;
}
/*..........................................................................*/
void BSP_randomSeed(uint32_t seed) {
l_rnd = seed;
}
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/win32-gui/dpp-gui.sln
================================================
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2013 for Windows Desktop
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dpp-gui", "dpp-gui.vcxproj", "{79027B25-0949-4F66-9765-4EFBCBBEFB94}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{79027B25-0949-4F66-9765-4EFBCBBEFB94}.Debug|Win32.ActiveCfg = Debug|Win32
{79027B25-0949-4F66-9765-4EFBCBBEFB94}.Debug|Win32.Build.0 = Debug|Win32
{79027B25-0949-4F66-9765-4EFBCBBEFB94}.Release|Win32.ActiveCfg = Release|Win32
{79027B25-0949-4F66-9765-4EFBCBBEFB94}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/win32-gui/dpp-gui.vcxproj
================================================
DebugWin32ReleaseWin32{79027B25-0949-4F66-9765-4EFBCBBEFB94}dpp-gui10.0ApplicationfalseNotSetv142ApplicationfalseNotSetv142
<_ProjectFileVersion>10.0.40219.1
$(Configuration)\$(Configuration)\falsefalse$(Configuration)\$(Configuration)\falsefalseNDEBUG;%(PreprocessorDefinitions)truetrueWin32.\Release/dpp-gui.tlbMaxSpeedOnlyExplicitInline.;..;../../../../include;../../../../ports/win32-qvQWIN_GUI;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)falseMultiThreadedtrue$(IntDir)$(IntDir)$(IntDir)Level3trueDefaultNDEBUG;%(PreprocessorDefinitions)0x0409%(AdditionalDependencies)$(OutDir)$(ProjectName).exetrue%(AdditionalLibraryDirectories)WindowsfalseMachineX86true.\Release/dpp-gui.bsc_DEBUG;%(PreprocessorDefinitions)truetrueWin32.\Debug/dpp-gui.tlbDisabled.;..;../../../../include;../../../../ports/win32-qvQWIN_GUI;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)falseDefaultMultiThreaded$(IntDir)$(IntDir)$(IntDir)trueLevel3trueProgramDatabaseDefault_DEBUG;%(PreprocessorDefinitions)0x0409%(AdditionalDependencies)$(OutDir)$(ProjectName).exetrue%(AdditionalLibraryDirectories)truefalseWindowsfalseMachineX86true.\Debug/dpp-gui.bsc
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/win32-gui/dpp-gui.vcxproj.filters
================================================
ResResResResResRes{382909e6-fb4e-4829-941e-d3461d9ce146}{cead428d-5be7-440c-b491-936bfc2a36a3}QPQPQP
================================================
FILE: examples/arm-cm/dpp_efm32-slstk3401a/win32-gui/resource.h
================================================
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Resource.rc
//
#define IDI_QP 2
#define IDD_APPLICATION 101
#define IDB_THINKING 134
#define IDB_EATING 135
#define IDB_HUNGRY 136
#define IDB_BTN_UP 137
#define IDB_BTN_DWN 138
#define IDC_PHILO_0 1000
#define IDC_PHILO_1 1001
#define IDC_PHILO_2 1002
#define IDC_PHILO_3 1003
#define IDC_PHILO_4 1004
#define IDC_PAUSE 1006
#define IDC_PAUSED 1009
#define IDS_APP_TITLE 40000
#define IDS_PAUSED 40001
#define IDS_RUNNING 40002
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 112
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1002
#define _APS_NEXT_SYMED_VALUE 123
#endif
#endif
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/README.txt
================================================
About this Example
==================
This directory contains the simple DPP QP-nano example application for
the EK-TM4C123GXL board (TivaC LauchPad). This directory contains portable
code that should compile with any C compiler.
The sub-directories contain the Board Support Packages (BSPs) for the
preemptive QK-nano kernel (sub-directory qk), the cooperative QV kernel
(sub-directory qv), and the Win32-QV emulation (Windows).
The native kernels (QK-nano and QV-nano) further provide code and project
files for the particular ARM toolchains, such as ARM (MDK-ARM), GNU, and IAR.
Please refer to the README files in the sub-directories for instructions
how to use and customize the example to your needs.
Support Code for EK-TM4C123GXL Board
====================================
The directory qpn\3rd_party\ek-tm4c123gxl contains the CMSIS-compliant
device code for the TM4C123GH6PM MCU. Please see the README.txt file in
this folder for more details.
Win32 Emulation
===============
The sub-directory win32-qv provides the emulation of the example on Windows
as a GUI application. The sub-directory contains the Makefile for the
MinGW toolset and a Visual Studio solution file (dpp-gui.sln) for Visual C++.
The Win32 emulation uses exactly the same code as the embedded board and
differs only in the Board Support Package (bsp.c). This example demonstrates
the "dual targeting" development approach, where most of the embedded code
is developed on the desktop machine (Windows), but is intended for a deeply
embedded target (TivaC LauchPad here).
Lint Support
============
The sub-directory lint provides the scripts and configuration files for
running the PC-Lint static analysis tool over the application code. Please
read the README.txt file in the lint directory for more information.
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/README.url
================================================
[InternetShortcut]
URL=http://www.state-machine.com/qpn/arm-cm_dpp_ek-tm4c123gxl.html
IconFile=http://www.state-machine.com/qp.ico
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/bsp.h
================================================
/*****************************************************************************
* Product: DPP example
* Last Updated for Version: 5.4.0
* Date of the Last Update: 2015-03-07
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* Web : www.state-machine.com
*
*****************************************************************************/
#ifndef BSP_H
#define BSP_H
#define BSP_TICKS_PER_SEC 100U
void BSP_init(void);
void BSP_displayPaused(uint8_t paused);
void BSP_displayPhilStat(uint8_t n, char_t const *stat);
void BSP_terminate(int16_t result);
void BSP_randomSeed(uint32_t seed); /* random seed */
uint32_t BSP_random(void); /* pseudo-random generator */
#endif /* BSP_H */
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/dpp.h
================================================
/*.$file${.::dpp.h} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: dpp.qm
* File: ${.::dpp.h}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::dpp.h} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#ifndef DPP_H
#define DPP_H
enum DPPSignals {
EAT_SIG = Q_USER_SIG, /* published by Table to let a philosopher eat */
DONE_SIG, /* published by Philosopher when done eating */
PAUSE_SIG, /* published by BSP to pause the application */
SERVE_SIG, /* published by BSP to pause the application */
TERMINATE_SIG, /* published by BSP to terminate the application */
HUNGRY_SIG, /* posted direclty to Table from hungry Philo */
MAX_SIG /* the last signal */
};
/* number of philosophers */
#define N_PHILO ((uint8_t)5)
#define PHILO_0_PRIO 1
/*.$declare${AOs::AO_Philo0} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo0;
/*.$enddecl${AOs::AO_Philo0} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo1} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo1;
/*.$enddecl${AOs::AO_Philo1} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo2} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo2;
/*.$enddecl${AOs::AO_Philo2} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo3} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo3;
/*.$enddecl${AOs::AO_Philo3} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo4} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo4;
/*.$enddecl${AOs::AO_Philo4} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Table AO_Table;
/*.$enddecl${AOs::AO_Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::Philo_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo_ctor} ......................................................*/
void Philo_ctor(void);
/*.$enddecl${AOs::Philo_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::Table_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table_ctor} ......................................................*/
void Table_ctor(void);
/*.$enddecl${AOs::Table_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#endif /* DPP_H */
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/dpp.qm
================================================
Dining Philosopher Problem example with QActiveQActive_armX(&me->super, 0U, THINK_TIME, 0U);QActive_disarmX(&me->super, 0U);Q_ERROR(); /* these events should never arrive in this state */QACTIVE_POST(&AO_Table, HUNGRY_SIG, me->super.prio);Q_ERROR(); /* this event should never arrive in this state */QActive_armX(&me->super, 0U, EAT_TIME, 0U);QActive_disarmX(&me->super, 0U);
QACTIVE_POST(QF_ACTIVE_CAST(&AO_Table), DONE_SIG, me->super.prio);Q_ERROR(); /* these events should never arrive in this state */uint8_t n;
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "thinking");
}BSP_terminate(0);Q_ERROR();uint8_t n;
for (n = 0U; n < N_PHILO; ++n) { /* give permissions to eat... */
if ((me->isHungry[n] != 0U)
&& (me->fork[LEFT(n)] == FREE)
&& (me->fork[n] == FREE))
{
QActive *philo;
me->fork[LEFT(n)] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "eating ");
}
}uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "hungry ");
m = LEFT(n);(me->fork[m] == FREE) && (me->fork[n] == FREE)me->fork[m] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
BSP_displayPhilStat(n, "eating ");elseme->isHungry[n] = 1U;uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;
m = RIGHT(n); /* check the right neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[m] == FREE)) {
me->fork[n] = USED;
me->fork[m] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}
m = LEFT(n); /* check the left neighbor */
n = LEFT(m); /* left fork of the left neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[n] == FREE)) {
me->fork[m] = USED;
me->fork[n] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}Q_ERROR();BSP_displayPaused(1U);BSP_displayPaused(0U);uint8_t n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* philo ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
me->isHungry[n] = 1U;
BSP_displayPhilStat(n, "hungry ");uint8_t n, m;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;QActive_ctor(&AO_Philo0.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo1.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo2.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo3.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo4.super, Q_STATE_CAST(&Philo_initial));
BSP_randomSeed(123U);uint8_t n;
Table *me = &AO_Table;
QActive_ctor(&me->super, Q_STATE_CAST(&Table_initial));
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
}#ifndef DPP_H
#define DPP_H
enum DPPSignals {
EAT_SIG = Q_USER_SIG, /* published by Table to let a philosopher eat */
DONE_SIG, /* published by Philosopher when done eating */
PAUSE_SIG, /* published by BSP to pause the application */
SERVE_SIG, /* published by BSP to pause the application */
TERMINATE_SIG, /* published by BSP to terminate the application */
HUNGRY_SIG, /* posted direclty to Table from hungry Philo */
MAX_SIG /* the last signal */
};
/* number of philosophers */
#define N_PHILO ((uint8_t)5)
#define PHILO_0_PRIO 1
$declare${AOs::AO_Philo0}
$declare${AOs::AO_Philo1}
$declare${AOs::AO_Philo2}
$declare${AOs::AO_Philo3}
$declare${AOs::AO_Philo4}
$declare${AOs::AO_Table}
$declare${AOs::Philo_ctor}
$declare${AOs::Table_ctor}
#endif /* DPP_H */
#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("philo")
/* Active object class -----------------------------------------------------*/
$declare${AOs::Philo}
/* Global objects ----------------------------------------------------------*/
$define${AOs::AO_Philo0}
$define${AOs::AO_Philo1}
$define${AOs::AO_Philo2}
$define${AOs::AO_Philo3}
$define${AOs::AO_Philo4}
/* Local objects -----------------------------------------------------------*/
#define THINK_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + (BSP_TICKS_PER_SEC/2U))
#define EAT_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + BSP_TICKS_PER_SEC)
/* Philo definition --------------------------------------------------------*/
$define${AOs::Philo_ctor}
$define${AOs::Philo}#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("table")
/* Active object class -----------------------------------------------------*/
$declare${AOs::Table}
/* Global objects ----------------------------------------------------------*/
$define${AOs::AO_Table}
#define RIGHT(n_) ((uint8_t)(((n_) + (N_PHILO - 1U)) % N_PHILO))
#define LEFT(n_) ((uint8_t)(((n_) + 1U) % N_PHILO))
#define FREE ((uint8_t)0)
#define USED ((uint8_t)1)
/*..........................................................................*/
$define${AOs::Table_ctor}
$define${AOs::Table}
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/lint-plus/README.txt
================================================
About this Example
==================
This directory contains the facilities for "linting" the application with
PC-Lint-Plus.
To "lint" the application, invoke the batch "lin.bat" without parameters.
The output from the "linting" is saved in the fle "lin_out.log".
***
NOTE: You need to adjust the symbol PCLP_DIR at the top of the lin.bat
file, to point to the directory where PC-Lint-Plus is installed on your
machine.
***
The PC-Lint-Plus Options File
=============================
The "options.lnt" file specifies the linting options. You might need
to modify this file to suit your needs.
****
NOTE: The purpose of this example is NOT to find problems with the
supporting 3rd-party code, which every non-trivial embedded system needs.
Rather, the purpose of this particular example is to check YOUR application
level code, such as state machines.
****
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/lint-plus/lin.bat
================================================
@echo off
:: ===========================================================================
:: Product: QP-nano build script for PC-Lint-Plus, "Standard" C compiler
:: Last Updated for Version: 6.7.0
:: Date of the Last Update: 2019-12-29
::
:: Q u a n t u m L e a P s
:: ------------------------
:: Modern Embedded Software
::
:: Copyright (C) Quantum Leaps, LLC. All rights reserved.
::
:: This program is open source software: you can redistribute it and/or
:: modify it under the terms of the GNU General Public License as published
:: by the Free Software Foundation, either version 3 of the License, or
:: (at your option) any later version.
::
:: Alternatively, this program may be distributed and modified under the
:: terms of Quantum Leaps commercial licenses, which expressly supersede
:: the GNU General Public License and are specifically designed for
:: licensees interested in retaining the proprietary status of their code.
::
:: This program is distributed in the hope that it will be useful,
:: but WITHOUT ANY WARRANTY; without even the implied warranty of
:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
:: GNU General Public License for more details.
::
:: You should have received a copy of the GNU General Public License
:: along with this program. If not, see .
::
:: Contact information:
::
::
:: ===========================================================================
setlocal
:: Options for calling lin.bat
:: NOTE: adjust to for your installation directory of PC-Lint-Plus
set PCLP_DIR=C:\tools\lint-plus
set PCLP=%PCLP_DIR%\pclp32.exe
if NOT exist "%PCLP%" (
@echo The PC-Lint-Plus toolset not found. Please adjust lin.bat
goto end
)
:: set the QP/C directory
set QPN=..\..\..\..
set QPN_LINT=%QPN%\ports\lint-plus
set LINTFLAGS=%QPN%\ports\lint-plus\std.lnt options.lnt %1 %2 %3 %4
set PROJ_DIR=..
:: linting -------------------------------------------------------------------
%PCLP% -os(lint_out.log) %LINTFLAGS% %PROJ_DIR%\philo.c %PROJ_DIR%\table.c
:end
endlocal
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/lint-plus/options.lnt
================================================
//////////////////////////////////////////////////////////////////////////////
// Product: PC-Lint-Plus options for linting QP-nano applications
// Last updated for version 6.7.0
// Last updated on 2019-12-30
//
// Q u a n t u m L e a P s
// ------------------------
// Modern Embedded Software
//
// Copyright (C) 2005-2019 Quantum Leaps. All rights reserved.
//
// This program is open source software: you can redistribute it and/or
// modify it under the terms of the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Alternatively, this program may be distributed and modified under the
// terms of Quantum Leaps commercial licenses, which expressly supersede
// the GNU General Public License and are specifically designed for
// licensees interested in retaining the proprietary status of their code.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
// Contact information:
//
//
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// general options
-unit_check // perform only subset check (suppresses Global Wrapup)
-max_threads=1 // suppress message "no '-max_threads=N' option"
//-vf // print names of all source files (for debugging linting)
// include directories
-i.. // application includes
-i%QPN%\include // QP-nano public includes
-i%QPN_LINT% // QP-nano lint "port"
-i%QPN_LINT%\qkn // QP-nano lint "port" to QK-nano
// size options corresponding to GNU-ARM
-si4 -sl4 -sll8 -ss2 -sw4 -sp4 -sf4 -sd8 -sld8 +fzl
// standards
%QPN_LINT%\au-misra3.lnt // MISRA-C:2012 options
%QPN_LINT%\au-misra3-amd1.lnt // MISRA-C:2012 amendment 1 options
%QPN_LINT%\au-ds.lnt // Dan Saks recommendations
//-strong(AXJ) // Strong type checking
/////////////////////////////////////////////////////////////////////////////
// QP-nano options for clients
qpn.lnt // QP-nano options
/////////////////////////////////////////////////////////////////////////////
// addtitional supporession rules for bulding this application
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/main.c
================================================
/*****************************************************************************
* Product: DPP example
* Last Updated for Version: 5.8.0
* Date of the Last Update: 2016-11-06
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h" /* QP-nano */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
/*..........................................................................*/
static QEvt l_philoQueue[N_PHILO][N_PHILO];
static QEvt l_tableQueue[2];
/* QF_active[] array defines all active object control blocks --------------*/
QActiveCB const Q_ROM QF_active[] = {
{ (QActive *)0, (QEvt *)0, 0U },
{ (QActive *)&AO_Philo0, l_philoQueue[0], Q_DIM(l_philoQueue[0]) },
{ (QActive *)&AO_Philo1, l_philoQueue[1], Q_DIM(l_philoQueue[1]) },
{ (QActive *)&AO_Philo2, l_philoQueue[2], Q_DIM(l_philoQueue[2]) },
{ (QActive *)&AO_Philo3, l_philoQueue[3], Q_DIM(l_philoQueue[3]) },
{ (QActive *)&AO_Philo4, l_philoQueue[4], Q_DIM(l_philoQueue[4]) },
{ (QActive *)&AO_Table, l_tableQueue, Q_DIM(l_tableQueue) }
};
/*..........................................................................*/
int_t main() {
Philo_ctor(); /* instantiate all Philo AOs */
Table_ctor(); /* instantiate the Table AO */
QF_init(Q_DIM(QF_active)); /* initialize the QF-nano framework */
BSP_init(); /* initialize the Board Support Package */
return QF_run(); /* transfer control to QF-nano */
}
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/philo.c
================================================
/*.$file${.::philo.c} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: dpp.qm
* File: ${.::philo.c}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::philo.c} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("philo")
/* Active object class -----------------------------------------------------*/
/*.$declare${AOs::Philo} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo} ...........................................................*/
typedef struct Philo {
/* protected: */
QActive super;
} Philo;
/* protected: */
static QState Philo_initial(Philo * const me);
static QState Philo_thinking(Philo * const me);
static QState Philo_hungry(Philo * const me);
static QState Philo_eating(Philo * const me);
/*.$enddecl${AOs::Philo} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Global objects ----------------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*. Check for the minimum required QP version */
#if (QP_VERSION < 650U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpn version 6.5.0 or higher required
#endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo0} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo0} .......................................................*/
struct Philo AO_Philo0;
/*.$enddef${AOs::AO_Philo0} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo1} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo1} .......................................................*/
struct Philo AO_Philo1;
/*.$enddef${AOs::AO_Philo1} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo2} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo2} .......................................................*/
struct Philo AO_Philo2;
/*.$enddef${AOs::AO_Philo2} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo3} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo3} .......................................................*/
struct Philo AO_Philo3;
/*.$enddef${AOs::AO_Philo3} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo4} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo4} .......................................................*/
struct Philo AO_Philo4;
/*.$enddef${AOs::AO_Philo4} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Local objects -----------------------------------------------------------*/
#define THINK_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + (BSP_TICKS_PER_SEC/2U))
#define EAT_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + BSP_TICKS_PER_SEC)
/* Philo definition --------------------------------------------------------*/
/*.$define${AOs::Philo_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo_ctor} ......................................................*/
void Philo_ctor(void) {
QActive_ctor(&AO_Philo0.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo1.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo2.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo3.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo4.super, Q_STATE_CAST(&Philo_initial));
BSP_randomSeed(123U);
}
/*.$enddef${AOs::Philo_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Philo} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo} ...........................................................*/
/*.${AOs::Philo::SM} .......................................................*/
static QState Philo_initial(Philo * const me) {
/*.${AOs::Philo::SM::initial} */
return Q_TRAN(&Philo_thinking);
}
/*.${AOs::Philo::SM::thinking} .............................................*/
static QState Philo_thinking(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Philo::SM::thinking} */
case Q_ENTRY_SIG: {
QActive_armX(&me->super, 0U, THINK_TIME, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::thinking} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::thinking::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Philo_hungry);
break;
}
/*.${AOs::Philo::SM::thinking::EAT, DONE} */
case EAT_SIG: /* intentionally fall through */
case DONE_SIG: {
Q_ERROR(); /* these events should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Philo::SM::hungry} ...............................................*/
static QState Philo_hungry(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Philo::SM::hungry} */
case Q_ENTRY_SIG: {
QACTIVE_POST(&AO_Table, HUNGRY_SIG, me->super.prio);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::hungry::EAT} */
case EAT_SIG: {
status_ = Q_TRAN(&Philo_eating);
break;
}
/*.${AOs::Philo::SM::hungry::DONE} */
case DONE_SIG: {
Q_ERROR(); /* this event should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Philo::SM::eating} ...............................................*/
static QState Philo_eating(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Philo::SM::eating} */
case Q_ENTRY_SIG: {
QActive_armX(&me->super, 0U, EAT_TIME, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::eating} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
QACTIVE_POST(QF_ACTIVE_CAST(&AO_Table), DONE_SIG, me->super.prio);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::eating::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Philo_thinking);
break;
}
/*.${AOs::Philo::SM::eating::EAT, DONE} */
case EAT_SIG: /* intentionally fall through */
case DONE_SIG: {
Q_ERROR(); /* these events should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.$enddef${AOs::Philo} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qk/arm/README.txt
================================================
About this Example
==================
This example demonstrates how to use the uVision IDE together with
the MDK-ARM toolchain.
***
NOTE: This example requires installing the following Software Pack
in the Keil uVision: Keil::TM4C_DFP.
***
uVision Project File
====================
The MDK-ARM uVision project file provided with this example uses
relative paths to the QP/C framework location (includes, port, and
libraries. These relative paths must be modified when the project
is moved to different relative location.
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the
command-line options for the ARM assembler (see the Asm tab in
the "Options for Target" dialog box in uVision). Specifically,
you should define symbols: Stack_Size=xxx Heap_Size=yyy, where
xxx represents a numerical value of stack size and yyy the
numerical value of the heap size (for most embedded projects
yyy should be 0, as the using the heap is not recommended).
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.s
The file startup_TM4C123GH6PM.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qk/arm/dpp-qk.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj; *.o*.lib*.txt; *.h; *.inc*.plm*.cpp000dpp-dbg0x4ARM-ADS120000001110016553500079668.\dbg\111011010000111111100101401111111110111010110018BIN\lmidk-agdi.dll0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10UL2CM3UL2CM3(-O207 -S0 -C0 -FO7 -FN1 -FC1000 -FD20000000 -FF0TM4C123_256 -FL040000 -FS00 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM)0DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E2006F4 -O4622 -S4 -FO61120x200002000200x40000001000010000000000000000000dpp-rel0x4ARM-ADS120000001110016553500079668.\rel\111011010000111111100100401111111110111010110018BIN\lmidk-agdi.dll0DLGUARMÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÈ`»
´ª¤ô 0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E10259B -O4622 -S4 -FO610UL2CM3-O207 -S0 -C0 -FO7 -FN1 -FC1000 -FD20000000 -FF0TM4C123_256 -FL040000 -FS00 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM)120x200002000200x40000001000010000000000000000000Applicatioin1000111000..\bsp.cbsp.c00121000..\..\main.cmain.c00135000..\..\dpp.hdpp.h00145000..\..\bsp.hbsp.h00151000..\..\philo.cphilo.c00161000..\..\table.ctable.c00ek-tm4c123gxl0000271000..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.csystem_TM4C123GH6PM.c00285000..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hTM4C123GH6PM.h00292000..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sstartup_TM4C123GH6PM.s002105000..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hgpio.h002115000..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hrom.h002125000..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsysctl.h002135000..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hsystem_TM4C123GH6PM.h00QP10003141000..\..\..\..\..\src\qfn\qepn.cqepn.c003151000..\..\..\..\..\src\qfn\qfn.cqfn.c003161000..\..\..\..\..\src\qkn\qkn.cqkn.c00QP-port10004175000..\..\..\..\..\ports\arm-cm\qk\arm\qfn_port.hqfn_port.h004181000..\..\..\..\..\ports\arm-cm\qk\arm\qkn_port.cqkn_port.c00
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qk/arm/dpp-qk.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwaredpp-dbg0x4ARM-ADS5060528::V5.06 update 5 (build 528)::ARMCC0TM4C123GH6PMTexas InstrumentsKeil.TM4C_DFP.1.1.0http://www.keil.com/pack/IROM(0x00000000,0x040000) IRAM(0x20000000,0x008000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C123_256 -FS00 -FL040000 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM))0$$Device:TM4C123GH6PM$Device\Include\TM4C123\TM4C123.h$$Device:TM4C123GH6PM$SVD\TM4C123\TM4C123GH6PM.svd0000001.\dbg\dpp-qk10011.\dbg\10000000000000010fromelf --bin --output .\dbg\dpp-qk.bin .\dbg\dpp-qk.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M4"000110020080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x4000000x00x010x00x010x00x010x00x010x00x4000010x00x000x00x000x00x000x00x000x200000000x800000x00x00100100000201000000000__FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\arm;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\ek-tm4c123gxl1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cmain.c1..\..\main.cdpp.h5..\..\dpp.hbsp.h5..\..\bsp.hphilo.c1..\..\philo.ctable.c1..\..\table.cek-tm4c123gxlsystem_TM4C123GH6PM.c1..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.cTM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hstartup_TM4C123GH6PM.s2..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sgpio.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hrom.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hsysctl.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsystem_TM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP-portqfn_port.h5..\..\..\..\..\ports\arm-cm\qk\arm\qfn_port.hqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\arm\qkn_port.cdpp-rel0x4ARM-ADS0TM4C123GH6PMTexas InstrumentsKeil.TM4C_DFP.1.1.0http://www.keil.com/pack/IROM(0x00000000,0x040000) IRAM(0x20000000,0x008000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C123_256 -FS00 -FL040000 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM))0$$Device:TM4C123GH6PM$Device\Include\TM4C123\TM4C123.h$$Device:TM4C123GH6PM$SVD\TM4C123\TM4C123GH6PM.svd0000001.\rel\dpp-qk10000.\rel\10000000000000010fromelf --bin --output .\rel\dpp-qk.bin .\rel\dpp-qk.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M4"000110020080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x4000000x00x010x00x010x00x010x00x010x00x4000010x00x000x00x000x00x000x00x000x200000000x800000x00x00400100000201000000000NDEBUG __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\arm;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\ek-tm4c123gxl1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000dpp-qk.sct--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cmain.c1..\..\main.cdpp.h5..\..\dpp.hbsp.h5..\..\bsp.hphilo.c1..\..\philo.ctable.c1..\..\table.cek-tm4c123gxlsystem_TM4C123GH6PM.c1..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.cTM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hstartup_TM4C123GH6PM.s2..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sgpio.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hrom.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hsysctl.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsystem_TM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP-portqfn_port.h5..\..\..\..\..\ports\arm-cm\qk\arm\qfn_port.hqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\arm\qkn_port.c
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qk/armclang/README.txt
================================================
About this Example
==================
This example demonstrates how to use the uVision IDE together with
the MDK-ARM toolchain.
***
NOTE: This example requires installing the following Software Pack
in the Keil uVision: Keil::TM4C_DFP.
***
uVision Project File
====================
The MDK-ARM uVision project file provided with this example uses
relative paths to the QP/C framework location (includes, port, and
libraries. These relative paths must be modified when the project
is moved to different relative location.
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the
command-line options for the ARM assembler (see the Asm tab in
the "Options for Target" dialog box in uVision). Specifically,
you should define symbols: Stack_Size=xxx Heap_Size=yyy, where
xxx represents a numerical value of stack size and yyy the
numerical value of the heap size (for most embedded projects
yyy should be 0, as the using the heap is not recommended).
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.s
The file startup_TM4C123GH6PM.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qk/armclang/dpp-qk.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj; *.o*.lib*.txt; *.h; *.inc*.plm*.cpp000dpp-dbg0x4ARM-ADS120000001110016553500079668.\dbg\11101101000011111110010140111111111011101011001008BIN\lmidk-agdi.dll0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10UL2CM3UL2CM3(-O207 -S0 -C0 -FO7 -FN1 -FC1000 -FD20000000 -FF0TM4C123_256 -FL040000 -FS00 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM)0DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E2006F4 -O4622 -S4 -FO61120x200002000200x40000001000010000000000000000000dpp-rel0x4ARM-ADS120000001110016553500079668.\rel\11101101000011111110010040111111111011101011001008BIN\lmidk-agdi.dll0DLGUARMÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÈ`»
´ª¤ô 0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E10259B -O4622 -S4 -FO610UL2CM3-O207 -S0 -C0 -FO7 -FN1 -FC1000 -FD20000000 -FF0TM4C123_256 -FL040000 -FS00 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM)120x200002000200x40000001000010000000000000000000Applicatioin1000111000..\bsp.cbsp.c00121000..\..\main.cmain.c00135000..\..\dpp.hdpp.h00145000..\..\bsp.hbsp.h00151000..\..\philo.cphilo.c00161000..\..\table.ctable.c00ek-tm4c123gxl1000271000..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.csystem_TM4C123GH6PM.c00285000..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hTM4C123GH6PM.h00295000..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hgpio.h002105000..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hrom.h002115000..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsysctl.h002125000..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hsystem_TM4C123GH6PM.h002132000..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sstartup_TM4C123GH6PM.s00QP10003141000..\..\..\..\..\src\qfn\qepn.cqepn.c003151000..\..\..\..\..\src\qfn\qfn.cqfn.c003161000..\..\..\..\..\src\qkn\qkn.cqkn.c00QP-port10004175000..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqfn_port.h004181000..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.cqkn_port.c00
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qk/armclang/dpp-qk.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwaredpp-dbg0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1TM4C123GH6PMTexas InstrumentsKeil.TM4C_DFP.1.1.0http://www.keil.com/pack/IROM(0x00000000,0x040000) IRAM(0x20000000,0x008000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C123_256 -FS00 -FL040000 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM))0$$Device:TM4C123GH6PM$Device\Include\TM4C123\TM4C123.h$$Device:TM4C123GH6PM$SVD\TM4C123\TM4C123GH6PM.svd0000001.\dbg\dpp-qk10011.\dbg\10000000000000010fromelf --bin --output .\dbg\dpp-qk.bin .\dbg\dpp-qk.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x4000000x00x010x00x010x00x010x00x010x00x4000010x00x000x00x000x00x000x00x000x200000000x800000x00x007001000003010003300000..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\ek-tm4c123gxl1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cmain.c1..\..\main.cdpp.h5..\..\dpp.hbsp.h5..\..\bsp.hphilo.c1..\..\philo.ctable.c1..\..\table.cek-tm4c123gxlsystem_TM4C123GH6PM.c1..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.cTM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hgpio.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hrom.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hsysctl.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsystem_TM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hstartup_TM4C123GH6PM.s2..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP-portqfn_port.h5..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.cdpp-rel0x4ARM-ADS6070000::V6.7::.\ARMCLANG1TM4C123GH6PMTexas InstrumentsKeil.TM4C_DFP.1.1.0http://www.keil.com/pack/IROM(0x00000000,0x040000) IRAM(0x20000000,0x008000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C123_256 -FS00 -FL040000 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM))0$$Device:TM4C123GH6PM$Device\Include\TM4C123\TM4C123.h$$Device:TM4C123GH6PM$SVD\TM4C123\TM4C123GH6PM.svd0000001.\rel\dpp-qk10000.\rel\10000000000000010fromelf --bin --output .\rel\dpp-qk.bin .\rel\dpp-qk.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x4000000x00x010x00x010x00x010x00x010x00x4000010x00x000x00x000x00x000x00x000x200000000x800000x00x007001000003010003300000NDEBUG __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\ek-tm4c123gxl1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000dpp-qk.sct--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cmain.c1..\..\main.cdpp.h5..\..\dpp.hbsp.h5..\..\bsp.hphilo.c1..\..\philo.ctable.c1..\..\table.cek-tm4c123gxlsystem_TM4C123GH6PM.c1..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.cTM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hgpio.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hrom.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hsysctl.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsystem_TM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hstartup_TM4C123GH6PM.s2..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP-portqfn_port.h5..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.c
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qk/bsp.c
================================================
/*****************************************************************************
* Product: DPP on EK-TM4C123GXL board, preemptive QK kernel
* Last Updated for Version: 6.1.1
* Date of the Last Update: 2018-02-18
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "dpp.h"
#include "bsp.h"
#include "TM4C123GH6PM.h" /* the device specific header (TI) */
#include "rom.h" /* the built-in ROM functions (TI) */
#include "sysctl.h" /* system control driver (TI) */
#include "gpio.h" /* GPIO driver (TI) */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
enum KernelUnawareISRs { /* see NOTE00 */
/* ... */
MAX_KERNEL_UNAWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-unaware" interrupts can't overlap "kernel-aware" interrupts */
Q_ASSERT_COMPILE(MAX_KERNEL_UNAWARE_CMSIS_PRI <= QF_AWARE_ISR_CMSIS_PRI);
enum KernelAwareISRs {
GPIOA_PRIO = QF_AWARE_ISR_CMSIS_PRI, /* see NOTE00 */
SYSTICK_PRIO,
/* ... */
MAX_KERNEL_AWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-aware" interrupts should not overlap the PendSV priority */
Q_ASSERT_COMPILE(MAX_KERNEL_AWARE_CMSIS_PRI <= (0xFF >>(8-__NVIC_PRIO_BITS)));
/* ISRs defined in this BSP ------------------------------------------------*/
void SysTick_Handler(void);
void GPIOPortA_IRQHandler(void);
/* Local-scope objects -----------------------------------------------------*/
#define LED_RED (1U << 1)
#define LED_GREEN (1U << 3)
#define LED_BLUE (1U << 2)
#define BTN_SW1 (1U << 4)
#define BTN_SW2 (1U << 0)
/* random seed */
static uint32_t l_rnd;
/* ISRs used in this project ===============================================*/
void SysTick_Handler(void) {
/* state of the button debouncing, see below */
static struct ButtonsDebouncing {
uint32_t depressed;
uint32_t previous;
} buttons = { ~0U, ~0U };
uint32_t current;
uint32_t tmp;
QK_ISR_ENTRY(); /* inform QK about entering an ISR */
QF_tickXISR(0U); /* process time events for rate 0 */
/* Perform the debouncing of buttons. The algorithm for debouncing
* adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
* and Michael Barr, page 71.
*/
current = ~GPIOF->DATA_Bits[BTN_SW1 | BTN_SW2]; /* read SW1 and SW2 */
tmp = buttons.depressed; /* save the debounced depressed buttons */
buttons.depressed |= (buttons.previous & current); /* set depressed */
buttons.depressed &= (buttons.previous | current); /* clear released */
buttons.previous = current; /* update the history */
tmp ^= buttons.depressed; /* changed debounced depressed */
if ((tmp & BTN_SW1) != 0U) { /* debounced SW1 state changed? */
if ((buttons.depressed & BTN_SW1) != 0U) { /* is SW1 depressed? */
QACTIVE_POST_ISR((QActive *)&AO_Table, PAUSE_SIG, 0U);
}
else { /* the button is released */
QACTIVE_POST_ISR((QActive *)&AO_Table, SERVE_SIG, 0U);
}
}
QK_ISR_EXIT(); /* inform QK about exiting an ISR */
}
/*..........................................................................*/
void GPIOPortA_IRQHandler(void) {
QK_ISR_ENTRY(); /* inform QK about entering an ISR */
QACTIVE_POST_ISR((QActive *)&AO_Table, MAX_SIG, 0U); /* for testing */
QK_ISR_EXIT(); /* inform QK about exiting an ISR */
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* NOTE: SystemInit() already called from the startup code
* but SystemCoreClock needs to be updated
*/
SystemCoreClockUpdate();
/* configure the FPU usage by choosing one of the options... */
#if 1
/* OPTION 1:
* Use the automatic FPU state preservation and the FPU lazy stacking.
*
* NOTE:
* Use the following setting when FPU is used in more than one task or
* in any ISRs. This setting is the safest and recommended, but requires
* extra stack space and CPU cycles.
*/
FPU->FPCCR |= (1U << FPU_FPCCR_ASPEN_Pos) | (1U << FPU_FPCCR_LSPEN_Pos);
#else
/* OPTION 2:
* Do NOT to use the automatic FPU state preservation and
* do NOT to use the FPU lazy stacking.
*
* NOTE:
* Use the following setting when FPU is used in ONE task only and not
* in any ISR. This setting is very efficient, but if more than one task
* (or ISR) start using the FPU, this can lead to corruption of the
* FPU registers. This option should be used with CAUTION.
*/
FPU->FPCCR &= ~((1U << FPU_FPCCR_ASPEN_Pos)
| (1U << FPU_FPCCR_LSPEN_Pos));
#endif
/* enable clock for to the peripherals used by this application... */
SYSCTL->RCGCGPIO |= (1U << 5); /* enable Run mode for GPIOF */
/* configure the LEDs and push buttons */
GPIOF->DIR |= (LED_RED | LED_GREEN | LED_BLUE);/* set direction: output */
GPIOF->DEN |= (LED_RED | LED_GREEN | LED_BLUE); /* digital enable */
GPIOF->DATA_Bits[LED_RED] = 0U; /* turn the LED off */
GPIOF->DATA_Bits[LED_GREEN] = 0U; /* turn the LED off */
GPIOF->DATA_Bits[LED_BLUE] = 0U; /* turn the LED off */
/* configure the Buttons */
GPIOF->DIR &= ~(BTN_SW1 | BTN_SW2); /* set direction: input */
ROM_GPIOPadConfigSet(GPIOF_BASE, (BTN_SW1 | BTN_SW2),
GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
BSP_randomSeed(1234U);
}
/*..........................................................................*/
void BSP_displayPhilStat(uint8_t n, char const *stat) {
GPIOF->DATA_Bits[LED_RED] = ((stat[0] == 'h') ? LED_RED : 0U);
GPIOF->DATA_Bits[LED_GREEN] = ((stat[0] == 'e') ? LED_GREEN : 0U);
}
/*..........................................................................*/
void BSP_displayPaused(uint8_t paused) {
GPIOF->DATA_Bits[LED_RED] = ((paused != 0U) ? LED_RED : 0U);
}
/*..........................................................................*/
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
uint32_t rnd;
QSchedStatus lockStat; /* <=== QK scheduler lock status */
/* The flating point code is to exercise the FPU... */
float volatile x = 3.1415926F;
x = x + 2.7182818F;
lockStat = QK_schedLock(N_PHILO); /* <=== lock scheduler up to N_PHILO prio */
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
rnd = l_rnd * (3U*7U*11U*13U*23U);
l_rnd = rnd; /* set for the next time */
QK_schedUnlock(lockStat); /* <=== unlock the scheduler */
return (rnd >> 8);
}
/*..........................................................................*/
void BSP_randomSeed(uint32_t seed) {
l_rnd = seed;
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
(void)result;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set up the SysTick timer to fire at BSP_TICKS_PER_SEC rate */
SysTick_Config(SystemCoreClock / BSP_TICKS_PER_SEC);
/* assing all priority bits for preemption-prio. and none to sub-prio. */
NVIC_SetPriorityGrouping(0U);
/* set priorities of ALL ISRs used in the system, see NOTE00
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
NVIC_SetPriority(SysTick_IRQn, SYSTICK_PRIO);
NVIC_SetPriority(GPIOA_IRQn, GPIOA_PRIO);
/* ... */
/* enable IRQs... */
NVIC_EnableIRQ(GPIOA_IRQn);
}
/*..........................................................................*/
#ifdef QK_ON_CONTEXT_SW
/* NOTE: the context-switch callback is called with interrupts DISABLED */
void QK_onContextSw(uint_fast8_t prev, uint_fast8_t next) {
(void)prev;
if (next != (uint_fast8_t)0) {
//_impure_ptr = &reentrant[next];
}
}
#endif /* QK_ON_CONTEXT_SW */
/*..........................................................................*/
void QK_onIdle(void) {
/* toggle LED2 on and then off, see NOTE01 */
QF_INT_DISABLE();
GPIOF->DATA_Bits[LED_BLUE] = 0xFFU;
GPIOF->DATA_Bits[LED_BLUE] = 0x00U;
QF_INT_ENABLE();
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular Cortex-M3 MCU.
*/
__WFI(); /* Wait-For-Interrupt */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int loc) {
/*
* NOTE: add here your application-specific error handling
*/
(void)module;
(void)loc;
NVIC_SystemReset();
}
/*****************************************************************************
* NOTE00:
* The QF_AWARE_ISR_CMSIS_PRI constant from the QF port specifies the highest
* ISR priority that is disabled by the QF framework. The value is suitable
* for the NVIC_SetPriority() CMSIS function.
*
* Only ISRs prioritized at or below the QF_AWARE_ISR_CMSIS_PRI level (i.e.,
* with the numerical values of priorities equal or higher than
* QF_AWARE_ISR_CMSIS_PRI) are allowed to call any QF services. These ISRs
* are "QF-aware".
*
* Conversely, any ISRs prioritized above the QF_AWARE_ISR_CMSIS_PRI priority
* level (i.e., with the numerical values of priorities less than
* QF_AWARE_ISR_CMSIS_PRI) are never disabled and are not aware of the kernel.
* Such "QF-unaware" ISRs cannot call any QF services. The only mechanism
* by which a "QF-unaware" ISR can communicate with the QF framework is by
* triggering a "QF-aware" ISR, which can post/publish events.
*
* NOTE01:
* One of the LEDs is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qk/gnu/.ccsproject
================================================
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qk/gnu/.cproject
================================================
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qk/gnu/.project
================================================
dpp-qkorg.eclipse.cdt.managedbuilder.core.genmakebuilderorg.eclipse.cdt.managedbuilder.core.ScannerConfigBuilderfull,incremental,com.ti.ccstudio.core.ccsNatureorg.eclipse.cdt.core.cnatureorg.eclipse.cdt.managedbuilder.core.managedBuildNatureorg.eclipse.cdt.core.ccnatureorg.eclipse.cdt.managedbuilder.core.ScannerConfigNatureQK-nano2PARENT-5-PROJECT_LOC/src/qknQP-nano2PARENT-5-PROJECT_LOC/src/qfnQP_port2PARENT-5-PROJECT_LOC/ports/arm-cm/qk/gnuTM4C123GH6PM.h1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/TM4C123GH6PM.hbsp.c1PARENT-1-PROJECT_LOC/bsp.cbsp.h1PARENT-2-PROJECT_LOC/bsp.hdpp.h1PARENT-2-PROJECT_LOC/dpp.hgpio.h1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/gpio.hmain.c1PARENT-2-PROJECT_LOC/main.cphilo.c1PARENT-2-PROJECT_LOC/philo.cqstamp.c1PARENT-5-PROJECT_LOC/include/qstamp.crom.h1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/rom.hstartup_TM4C123GH6PM.c1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/gnu/startup_TM4C123GH6PM.csysctl.h1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/sysctl.hsystem_TM4C123GH6PM.c1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/system_TM4C123GH6PM.csystem_TM4C123GH6PM.h1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/system_TM4C123GH6PM.htable.c1PARENT-2-PROJECT_LOC/table.c
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qk/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano on EK-TM4C123GXL, QK-nano, GNU-ARM
# Last Updated for Version: 6.5.0
# Date of the Last Update: 2019-04-15
#
# Q u a n t u m L e a P s
# ------------------------
# Modern Embedded Software
#
# Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# https://www.state-machine.com
# mailto:info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := dpp-qk
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/arm-cm/qk/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qkn \
$(QP_PORT_DIR) \
$(QPN)/3rd_party/ek-tm4c123gxl \
$(QPN)/3rd_party/ek-tm4c123gxl/gnu
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR) \
-I$(QPN)/3rd_party/CMSIS/Include \
-I$(QPN)/3rd_party/ek-tm4c123gxl
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
bsp.c \
main.c \
philo.c \
table.c \
system_TM4C123GH6PM.c \
startup_TM4C123GH6PM.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qepn.c \
qfn.c \
qkn.c \
qkn_port.c
QP_ASMS :=
LIB_DIRS :=
LIBS :=
# defines
DEFINES :=
# ARM CPU, ARCH, FPU, and Float-ABI types...
# ARM_CPU: [cortex-m0 | cortex-m0plus | cortex-m1 | cortex-m3 | cortex-m4]
# ARM_ARCH: [6 | 7] (NOTE: must match ARM_CPU!)
# ARM_FPU: [ | vfp]
# FLOAT_ABI: [ | soft | softfp | hard]
#
ARM_CPU := -mcpu=cortex-m4
ARM_ARCH := 7 # NOTE: must match the ARM_CPU!
ARM_FPU := -mfpu=vfp
FLOAT_ABI := -mfloat-abi=softfp
#-----------------------------------------------------------------------------
# GNU-ARM toolset (NOTE: You need to adjust to your machine)
# see https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
#
ifeq ($(GNU_ARM),)
GNU_ARM := $(QTOOLS)/gnu_arm-none-eabi
endif
# make sure that the GNU-ARM toolset exists...
ifeq ("$(wildcard $(GNU_ARM))","")
$(error GNU_ARM toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_ARM)/bin/arm-none-eabi-gcc
CPP := $(GNU_ARM)/bin/arm-none-eabi-g++
AS := $(GNU_ARM)/bin/arm-none-eabi-as
LINK := $(GNU_ARM)/bin/arm-none-eabi-g++
BIN := $(GNU_ARM)/bin/arm-none-eabi-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M
#
# combine all the soruces...
C_SRCS += $(QP_SRCS)
ASM_SRCS += $(QP_ASMS)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS = $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration ..........................................
BIN_DIR := dbg
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O $(INCLUDES) $(DEFINES)
CPPFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES)
endif # ......................................................................
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
-specs=nosys.specs -specs=nano.specs \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_BIN := $(BIN_DIR)/$(OUTPUT).bin
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_BIN)
#all: $(TARGET_ELF)
$(TARGET_BIN): $(TARGET_ELF)
$(BIN) -O binary $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(CC) $(CFLAGS) $(QPN)/include/qstamp.c -o $(BIN_DIR)/qstamp.o
$(LINK) $(LINKFLAGS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.bin \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qk/gnu/README.txt
================================================
About this Example
==================
This example can be built in two different ways:
- from the command prompt with the provided Makefile.
- from the TI Code Composer Studio with the provided CCS project.
The Makefile
============
The provided Makefile should be easy to adapt for your own projects.
It contains three build configurations: Debug (default), Release, and
Spy.
Also, the Makefile has been specifically designed to work as an external
Makefile with the Eclipse CDT.
The various build configurations are built as follows:
make
make CONF=rel
make CONF=spy
make clean
make CONF=rel clean
make CONF=spy clean
***
NOTE:
The installation folder of the GNU-ARM toolset on YOUR machine needs
to be adjusted in the provided Makefile, by editing the symbol: GNU_ARM.
As described in the comment for this symbol, the GNU-ARM toolset is taken
from: http://gnutoolchains.com/arm-eabi
It is highly recommened to use the same GNU-ARM distribution, especially
for ARM Cortex-M4F projects, due to the support for the hardware FPU
(float-abi=hard).
***
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the GCC linker
script (.ld file), which provides a template of the recommended GCC linker
script for QP applications.
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\gcc\startup_TM4C123GH6PM.c
The file startup_TM4C123GH6PM.c provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qk/gnu/dpp-qk.ld
================================================
/*****************************************************************************
* Product: Linker script for EK-TM4C123GXL, GNU-ARM linker
* Last Updated for Version: 5.9.8
* Date of the Last Update: 2017-09-13
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* Web : http://www.state-machine.com
* Email: info@state-machine.com
*****************************************************************************/
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(Reset_Handler) /* entry Point */
MEMORY { /* memory map of Tiva TM4C123GH6PM */
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 256K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
}
/* The size of the stack used by the application. NOTE: you need to adjust */
STACK_SIZE = 1024;
/* The size of the heap used by the application. NOTE: you need to adjust */
HEAP_SIZE = 0;
SECTIONS {
.isr_vector : { /* the vector table goes FIRST into ROM */
KEEP(*(.isr_vector)) /* vector table */
. = ALIGN(4);
} >ROM
.text : { /* code and constants */
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} >ROM
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >ROM
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >ROM
.fini_array : {
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array*))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >ROM
_etext = .; /* global symbols at end of code */
.stack : {
__stack_start__ = .;
. = . + STACK_SIZE;
. = ALIGN(4);
__stack_end__ = .;
} >RAM
.data : AT (_etext) {
__data_load = LOADADDR (.data);
__data_start = .;
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
__data_end__ = .;
_edata = __data_end__;
} >RAM
.bss : {
__bss_start__ = .;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = .;
} >RAM
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >RAM
__exidx_end = .;
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );
PROVIDE ( __end__ = _ebss );
.heap : {
__heap_start__ = .;
. = . + HEAP_SIZE;
. = ALIGN(4);
__heap_end__ = .;
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ : {
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
}
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qk/gnu/flash.bat
================================================
::============================================================================
:: Batch file to program the flash of EK-TM4C123GXL
::
:: NOTE: requires the LMFlash programmer (included in QTools for Windows)
::
@echo off
setlocal
@echo Load a given binary file to the flash of EK-TM4C123GXL
@echo usage: flash binary-file
@echo example: flash dbg\blinky-qk.bin
::----------------------------------------------------------------------------
:: NOTE: The following symbol LMFLASH assumes that LMFlash.exe can
:: be found on the PATH. You might need to adjust this symbol to the
:: location of the LMFlash utility on your machine
::
set LMFLASH=LMFlash.exe
if ["%~1"]==[""] (
@echo The binary file missing
@goto end
)
if not exist %~s1 (
@echo The binary file '%1' does not exist
@goto end
)
%LMFLASH% -q ek-tm4c123gxl -e -v -r %1
:end
endlocal
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qk/iar/README.txt
================================================
About this Example
==================
This example demonstrates how to use the IAR EWARM IDE to build
a QP application.
IAR Project File
----------------
The IAR EWARM project file provided with this example uses relative paths
to the QP/C framework location (includes, port, and libraries. These
relative paths must be modified when the project is moved to different
relative location.
Stack Size and Heap Size
------------------------
In this project, the size of the C stack and heap are determined in
the linker script blinky-qk.icf (see the next section).
Linker Script
-------------
The IAR linker script provides a template of the recommended linker script
for QP applications. This file needs to be customized to set the
application-specific sizes of the Stack and Heap. This file can be edited
from the IAR EWARM IDE via the Project Options/Linker settings.
Startup Code
------------
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\iar\startup_TM4C123GH6PM.s
The file startup_TM4C123GH6PM.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qk/iar/dpp-qk.ewd
================================================
3DebugARM1C-SPY22811ARMSIM_ID2111CADI_ID2011CMSISDAP_ID2411GDBSERVER_ID2011IJET_ID2811JLINK_ID21611LMIFTDI_ID2211PEMICRO_ID2311STLINK_ID2411THIRDPARTY_ID2011TIFET_ID2111XDS100_ID2611$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseARM0C-SPY22810ARMSIM_ID2110CADI_ID2010CMSISDAP_ID2410GDBSERVER_ID2010IJET_ID2810JLINK_ID21610LMIFTDI_ID2210PEMICRO_ID2310STLINK_ID2410THIRDPARTY_ID2010TIFET_ID2110XDS100_ID2610$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qk/iar/dpp-qk.ewp
================================================
3DebugARM1General33111ICCARM23511AARM21011OBJCOPY0111CUSTOM30BICOMP0BUILDACTION1ILINK02311IARCHIVE0011BILINK0Coder0ReleaseARM0General33110ICCARM23510AARM21010OBJCOPY0110CUSTOM30BICOMP0BUILDACTION1ILINK02310IARCHIVE0010BILINK0Coder0DebugApplication$PROJ_DIR$\..\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\dpp.h$PROJ_DIR$\..\..\main.c$PROJ_DIR$\..\..\philo.c$PROJ_DIR$\..\..\table.cek-tm4c123gxl$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\iar\startup_TM4C123GH6PM.s$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.c$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.h$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qkn\qkn.cQP_port$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qk\iar\qfn_port.h$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qk\iar\qkn_port.c
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qk/iar/dpp-qk.eww
================================================
$WS_DIR$\dpp-qk.ewp
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qk/iar/dpp-qk.icf
================================================
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0003FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 1024;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place at start of RAM_region {block CSTACK };
place in RAM_region { readwrite, block HEAP };
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qpn_conf.h
================================================
/*****************************************************************************
* Product: QP-nano configuration for the Blinky example
* Last Updated for Version: 6.1.1
* Date of the Last Update: 2018-02-18
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef QPN_CONF_H
#define QPN_CONF_H
#define Q_PARAM_SIZE 4U
#define QF_MAX_TICK_RATE 1U
#define QF_TIMEEVT_CTR_SIZE 2U
#define QF_TIMEEVT_PERIODIC
#define QK_SCHED_LOCK
#endif /* QPN_CONF_H */
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qv/arm/README.txt
================================================
About this Example
==================
This example demonstrates how to use the uVision IDE together with
the MDK-ARM toolchain.
***
NOTE: This example requires installing the following Software Pack
in the Keil uVision: Keil::TM4C_DFP.
***
uVision Project File
====================
The MDK-ARM uVision project file provided with this example uses
relative paths to the QP/C framework location (includes, port, and
libraries. These relative paths must be modified when the project
is moved to different relative location.
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the
command-line options for the ARM assembler (see the Asm tab in
the "Options for Target" dialog box in uVision). Specifically,
you should define symbols: Stack_Size=xxx Heap_Size=yyy, where
xxx represents a numerical value of stack size and yyy the
numerical value of the heap size (for most embedded projects
yyy should be 0, as the using the heap is not recommended).
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.s
The file startup_TM4C123GH6PM.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qv/arm/dpp-qv.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj*.lib*.txt; *.h; *.inc*.plm*.cpp000dpp-dbg0x4ARM-ADS120000001110016553500079668.\dbg\11101101000011111110010140111111111011101011008BIN\lmidk-agdi.dll0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10UL2CM3UL2CM3(-O207 -S0 -C0 -FO7 -FN1 -FC1000 -FD20000000 -FF0TM4C123_256 -FL040000 -FS00 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM)0DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E2006F4 -O4622 -S4 -FO61120x200002000200x4000000100001000000000000000000dpp-rel0x4ARM-ADS120000001110016553500079668.\rel\11101101000011111110010040111111111011101011003BIN\lmidk-agdi.dll0DLGUARMÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÈ`»
´ª¤ô 0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E10259B -O4622 -S4 -FO610UL2CM3-O207 -S0 -C0 -FO7 -FN1 -FC1000 -FD20000000 -FF0TM4C123_256 -FL040000 -FS00 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM)120x200002000200x4000000100001000000000000000000Applicatioin0000111000..\bsp.cbsp.c00121000..\..\main.cmain.c00135000..\..\dpp.hdpp.h00145000..\..\bsp.hbsp.h00151000..\..\philo.cphilo.c00161000..\..\table.ctable.c00ek-tm4c123gxl1000271000..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.csystem_TM4C123GH6PM.c00285000..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hTM4C123GH6PM.h00292000..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sstartup_TM4C123GH6PM.s002105000..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hgpio.h002115000..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hrom.h002125000..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsysctl.h002135000..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hsystem_TM4C123GH6PM.h00QP10003141000..\..\..\..\..\src\qfn\qepn.cqepn.c003151000..\..\..\..\..\src\qfn\qfn.cqfn.c003161000..\..\..\..\..\src\qvn\qvn.cqvn.c003171000..\..\..\..\..\ports\arm-cm\qv\arm\qvn_port.cqvn_port.c00
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qv/arm/dpp-qv.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwaredpp-dbg0x4ARM-ADS5060183::V5.06 update 2 (build 183)::ARMCCTM4C123GH6PMTexas InstrumentsKeil.TM4C_DFP.1.1.0http://www.keil.com/pack/IROM(0x00000000,0x040000) IRAM(0x20000000,0x008000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C123_256 -FS00 -FL040000 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM))0$$Device:TM4C123GH6PM$Device\Include\TM4C123\TM4C123.h$$Device:TM4C123GH6PM$SVD\TM4C123\TM4C123GH6PM.svd0000001.\dbg\dpp-qv10011.\dbg\10000000000000010fromelf --bin --output .\dbg\dpp-qv.bin .\dbg\dpp-qv.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M4"000110020080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x4000000x00x010x00x010x00x010x00x010x00x4000010x00x000x00x000x00x000x00x000x200000000x800000x00x0010010000020100111100__FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\arm;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\ek-tm4c123gxl100000010Stack_Size=1024 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cmain.c1..\..\main.cdpp.h5..\..\dpp.hbsp.h5..\..\bsp.hphilo.c1..\..\philo.ctable.c1..\..\table.cek-tm4c123gxlsystem_TM4C123GH6PM.c1..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.cTM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hstartup_TM4C123GH6PM.s2..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sgpio.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hrom.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hsysctl.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsystem_TM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\arm\qvn_port.cdpp-rel0x4ARM-ADSTM4C123GH6PMTexas InstrumentsKeil.TM4C_DFP.1.1.0http://www.keil.com/pack/IROM(0x00000000,0x040000) IRAM(0x20000000,0x008000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C123_256 -FS00 -FL040000 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM))0$$Device:TM4C123GH6PM$Device\Include\TM4C123\TM4C123.h$$Device:TM4C123GH6PM$SVD\TM4C123\TM4C123GH6PM.svd0000001.\rel\dpp-qv10000.\rel\10000000000000010fromelf --bin --output .\rel\dpp-qv.bin .\rel\dpp-qv.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M4"000110020080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x4000000x00x010x00x010x00x010x00x010x00x4000010x00x000x00x000x00x000x00x000x200000000x800000x00x0040010000020100111100NDEBUG __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\arm;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\ek-tm4c123gxl100000010Stack_Size=1024 Heap_Size=01000100x000000000x20000000dpp-qv.sct--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cmain.c1..\..\main.cdpp.h5..\..\dpp.hbsp.h5..\..\bsp.hphilo.c1..\..\philo.ctable.c1..\..\table.cek-tm4c123gxlsystem_TM4C123GH6PM.c1..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.cTM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hstartup_TM4C123GH6PM.s2..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sgpio.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hrom.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hsysctl.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsystem_TM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\arm\qvn_port.c
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qv/armclang/README.txt
================================================
About this Example
==================
This example demonstrates how to use the uVision IDE together with
the MDK-ARM toolchain.
***
NOTE: This example requires installing the following Software Pack
in the Keil uVision: Keil::TM4C_DFP.
***
uVision Project File
====================
The MDK-ARM uVision project file provided with this example uses
relative paths to the QP/C framework location (includes, port, and
libraries. These relative paths must be modified when the project
is moved to different relative location.
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the
command-line options for the ARM assembler (see the Asm tab in
the "Options for Target" dialog box in uVision). Specifically,
you should define symbols: Stack_Size=xxx Heap_Size=yyy, where
xxx represents a numerical value of stack size and yyy the
numerical value of the heap size (for most embedded projects
yyy should be 0, as the using the heap is not recommended).
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.s
The file startup_TM4C123GH6PM.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qv/armclang/dpp-qv.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj; *.o*.lib*.txt; *.h; *.inc*.plm*.cpp000dpp-dbg0x4ARM-ADS120000001110016553500079668.\dbg\111011010000111111100101401111111110111010110018BIN\lmidk-agdi.dll0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10UL2CM3UL2CM3(-O207 -S0 -C0 -FO7 -FN1 -FC1000 -FD20000000 -FF0TM4C123_256 -FL040000 -FS00 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM)0DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E2006F4 -O4622 -S4 -FO61120x200002000200x40000001000010000000000000000000dpp-rel0x4ARM-ADS120000001110016553500079668.\rel\111011010000111111100100401111111110111010110018BIN\lmidk-agdi.dll0DLGUARMÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÈ`»
´ª¤ô 0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E10259B -O4622 -S4 -FO610UL2CM3-O207 -S0 -C0 -FO7 -FN1 -FC1000 -FD20000000 -FF0TM4C123_256 -FL040000 -FS00 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM)120x200002000200x40000001000010000000000000000000Applicatioin0000111000..\bsp.cbsp.c00121000..\..\main.cmain.c00135000..\..\dpp.hdpp.h00145000..\..\bsp.hbsp.h00151000..\..\philo.cphilo.c00161000..\..\table.ctable.c00ek-tm4c123gxl1000271000..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.csystem_TM4C123GH6PM.c00285000..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hTM4C123GH6PM.h00292000..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sstartup_TM4C123GH6PM.s002105000..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hgpio.h002115000..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hrom.h002125000..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsysctl.h002135000..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hsystem_TM4C123GH6PM.h00QP10003141000..\..\..\..\..\src\qfn\qepn.cqepn.c003151000..\..\..\..\..\src\qfn\qfn.cqfn.c003161000..\..\..\..\..\src\qvn\qvn.cqvn.c00QP_port10004175000..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqfn_port.h004181000..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.cqvn_port.c00
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qv/armclang/dpp-qv.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwaredpp-dbg0x4ARM-ADS6070000::V6.7::.\ARMCLANG1TM4C123GH6PMTexas InstrumentsKeil.TM4C_DFP.1.1.0http://www.keil.com/pack/IROM(0x00000000,0x040000) IRAM(0x20000000,0x008000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C123_256 -FS00 -FL040000 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM))0$$Device:TM4C123GH6PM$Device\Include\TM4C123\TM4C123.h$$Device:TM4C123GH6PM$SVD\TM4C123\TM4C123GH6PM.svd0000001.\dbg\dpp-qv10011.\dbg\10000000000000010fromelf --bin --output .\dbg\dpp-qv.bin .\dbg\dpp-qv.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M4"000110020080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x4000000x00x010x00x010x00x010x00x010x00x4000010x00x000x00x000x00x000x00x000x200000000x800000x00x00700100000301003311000__FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\ek-tm4c123gxl1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cmain.c1..\..\main.cdpp.h5..\..\dpp.hbsp.h5..\..\bsp.hphilo.c1..\..\philo.ctable.c1..\..\table.cek-tm4c123gxlsystem_TM4C123GH6PM.c1..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.cTM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hstartup_TM4C123GH6PM.s2..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sgpio.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hrom.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hsysctl.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsystem_TM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.cdpp-rel0x4ARM-ADS6070000::V6.7::.\ARMCLANG1TM4C123GH6PMTexas InstrumentsKeil.TM4C_DFP.1.1.0http://www.keil.com/pack/IROM(0x00000000,0x040000) IRAM(0x20000000,0x008000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C123_256 -FS00 -FL040000 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM))0$$Device:TM4C123GH6PM$Device\Include\TM4C123\TM4C123.h$$Device:TM4C123GH6PM$SVD\TM4C123\TM4C123GH6PM.svd0000001.\rel\dpp-qv10000.\rel\10000000000000010fromelf --bin --output .\rel\dpp-qv.bin .\rel\dpp-qv.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M4"000110020080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x4000000x00x010x00x010x00x010x00x010x00x4000010x00x000x00x000x00x000x00x000x200000000x800000x00x00700100000301003311000NDEBUG..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\ek-tm4c123gxl1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000dpp-qv.sct--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cmain.c1..\..\main.cdpp.h5..\..\dpp.hbsp.h5..\..\bsp.hphilo.c1..\..\philo.ctable.c1..\..\table.cek-tm4c123gxlsystem_TM4C123GH6PM.c1..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.cTM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hstartup_TM4C123GH6PM.s2..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sgpio.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hrom.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hsysctl.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsystem_TM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.c
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qv/bsp.c
================================================
/*****************************************************************************
* Product: DPP on EK-TM4C123GXL board, cooperative QV kernel
* Last Updated for Version: 5.8.0
* Date of the Last Update: 2016-11-06
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "dpp.h"
#include "bsp.h"
#include "TM4C123GH6PM.h" /* the device specific header (TI) */
#include "rom.h" /* the built-in ROM functions (TI) */
#include "sysctl.h" /* system control driver (TI) */
#include "gpio.h" /* GPIO driver (TI) */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
enum KernelUnawareISRs { /* see NOTE00 */
/* ... */
MAX_KERNEL_UNAWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-unaware" interrupts can't overlap "kernel-aware" interrupts */
Q_ASSERT_COMPILE(MAX_KERNEL_UNAWARE_CMSIS_PRI <= QF_AWARE_ISR_CMSIS_PRI);
enum KernelAwareISRs {
GPIOA_PRIO = QF_AWARE_ISR_CMSIS_PRI, /* see NOTE00 */
SYSTICK_PRIO,
/* ... */
MAX_KERNEL_AWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-aware" interrupts should not overlap the PendSV priority */
Q_ASSERT_COMPILE(MAX_KERNEL_AWARE_CMSIS_PRI <= (0xFF >>(8-__NVIC_PRIO_BITS)));
/* ISRs defined in this BSP ------------------------------------------------*/
void SysTick_Handler(void);
void GPIOPortA_IRQHandler(void);
/* Local-scope objects -----------------------------------------------------*/
#define LED_RED (1U << 1)
#define LED_GREEN (1U << 3)
#define LED_BLUE (1U << 2)
#define BTN_SW1 (1U << 4)
#define BTN_SW2 (1U << 0)
/* random seed */
static uint32_t l_rnd;
/* ISRs used in this project ===============================================*/
void SysTick_Handler(void) {
/* state of the button debouncing, see below */
static struct ButtonsDebouncing {
uint32_t depressed;
uint32_t previous;
} buttons = { ~0U, ~0U };
uint32_t current;
uint32_t tmp;
QF_tickXISR(0U); /* process time events for rate 0 */
/* Perform the debouncing of buttons. The algorithm for debouncing
* adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
* and Michael Barr, page 71.
*/
current = ~GPIOF->DATA_Bits[BTN_SW1 | BTN_SW2]; /* read SW1 and SW2 */
tmp = buttons.depressed; /* save the debounced depressed buttons */
buttons.depressed |= (buttons.previous & current); /* set depressed */
buttons.depressed &= (buttons.previous | current); /* clear released */
buttons.previous = current; /* update the history */
tmp ^= buttons.depressed; /* changed debounced depressed */
if ((tmp & BTN_SW1) != 0U) { /* debounced SW1 state changed? */
if ((buttons.depressed & BTN_SW1) != 0U) { /* is SW1 depressed? */
QACTIVE_POST_ISR((QActive *)&AO_Table, PAUSE_SIG, 0U);
}
else { /* the button is released */
QACTIVE_POST_ISR((QActive *)&AO_Table, SERVE_SIG, 0U);
}
}
}
/*..........................................................................*/
void GPIOPortA_IRQHandler(void) {
QACTIVE_POST_ISR((QActive *)&AO_Table, MAX_SIG, 0U); /* for testing */
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* NOTE: SystemInit() already called from the startup code
* but SystemCoreClock needs to be updated
*/
SystemCoreClockUpdate();
/*
* Do NOT to use the automatic FPU state preservation and
* do NOT to use the FPU lazy stacking.
*
* NOTE:
* Use the following setting when FPU is used at the task-level only and
* NOT in any ISR. This setting is very efficient, but if ISRs start using
* the FPU, this can lead to corruption of the FPU registers.
*/
FPU->FPCCR &= ~((1U << FPU_FPCCR_ASPEN_Pos)
| (1U << FPU_FPCCR_LSPEN_Pos));
/* enable clock for to the peripherals used by this application... */
SYSCTL->RCGCGPIO |= (1U << 5); /* enable Run mode for GPIOF */
/* configure the LEDs and push buttons */
GPIOF->DIR |= (LED_RED | LED_GREEN | LED_BLUE);/* set direction: output */
GPIOF->DEN |= (LED_RED | LED_GREEN | LED_BLUE); /* digital enable */
GPIOF->DATA_Bits[LED_RED] = 0U; /* turn the LED off */
GPIOF->DATA_Bits[LED_GREEN] = 0U; /* turn the LED off */
GPIOF->DATA_Bits[LED_BLUE] = 0U; /* turn the LED off */
/* configure the Buttons */
GPIOF->DIR &= ~(BTN_SW1 | BTN_SW2); /* set direction: input */
ROM_GPIOPadConfigSet(GPIOF_BASE, (BTN_SW1 | BTN_SW2),
GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
BSP_randomSeed(1234U);
}
/*..........................................................................*/
void BSP_displayPhilStat(uint8_t n, char const *stat) {
GPIOF->DATA_Bits[LED_RED] = ((stat[0] == 'h') ? LED_RED : 0U);
GPIOF->DATA_Bits[LED_GREEN] = ((stat[0] == 'e') ? LED_GREEN : 0U);
}
/*..........................................................................*/
void BSP_displayPaused(uint8_t paused) {
GPIOF->DATA_Bits[LED_RED] = ((paused != 0U) ? LED_RED : 0U);
}
/*..........................................................................*/
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
/* The flating point code is to exercise the FPU... */
float volatile x = 3.1415926F;
x = x + 2.7182818F;
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
l_rnd = l_rnd * (3U*7U*11U*13U*23U);
return l_rnd >> 8;
}
/*..........................................................................*/
void BSP_randomSeed(uint32_t seed) {
l_rnd = seed;
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
(void)result;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set up the SysTick timer to fire at BSP_TICKS_PER_SEC rate */
SysTick_Config(SystemCoreClock / BSP_TICKS_PER_SEC);
/* assing all priority bits for preemption-prio. and none to sub-prio. */
NVIC_SetPriorityGrouping(0U);
/* set priorities of ALL ISRs used in the system, see NOTE00
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
NVIC_SetPriority(SysTick_IRQn, SYSTICK_PRIO);
NVIC_SetPriority(GPIOA_IRQn, GPIOA_PRIO);
/* ... */
/* enable IRQs... */
NVIC_EnableIRQ(GPIOA_IRQn);
}
/*..........................................................................*/
void QV_onIdle(void) { /* called with interrupts disabled, see NOTE01 */
/* toggle the User LED on and then off, see NOTE02 */
GPIOF->DATA_Bits[LED_BLUE] = LED_BLUE; /* turn the Blue LED on */
GPIOF->DATA_Bits[LED_BLUE] = 0U; /* turn the Blue LED off */
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular Cortex-M MCU.
*/
QV_CPU_SLEEP(); /* atomically go to sleep and enable interrupts */
#else
QF_INT_ENABLE(); /* just enable interrupts */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int loc) {
/*
* NOTE: add here your application-specific error handling
*/
(void)module;
(void)loc;
NVIC_SystemReset();
}
/*****************************************************************************
* NOTE00:
* The QF_AWARE_ISR_CMSIS_PRI constant from the QF port specifies the highest
* ISR priority that is disabled by the QF framework. The value is suitable
* for the NVIC_SetPriority() CMSIS function.
*
* Only ISRs prioritized at or below the QF_AWARE_ISR_CMSIS_PRI level (i.e.,
* with the numerical values of priorities equal or higher than
* QF_AWARE_ISR_CMSIS_PRI) are allowed to call any QF services. These ISRs
* are "QF-aware".
*
* Conversely, any ISRs prioritized above the QF_AWARE_ISR_CMSIS_PRI priority
* level (i.e., with the numerical values of priorities less than
* QF_AWARE_ISR_CMSIS_PRI) are never disabled and are not aware of the kernel.
* Such "QF-unaware" ISRs cannot call any QF services. The only mechanism
* by which a "QF-unaware" ISR can communicate with the QF framework is by
* triggering a "QF-aware" ISR, which can post/publish events.
*
* NOTE01:
* The QV_onIdle() callback is called with interrupts disabled, because the
* determination of the idle condition might change by any interrupt posting
* an event. QV_onIdle() must internally enable interrupts, ideally
* atomically with putting the CPU to the power-saving mode.
*
* NOTE02:
* The User LED is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qv/gnu/.ccsproject
================================================
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qv/gnu/.cproject
================================================
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qv/gnu/.project
================================================
dpp-qvorg.eclipse.cdt.managedbuilder.core.genmakebuilderorg.eclipse.cdt.managedbuilder.core.ScannerConfigBuilderfull,incremental,com.ti.ccstudio.core.ccsNatureorg.eclipse.cdt.core.cnatureorg.eclipse.cdt.managedbuilder.core.managedBuildNatureorg.eclipse.cdt.core.ccnatureorg.eclipse.cdt.managedbuilder.core.ScannerConfigNatureqv-nano2PARENT-5-PROJECT_LOC/src/qvnQP-nano2PARENT-5-PROJECT_LOC/src/qfnQP_port2PARENT-5-PROJECT_LOC/ports/arm-cm/qv/gnuTM4C123GH6PM.h1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/TM4C123GH6PM.hbsp.c1PARENT-1-PROJECT_LOC/bsp.cbsp.h1PARENT-2-PROJECT_LOC/bsp.hdpp.h1PARENT-2-PROJECT_LOC/dpp.hgpio.h1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/gpio.hmain.c1PARENT-2-PROJECT_LOC/main.cphilo.c1PARENT-2-PROJECT_LOC/philo.cqstamp.c1PARENT-5-PROJECT_LOC/include/qstamp.crom.h1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/rom.hstartup_TM4C123GH6PM.c1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/gnu/startup_TM4C123GH6PM.csysctl.h1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/sysctl.hsystem_TM4C123GH6PM.c1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/system_TM4C123GH6PM.csystem_TM4C123GH6PM.h1PARENT-5-PROJECT_LOC/3rd_party/ek-tm4c123gxl/system_TM4C123GH6PM.htable.c1PARENT-2-PROJECT_LOC/table.c
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qv/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano on EK-TM4C123GXL, QV-nano, GNU-ARM
# Last Updated for Version: 6.5.0
# Date of the Last Update: 2019-04-15
#
# Q u a n t u m L e a P s
# ------------------------
# Modern Embedded Software
#
# Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# https://www.state-machine.com
# mailto:info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := dpp-qv
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/arm-cm/qv/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qvn \
$(QP_PORT_DIR) \
$(QPN)/3rd_party/ek-tm4c123gxl \
$(QPN)/3rd_party/ek-tm4c123gxl/gnu
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR) \
-I$(QPN)/3rd_party/CMSIS/Include \
-I$(QPN)/3rd_party/ek-tm4c123gxl
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
bsp.c \
main.c \
philo.c \
table.c \
system_TM4C123GH6PM.c \
startup_TM4C123GH6PM.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qepn.c \
qfn.c \
qvn.c \
qvn_port.c
QP_ASMS :=
LIB_DIRS :=
LIBS :=
# defines
DEFINES := -DTARGET_IS_TM4C123_RB1
# ARM CPU, ARCH, FPU, and Float-ABI types...
# ARM_CPU: [cortex-m0 | cortex-m0plus | cortex-m1 | cortex-m3 | cortex-m4]
# ARM_ARCH: [6 | 7] (NOTE: must match ARM_CPU!)
# ARM_FPU: [ | vfp]
# FLOAT_ABI: [ | soft | softfp | hard]
#
ARM_CPU := -mcpu=cortex-m4
ARM_ARCH := 7 # NOTE: must match the ARM_CPU!
ARM_FPU := -mfpu=vfp
FLOAT_ABI := -mfloat-abi=softfp
#-----------------------------------------------------------------------------
# GNU-ARM toolset (NOTE: You need to adjust to your machine)
# see https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
#
ifeq ($(GNU_ARM),)
GNU_ARM := $(QTOOLS)/gnu_arm-none-eabi
endif
# make sure that the GNU-ARM toolset exists...
ifeq ("$(wildcard $(GNU_ARM))","")
$(error GNU_ARM toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_ARM)/bin/arm-none-eabi-gcc
CPP := $(GNU_ARM)/bin/arm-none-eabi-g++
AS := $(GNU_ARM)/bin/arm-none-eabi-as
LINK := $(GNU_ARM)/bin/arm-none-eabi-g++
BIN := $(GNU_ARM)/bin/arm-none-eabi-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M
#
# combine all the soruces...
C_SRCS += $(QP_SRCS)
ASM_SRCS += $(QP_ASMS)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS = $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration ..........................................
BIN_DIR := dbg
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O $(INCLUDES) $(DEFINES)
CPPFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES)
endif # ......................................................................
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
-specs=nosys.specs -specs=nano.specs \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_BIN := $(BIN_DIR)/$(OUTPUT).bin
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_BIN)
#all: $(TARGET_ELF)
$(TARGET_BIN): $(TARGET_ELF)
$(BIN) -O binary $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(CC) $(CFLAGS) $(QPN)/include/qstamp.c -o $(BIN_DIR)/qstamp.o
$(LINK) $(LINKFLAGS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.bin \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qv/gnu/README.txt
================================================
About this Example
==================
This example can be built in two different ways:
- from the command prompt with the provided Makefile.
- from the TI Code Composer Studio with the provided CCS project.
The Makefile
============
The provided Makefile should be easy to adapt for your own projects.
It contains three build configurations: Debug (default), Release, and
Spy.
Also, the Makefile has been specifically designed to work as an external
Makefile with the Eclipse CDT.
The various build configurations are built as follows:
make
make CONF=rel
make CONF=spy
make clean
make CONF=rel clean
make CONF=spy clean
***
NOTE:
The installation folder of the GNU-ARM toolset on YOUR machine needs
to be adjusted in the provided Makefile, by editing the symbol: GNU_ARM.
As described in the comment for this symbol, the GNU-ARM toolset is taken
from: http://gnutoolchains.com/arm-eabi
It is highly recommened to use the same GNU-ARM distribution, especially
for ARM Cortex-M4F projects, due to the support for the hardware FPU
(float-abi=hard).
***
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the GCC linker
script (.ld file), which provides a template of the recommended GCC linker
script for QP applications.
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\gcc\startup_TM4C123GH6PM.c
The file startup_TM4C123GH6PM.c provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qv/gnu/dpp-qv.ld
================================================
/*****************************************************************************
* Product: Linker script for EK-TM4C123GXL, GNU-ARM linker
* Last Updated for Version: 5.9.8
* Date of the Last Update: 2017-09-13
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* Web : http://www.state-machine.com
* Email: info@state-machine.com
*****************************************************************************/
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(Reset_Handler) /* entry Point */
MEMORY { /* memory map of Tiva TM4C123GH6PM */
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 256K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
}
/* The size of the stack used by the application. NOTE: you need to adjust */
STACK_SIZE = 1024;
/* The size of the heap used by the application. NOTE: you need to adjust */
HEAP_SIZE = 0;
SECTIONS {
.isr_vector : { /* the vector table goes FIRST into ROM */
KEEP(*(.isr_vector)) /* vector table */
. = ALIGN(4);
} >ROM
.text : { /* code and constants */
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} >ROM
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >ROM
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >ROM
.fini_array : {
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array*))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >ROM
_etext = .; /* global symbols at end of code */
.stack : {
__stack_start__ = .;
. = . + STACK_SIZE;
. = ALIGN(4);
__stack_end__ = .;
} >RAM
.data : AT (_etext) {
__data_load = LOADADDR (.data);
__data_start = .;
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
__data_end__ = .;
_edata = __data_end__;
} >RAM
.bss : {
__bss_start__ = .;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = .;
} >RAM
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >RAM
__exidx_end = .;
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );
PROVIDE ( __end__ = _ebss );
.heap : {
__heap_start__ = .;
. = . + HEAP_SIZE;
. = ALIGN(4);
__heap_end__ = .;
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ : {
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
}
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qv/gnu/flash.bat
================================================
::============================================================================
:: Batch file to program the flash of EK-TM4C123GXL
::
:: NOTE: requires the LMFlash programmer (included in QTools for Windows)
::
@echo off
setlocal
@echo Load a given binary file to the flash of EK-TM4C123GXL
@echo usage: flash binary-file
@echo example: flash dbg\blinky-qk.bin
::----------------------------------------------------------------------------
:: NOTE: The following symbol LMFLASH assumes that LMFlash.exe can
:: be found on the PATH. You might need to adjust this symbol to the
:: location of the LMFlash utility on your machine
::
set LMFLASH=LMFlash.exe
if ["%~1"]==[""] (
@echo The binary file missing
@goto end
)
if not exist %~s1 (
@echo The binary file '%1' does not exist
@goto end
)
%LMFLASH% -q ek-tm4c123gxl -e -v -r %1
:end
endlocal
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qv/iar/README.txt
================================================
About this Example
==================
This example demonstrates how to use the IAR EWARM IDE to build
a QP application.
IAR Project File
----------------
The IAR EWARM project file provided with this example uses relative paths
to the QP/C framework location (includes, port, and libraries. These
relative paths must be modified when the project is moved to different
relative location.
Stack Size and Heap Size
------------------------
In this project, the size of the C stack and heap are determined in
the linker script blinky-qk.icf (see the next section).
Linker Script
-------------
The IAR linker script provides a template of the recommended linker script
for QP applications. This file needs to be customized to set the
application-specific sizes of the Stack and Heap. This file can be edited
from the IAR EWARM IDE via the Project Options/Linker settings.
Startup Code
------------
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\iar\startup_TM4C123GH6PM.s
The file startup_TM4C123GH6PM.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qv/iar/dpp-qv.ewd
================================================
3DebugARM1C-SPY22811ARMSIM_ID2111CADI_ID2011CMSISDAP_ID2411GDBSERVER_ID2011IJET_ID2811JLINK_ID21611LMIFTDI_ID2211PEMICRO_ID2311STLINK_ID2411THIRDPARTY_ID2011TIFET_ID2111XDS100_ID2611$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseARM0C-SPY22810ARMSIM_ID2110CADI_ID2010CMSISDAP_ID2410GDBSERVER_ID2010IJET_ID2810JLINK_ID21610LMIFTDI_ID2210PEMICRO_ID2310STLINK_ID2410THIRDPARTY_ID2010TIFET_ID2110XDS100_ID2610$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qv/iar/dpp-qv.ewp
================================================
3DebugARM1General32811ICCARM23411AARM21011OBJCOPY0111CUSTOM30BICOMP0BUILDACTION1ILINK02011IARCHIVE0011BILINK0Coder0ReleaseARM0General32810ICCARM23410AARM21010OBJCOPY0110CUSTOM30BICOMP0BUILDACTION1ILINK02010IARCHIVE0010BILINK0Coder0Application$PROJ_DIR$\..\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\dpp.h$PROJ_DIR$\..\..\main.c$PROJ_DIR$\..\..\philo.c$PROJ_DIR$\..\..\table.cek-tm4c123gxl$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\iar\startup_TM4C123GH6PM.s$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.c$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.h$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qvn\qvn.cQP_port$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qv\iar\qfn_port.h$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qv\iar\qvn_port.c
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qv/iar/dpp-qv.eww
================================================
$WS_DIR$\dpp-qv.ewp
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/qv/iar/dpp-qv.icf
================================================
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0003FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 1024;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place at start of RAM_region {block CSTACK };
place in RAM_region { readwrite, block HEAP };
================================================
FILE: examples/arm-cm/dpp_ek-tm4c123gxl/table.c
================================================
/*.$file${.::table.c} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: dpp.qm
* File: ${.::table.c}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::table.c} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("table")
/* Active object class -----------------------------------------------------*/
/*.$declare${AOs::Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table} ...........................................................*/
typedef struct Table {
/* protected: */
QActive super;
/* private: */
uint8_t fork[N_PHILO];
uint8_t isHungry[N_PHILO];
} Table;
/* protected: */
static QState Table_initial(Table * const me);
static QState Table_active(Table * const me);
static QState Table_serving(Table * const me);
static QState Table_paused(Table * const me);
/*.$enddecl${AOs::Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Global objects ----------------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*. Check for the minimum required QP version */
#if (QP_VERSION < 650U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpn version 6.5.0 or higher required
#endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Table} ........................................................*/
struct Table AO_Table;
/*.$enddef${AOs::AO_Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#define RIGHT(n_) ((uint8_t)(((n_) + (N_PHILO - 1U)) % N_PHILO))
#define LEFT(n_) ((uint8_t)(((n_) + 1U) % N_PHILO))
#define FREE ((uint8_t)0)
#define USED ((uint8_t)1)
/*..........................................................................*/
/*.$define${AOs::Table_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table_ctor} ......................................................*/
void Table_ctor(void) {
uint8_t n;
Table *me = &AO_Table;
QActive_ctor(&me->super, Q_STATE_CAST(&Table_initial));
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
}
}
/*.$enddef${AOs::Table_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table} ...........................................................*/
/*.${AOs::Table::SM} .......................................................*/
static QState Table_initial(Table * const me) {
/*.${AOs::Table::SM::initial} */
uint8_t n;
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "thinking");
}
return Q_TRAN(&Table_serving);
}
/*.${AOs::Table::SM::active} ...............................................*/
static QState Table_active(Table * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Table::SM::active::TERMINATE} */
case TERMINATE_SIG: {
BSP_terminate(0);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::EAT} */
case EAT_SIG: {
Q_ERROR();
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Table::SM::active::serving} ......................................*/
static QState Table_serving(Table * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Table::SM::active::serving} */
case Q_ENTRY_SIG: {
uint8_t n;
for (n = 0U; n < N_PHILO; ++n) { /* give permissions to eat... */
if ((me->isHungry[n] != 0U)
&& (me->fork[LEFT(n)] == FREE)
&& (me->fork[n] == FREE))
{
QActive *philo;
me->fork[LEFT(n)] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "eating ");
}
}
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::serving::HUNGRY} */
case HUNGRY_SIG: {
uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "hungry ");
m = LEFT(n);
/*.${AOs::Table::SM::active::serving::HUNGRY::[bothfree]} */
if ((me->fork[m] == FREE) && (me->fork[n] == FREE)) {
me->fork[m] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
BSP_displayPhilStat(n, "eating ");
status_ = Q_HANDLED();
}
/*.${AOs::Table::SM::active::serving::HUNGRY::[else]} */
else {
me->isHungry[n] = 1U;
status_ = Q_HANDLED();
}
break;
}
/*.${AOs::Table::SM::active::serving::DONE} */
case DONE_SIG: {
uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;
m = RIGHT(n); /* check the right neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[m] == FREE)) {
me->fork[n] = USED;
me->fork[m] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}
m = LEFT(n); /* check the left neighbor */
n = LEFT(m); /* left fork of the left neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[n] == FREE)) {
me->fork[m] = USED;
me->fork[n] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::serving::EAT} */
case EAT_SIG: {
Q_ERROR();
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::serving::PAUSE} */
case PAUSE_SIG: {
status_ = Q_TRAN(&Table_paused);
break;
}
default: {
status_ = Q_SUPER(&Table_active);
break;
}
}
return status_;
}
/*.${AOs::Table::SM::active::paused} .......................................*/
static QState Table_paused(Table * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Table::SM::active::paused} */
case Q_ENTRY_SIG: {
BSP_displayPaused(1U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::paused} */
case Q_EXIT_SIG: {
BSP_displayPaused(0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::paused::SERVE} */
case SERVE_SIG: {
status_ = Q_TRAN(&Table_serving);
break;
}
/*.${AOs::Table::SM::active::paused::HUNGRY} */
case HUNGRY_SIG: {
uint8_t n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* philo ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
me->isHungry[n] = 1U;
BSP_displayPhilStat(n, "hungry ");
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::paused::DONE} */
case DONE_SIG: {
uint8_t n, m;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&Table_active);
break;
}
}
return status_;
}
/*.$enddef${AOs::Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/README.txt
================================================
About this Example
==================
This directory contains the "Dining Philosophers Problem" (DPP) example
for the preemptive QK kernel running on the NXP mbed-LPC1768 board
(ARM Cortex-M3). This directory contains portable code that should
compile with any C compiler for ARM Cortex-M.
The sub-directory "gnu" contains the Makefile for a generic GNU-ARM
toolset (e.g., see http://gnutoolchains.com/arm-eabi/). Thus, this
project provides a way of building mbed applications locally with
free and unrestricted tools.
***
NOTE: To build the code on Windows, you need to download and install
the GNU make utility. The Qtools collection from Quantum Leaps contains
GNU make and other UNIX-style utilites for Windows (native Windows,
without the need to install CygWin).
***
After building the code with the provided Makefile, you can simply
copy the binary image to the mbed folder for execution.
The whole build process and loading the image to the mbed board can
be executed directly from the QM modeling (by means of external tools).
The provided QM model (dpp.qm) comes pre-configured with tools
setup to build (via make) and copy the code to the mbed board.
Support Code for NXP mbed-LPC1768 Board
=======================================
The directory 3rd_party\mbed-lpc1768 contains the CMSIS-compliant
device code for the NXP LPC176xx MCUs (ARM Cortex-M3). Please see the
README.txt file in this folder for more details.
Note About the Board Support Package for NXP mbed-LPC1768
=========================================================
The provided Board Support Package (see bsp.c) is minimal for the
application at hand and is completely **standalone**, meaning that
it does NOT use the extensive mbed driver library. The use of the
mbed-library is possible, but not necessary (but requires C++).
QS Software Tracing Instrumentation
===================================
This example provides the "Spy" build configuration, which outputs the QS
(Quantum Spy) software tracing data through UART0 of the mbed-LPC1768 board,
which is connected to the virtual COM port of the mbed USB connection.
The output is generated at 115200 baud rate.
Here is an example invocation of the QSPY host application to receive
the QS data from mbed-LPC1768 :
qspy -cCOM20
The actual COM port number might be different on your Windows machine.
Please check the Device Manager to find the COM port number.
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/README.url
================================================
[InternetShortcut]
URL=http://www.state-machine.com/qpn/arm-cm_dpp_mbed-lpc1768.html
IconFile=http://www.state-machine.com/qp.ico
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/bsp.h
================================================
/*****************************************************************************
* Product: DPP example
* Last Updated for Version: 5.4.0
* Date of the Last Update: 2015-03-07
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* Web : www.state-machine.com
*
*****************************************************************************/
#ifndef BSP_H
#define BSP_H
#define BSP_TICKS_PER_SEC 100U
void BSP_init(void);
void BSP_displayPaused(uint8_t paused);
void BSP_displayPhilStat(uint8_t n, char_t const *stat);
void BSP_terminate(int16_t result);
void BSP_randomSeed(uint32_t seed); /* random seed */
uint32_t BSP_random(void); /* pseudo-random generator */
#endif /* BSP_H */
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/dpp.h
================================================
/*.$file${.::dpp.h} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: dpp.qm
* File: ${.::dpp.h}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::dpp.h} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#ifndef DPP_H
#define DPP_H
enum DPPSignals {
EAT_SIG = Q_USER_SIG, /* published by Table to let a philosopher eat */
DONE_SIG, /* published by Philosopher when done eating */
PAUSE_SIG, /* published by BSP to pause the application */
SERVE_SIG, /* published by BSP to pause the application */
TERMINATE_SIG, /* published by BSP to terminate the application */
HUNGRY_SIG, /* posted direclty to Table from hungry Philo */
MAX_SIG /* the last signal */
};
/* number of philosophers */
#define N_PHILO ((uint8_t)5)
#define PHILO_0_PRIO 1
/*.$declare${AOs::AO_Philo0} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo0;
/*.$enddecl${AOs::AO_Philo0} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo1} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo1;
/*.$enddecl${AOs::AO_Philo1} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo2} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo2;
/*.$enddecl${AOs::AO_Philo2} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo3} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo3;
/*.$enddecl${AOs::AO_Philo3} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo4} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo4;
/*.$enddecl${AOs::AO_Philo4} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Table AO_Table;
/*.$enddecl${AOs::AO_Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::Philo_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo_ctor} ......................................................*/
void Philo_ctor(void);
/*.$enddecl${AOs::Philo_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::Table_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table_ctor} ......................................................*/
void Table_ctor(void);
/*.$enddecl${AOs::Table_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#endif /* DPP_H */
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/dpp.qm
================================================
Dining Philosopher Problem example with QActiveQActive_armX(&me->super, 0U, THINK_TIME, 0U);QActive_disarmX(&me->super, 0U);Q_ERROR(); /* these events should never arrive in this state */QACTIVE_POST(&AO_Table, HUNGRY_SIG, me->super.prio);Q_ERROR(); /* this event should never arrive in this state */QActive_armX(&me->super, 0U, EAT_TIME, 0U);QActive_disarmX(&me->super, 0U);
QACTIVE_POST(QF_ACTIVE_CAST(&AO_Table), DONE_SIG, me->super.prio);Q_ERROR(); /* these events should never arrive in this state */uint8_t n;
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "thinking");
}BSP_terminate(0);Q_ERROR();uint8_t n;
for (n = 0U; n < N_PHILO; ++n) { /* give permissions to eat... */
if ((me->isHungry[n] != 0U)
&& (me->fork[LEFT(n)] == FREE)
&& (me->fork[n] == FREE))
{
QActive *philo;
me->fork[LEFT(n)] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "eating ");
}
}uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "hungry ");
m = LEFT(n);(me->fork[m] == FREE) && (me->fork[n] == FREE)me->fork[m] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
BSP_displayPhilStat(n, "eating ");elseme->isHungry[n] = 1U;uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;
m = RIGHT(n); /* check the right neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[m] == FREE)) {
me->fork[n] = USED;
me->fork[m] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}
m = LEFT(n); /* check the left neighbor */
n = LEFT(m); /* left fork of the left neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[n] == FREE)) {
me->fork[m] = USED;
me->fork[n] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}Q_ERROR();BSP_displayPaused(1U);BSP_displayPaused(0U);uint8_t n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* philo ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
me->isHungry[n] = 1U;
BSP_displayPhilStat(n, "hungry ");uint8_t n, m;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;QActive_ctor(&AO_Philo0.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo1.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo2.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo3.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo4.super, Q_STATE_CAST(&Philo_initial));
BSP_randomSeed(123U);uint8_t n;
Table *me = &AO_Table;
QActive_ctor(&me->super, Q_STATE_CAST(&Table_initial));
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
}#ifndef DPP_H
#define DPP_H
enum DPPSignals {
EAT_SIG = Q_USER_SIG, /* published by Table to let a philosopher eat */
DONE_SIG, /* published by Philosopher when done eating */
PAUSE_SIG, /* published by BSP to pause the application */
SERVE_SIG, /* published by BSP to pause the application */
TERMINATE_SIG, /* published by BSP to terminate the application */
HUNGRY_SIG, /* posted direclty to Table from hungry Philo */
MAX_SIG /* the last signal */
};
/* number of philosophers */
#define N_PHILO ((uint8_t)5)
#define PHILO_0_PRIO 1
$declare${AOs::AO_Philo0}
$declare${AOs::AO_Philo1}
$declare${AOs::AO_Philo2}
$declare${AOs::AO_Philo3}
$declare${AOs::AO_Philo4}
$declare${AOs::AO_Table}
$declare${AOs::Philo_ctor}
$declare${AOs::Table_ctor}
#endif /* DPP_H */
#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("philo")
/* Active object class -----------------------------------------------------*/
$declare${AOs::Philo}
/* Global objects ----------------------------------------------------------*/
$define${AOs::AO_Philo0}
$define${AOs::AO_Philo1}
$define${AOs::AO_Philo2}
$define${AOs::AO_Philo3}
$define${AOs::AO_Philo4}
/* Local objects -----------------------------------------------------------*/
#define THINK_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + (BSP_TICKS_PER_SEC/2U))
#define EAT_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + BSP_TICKS_PER_SEC)
/* Philo definition --------------------------------------------------------*/
$define${AOs::Philo_ctor}
$define${AOs::Philo}#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("table")
/* Active object class -----------------------------------------------------*/
$declare${AOs::Table}
/* Global objects ----------------------------------------------------------*/
$define${AOs::AO_Table}
#define RIGHT(n_) ((uint8_t)(((n_) + (N_PHILO - 1U)) % N_PHILO))
#define LEFT(n_) ((uint8_t)(((n_) + 1U) % N_PHILO))
#define FREE ((uint8_t)0)
#define USED ((uint8_t)1)
/*..........................................................................*/
$define${AOs::Table_ctor}
$define${AOs::Table}
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/main.c
================================================
/*****************************************************************************
* Product: DPP example
* Last Updated for Version: 5.8.0
* Date of the Last Update: 2016-11-06
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h" /* QP-nano */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
/*..........................................................................*/
static QEvt l_philoQueue[N_PHILO][N_PHILO];
static QEvt l_tableQueue[2];
/* QF_active[] array defines all active object control blocks --------------*/
QActiveCB const Q_ROM QF_active[] = {
{ (QActive *)0, (QEvt *)0, 0U },
{ (QActive *)&AO_Philo0, l_philoQueue[0], Q_DIM(l_philoQueue[0]) },
{ (QActive *)&AO_Philo1, l_philoQueue[1], Q_DIM(l_philoQueue[1]) },
{ (QActive *)&AO_Philo2, l_philoQueue[2], Q_DIM(l_philoQueue[2]) },
{ (QActive *)&AO_Philo3, l_philoQueue[3], Q_DIM(l_philoQueue[3]) },
{ (QActive *)&AO_Philo4, l_philoQueue[4], Q_DIM(l_philoQueue[4]) },
{ (QActive *)&AO_Table, l_tableQueue, Q_DIM(l_tableQueue) }
};
/*..........................................................................*/
int_t main() {
Philo_ctor(); /* instantiate all Philo AOs */
Table_ctor(); /* instantiate the Table AO */
QF_init(Q_DIM(QF_active)); /* initialize the QF-nano framework */
BSP_init(); /* initialize the Board Support Package */
return QF_run(); /* transfer control to QF-nano */
}
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/philo.c
================================================
/*.$file${.::philo.c} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: dpp.qm
* File: ${.::philo.c}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::philo.c} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("philo")
/* Active object class -----------------------------------------------------*/
/*.$declare${AOs::Philo} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo} ...........................................................*/
typedef struct Philo {
/* protected: */
QActive super;
} Philo;
/* protected: */
static QState Philo_initial(Philo * const me);
static QState Philo_thinking(Philo * const me);
static QState Philo_hungry(Philo * const me);
static QState Philo_eating(Philo * const me);
/*.$enddecl${AOs::Philo} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Global objects ----------------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*. Check for the minimum required QP version */
#if (QP_VERSION < 650U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpn version 6.5.0 or higher required
#endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo0} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo0} .......................................................*/
struct Philo AO_Philo0;
/*.$enddef${AOs::AO_Philo0} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo1} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo1} .......................................................*/
struct Philo AO_Philo1;
/*.$enddef${AOs::AO_Philo1} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo2} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo2} .......................................................*/
struct Philo AO_Philo2;
/*.$enddef${AOs::AO_Philo2} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo3} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo3} .......................................................*/
struct Philo AO_Philo3;
/*.$enddef${AOs::AO_Philo3} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo4} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo4} .......................................................*/
struct Philo AO_Philo4;
/*.$enddef${AOs::AO_Philo4} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Local objects -----------------------------------------------------------*/
#define THINK_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + (BSP_TICKS_PER_SEC/2U))
#define EAT_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + BSP_TICKS_PER_SEC)
/* Philo definition --------------------------------------------------------*/
/*.$define${AOs::Philo_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo_ctor} ......................................................*/
void Philo_ctor(void) {
QActive_ctor(&AO_Philo0.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo1.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo2.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo3.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo4.super, Q_STATE_CAST(&Philo_initial));
BSP_randomSeed(123U);
}
/*.$enddef${AOs::Philo_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Philo} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo} ...........................................................*/
/*.${AOs::Philo::SM} .......................................................*/
static QState Philo_initial(Philo * const me) {
/*.${AOs::Philo::SM::initial} */
return Q_TRAN(&Philo_thinking);
}
/*.${AOs::Philo::SM::thinking} .............................................*/
static QState Philo_thinking(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Philo::SM::thinking} */
case Q_ENTRY_SIG: {
QActive_armX(&me->super, 0U, THINK_TIME, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::thinking} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::thinking::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Philo_hungry);
break;
}
/*.${AOs::Philo::SM::thinking::EAT, DONE} */
case EAT_SIG: /* intentionally fall through */
case DONE_SIG: {
Q_ERROR(); /* these events should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Philo::SM::hungry} ...............................................*/
static QState Philo_hungry(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Philo::SM::hungry} */
case Q_ENTRY_SIG: {
QACTIVE_POST(&AO_Table, HUNGRY_SIG, me->super.prio);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::hungry::EAT} */
case EAT_SIG: {
status_ = Q_TRAN(&Philo_eating);
break;
}
/*.${AOs::Philo::SM::hungry::DONE} */
case DONE_SIG: {
Q_ERROR(); /* this event should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Philo::SM::eating} ...............................................*/
static QState Philo_eating(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Philo::SM::eating} */
case Q_ENTRY_SIG: {
QActive_armX(&me->super, 0U, EAT_TIME, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::eating} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
QACTIVE_POST(QF_ACTIVE_CAST(&AO_Table), DONE_SIG, me->super.prio);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::eating::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Philo_thinking);
break;
}
/*.${AOs::Philo::SM::eating::EAT, DONE} */
case EAT_SIG: /* intentionally fall through */
case DONE_SIG: {
Q_ERROR(); /* these events should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.$enddef${AOs::Philo} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/qk/armclang/dpp-qk.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj; *.o*.lib*.txt; *.h; *.inc*.plm*.cpp000dpp-dbg0x4ARM-ADS120000001110016553500079668.\dbg\11101101000011111110010180111111111011101011001000BIN\UL2CM3.DLL0DLGUARMÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÈ`Â
—.Çv´ð40ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10UL2CM3UL2CM3(-O207 -S0 -C0 -FO7 -FN1 -FCFE0 -FD10000000 -FF0LPC_IAP_512 -FL080000 -FS00 -FP0($$Device:LPC1768$Flash\LPC_IAP_512.FLM)0DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E10259B -O4622 -S4 -FO6101me120x200002000200x40000001000010000000000000000000dpp-rel0x4ARM-ADS120000001110016553500079668.\rel\11101101000011111110010080111111111011101011001000BIN\UL2CM3.DLL0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E10259B -O4622 -S4 -FO610UL2CM3-O207 -S0 -C0 -FO7 -FN1 -FCFE0 -FD10000000 -FF0LPC_IAP_512 -FL080000 -FS00 -FP0($$Device:LPC1768$Flash\LPC_IAP_512.FLM)120x200002000200x40000001000010000000000000000000Source Code1000111000..\bsp.cbsp.c00125000..\..\bsp.hbsp.h00135000..\..\dpp.hdpp.h00141000..\..\main.cmain.c00151000..\..\philo.cphilo.c00161000..\..\table.ctable.c00mbed-lpc17681000271000..\..\..\..\..\3rd_party\mbed-lpc1768\system_LPC17xx.csystem_LPC17xx.c00282000..\..\..\..\.arm\startup-lpc1768\armclang\startup_LPC17xx.sstartup_LPC17xx.s00QP1000391000..\..\..\..\..\src\qfn\qepn.cqepn.c003101000..\..\..\..\..\src\qfn\qfn.cqfn.c003111000..\..\..\..\..\src\qkn\qkn.cqkn.c00QP_port10004125000..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqfn_port.h004131000..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.cqkn_port.c00
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/qk/armclang/dpp-qk.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwaredpp-dbg0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1LPC1768NXPKeil.LPC1700_DFP.2.2.0http://www.keil.com/pack/IROM(0x00000000,0x80000) IRAM(0x10000000,0x8000) IRAM2(0x2007C000,0x8000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD10000000 -FCFE0 -FN1 -FF0LPC_IAP_512 -FS00 -FL080000 -FP0($$Device:LPC1768$Flash\LPC_IAP_512.FLM))0$$Device:LPC1768$Device\Include\LPC17xx.h$$Device:LPC1768$SVD\LPC176x5x.svd0000001.\dbg\dpp-qk10011.\dbg\10000000000000010fromelf --bin --output .\dbg\dpp-qk.bin .\dbg\dpp-qk.axf00000000001000031SARMCM3.DLL -MPUDCM.DLL-pCM3SARMCM3.DLL -MPUTCM.DLL-pCM31000161001140961BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M3"0001100001080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x100000000x800010x00x8000000x00x010x00x010x00x010x00x010x00x8000010x00x000x00x000x00x000x00x000x100000000x800000x2007c0000x800007001000003010003311000rvmdk __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\mbed-lpc17681000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerSource Codebsp.c1..\bsp.cbsp.h5..\..\bsp.hdpp.h5..\..\dpp.hmain.c1..\..\main.cphilo.c1..\..\philo.ctable.c1..\..\table.cmbed-lpc1768system_LPC17xx.c1..\..\..\..\..\3rd_party\mbed-lpc1768\system_LPC17xx.cstartup_LPC17xx.s2..\..\..\..\..\3rd_party\mbed-lpc1768\arm\startup_LPC17xx.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.cdpp-rel0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1LPC1768NXPKeil.LPC1700_DFP.2.2.0http://www.keil.com/pack/IROM(0x00000000,0x80000) IRAM(0x10000000,0x8000) IRAM2(0x2007C000,0x8000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD10000000 -FCFE0 -FN1 -FF0LPC_IAP_512 -FS00 -FL080000 -FP0($$Device:LPC1768$Flash\LPC_IAP_512.FLM))0$$Device:LPC1768$Device\Include\LPC17xx.h$$Device:LPC1768$SVD\LPC176x5x.svd0000001.\rel\dpp-qk10000.\rel\10000000000000010fromelf --bin --output .\rel\dpp-qk.bin .\rel\dpp-qk.axf00000000001000031SARMCM3.DLL -MPUDCM.DLL-pCM3SARMCM3.DLL -MPUTCM.DLL-pCM31000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M3"0001100001080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x100000000x800010x00x8000000x00x010x00x010x00x010x00x010x00x8000010x00x000x00x000x00x000x00x000x100000000x800000x2007c0000x800007001000003010003311000NDEBUG __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\mbed-lpc17681000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000dpp-qk.sct--entry Reset_HandlerSource Codebsp.c1..\bsp.cbsp.h5..\..\bsp.hdpp.h5..\..\dpp.hmain.c1..\..\main.cphilo.c1..\..\philo.ctable.c1..\..\table.cmbed-lpc1768system_LPC17xx.c1..\..\..\..\..\3rd_party\mbed-lpc1768\system_LPC17xx.cstartup_LPC17xx.s2..\..\..\..\..\3rd_party\mbed-lpc1768\arm\startup_LPC17xx.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.c
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/qk/bsp.c
================================================
/*****************************************************************************
* Product: DPP on EK-TM4C123GXL board, preemptive QK kernel
* Last Updated for Version: 5.5.1
* Date of the Last Update: 2015-10-05
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "dpp.h"
#include "bsp.h"
#include "LPC17xx.h" /* CMSIS-compliant header file for the MCU used */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
enum KernelUnawareISRs { /* see NOTE00 */
/* ... */
MAX_KERNEL_UNAWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-unaware" interrupts can't overlap "kernel-aware" interrupts */
Q_ASSERT_COMPILE(MAX_KERNEL_UNAWARE_CMSIS_PRI <= QF_AWARE_ISR_CMSIS_PRI);
enum KernelAwareISRs {
EINT0_PRIO = QF_AWARE_ISR_CMSIS_PRI, /* see NOTE00 */
SYSTICK_PRIO,
/* ... */
MAX_KERNEL_AWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-aware" interrupts should not overlap the PendSV priority */
Q_ASSERT_COMPILE(MAX_KERNEL_AWARE_CMSIS_PRI <= (0xFF >>(8-__NVIC_PRIO_BITS)));
/* ISRs defined in this BSP ------------------------------------------------*/
void SysTick_Handler(void);
void EINT0_IRQHandler(void);
/* Local-scope objects -----------------------------------------------------*/
/* LEDs available on the board */
#define LED_1 (1U << 18) /* P1.18 */
#define LED_2 (1U << 20) /* P1.20 */
#define LED_3 (1U << 21) /* P1.21 */
#define LED_4 (1U << 23) /* P1.23 */
/* Push-Button wired externally to DIP8 (P0.6) */
#define BTN_EXT (1U << 6) /* P0.6 */
/* random seed */
static uint32_t l_rnd;
/* ISRs used in this project ===============================================*/
void SysTick_Handler(void) {
/* state of the button debouncing, see below */
static struct ButtonsDebouncing {
uint32_t depressed;
uint32_t previous;
} buttons = { ~0U, ~0U };
uint32_t current;
uint32_t tmp;
QK_ISR_ENTRY(); /* inform QK about entering an ISR */
QF_tickXISR(0U); /* process time events for rate 0 */
/* Perform the debouncing of buttons. The algorithm for debouncing
* adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
* and Michael Barr, page 71.
*/
current = ~LPC_GPIO0->FIOPIN; /* read P0 with the state of the Buttons */
tmp = buttons.depressed; /* save the debounced depressed buttons */
buttons.depressed |= (buttons.previous & current); /* set depressed */
buttons.depressed &= (buttons.previous | current); /* clear released */
buttons.previous = current; /* update the history */
tmp ^= buttons.depressed; /* changed debounced depressed */
if ((tmp & BTN_EXT) != 0U) { /* debounced BTN_EXT state changed? */
if ((buttons.depressed & BTN_EXT) != 0U) { /* is BTN_EXT depressed? */
QACTIVE_POST_ISR(&AO_Table, PAUSE_SIG, 0U);
}
else { /* the button is released */
QACTIVE_POST_ISR(&AO_Table, SERVE_SIG, 0U);
}
}
QK_ISR_EXIT(); /* inform QK about exiting an ISR */
}
/*..........................................................................*/
void EINT0_IRQHandler(void) {
QK_ISR_ENTRY(); /* inform QK about entering an ISR */
QACTIVE_POST_ISR(&AO_Table, MAX_SIG, 0U); /* for testing */
QK_ISR_EXIT(); /* inform QK about exiting an ISR */
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* NOTE: SystemInit() already called from the startup code
* but SystemCoreClock needs to be updated
*/
SystemCoreClockUpdate();
/* turn the GPIO clock on */
LPC_SC->PCONP |= (1U << 15);
/* setup the GPIO pin functions for the LEDs... */
LPC_PINCON->PINSEL3 &= ~(3U << 4); /* LED_1: function P1.18 to GPIO */
LPC_PINCON->PINSEL3 &= ~(3U << 8); /* LED_2: function P1.20 to GPIO */
LPC_PINCON->PINSEL3 &= ~(3U << 10); /* LED_3: function P1.21 to GPIO */
LPC_PINCON->PINSEL3 &= ~(3U << 14); /* LED_4: function P1.23 to GPIO */
/* Set GPIO-P1 LED pins to output */
LPC_GPIO1->FIODIR |= (LED_1 | LED_2 | LED_3 | LED_4);
/* setup the GPIO pin function for the Button... */
LPC_PINCON->PINSEL0 &= ~(3U << 12); /* function P0.6 to GPIO, pull-up */
/* Set GPIO-P0 Button pin as input */
LPC_GPIO0->FIODIR &= ~BTN_EXT;
BSP_randomSeed(1234U);
}
/*..........................................................................*/
void BSP_displayPhilStat(uint8_t n, char const *stat) {
if (stat[0] == 'h') {
LPC_GPIO1->FIOSET = LED_1; /* turn LED on */
}
else {
LPC_GPIO1->FIOCLR = LED_1; /* turn LED off */
}
if (stat[0] == 'e') {
LPC_GPIO1->FIOSET = LED_2; /* turn LED on */
}
else {
LPC_GPIO1->FIOCLR = LED_2; /* turn LED off */
}
}
/*..........................................................................*/
void BSP_displayPaused(uint8_t paused) {
if (paused != (uint8_t)0) {
LPC_GPIO1->FIOSET = LED_3; /* turn LED on */
}
else {
LPC_GPIO1->FIOCLR = LED_3; /* turn LED off */
}
}
/*..........................................................................*/
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
l_rnd = l_rnd * (3U*7U*11U*13U*23U);
return l_rnd >> 8;
}
/*..........................................................................*/
void BSP_randomSeed(uint32_t seed) {
l_rnd = seed;
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
(void)result;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set up the SysTick timer to fire at BSP_TICKS_PER_SEC rate */
SysTick_Config(SystemCoreClock / BSP_TICKS_PER_SEC);
/* assing all priority bits for preemption-prio. and none to sub-prio. */
NVIC_SetPriorityGrouping(0U);
/* set priorities of ALL ISRs used in the system, see NOTE00
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
NVIC_SetPriority(SysTick_IRQn, SYSTICK_PRIO);
NVIC_SetPriority(EINT0_IRQn, EINT0_PRIO);
/* ... */
/* enable IRQs in the NVIC... */
NVIC_EnableIRQ(EINT0_IRQn);
}
/*..........................................................................*/
void QK_onIdle(void) {
/* toggle the User LED on and then off, see NOTE01 */
QF_INT_DISABLE();
LPC_GPIO1->FIOSET = LED_4; /* turn LED on */
__NOP(); /* a couple of NOPs to actually see the LED glow */
__NOP();
__NOP();
__NOP();
LPC_GPIO1->FIOCLR = LED_4; /* turn LED off */
QF_INT_ENABLE();
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular Cortex-M3 MCU.
*/
__WFI(); /* Wait-For-Interrupt */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int loc) {
/*
* NOTE: add here your application-specific error handling
*/
(void)module;
(void)loc;
NVIC_SystemReset();
}
/*****************************************************************************
* NOTE00:
* The QF_AWARE_ISR_CMSIS_PRI constant from the QF port specifies the highest
* ISR priority that is disabled by the QF framework. The value is suitable
* for the NVIC_SetPriority() CMSIS function.
*
* Only ISRs prioritized at or below the QF_AWARE_ISR_CMSIS_PRI level (i.e.,
* with the numerical values of priorities equal or higher than
* QF_AWARE_ISR_CMSIS_PRI) are allowed to call any QF services. These ISRs
* are "QF-aware".
*
* Conversely, any ISRs prioritized above the QF_AWARE_ISR_CMSIS_PRI priority
* level (i.e., with the numerical values of priorities less than
* QF_AWARE_ISR_CMSIS_PRI) are never disabled and are not aware of the kernel.
* Such "QF-unaware" ISRs cannot call any QF services. The only mechanism
* by which a "QF-unaware" ISR can communicate with the QF framework is by
* triggering a "QF-aware" ISR, which can post/publish events.
*
* NOTE01:
* One of the LEDs is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/qk/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano on mbed-LPC1768, QK-nano kernel, GNU-ARM
# Last Updated for Version: 6.5.0
# Date of the Last Update: 2019-04-15
#
# Q u a n t u m L e a P s
# ------------------------
# Modern Embedded Software
#
# Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# https://www.state-machine.com
# mailto:info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := dpp-qk
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/arm-cm/qk/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qkn \
$(QP_PORT_DIR) \
$(QPN)/3rd_party/mbed-lpc1768 \
$(QPN)/3rd_party/mbed-lpc1768/gnu
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR) \
-I$(QPN)/3rd_party/CMSIS/Include \
-I$(QPN)/3rd_party/mbed-lpc1768
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
bsp.c \
main.c \
philo.c \
table.c \
system_LPC17xx.c \
startup_LPC17xx.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qepn.c \
qfn.c \
qkn.c \
qkn_port.c
QP_ASMS :=
LIB_DIRS :=
LIBS :=
# defines
DEFINES :=
# ARM CPU, ARCH, FPU, and Float-ABI types...
# ARM_CPU: [cortex-m0 | cortex-m0plus | cortex-m1 | cortex-m3 | cortex-m4]
# ARM_ARCH: [6 | 7] (NOTE: must match ARM_CPU!)
# ARM_FPU: [ | vfp]
# FLOAT_ABI: [ | soft | softfp | hard]
#
ARM_CPU := -mcpu=cortex-m3
ARM_ARCH := 7 # NOTE: must match the ARM_CPU!
ARM_FPU :=
FLOAT_ABI :=
#-----------------------------------------------------------------------------
# GNU-ARM toolset (NOTE: You need to adjust to your machine)
# see https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
#
ifeq ($(GNU_ARM),)
GNU_ARM := $(QTOOLS)/gnu_arm-none-eabi
endif
# make sure that the GNU-ARM toolset exists...
ifeq ("$(wildcard $(GNU_ARM))","")
$(error GNU_ARM toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_ARM)/bin/arm-none-eabi-gcc
CPP := $(GNU_ARM)/bin/arm-none-eabi-g++
AS := $(GNU_ARM)/bin/arm-none-eabi-as
LINK := $(GNU_ARM)/bin/arm-none-eabi-g++
BIN := $(GNU_ARM)/bin/arm-none-eabi-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M
#
# combine all the soruces...
C_SRCS += $(QP_SRCS)
ASM_SRCS += $(QP_ASMS)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS = $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration ..........................................
BIN_DIR := dbg
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O $(INCLUDES) $(DEFINES)
CPPFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES)
endif # ......................................................................
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
-specs=nosys.specs -specs=nano.specs \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_BIN := $(BIN_DIR)/$(OUTPUT).bin
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_BIN)
#all: $(TARGET_ELF)
$(TARGET_BIN): $(TARGET_ELF)
$(BIN) -O binary $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(CC) $(CFLAGS) $(QPN)/include/qstamp.c -o $(BIN_DIR)/qstamp.o
$(LINK) $(LINKFLAGS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.bin \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/qk/gnu/dpp-qk.ld
================================================
/*****************************************************************************
* Product: Linker script for for LPC1768, GNU-ARM linker
* Last Updated for Version: 5.9.8
* Date of the Last Update: 2017-09-13
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) 2002-2013 Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* https://state-machine.com
* mailto:info@state-machine.com
*****************************************************************************/
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(Reset_Handler) /* entry Point */
MEMORY { /* memory map of mbed-LPC1768 */
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 512K
RAM (rwx) : ORIGIN = 0x10000000, LENGTH = 0x7FDF
USB_RAM(rwx) : ORIGIN = 0x2007C000, LENGTH = 16K
ETH_RAM(rwx) : ORIGIN = 0x20080000, LENGTH = 16K
}
/* The size of the stack used by the application. NOTE: you need to adjust */
STACK_SIZE = 1024;
/* The size of the heap used by the application. NOTE: you need to adjust */
HEAP_SIZE = 0;
SECTIONS {
.isr_vector : { /* the vector table goes FIRST into ROM */
KEEP(*(.isr_vector)) /* vector table */
. = ALIGN(4);
} >ROM
.text : { /* code and constants */
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} >ROM
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >ROM
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >ROM
.fini_array : {
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array*))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >ROM
_etext = .; /* global symbols at end of code */
.stack : {
__stack_start__ = .;
. = . + STACK_SIZE;
. = ALIGN(4);
__stack_end__ = .;
} >RAM
.data : AT (_etext) {
__data_load = LOADADDR (.data);
__data_start = .;
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
__data_end__ = .;
_edata = __data_end__;
} >RAM
.bss : {
__bss_start__ = .;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = .;
} >RAM
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >RAM
__exidx_end = .;
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );
PROVIDE ( __end__ = _ebss );
.heap : {
__heap_start__ = .;
. = . + HEAP_SIZE;
. = ALIGN(4);
__heap_end__ = .;
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ : {
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
}
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/qk/iar/dpp-qk.ewd
================================================
2DebugARM1C-SPY22611ARMSIM_ID2111ANGEL_ID2011CMSISDAP_ID2211GDBSERVER_ID2011IARROM_ID2111IJET_ID2611JLINK_ID21511LMIFTDI_ID2211MACRAIGOR_ID2311PEMICRO_ID2111RDI_ID2211STLINK_ID2211THIRDPARTY_ID2011XDS100_ID2211$TOOLKIT_DIR$\plugins\middleware\HCCWare\HCCWare.ewplugin0$TOOLKIT_DIR$\plugins\rtos\AVIX\AVIX.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\MQX\MQXRtosPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\Quadros\Quadros_EWB7_Plugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin1$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseARM0C-SPY22610ARMSIM_ID2110ANGEL_ID2010CMSISDAP_ID2210GDBSERVER_ID2010IARROM_ID2110IJET_ID2610JLINK_ID21510LMIFTDI_ID2210MACRAIGOR_ID2310PEMICRO_ID2110RDI_ID2210STLINK_ID2210THIRDPARTY_ID2010XDS100_ID2210$TOOLKIT_DIR$\plugins\middleware\HCCWare\HCCWare.ewplugin0$TOOLKIT_DIR$\plugins\rtos\AVIX\AVIX.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\MQX\MQXRtosPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\Quadros\Quadros_EWB7_Plugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin1$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/qk/iar/dpp-qk.ewp
================================================
2DebugARM1General32211ICCARM23111AARM2911OBJCOPY0111CUSTOM30BICOMP0BUILDACTION1ILINK01611IARCHIVE0011BILINK0Coder0ReleaseARM0General32210ICCARM23110AARM2910OBJCOPY0110CUSTOM30BICOMP0BUILDACTION1ILINK01610IARCHIVE0010BILINK0Coder0Application$PROJ_DIR$\..\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\dpp.h$PROJ_DIR$\..\..\main.c$PROJ_DIR$\..\..\philo.c$PROJ_DIR$\..\..\table.cmbed-lpc1768$PROJ_DIR$\..\..\..\..\..\3rd_party\mbed-lpc1768\LPC17xx.h$PROJ_DIR$\..\..\..\..\..\3rd_party\mbed-lpc1768\iar\startup_LPC17xx.s$PROJ_DIR$\..\..\..\..\..\3rd_party\mbed-lpc1768\system_LPC17xx.c$PROJ_DIR$\..\..\..\..\..\3rd_party\mbed-lpc1768\system_LPC17xx.hQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qkn\qkn.cQP-port$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qk\iar\qfn_port.h$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qk\iar\qkn_port.c
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/qk/iar/dpp-qk.eww
================================================
$WS_DIR$\dpp-qk.ewp
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/qk/iar/dpp-qk.icf
================================================
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0007FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x10000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x10007FDF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 1024;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/
define symbol __CRP_start__ = 0x000002FC;
define symbol __CRP_end__ = 0x000002FF;
define symbol __RAM1_start__ = 0x2007C000;
define symbol __RAM1_end__ = 0x20083FFF;
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__] - mem:[from __CRP_start__ to __CRP_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define region CRP_region = mem:[from __CRP_start__ to __CRP_end__];
define region RAM1_region = mem:[from __RAM1_start__ to __RAM1_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place in RAM_region { readwrite,
block CSTACK, block HEAP };
place in CRP_region { section .crp };
place in RAM1_region { section .sram };
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/qpn_conf.h
================================================
/*****************************************************************************
* Product: QP-nano configuration for the Blinky example
* Last Updated for Version: 5.6.2
* Date of the Last Update: 2016-04-05
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef QPN_CONF_H
#define QPN_CONF_H
#define Q_PARAM_SIZE 4U
#define QF_MAX_TICK_RATE 1U
#define QF_TIMEEVT_CTR_SIZE 2U
#define QF_TIMEEVT_PERIODIC
#endif /* QPN_CONF_H */
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/qv/armclang/dpp-qv.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj; *.o*.lib*.txt; *.h; *.inc*.plm*.cpp000dpp-dbg0x4ARM-ADS120000001110016553500079668.\dbg\11101101000011111110010180111111111011101011001000BIN\UL2CM3.DLL0DLGUARMÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÈ`Â
—.Çv´ð40ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10UL2CM3UL2CM3(-O207 -S0 -C0 -FO7 -FN1 -FCFE0 -FD10000000 -FF0LPC_IAP_512 -FL080000 -FS00 -FP0($$Device:LPC1768$Flash\LPC_IAP_512.FLM)0DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E10259B -O4622 -S4 -FO6101me120x200002000200x40000001000010000000000000000000dpp-rel0x4ARM-ADS120000001110016553500079668.\rel\11101101000011111110010080111111111011101011001000BIN\UL2CM3.DLL0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E10259B -O4622 -S4 -FO610UL2CM3-O207 -S0 -C0 -FO7 -FN1 -FCFE0 -FD10000000 -FF0LPC_IAP_512 -FL080000 -FS00 -FP0($$Device:LPC1768$Flash\LPC_IAP_512.FLM)120x200002000200x40000001000010000000000000000000Source Code1000111000..\bsp.cbsp.c00125000..\..\bsp.hbsp.h00135000..\..\dpp.hdpp.h00141000..\..\main.cmain.c00151000..\..\philo.cphilo.c00161000..\..\table.ctable.c00mbed-lpc17681000271000..\..\..\..\..\3rd_party\mbed-lpc1768\system_LPC17xx.csystem_LPC17xx.c00282000..\..\..\..\.arm\startup-lpc1768\armclang\startup_LPC17xx.sstartup_LPC17xx.s00QP1000391000..\..\..\..\..\src\qfn\qepn.cqepn.c003101000..\..\..\..\..\src\qfn\qfn.cqfn.c003111000..\..\..\..\..\src\qvn\qvn.cqvn.c00QP-port10004125000..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqfn_port.h004131000..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.cqvn_port.c00
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/qv/armclang/dpp-qv.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwaredpp-dbg0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1LPC1768NXPKeil.LPC1700_DFP.2.2.0http://www.keil.com/pack/IROM(0x00000000,0x80000) IRAM(0x10000000,0x8000) IRAM2(0x2007C000,0x8000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD10000000 -FCFE0 -FN1 -FF0LPC_IAP_512 -FS00 -FL080000 -FP0($$Device:LPC1768$Flash\LPC_IAP_512.FLM))0$$Device:LPC1768$Device\Include\LPC17xx.h$$Device:LPC1768$SVD\LPC176x5x.svd0000001.\dbg\dpp-qv10011.\dbg\10000000000000010fromelf --bin --output .\dbg\dpp-qv.bin .\dbg\dpp-qv.axf00000000001000031SARMCM3.DLL -MPUDCM.DLL-pCM3SARMCM3.DLL -MPUTCM.DLL-pCM31000161001140961BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M3"0001100001080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x100000000x800010x00x8000000x00x010x00x010x00x010x00x010x00x8000010x00x000x00x000x00x000x00x000x100000000x800000x2007c0000x800007001000003010003311000rvmdk __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\mbed-lpc17681000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerSource Codebsp.c1..\bsp.cbsp.h5..\..\bsp.hdpp.h5..\..\dpp.hmain.c1..\..\main.cphilo.c1..\..\philo.ctable.c1..\..\table.cmbed-lpc1768system_LPC17xx.c1..\..\..\..\..\3rd_party\mbed-lpc1768\system_LPC17xx.cstartup_LPC17xx.s2..\..\..\..\..\3rd_party\mbed-lpc1768\arm\startup_LPC17xx.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cQP-portqfn_port.h5..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.cdpp-rel0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1LPC1768NXPKeil.LPC1700_DFP.2.2.0http://www.keil.com/pack/IROM(0x00000000,0x80000) IRAM(0x10000000,0x8000) IRAM2(0x2007C000,0x8000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD10000000 -FCFE0 -FN1 -FF0LPC_IAP_512 -FS00 -FL080000 -FP0($$Device:LPC1768$Flash\LPC_IAP_512.FLM))0$$Device:LPC1768$Device\Include\LPC17xx.h$$Device:LPC1768$SVD\LPC176x5x.svd0000001.\rel\dpp-qv10000.\rel\10000000000000010fromelf --bin --output .\rel\dpp-qv.bin .\rel\dpp-qv.axf00000000001000031SARMCM3.DLL -MPUDCM.DLL-pCM3SARMCM3.DLL -MPUTCM.DLL-pCM31000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M3"0001100001080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x100000000x800010x00x8000000x00x010x00x010x00x010x00x010x00x8000010x00x000x00x000x00x000x00x000x100000000x800000x2007c0000x800007001000003010003311000NDEBUG __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\mbed-lpc17681000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000dpp-qv.sct--entry Reset_HandlerSource Codebsp.c1..\bsp.cbsp.h5..\..\bsp.hdpp.h5..\..\dpp.hmain.c1..\..\main.cphilo.c1..\..\philo.ctable.c1..\..\table.cmbed-lpc1768system_LPC17xx.c1..\..\..\..\..\3rd_party\mbed-lpc1768\system_LPC17xx.cstartup_LPC17xx.s2..\..\..\..\..\3rd_party\mbed-lpc1768\arm\startup_LPC17xx.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cQP-portqfn_port.h5..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.c
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/qv/bsp.c
================================================
/*****************************************************************************
* Product: DPP on EK-TM4C123GXL board, coopearative QV kernel
* Last Updated for Version: 5.5.1
* Date of the Last Update: 2015-10-05
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "dpp.h"
#include "bsp.h"
#include "LPC17xx.h" /* CMSIS-compliant header file for the MCU used */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
enum KernelUnawareISRs { /* see NOTE00 */
/* ... */
MAX_KERNEL_UNAWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-unaware" interrupts can't overlap "kernel-aware" interrupts */
Q_ASSERT_COMPILE(MAX_KERNEL_UNAWARE_CMSIS_PRI <= QF_AWARE_ISR_CMSIS_PRI);
enum KernelAwareISRs {
EINT0_PRIO = QF_AWARE_ISR_CMSIS_PRI, /* see NOTE00 */
SYSTICK_PRIO,
/* ... */
MAX_KERNEL_AWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-aware" interrupts should not overlap the PendSV priority */
Q_ASSERT_COMPILE(MAX_KERNEL_AWARE_CMSIS_PRI <= (0xFF >>(8-__NVIC_PRIO_BITS)));
/* ISRs defined in this BSP ------------------------------------------------*/
void SysTick_Handler(void);
void EINT0_IRQHandler(void);
/* Local-scope objects -----------------------------------------------------*/
/* LEDs available on the board */
#define LED_1 (1U << 18) /* P1.18 */
#define LED_2 (1U << 20) /* P1.20 */
#define LED_3 (1U << 21) /* P1.21 */
#define LED_4 (1U << 23) /* P1.23 */
/* Push-Button wired externally to DIP8 (P0.6) */
#define BTN_EXT (1U << 6) /* P0.6 */
/* random seed */
static uint32_t l_rnd;
/* ISRs used in this project ===============================================*/
void SysTick_Handler(void) {
/* state of the button debouncing, see below */
static struct ButtonsDebouncing {
uint32_t depressed;
uint32_t previous;
} buttons = { ~0U, ~0U };
uint32_t current;
uint32_t tmp;
QF_tickXISR(0U); /* process time events for rate 0 */
/* Perform the debouncing of buttons. The algorithm for debouncing
* adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
* and Michael Barr, page 71.
*/
current = ~LPC_GPIO0->FIOPIN; /* read P0 with the state of the Buttons */
tmp = buttons.depressed; /* save the debounced depressed buttons */
buttons.depressed |= (buttons.previous & current); /* set depressed */
buttons.depressed &= (buttons.previous | current); /* clear released */
buttons.previous = current; /* update the history */
tmp ^= buttons.depressed; /* changed debounced depressed */
if ((tmp & BTN_EXT) != 0U) { /* debounced BTN_EXT state changed? */
if ((buttons.depressed & BTN_EXT) != 0U) { /* is BTN_EXT depressed? */
QACTIVE_POST_ISR(&AO_Table, PAUSE_SIG, 0U);
}
else { /* the button is released */
QACTIVE_POST_ISR(&AO_Table, SERVE_SIG, 0U);
}
}
}
/*..........................................................................*/
void EINT0_IRQHandler(void) {
QACTIVE_POST_ISR(&AO_Table, MAX_SIG, 0U); /* for testing */
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* NOTE: SystemInit() already called from the startup code
* but SystemCoreClock needs to be updated
*/
SystemCoreClockUpdate();
/* turn the GPIO clock on */
LPC_SC->PCONP |= (1U << 15);
/* setup the GPIO pin functions for the LEDs... */
LPC_PINCON->PINSEL3 &= ~(3U << 4); /* LED_1: function P1.18 to GPIO */
LPC_PINCON->PINSEL3 &= ~(3U << 8); /* LED_2: function P1.20 to GPIO */
LPC_PINCON->PINSEL3 &= ~(3U << 10); /* LED_3: function P1.21 to GPIO */
LPC_PINCON->PINSEL3 &= ~(3U << 14); /* LED_4: function P1.23 to GPIO */
/* Set GPIO-P1 LED pins to output */
LPC_GPIO1->FIODIR |= (LED_1 | LED_2 | LED_3 | LED_4);
/* setup the GPIO pin function for the Button... */
LPC_PINCON->PINSEL0 &= ~(3U << 12); /* function P0.6 to GPIO, pull-up */
/* Set GPIO-P0 Button pin as input */
LPC_GPIO0->FIODIR &= ~BTN_EXT;
BSP_randomSeed(1234U);
}
/*..........................................................................*/
void BSP_displayPhilStat(uint8_t n, char const *stat) {
if (stat[0] == 'h') {
LPC_GPIO1->FIOSET = LED_1; /* turn LED on */
}
else {
LPC_GPIO1->FIOCLR = LED_1; /* turn LED off */
}
if (stat[0] == 'e') {
LPC_GPIO1->FIOSET = LED_2; /* turn LED on */
}
else {
LPC_GPIO1->FIOCLR = LED_2; /* turn LED off */
}
}
/*..........................................................................*/
void BSP_displayPaused(uint8_t paused) {
if (paused != (uint8_t)0) {
LPC_GPIO1->FIOSET = LED_3; /* turn LED on */
}
else {
LPC_GPIO1->FIOCLR = LED_3; /* turn LED off */
}
}
/*..........................................................................*/
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
l_rnd = l_rnd * (3U*7U*11U*13U*23U);
return l_rnd >> 8;
}
/*..........................................................................*/
void BSP_randomSeed(uint32_t seed) {
l_rnd = seed;
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
(void)result;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set up the SysTick timer to fire at BSP_TICKS_PER_SEC rate */
SysTick_Config(SystemCoreClock / BSP_TICKS_PER_SEC);
/* assing all priority bits for preemption-prio. and none to sub-prio. */
NVIC_SetPriorityGrouping(0U);
/* set priorities of ALL ISRs used in the system, see NOTE00
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
NVIC_SetPriority(SysTick_IRQn, SYSTICK_PRIO);
NVIC_SetPriority(EINT0_IRQn, EINT0_PRIO);
/* ... */
/* enable IRQs in the NVIC... */
NVIC_EnableIRQ(EINT0_IRQn);
}
/*..........................................................................*/
void QV_onIdle(void) { /* called with interrupts disabled, see NOTE01 */
/* toggle the User LED on and then off, see NOTE01 */
LPC_GPIO1->FIOSET = LED_4; /* turn LED on */
__NOP(); /* a couple of NOPs to actually see the LED glow */
__NOP();
__NOP();
__NOP();
LPC_GPIO1->FIOCLR = LED_4; /* turn LED off */
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular Cortex-M MCU.
*/
QV_CPU_SLEEP(); /* atomically go to sleep and enable interrupts */
#else
QF_INT_ENABLE(); /* just enable interrupts */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int loc) {
/*
* NOTE: add here your application-specific error handling
*/
(void)module;
(void)loc;
NVIC_SystemReset();
}
/*****************************************************************************
* NOTE00:
* The QF_AWARE_ISR_CMSIS_PRI constant from the QF port specifies the highest
* ISR priority that is disabled by the QF framework. The value is suitable
* for the NVIC_SetPriority() CMSIS function.
*
* Only ISRs prioritized at or below the QF_AWARE_ISR_CMSIS_PRI level (i.e.,
* with the numerical values of priorities equal or higher than
* QF_AWARE_ISR_CMSIS_PRI) are allowed to call the QK_ISR_ENTRY/QK_ISR_ENTRY
* macros or any other QF/QK services. These ISRs are "QF-aware".
*
* Conversely, any ISRs prioritized above the QF_AWARE_ISR_CMSIS_PRI priority
* level (i.e., with the numerical values of priorities less than
* QF_AWARE_ISR_CMSIS_PRI) are never disabled and are not aware of the kernel.
* Such "QF-unaware" ISRs cannot call any QF/QK services. In particular they
* can NOT call the macros QK_ISR_ENTRY/QK_ISR_ENTRY. The only mechanism
* by which a "QF-unaware" ISR can communicate with the QF framework is by
* triggering a "QF-aware" ISR, which can post/publish events.
*
* NOTE01:
* The QV_onIdle() callback is called with interrupts disabled, because the
* determination of the idle condition might change by any interrupt posting
* an event. QV_onIdle() must internally enable interrupts, ideally
* atomically with putting the CPU to the power-saving mode.
*
* NOTE02:
* The User LED is used to visualize the idle loop activity. The brightness
* The User LED is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/qv/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano on mbed-LPC1768, QV-nano kernel, GNU-ARM
# Last Updated for Version: 6.5.0
# Date of the Last Update: 2019-04-15
#
# Q u a n t u m L e a P s
# ------------------------
# Modern Embedded Software
#
# Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# https://www.state-machine.com
# mailto:info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := dpp-qv
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/arm-cm/qv/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qvn \
$(QP_PORT_DIR) \
$(QPN)/3rd_party/mbed-lpc1768 \
$(QPN)/3rd_party/mbed-lpc1768/gnu
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR) \
-I$(QPN)/3rd_party/CMSIS/Include \
-I$(QPN)/3rd_party/mbed-lpc1768
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
bsp.c \
main.c \
philo.c \
table.c \
system_LPC17xx.c \
startup_LPC17xx.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qepn.c \
qfn.c \
qvn.c \
qvn_port.c
QP_ASMS :=
LIB_DIRS :=
LIBS :=
# defines
DEFINES :=
# ARM CPU, ARCH, FPU, and Float-ABI types...
# ARM_CPU: [cortex-m0 | cortex-m0plus | cortex-m1 | cortex-m3 | cortex-m4]
# ARM_ARCH: [6 | 7] (NOTE: must match ARM_CPU!)
# ARM_FPU: [ | vfp]
# FLOAT_ABI: [ | soft | softfp | hard]
#
ARM_CPU := -mcpu=cortex-m3
ARM_ARCH := 7 # NOTE: must match the ARM_CPU!
ARM_FPU :=
FLOAT_ABI :=
#-----------------------------------------------------------------------------
# GNU-ARM toolset (NOTE: You need to adjust to your machine)
# see https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
#
ifeq ($(GNU_ARM),)
GNU_ARM := $(QTOOLS)/gnu_arm-none-eabi
endif
# make sure that the GNU-ARM toolset exists...
ifeq ("$(wildcard $(GNU_ARM))","")
$(error GNU_ARM toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_ARM)/bin/arm-none-eabi-gcc
CPP := $(GNU_ARM)/bin/arm-none-eabi-g++
AS := $(GNU_ARM)/bin/arm-none-eabi-as
LINK := $(GNU_ARM)/bin/arm-none-eabi-g++
BIN := $(GNU_ARM)/bin/arm-none-eabi-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M
#
# combine all the soruces...
C_SRCS += $(QP_SRCS)
ASM_SRCS += $(QP_ASMS)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS = $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration ..........................................
BIN_DIR := dbg
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O $(INCLUDES) $(DEFINES)
CPPFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES)
endif # ......................................................................
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
-specs=nosys.specs -specs=nano.specs \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_BIN := $(BIN_DIR)/$(OUTPUT).bin
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_BIN)
#all: $(TARGET_ELF)
$(TARGET_BIN): $(TARGET_ELF)
$(BIN) -O binary $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(CC) $(CFLAGS) $(QPN)/include/qstamp.c -o $(BIN_DIR)/qstamp.o
$(LINK) $(LINKFLAGS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.bin \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/qv/gnu/dpp-qv.ld
================================================
/*****************************************************************************
* Product: Linker script for for LPC1768, GNU-ARM linker
* Last Updated for Version: 5.9.8
* Date of the Last Update: 2017-09-13
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) 2002-2013 Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* https://state-machine.com
* mailto:info@state-machine.com
*****************************************************************************/
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(Reset_Handler) /* entry Point */
MEMORY { /* memory map of mbed-LPC1768 */
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 512K
RAM (rwx) : ORIGIN = 0x10000000, LENGTH = 0x7FDF
USB_RAM(rwx) : ORIGIN = 0x2007C000, LENGTH = 16K
ETH_RAM(rwx) : ORIGIN = 0x20080000, LENGTH = 16K
}
/* The size of the stack used by the application. NOTE: you need to adjust */
STACK_SIZE = 1024;
/* The size of the heap used by the application. NOTE: you need to adjust */
HEAP_SIZE = 0;
SECTIONS {
.isr_vector : { /* the vector table goes FIRST into ROM */
KEEP(*(.isr_vector)) /* vector table */
. = ALIGN(4);
} >ROM
.text : { /* code and constants */
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} >ROM
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >ROM
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >ROM
.fini_array : {
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array*))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >ROM
_etext = .; /* global symbols at end of code */
.stack : {
__stack_start__ = .;
. = . + STACK_SIZE;
. = ALIGN(4);
__stack_end__ = .;
} >RAM
.data : AT (_etext) {
__data_load = LOADADDR (.data);
__data_start = .;
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
__data_end__ = .;
_edata = __data_end__;
} >RAM
.bss : {
__bss_start__ = .;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = .;
} >RAM
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >RAM
__exidx_end = .;
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );
PROVIDE ( __end__ = _ebss );
.heap : {
__heap_start__ = .;
. = . + HEAP_SIZE;
. = ALIGN(4);
__heap_end__ = .;
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ : {
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
}
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/qv/iar/dpp-qv.ewd
================================================
2DebugARM1C-SPY22811ARMSIM_ID2111ANGEL_ID2011CADI_ID2011CMSISDAP_ID2411GDBSERVER_ID2011IARROM_ID2111IJET_ID2811JLINK_ID21611LMIFTDI_ID2211MACRAIGOR_ID2311PEMICRO_ID2311RDI_ID2211STLINK_ID2311THIRDPARTY_ID2011TIFET_ID2111XDS100_ID2511$TOOLKIT_DIR$\plugins\middleware\HCCWare\HCCWare.ewplugin0$TOOLKIT_DIR$\plugins\middleware\PercepioTraceExporter\PercepioTraceExportPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\AVIX\AVIX.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\MQX\MQXRtosPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\Quadros\Quadros_EWB7_Plugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseARM0C-SPY22810ARMSIM_ID2110ANGEL_ID2010CADI_ID2010CMSISDAP_ID2410GDBSERVER_ID2010IARROM_ID2110IJET_ID2810JLINK_ID21610LMIFTDI_ID2210MACRAIGOR_ID2310PEMICRO_ID2310RDI_ID2210STLINK_ID2310THIRDPARTY_ID2010TIFET_ID2110XDS100_ID2510$TOOLKIT_DIR$\plugins\middleware\HCCWare\HCCWare.ewplugin0$TOOLKIT_DIR$\plugins\middleware\PercepioTraceExporter\PercepioTraceExportPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\AVIX\AVIX.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\MQX\MQXRtosPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\Quadros\Quadros_EWB7_Plugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/qv/iar/dpp-qv.ewp
================================================
2DebugARM1General32411ICCARM23111AARM2911OBJCOPY0111CUSTOM30BICOMP0BUILDACTION1ILINK01711IARCHIVE0011BILINK0Coder0ReleaseARM0General32410ICCARM23110AARM2910OBJCOPY0110CUSTOM30BICOMP0BUILDACTION1ILINK01710IARCHIVE0010BILINK0Coder0Application$PROJ_DIR$\..\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\dpp.h$PROJ_DIR$\..\..\main.c$PROJ_DIR$\..\..\philo.c$PROJ_DIR$\..\..\table.cmbed-lpc1768$PROJ_DIR$\..\..\..\..\..\3rd_party\mbed-lpc1768\LPC17xx.h$PROJ_DIR$\..\..\..\..\..\3rd_party\mbed-lpc1768\iar\startup_LPC17xx.s$PROJ_DIR$\..\..\..\..\..\3rd_party\mbed-lpc1768\system_LPC17xx.c$PROJ_DIR$\..\..\..\..\..\3rd_party\mbed-lpc1768\system_LPC17xx.hQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qvn\qvn.cQP_port$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qv\iar\qfn_port.h$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qv\iar\qvn_port.c
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/qv/iar/dpp-qv.eww
================================================
$WS_DIR$\dpp-qv.ewp
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/qv/iar/dpp-qv.icf
================================================
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0007FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x10000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x10007FDF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 1024;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/
define symbol __CRP_start__ = 0x000002FC;
define symbol __CRP_end__ = 0x000002FF;
define symbol __RAM1_start__ = 0x2007C000;
define symbol __RAM1_end__ = 0x20083FFF;
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__] - mem:[from __CRP_start__ to __CRP_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define region CRP_region = mem:[from __CRP_start__ to __CRP_end__];
define region RAM1_region = mem:[from __RAM1_start__ to __RAM1_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place in RAM_region { readwrite,
block CSTACK, block HEAP };
place in CRP_region { section .crp };
place in RAM1_region { section .sram };
================================================
FILE: examples/arm-cm/dpp_mbed-lpc1768/table.c
================================================
/*.$file${.::table.c} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: dpp.qm
* File: ${.::table.c}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::table.c} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("table")
/* Active object class -----------------------------------------------------*/
/*.$declare${AOs::Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table} ...........................................................*/
typedef struct Table {
/* protected: */
QActive super;
/* private: */
uint8_t fork[N_PHILO];
uint8_t isHungry[N_PHILO];
} Table;
/* protected: */
static QState Table_initial(Table * const me);
static QState Table_active(Table * const me);
static QState Table_serving(Table * const me);
static QState Table_paused(Table * const me);
/*.$enddecl${AOs::Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Global objects ----------------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*. Check for the minimum required QP version */
#if (QP_VERSION < 650U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpn version 6.5.0 or higher required
#endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Table} ........................................................*/
struct Table AO_Table;
/*.$enddef${AOs::AO_Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#define RIGHT(n_) ((uint8_t)(((n_) + (N_PHILO - 1U)) % N_PHILO))
#define LEFT(n_) ((uint8_t)(((n_) + 1U) % N_PHILO))
#define FREE ((uint8_t)0)
#define USED ((uint8_t)1)
/*..........................................................................*/
/*.$define${AOs::Table_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table_ctor} ......................................................*/
void Table_ctor(void) {
uint8_t n;
Table *me = &AO_Table;
QActive_ctor(&me->super, Q_STATE_CAST(&Table_initial));
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
}
}
/*.$enddef${AOs::Table_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table} ...........................................................*/
/*.${AOs::Table::SM} .......................................................*/
static QState Table_initial(Table * const me) {
/*.${AOs::Table::SM::initial} */
uint8_t n;
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "thinking");
}
return Q_TRAN(&Table_serving);
}
/*.${AOs::Table::SM::active} ...............................................*/
static QState Table_active(Table * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Table::SM::active::TERMINATE} */
case TERMINATE_SIG: {
BSP_terminate(0);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::EAT} */
case EAT_SIG: {
Q_ERROR();
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Table::SM::active::serving} ......................................*/
static QState Table_serving(Table * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Table::SM::active::serving} */
case Q_ENTRY_SIG: {
uint8_t n;
for (n = 0U; n < N_PHILO; ++n) { /* give permissions to eat... */
if ((me->isHungry[n] != 0U)
&& (me->fork[LEFT(n)] == FREE)
&& (me->fork[n] == FREE))
{
QActive *philo;
me->fork[LEFT(n)] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "eating ");
}
}
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::serving::HUNGRY} */
case HUNGRY_SIG: {
uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "hungry ");
m = LEFT(n);
/*.${AOs::Table::SM::active::serving::HUNGRY::[bothfree]} */
if ((me->fork[m] == FREE) && (me->fork[n] == FREE)) {
me->fork[m] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
BSP_displayPhilStat(n, "eating ");
status_ = Q_HANDLED();
}
/*.${AOs::Table::SM::active::serving::HUNGRY::[else]} */
else {
me->isHungry[n] = 1U;
status_ = Q_HANDLED();
}
break;
}
/*.${AOs::Table::SM::active::serving::DONE} */
case DONE_SIG: {
uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;
m = RIGHT(n); /* check the right neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[m] == FREE)) {
me->fork[n] = USED;
me->fork[m] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}
m = LEFT(n); /* check the left neighbor */
n = LEFT(m); /* left fork of the left neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[n] == FREE)) {
me->fork[m] = USED;
me->fork[n] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::serving::EAT} */
case EAT_SIG: {
Q_ERROR();
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::serving::PAUSE} */
case PAUSE_SIG: {
status_ = Q_TRAN(&Table_paused);
break;
}
default: {
status_ = Q_SUPER(&Table_active);
break;
}
}
return status_;
}
/*.${AOs::Table::SM::active::paused} .......................................*/
static QState Table_paused(Table * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Table::SM::active::paused} */
case Q_ENTRY_SIG: {
BSP_displayPaused(1U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::paused} */
case Q_EXIT_SIG: {
BSP_displayPaused(0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::paused::SERVE} */
case SERVE_SIG: {
status_ = Q_TRAN(&Table_serving);
break;
}
/*.${AOs::Table::SM::active::paused::HUNGRY} */
case HUNGRY_SIG: {
uint8_t n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* philo ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
me->isHungry[n] = 1U;
BSP_displayPhilStat(n, "hungry ");
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::paused::DONE} */
case DONE_SIG: {
uint8_t n, m;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&Table_active);
break;
}
}
return status_;
}
/*.$enddef${AOs::Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/README.txt
================================================
About this Example
==================
This folder contains the simple "Blinky" QP example application.
This directory contains portable code that should compile with any C
compiler for ARM Cortex-M.
The sub-directories contain code and project files, which are
specific to the particular ARM toolchains, such as ARM-KEIL (MDK-ARM),
GNU, and IAR.
Please refer to the README files in the sub-directories for specific
instructions how to use and customize the example to your needs.
Support Code for STM32 NUCLEO-L053R8 Board
------------------------------------------
The directory qpc\3rd_party\nucleo-l053r8 contains the CMSIS-
compliant device code for the STM32L0xx MCUs (ARM Cortex-M0+). Please see
the README file in this folder for more details.
QS Software Tracing Instrumentation
===================================
This example provides the "Spy" build configuration, which outputs the QS
(Quantum Spy) software tracing data through UART2, which is connected to
the virtual COM port of the ST-Link V2 USB debugger.
The output is generated at 115200 baud rate.
Here is an example invocation of the QSPY host application to receive
the QS data from NUCLEO board:
qspy -cCOM20
The actual COM port number might be different on your Windows machine.
Please check the Device Manager to find the COM port number.
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/README.url
================================================
[InternetShortcut]
URL=http://www.state-machine.com/qpn/arm-cm_dpp_nucleo-l053r8.html
IconFile=http://www.state-machine.com/qp.ico
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/bsp.h
================================================
/*****************************************************************************
* Product: DPP example
* Last Updated for Version: 5.4.0
* Date of the Last Update: 2015-03-07
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* Web : www.state-machine.com
*
*****************************************************************************/
#ifndef BSP_H
#define BSP_H
#define BSP_TICKS_PER_SEC 100U
void BSP_init(void);
void BSP_displayPaused(uint8_t paused);
void BSP_displayPhilStat(uint8_t n, char_t const *stat);
void BSP_terminate(int16_t result);
void BSP_randomSeed(uint32_t seed); /* random seed */
uint32_t BSP_random(void); /* pseudo-random generator */
#endif /* BSP_H */
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/dpp.h
================================================
/*.$file${.::dpp.h} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: dpp.qm
* File: ${.::dpp.h}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::dpp.h} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#ifndef DPP_H
#define DPP_H
enum DPPSignals {
EAT_SIG = Q_USER_SIG, /* published by Table to let a philosopher eat */
DONE_SIG, /* published by Philosopher when done eating */
PAUSE_SIG, /* published by BSP to pause the application */
SERVE_SIG, /* published by BSP to pause the application */
TERMINATE_SIG, /* published by BSP to terminate the application */
HUNGRY_SIG, /* posted direclty to Table from hungry Philo */
MAX_SIG /* the last signal */
};
/* number of philosophers */
#define N_PHILO ((uint8_t)5)
#define PHILO_0_PRIO 1
/*.$declare${AOs::AO_Philo0} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo0;
/*.$enddecl${AOs::AO_Philo0} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo1} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo1;
/*.$enddecl${AOs::AO_Philo1} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo2} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo2;
/*.$enddecl${AOs::AO_Philo2} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo3} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo3;
/*.$enddecl${AOs::AO_Philo3} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo4} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo4;
/*.$enddecl${AOs::AO_Philo4} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Table AO_Table;
/*.$enddecl${AOs::AO_Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::Philo_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo_ctor} ......................................................*/
void Philo_ctor(void);
/*.$enddecl${AOs::Philo_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::Table_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table_ctor} ......................................................*/
void Table_ctor(void);
/*.$enddecl${AOs::Table_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#endif /* DPP_H */
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/dpp.qm
================================================
Dining Philosopher Problem example with QActiveQActive_armX(&me->super, 0U, THINK_TIME, 0U);QActive_disarmX(&me->super, 0U);Q_ERROR(); /* these events should never arrive in this state */QACTIVE_POST(&AO_Table, HUNGRY_SIG, me->super.prio);Q_ERROR(); /* this event should never arrive in this state */QActive_armX(&me->super, 0U, EAT_TIME, 0U);QActive_disarmX(&me->super, 0U);
QACTIVE_POST(QF_ACTIVE_CAST(&AO_Table), DONE_SIG, me->super.prio);Q_ERROR(); /* these events should never arrive in this state */uint8_t n;
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "thinking");
}BSP_terminate(0);Q_ERROR();uint8_t n;
for (n = 0U; n < N_PHILO; ++n) { /* give permissions to eat... */
if ((me->isHungry[n] != 0U)
&& (me->fork[LEFT(n)] == FREE)
&& (me->fork[n] == FREE))
{
QActive *philo;
me->fork[LEFT(n)] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "eating ");
}
}uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "hungry ");
m = LEFT(n);(me->fork[m] == FREE) && (me->fork[n] == FREE)me->fork[m] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
BSP_displayPhilStat(n, "eating ");elseme->isHungry[n] = 1U;uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;
m = RIGHT(n); /* check the right neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[m] == FREE)) {
me->fork[n] = USED;
me->fork[m] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}
m = LEFT(n); /* check the left neighbor */
n = LEFT(m); /* left fork of the left neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[n] == FREE)) {
me->fork[m] = USED;
me->fork[n] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}Q_ERROR();BSP_displayPaused(1U);BSP_displayPaused(0U);uint8_t n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* philo ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
me->isHungry[n] = 1U;
BSP_displayPhilStat(n, "hungry ");uint8_t n, m;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;QActive_ctor(&AO_Philo0.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo1.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo2.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo3.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo4.super, Q_STATE_CAST(&Philo_initial));
BSP_randomSeed(123U);uint8_t n;
Table *me = &AO_Table;
QActive_ctor(&me->super, Q_STATE_CAST(&Table_initial));
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
}#ifndef DPP_H
#define DPP_H
enum DPPSignals {
EAT_SIG = Q_USER_SIG, /* published by Table to let a philosopher eat */
DONE_SIG, /* published by Philosopher when done eating */
PAUSE_SIG, /* published by BSP to pause the application */
SERVE_SIG, /* published by BSP to pause the application */
TERMINATE_SIG, /* published by BSP to terminate the application */
HUNGRY_SIG, /* posted direclty to Table from hungry Philo */
MAX_SIG /* the last signal */
};
/* number of philosophers */
#define N_PHILO ((uint8_t)5)
#define PHILO_0_PRIO 1
$declare${AOs::AO_Philo0}
$declare${AOs::AO_Philo1}
$declare${AOs::AO_Philo2}
$declare${AOs::AO_Philo3}
$declare${AOs::AO_Philo4}
$declare${AOs::AO_Table}
$declare${AOs::Philo_ctor}
$declare${AOs::Table_ctor}
#endif /* DPP_H */
#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("philo")
/* Active object class -----------------------------------------------------*/
$declare${AOs::Philo}
/* Global objects ----------------------------------------------------------*/
$define${AOs::AO_Philo0}
$define${AOs::AO_Philo1}
$define${AOs::AO_Philo2}
$define${AOs::AO_Philo3}
$define${AOs::AO_Philo4}
/* Local objects -----------------------------------------------------------*/
#define THINK_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + (BSP_TICKS_PER_SEC/2U))
#define EAT_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + BSP_TICKS_PER_SEC)
/* Philo definition --------------------------------------------------------*/
$define${AOs::Philo_ctor}
$define${AOs::Philo}#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("table")
/* Active object class -----------------------------------------------------*/
$declare${AOs::Table}
/* Global objects ----------------------------------------------------------*/
$define${AOs::AO_Table}
#define RIGHT(n_) ((uint8_t)(((n_) + (N_PHILO - 1U)) % N_PHILO))
#define LEFT(n_) ((uint8_t)(((n_) + 1U) % N_PHILO))
#define FREE ((uint8_t)0)
#define USED ((uint8_t)1)
/*..........................................................................*/
$define${AOs::Table_ctor}
$define${AOs::Table}
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/main.c
================================================
/*****************************************************************************
* Product: DPP example
* Last Updated for Version: 5.8.0
* Date of the Last Update: 2016-11-06
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h" /* QP-nano */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
/*..........................................................................*/
static QEvt l_philoQueue[N_PHILO][N_PHILO];
static QEvt l_tableQueue[2];
/* QF_active[] array defines all active object control blocks --------------*/
QActiveCB const Q_ROM QF_active[] = {
{ (QActive *)0, (QEvt *)0, 0U },
{ (QActive *)&AO_Philo0, l_philoQueue[0], Q_DIM(l_philoQueue[0]) },
{ (QActive *)&AO_Philo1, l_philoQueue[1], Q_DIM(l_philoQueue[1]) },
{ (QActive *)&AO_Philo2, l_philoQueue[2], Q_DIM(l_philoQueue[2]) },
{ (QActive *)&AO_Philo3, l_philoQueue[3], Q_DIM(l_philoQueue[3]) },
{ (QActive *)&AO_Philo4, l_philoQueue[4], Q_DIM(l_philoQueue[4]) },
{ (QActive *)&AO_Table, l_tableQueue, Q_DIM(l_tableQueue) }
};
/*..........................................................................*/
int_t main() {
Philo_ctor(); /* instantiate all Philo AOs */
Table_ctor(); /* instantiate the Table AO */
QF_init(Q_DIM(QF_active)); /* initialize the QF-nano framework */
BSP_init(); /* initialize the Board Support Package */
return QF_run(); /* transfer control to QF-nano */
}
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/philo.c
================================================
/*.$file${.::philo.c} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: dpp.qm
* File: ${.::philo.c}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::philo.c} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("philo")
/* Active object class -----------------------------------------------------*/
/*.$declare${AOs::Philo} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo} ...........................................................*/
typedef struct Philo {
/* protected: */
QActive super;
} Philo;
/* protected: */
static QState Philo_initial(Philo * const me);
static QState Philo_thinking(Philo * const me);
static QState Philo_hungry(Philo * const me);
static QState Philo_eating(Philo * const me);
/*.$enddecl${AOs::Philo} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Global objects ----------------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*. Check for the minimum required QP version */
#if (QP_VERSION < 650U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpn version 6.5.0 or higher required
#endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo0} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo0} .......................................................*/
struct Philo AO_Philo0;
/*.$enddef${AOs::AO_Philo0} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo1} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo1} .......................................................*/
struct Philo AO_Philo1;
/*.$enddef${AOs::AO_Philo1} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo2} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo2} .......................................................*/
struct Philo AO_Philo2;
/*.$enddef${AOs::AO_Philo2} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo3} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo3} .......................................................*/
struct Philo AO_Philo3;
/*.$enddef${AOs::AO_Philo3} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo4} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo4} .......................................................*/
struct Philo AO_Philo4;
/*.$enddef${AOs::AO_Philo4} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Local objects -----------------------------------------------------------*/
#define THINK_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + (BSP_TICKS_PER_SEC/2U))
#define EAT_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + BSP_TICKS_PER_SEC)
/* Philo definition --------------------------------------------------------*/
/*.$define${AOs::Philo_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo_ctor} ......................................................*/
void Philo_ctor(void) {
QActive_ctor(&AO_Philo0.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo1.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo2.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo3.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo4.super, Q_STATE_CAST(&Philo_initial));
BSP_randomSeed(123U);
}
/*.$enddef${AOs::Philo_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Philo} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo} ...........................................................*/
/*.${AOs::Philo::SM} .......................................................*/
static QState Philo_initial(Philo * const me) {
/*.${AOs::Philo::SM::initial} */
return Q_TRAN(&Philo_thinking);
}
/*.${AOs::Philo::SM::thinking} .............................................*/
static QState Philo_thinking(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Philo::SM::thinking} */
case Q_ENTRY_SIG: {
QActive_armX(&me->super, 0U, THINK_TIME, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::thinking} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::thinking::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Philo_hungry);
break;
}
/*.${AOs::Philo::SM::thinking::EAT, DONE} */
case EAT_SIG: /* intentionally fall through */
case DONE_SIG: {
Q_ERROR(); /* these events should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Philo::SM::hungry} ...............................................*/
static QState Philo_hungry(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Philo::SM::hungry} */
case Q_ENTRY_SIG: {
QACTIVE_POST(&AO_Table, HUNGRY_SIG, me->super.prio);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::hungry::EAT} */
case EAT_SIG: {
status_ = Q_TRAN(&Philo_eating);
break;
}
/*.${AOs::Philo::SM::hungry::DONE} */
case DONE_SIG: {
Q_ERROR(); /* this event should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Philo::SM::eating} ...............................................*/
static QState Philo_eating(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Philo::SM::eating} */
case Q_ENTRY_SIG: {
QActive_armX(&me->super, 0U, EAT_TIME, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::eating} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
QACTIVE_POST(QF_ACTIVE_CAST(&AO_Table), DONE_SIG, me->super.prio);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::eating::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Philo_thinking);
break;
}
/*.${AOs::Philo::SM::eating::EAT, DONE} */
case EAT_SIG: /* intentionally fall through */
case DONE_SIG: {
Q_ERROR(); /* these events should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.$enddef${AOs::Philo} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qk/armclang/README.txt
================================================
About this Example
==================
This example demonstrates how to use the uVision IDE together with
the MDK-ARM toolchain.
***
NOTE: This example requires installing the following Software Pack
in the Keil uVision: Keil::STM32L0xx_DFP.
***
uVision Project File
====================
The MDK-ARM uVision project file provided with this example uses
relative paths to the QP/C framework location (includes, port, and
libraries. These relative paths must be modified when the project
is moved to different relative location.
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the
command-line options for the ARM assembler (see the Asm tab in
the "Options for Target" dialog box in uVision). Specifically,
you should define symbols: Stack_Size=xxx Heap_Size=yyy, where
xxx represents a numerical value of stack size and yyy the
numberical value of the heap size.
Startup Code
============
The startup code for the STM32L1xx MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\nucleo-l053r8\arm\startup_stm32l053xx.s
The file startup_stm32l053xx.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
Adjusting the CPU Clock Speed
=============================
The current setting is to run at 2MHz from the MSI (internal oscillator),
but the CPU clock speed can be modified by editing the file
system_stm32l1xx.c. Ther file system_stm32l0xx.c.pll provides an example
of clock setting using the PLL driven from the MSE.
***
NOTE:
The NUCLEO boards have a wide range of possible clock selections, depending
on the solder bridge configuration. Please see Chapter 5.7 "OSC clock" in
the STM32 NUCLEO Boards User Manual (ST document UM1724) for more information.
***
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qk/armclang/dpp-qk.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj; *.o*.lib*.txt; *.h; *.inc*.plm*.cpp000dpp-dbg0x4ARM-ADS120000001101016553500079668.\dbg\111011010000111111100101180111111111111101011001005STLink\ST-LINKIII-KEIL_SWO.dll0UL2CM3UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32L0xx_64 -FS08000000 -FL010000 -FP0($$Device:STM32L053R8Tx$CMSIS\Flash\STM32L0xx_64.FLM))0ST-LINKIII-KEIL_SWO-U066CFF484951775087074312 -O8431 -SF480 -C0 -A0 -I0 -HNlocalhost -HP7184 -P2 -N00("ARM CoreSight SW-DP") -D00(0BC11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8004 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC800 -FN1 -FF0STM32L0xx_64.FLM -FS08000000 -FL010000 -FP0($$Device:STM32L053R8Tx$CMSIS\Flash\STM32L0xx_64.FLM)0DLGUARM(105=-1,-1,-1,-1,0)0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)0ARMDBGFLAGS120x200002000200x40000001000010000000000000000000100210000000dpp-rel0x4ARM-ADS120000001101016553500079668.\rel\111011010000111111100100180111111111111101011001005STLink\ST-LINKIII-KEIL_SWO.dll0UL2CM3UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32L0xx_64 -FS08000000 -FL010000 -FP0($$Device:STM32L053R8Tx$CMSIS\Flash\STM32L0xx_64.FLM))0ST-LINKIII-KEIL_SWO-U066CFF484951775087074312 -O8431 -SF4000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P2 -N00("ARM CoreSight SW-DP") -D00(0BC11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32L0xx_64.FLM -FS08000000 -FL010000 -FP0($$Device:STM32L053R8Tx$CMSIS\Flash\STM32L0xx_64.FLM)0DLGUARM(105=-1,-1,-1,-1,0)0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)0ARMDBGFLAGS120x200002000200x40000001000010000000000000000000100210000000Source Code1000111000..\bsp.cbsp.c00125000..\..\bsp.hbsp.h00135000..\..\dpp.hdpp.h00141000..\..\main.cmain.c00151000..\..\philo.cphilo.c00161000..\..\table.ctable.c00nucleo-l053r81000275000..\..\..\..\..\3rd_party\nucleo-l053r8\stm32l0xx.hstm32l0xx.h00285000..\..\..\..\..\3rd_party\nucleo-l053r8\stm32l053xx.hstm32l053xx.h00291000..\..\..\..\..\3rd_party\nucleo-l053r8\system_stm32l0xx.csystem_stm32l0xx.c002105000..\..\..\..\..\3rd_party\nucleo-l053r8\system_stm32l0xx.hsystem_stm32l0xx.h002112000..\..\..\..\..\3rd_party\nucleo-l053r8\arm\startup_stm32l053xx.sstartup_stm32l053xx.s00QP10003121000..\..\..\..\..\src\qfn\qepn.cqepn.c003131000..\..\..\..\..\src\qfn\qfn.cqfn.c003141000..\..\..\..\..\src\qkn\qkn.cqkn.c00QP_port10004155000..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqfn_port.h004161000..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.cqkn_port.c00
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qk/armclang/dpp-qk.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwaredpp-dbg0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1STM32L053R8TxSTMicroelectronicsKeil.STM32L0xx_DFP.2.0.0http://www.keil.com/pack/IRAM(0x20000000,0x00002000) IROM(0x08000000,0x00010000) CPUTYPE("Cortex-M0+") CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32L0xx_64 -FS08000000 -FL010000 -FP0($$Device:STM32L053R8Tx$Flash\STM32L0xx_64.FLM))0$$Device:STM32L053R8Tx$Device\Include\stm32l0xx.h$$Device:STM32L053R8Tx$SVD\STM32L053x.svd0000001.\dbg\dpp-qk10011.\dbg\10000000000000010fromelf --bin --output .\dbg\dpp-qk.bin .\dbg\dpp-qk.axf00000000001000031SARMCM3.DLL -REMAP DARMCM1.DLL-pCM0+SARMCM3.DLLTARMCM1.DLL-pCM0+1000161001140961BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M0+"0001100000080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x200010x80000000x1000000x00x010x00x010x00x010x00x010x80000000x1000010x00x000x00x000x00x000x00x000x200000000x200000x00x007001000003010003311000..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\nucleo-l053r81000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerSource Codebsp.c1..\bsp.cbsp.h5..\..\bsp.hdpp.h5..\..\dpp.hmain.c1..\..\main.cphilo.c1..\..\philo.ctable.c1..\..\table.cnucleo-l053r8stm32l0xx.h5..\..\..\..\..\3rd_party\nucleo-l053r8\stm32l0xx.hstm32l053xx.h5..\..\..\..\..\3rd_party\nucleo-l053r8\stm32l053xx.hsystem_stm32l0xx.c1..\..\..\..\..\3rd_party\nucleo-l053r8\system_stm32l0xx.csystem_stm32l0xx.h5..\..\..\..\..\3rd_party\nucleo-l053r8\system_stm32l0xx.hstartup_stm32l053xx.s2..\..\..\..\..\3rd_party\nucleo-l053r8\arm\startup_stm32l053xx.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.cdpp-rel0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1STM32L053R8TxSTMicroelectronicsKeil.STM32L0xx_DFP.2.0.0http://www.keil.com/pack/IRAM(0x20000000,0x00002000) IROM(0x08000000,0x00010000) CPUTYPE("Cortex-M0+") CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32L0xx_64 -FS08000000 -FL010000 -FP0($$Device:STM32L053R8Tx$Flash\STM32L0xx_64.FLM))0$$Device:STM32L053R8Tx$Device\Include\stm32l0xx.h$$Device:STM32L053R8Tx$SVD\STM32L053x.svd0000001.\rel\dpp-qk10000.\rel\10000000000000010fromelf --bin --output .\rel\dpp-qk.bin .\rel\dpp-qk.axf00000000001000031SARMCM3.DLL -REMAP DARMCM1.DLL-pCM0+SARMCM3.DLLTARMCM1.DLL-pCM0+1000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M0+"0001100000080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x200010x80000000x1000000x00x010x00x010x00x010x00x010x80000000x1000010x00x000x00x000x00x000x00x000x200000000x200000x00x007001000003010003311000NDEBUG..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\nucleo-l053r81000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000dpp-qk.sct--entry Reset_HandlerSource Codebsp.c1..\bsp.cbsp.h5..\..\bsp.hdpp.h5..\..\dpp.hmain.c1..\..\main.cphilo.c1..\..\philo.ctable.c1..\..\table.cnucleo-l053r8stm32l0xx.h5..\..\..\..\..\3rd_party\nucleo-l053r8\stm32l0xx.hstm32l053xx.h5..\..\..\..\..\3rd_party\nucleo-l053r8\stm32l053xx.hsystem_stm32l0xx.c1..\..\..\..\..\3rd_party\nucleo-l053r8\system_stm32l0xx.csystem_stm32l0xx.h5..\..\..\..\..\3rd_party\nucleo-l053r8\system_stm32l0xx.hstartup_stm32l053xx.s2..\..\..\..\..\3rd_party\nucleo-l053r8\arm\startup_stm32l053xx.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.c
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qk/bsp.c
================================================
/*****************************************************************************
* Product: DPP on STM32 NUCLEO-L053R8 board, preemptive QK kernel
* Last Updated for Version: 6.1.1
* Date of the Last Update: 2018-02-18
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "dpp.h"
#include "bsp.h"
#include "stm32l0xx.h" /* CMSIS-compliant header file for the MCU used */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
enum KernelAwareISRs {
GPIOPORTA_PRIO = QF_AWARE_ISR_CMSIS_PRI, /* see NOTE00 */
SYSTICK_PRIO,
/* ... */
MAX_KERNEL_AWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-aware" interrupts should not overlap the PendSV priority */
Q_ASSERT_COMPILE(MAX_KERNEL_AWARE_CMSIS_PRI <= (0xFF >>(8-__NVIC_PRIO_BITS)));
/* ISRs defined in this BSP ------------------------------------------------*/
void SysTick_Handler(void);
/* Local-scope objects -----------------------------------------------------*/
/* LED pins available on the board (just one user LED LD2--Green on PA.5) */
#define LED_LD2 (1U << 5)
/* Button pins available on the board (just one user Button B1 on PC.13) */
#define BTN_B1 (1U << 13)
/* random seed */
static uint32_t l_rnd;
/* ISRs used in this project ===============================================*/
void SysTick_Handler(void) {
/* state of the button debouncing, see below */
static struct ButtonsDebouncing {
uint32_t depressed;
uint32_t previous;
} buttons = { ~0U, ~0U };
uint32_t current;
uint32_t tmp;
QK_ISR_ENTRY(); /* inform QK about entering an ISR */
QF_tickXISR(0U); /* process time events for rate 0 */
/* Perform the debouncing of buttons. The algorithm for debouncing
* adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
* and Michael Barr, page 71.
*/
current = ~GPIOC->IDR; /* read Port C with the state of Button B1 */
tmp = buttons.depressed; /* save the debounced depressed buttons */
buttons.depressed |= (buttons.previous & current); /* set depressed */
buttons.depressed &= (buttons.previous | current); /* clear released */
buttons.previous = current; /* update the history */
tmp ^= buttons.depressed; /* changed debounced depressed */
if ((tmp & BTN_B1) != 0U) { /* debounced B1 state changed? */
if ((buttons.depressed & BTN_B1) != 0U) { /* is B1 depressed? */
QACTIVE_POST_ISR(&AO_Table, PAUSE_SIG, 0U);
}
else { /* the button is released */
QACTIVE_POST_ISR(&AO_Table, SERVE_SIG, 0U);
}
}
QK_ISR_EXIT(); /* inform QK about exiting an ISR */
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* NOTE: SystemInit() has been already called from the startup code
* but SystemCoreClock needs to be updated
*/
SystemCoreClockUpdate();
/* enable GPIOA clock port for the LED LD2 */
RCC->IOPENR |= (1U << 0);
/* configure LED (PA.5) pin as push-pull output, no pull-up, pull-down */
GPIOA->MODER &= ~((3U << 2*5));
GPIOA->MODER |= ((1U << 2*5));
GPIOA->OTYPER &= ~((1U << 5));
GPIOA->OSPEEDR &= ~((3U << 2*5));
GPIOA->OSPEEDR |= ((1U << 2*5));
GPIOA->PUPDR &= ~((3U << 2*5));
/* enable GPIOC clock port for the Button B1 */
RCC->IOPENR |= (1U << 2);
/* configure Button (PC.13) pins as input, no pull-up, pull-down */
GPIOC->MODER &= ~(3U << 2*13);
GPIOC->OSPEEDR &= ~(3U << 2*13);
GPIOC->OSPEEDR |= (1U << 2*13);
GPIOC->PUPDR &= ~(3U << 2*13);
BSP_randomSeed(1234U); /* seed the random number generator */
}
/*..........................................................................*/
void BSP_displayPhilStat(uint8_t n, char const *stat) {
if (stat[0] == 'h') {
GPIOA->BSRR |= LED_LD2; /* turn LED on */
}
else {
GPIOA->BSRR |= (LED_LD2 << 16); /* turn LED off */
}
}
/*..........................................................................*/
void BSP_displayPaused(uint8_t paused) {
/* not enough LEDs to implement this feature */
if (paused != (uint8_t)0) {
//GPIOA->BSRR |= (LED_LD2); /* turn LED[n] on */
}
else {
//GPIOA->BSRR |= (LED_LD2 << 16); /* turn LED[n] off */
}
}
/*..........................................................................*/
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
l_rnd = l_rnd * (3U*7U*11U*13U*23U);
return l_rnd >> 8;
}
/*..........................................................................*/
void BSP_randomSeed(uint32_t seed) {
l_rnd = seed;
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
(void)result;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set up the SysTick timer to fire at BSP_TICKS_PER_SEC rate */
SysTick_Config(SystemCoreClock / BSP_TICKS_PER_SEC);
/* set priorities of ALL ISRs used in the system, see NOTE00
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
NVIC_SetPriority(SysTick_IRQn, SYSTICK_PRIO);
/* ... */
/* enable IRQs... */
}
/*..........................................................................*/
#ifdef QK_ON_CONTEXT_SW
/* NOTE: the context-switch callback is called with interrupts DISABLED */
void QK_onContextSw(uint_fast8_t prev, uint_fast8_t next) {
(void)prev;
if (next != (uint_fast8_t)0) {
//_impure_ptr = &reentrant[next];
}
}
#endif /* QK_ON_CONTEXT_SW */
/*..........................................................................*/
void QK_onIdle(void) {
/* toggle an LED on and then off (not enough LEDs, see NOTE01) */
QF_INT_DISABLE();
//GPIOA->BSRR |= (LED_LD2); /* turn LED[n] on */
//GPIOA->BSRR |= (LED_LD2 << 16); /* turn LED[n] off */
QF_INT_ENABLE();
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular Cortex-M3 MCU.
*/
/* !!!CAUTION!!!
* The WFI instruction stops the CPU clock, which unfortunately disables
* the JTAG port, so the ST-Link debugger can no longer connect to the
* board. For that reason, the call to __WFI() has to be used with CAUTION.
*
* NOTE: If you find your board "frozen" like this, strap BOOT0 to VDD and
* reset the board, then connect with ST-Link Utilities and erase the part.
* The trick with BOOT(0) is it gets the part to run the System Loader
* instead of your broken code. When done disconnect BOOT0, and start over.
*/
//__WFI(); /* Wait-For-Interrupt */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int loc) {
/*
* NOTE: add here your application-specific error handling
*/
(void)module;
(void)loc;
#ifndef NDEBUG
GPIOA->BSRR |= LED_LD2; /* turn LED on */
for (;;) {
}
#endif
NVIC_SystemReset();
}
/*****************************************************************************
* NOTE01:
* One of the LEDs is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qk/gnu/.cproject
================================================
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qk/gnu/.project
================================================
dpp-qk_nucleo-l053r8org.eclipse.cdt.managedbuilder.core.genmakebuilderclean,full,incremental,org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilderfull,incremental,org.eclipse.cdt.core.cnatureorg.eclipse.cdt.managedbuilder.core.managedBuildNatureorg.eclipse.cdt.managedbuilder.core.ScannerConfigNatureQK-nano2$%7BPARENT-5-PROJECT_LOC%7D/src/qknQP-nano2$%7BPARENT-5-PROJECT_LOC%7D/src/qfnQP_port2$%7BPARENT-5-PROJECT_LOC%7D/ports/arm-cm/qk/gnubsp.c1$%7BPARENT-1-PROJECT_LOC%7D/bsp.cbsp.h1$%7BPARENT-2-PROJECT_LOC%7D/bsp.hdpp.h1$%7BPARENT-2-PROJECT_LOC%7D/dpp.hmain.c1$%7BPARENT-2-PROJECT_LOC%7D/main.cnucleo-l053r82$%7BPARENT-5-PROJECT_LOC%7D/3rd_party/nucleo-l053r8philo.c1$%7BPARENT-2-PROJECT_LOC%7D/philo.cqstamp.c1$%7BPARENT-5-PROJECT_LOC%7D/include/qstamp.ctable.c1$%7BPARENT-2-PROJECT_LOC%7D/table.c
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qk/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano on NUCLEO-L053R8, QK-nano kernel, GNU-ARM
# Last Updated for Version: 6.5.0
# Date of the Last Update: 2019-04-15
#
# Q u a n t u m L e a P s
# ------------------------
# Modern Embedded Software
#
# Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# https://www.state-machine.com
# mailto:info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := dpp-qk
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/arm-cm/qk/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qkn \
$(QP_PORT_DIR) \
$(QPN)/3rd_party/nucleo-l053r8 \
$(QPN)/3rd_party/nucleo-l053r8/gnu
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR) \
-I$(QPN)/3rd_party/CMSIS/Include \
-I$(QPN)/3rd_party/nucleo-l053r8
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
bsp.c \
main.c \
philo.c \
table.c \
system_stm32l0xx.c \
startup_stm32l053xx.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qepn.c \
qfn.c \
qkn.c \
qkn_port.c
QP_ASMS :=
LIB_DIRS :=
LIBS :=
# defines
DEFINES :=
# ARM CPU, ARCH, FPU, and Float-ABI types...
# ARM_CPU: [cortex-m0 | cortex-m0plus | cortex-m1 | cortex-m3 | cortex-m4]
# ARM_ARCH: [6 | 7] (NOTE: must match ARM_CPU!)
# ARM_FPU: [ | vfp]
# FLOAT_ABI: [ | soft | softfp | hard]
#
ARM_CPU := -mcpu=cortex-m0plus
ARM_ARCH := 6 # NOTE: must match the ARM_CPU!
ARM_FPU :=
FLOAT_ABI :=
#-----------------------------------------------------------------------------
# GNU-ARM toolset (NOTE: You need to adjust to your machine)
# see https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
#
ifeq ($(GNU_ARM),)
GNU_ARM := $(QTOOLS)/gnu_arm-none-eabi
endif
# make sure that the GNU-ARM toolset exists...
ifeq ("$(wildcard $(GNU_ARM))","")
$(error GNU_ARM toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_ARM)/bin/arm-none-eabi-gcc
CPP := $(GNU_ARM)/bin/arm-none-eabi-g++
AS := $(GNU_ARM)/bin/arm-none-eabi-as
LINK := $(GNU_ARM)/bin/arm-none-eabi-g++
BIN := $(GNU_ARM)/bin/arm-none-eabi-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M
#
# combine all the soruces...
C_SRCS += $(QP_SRCS)
ASM_SRCS += $(QP_ASMS)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS = $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O2 $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O2 $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration ..........................................
BIN_DIR := dbg
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O2 $(INCLUDES) $(DEFINES)
CPPFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O2 $(INCLUDES) $(DEFINES)
endif # ......................................................................
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
-specs=nosys.specs -specs=nano.specs \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_BIN := $(BIN_DIR)/$(OUTPUT).bin
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_BIN)
#all: $(TARGET_ELF)
$(TARGET_BIN): $(TARGET_ELF)
$(BIN) -O binary $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(CC) $(CFLAGS) $(QPN)/include/qstamp.c -o $(BIN_DIR)/qstamp.o
$(LINK) $(LINKFLAGS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.bin \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qk/gnu/dpp-qk.ld
================================================
/*****************************************************************************
* Product: Linker script for for STM32L053R8, GNU-ARM linker
* Last Updated for Version: 5.9.8
* Date of the Last Update: 2017-09-13
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* https://state-machine.com
* mailto:info@state-machine.com
*****************************************************************************/
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(Reset_Handler) /* entry Point */
MEMORY { /* memory map of STM32L053R8 */
ROM (rx) : ORIGIN = 0x08000000, LENGTH = 64K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 8K
}
/* The size of the stack used by the application. NOTE: you need to adjust */
STACK_SIZE = 1024;
/* The size of the heap used by the application. NOTE: you need to adjust */
HEAP_SIZE = 0;
SECTIONS {
.isr_vector : { /* the vector table goes FIRST into ROM */
KEEP(*(.isr_vector)) /* vector table */
. = ALIGN(4);
} >ROM
.text : { /* code and constants */
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} >ROM
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >ROM
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >ROM
.fini_array : {
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array*))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >ROM
_etext = .; /* global symbols at end of code */
.stack : {
__stack_start__ = .;
. = . + STACK_SIZE;
. = ALIGN(4);
__stack_end__ = .;
} >RAM
.data : AT (_etext) {
__data_load = LOADADDR (.data);
__data_start = .;
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
__data_end__ = .;
_edata = __data_end__;
} >RAM
.bss : {
__bss_start__ = .;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = .;
} >RAM
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >RAM
__exidx_end = .;
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );
PROVIDE ( __end__ = _ebss );
.heap : {
__heap_start__ = .;
. = . + HEAP_SIZE;
. = ALIGN(4);
__heap_end__ = .;
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ : {
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
}
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qk/gnu/dpp-qk_nucleo-l053r8.elf.launch
================================================
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qk/gnu/stm32_flash.ld
================================================
/*
******************************************************************************
File: stm32_flash.ld
Info: Generated by Atollic TrueSTUDIO(R) 9.0.0 2018-02-14
Abstract: Linker script for STM32L053R8 device
Set heap size, stack size, stack location, memory areas and
sections according to application requirements.
The MIT License (MIT)
Copyright (c) 2018 STMicroelectronics
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************
*/
/* Entry Point */
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = 0x20002000; /* end of 8K RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0; /* required amount of heap */
_Min_Stack_Size = 0x80; /* required amount of stack */
/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 8K
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
}
/* Define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH
/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH
/* Constant data goes into FLASH */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >FLASH
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
.ARM : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >FLASH
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM AT> FLASH
/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM
/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
{
. = ALIGN(4);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(4);
} >RAM
/* MEMORY_bank1 section, code must be located here explicitly */
/* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
.memory_b1_text :
{
*(.mb1text) /* .mb1text sections (code) */
*(.mb1text*) /* .mb1text* sections (code) */
*(.mb1rodata) /* read-only data (constants) */
*(.mb1rodata*)
} >MEMORY_B1
/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
.ARM.attributes 0 : { *(.ARM.attributes) }
}
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qk/iar/dpp-qk.ewd
================================================
3DebugARM1C-SPY22811ARMSIM_ID2111CADI_ID2011CMSISDAP_ID2411GDBSERVER_ID2011IJET_ID2811JLINK_ID21611LMIFTDI_ID2211PEMICRO_ID2311STLINK_ID2411THIRDPARTY_ID2011TIFET_ID2111XDS100_ID2611$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseARM0C-SPY22810ARMSIM_ID2110CADI_ID2010CMSISDAP_ID2410GDBSERVER_ID2010IJET_ID2810JLINK_ID21610LMIFTDI_ID2210PEMICRO_ID2310STLINK_ID2410THIRDPARTY_ID2010TIFET_ID2110XDS100_ID2610$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qk/iar/dpp-qk.ewp
================================================
3DebugARM1General32811ICCARM23411AARM21011OBJCOPY0111CUSTOM30BICOMP0BUILDACTION1ILINK02011IARCHIVE0011BILINK0Coder0ReleaseARM0General32810ICCARM23410AARM21010OBJCOPY0110CUSTOM30BICOMP0BUILDACTION1ILINK02010IARCHIVE0010BILINK0Coder0Application$PROJ_DIR$\..\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\dpp.h$PROJ_DIR$\..\..\main.c$PROJ_DIR$\..\..\philo.c$PROJ_DIR$\..\..\table.cnucleo-l053r8$PROJ_DIR$\..\..\..\..\..\3rd_party\nucleo-l053r8\iar\startup_stm32l053xx.s$PROJ_DIR$\..\..\..\..\..\3rd_party\nucleo-l053r8\stm32l053xx.h$PROJ_DIR$\..\..\..\..\..\3rd_party\nucleo-l053r8\stm32l0xx.h$PROJ_DIR$\..\..\..\..\..\3rd_party\nucleo-l053r8\system_stm32l0xx.c$PROJ_DIR$\..\..\..\..\..\3rd_party\nucleo-l053r8\system_stm32l0xx.hQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qkn\qkn.cQP_port$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qk\iar\qfn_port.h$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qk\iar\qkn_port.c
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qk/iar/dpp-qk.eww
================================================
$WS_DIR$\dpp-qk.ewp
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qk/iar/dpp-qk.icf
================================================
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0800FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20001FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 1024;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place in RAM_region { readwrite,
block CSTACK, block HEAP };
define symbol __region_EEPROM_start__ = 0x08080000;
define symbol __region_EEPROM_end__ = 0x080807FF;
define region EEPROM_region = mem:[from __region_EEPROM_start__ to __region_EEPROM_end__];
place in EEPROM_region { section .eeprom };
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qpn_conf.h
================================================
/*****************************************************************************
* Product: QP-nano configuration for the Blinky example
* Last Updated for Version: 6.1.1
* Date of the Last Update: 2018-02-18
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef QPN_CONF_H
#define QPN_CONF_H
#define Q_PARAM_SIZE 4U
#define QF_MAX_TICK_RATE 1U
#define QF_TIMEEVT_CTR_SIZE 2U
#define QF_TIMEEVT_PERIODIC
#define QK_ON_CONTEXT_SW
#endif /* QPN_CONF_H */
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qv/armclang/README.txt
================================================
About this Example
==================
This example demonstrates how to use the uVision IDE together with
the MDK-ARM toolchain.
***
NOTE: This example requires installing the following Software Pack
in the Keil uVision: Keil::STM32L0xx_DFP.
***
uVision Project File
====================
The MDK-ARM uVision project file provided with this example uses
relative paths to the QP/C framework location (includes, port, and
libraries. These relative paths must be modified when the project
is moved to different relative location.
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the
command-line options for the ARM assembler (see the Asm tab in
the "Options for Target" dialog box in uVision). Specifically,
you should define symbols: Stack_Size=xxx Heap_Size=yyy, where
xxx represents a numerical value of stack size and yyy the
numberical value of the heap size.
Startup Code
============
The startup code for the STM32L1xx MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\nucleo-l053r8\arm\startup_stm32l053xx.s
The file startup_stm32l053xx.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
Adjusting the CPU Clock Speed
=============================
The current setting is to run at 2MHz from the MSI (internal oscillator),
but the CPU clock speed can be modified by editing the file
system_stm32l1xx.c. Ther file system_stm32l0xx.c.pll provides an example
of clock setting using the PLL driven from the MSE.
***
NOTE:
The NUCLEO boards have a wide range of possible clock selections, depending
on the solder bridge configuration. Please see Chapter 5.7 "OSC clock" in
the STM32 NUCLEO Boards User Manual (ST document UM1724) for more information.
***
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qv/armclang/dpp-qv.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj; *.o*.lib*.txt; *.h; *.inc*.plm*.cpp000dpp-dbg0x4ARM-ADS120000001101016553500079668.\dbg\111011010000111111100101180111111111111101011001005STLink\ST-LINKIII-KEIL_SWO.dll0UL2CM3UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32L0xx_64 -FS08000000 -FL010000 -FP0($$Device:STM32L053R8Tx$CMSIS\Flash\STM32L0xx_64.FLM))0ST-LINKIII-KEIL_SWO-U066CFF484951775087074312 -O8431 -SF480 -C0 -A0 -I0 -HNlocalhost -HP7184 -P2 -N00("ARM CoreSight SW-DP") -D00(0BC11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8004 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC800 -FN1 -FF0STM32L0xx_64.FLM -FS08000000 -FL010000 -FP0($$Device:STM32L053R8Tx$CMSIS\Flash\STM32L0xx_64.FLM)0DLGUARM(105=-1,-1,-1,-1,0)0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)0ARMDBGFLAGS120x200002000200x40000001000010000000000000000000100210000000dpp-rel0x4ARM-ADS120000001101016553500079668.\rel\111011010000111111100100180111111111111101011001005STLink\ST-LINKIII-KEIL_SWO.dll0UL2CM3UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32L0xx_64 -FS08000000 -FL010000 -FP0($$Device:STM32L053R8Tx$CMSIS\Flash\STM32L0xx_64.FLM))0ST-LINKIII-KEIL_SWO-U066CFF484951775087074312 -O8431 -SF4000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P2 -N00("ARM CoreSight SW-DP") -D00(0BC11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32L0xx_64.FLM -FS08000000 -FL010000 -FP0($$Device:STM32L053R8Tx$CMSIS\Flash\STM32L0xx_64.FLM)0DLGUARM(105=-1,-1,-1,-1,0)0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)0ARMDBGFLAGS120x200002000200x40000001000010000000000000000000100210000000Source Code1000111000..\bsp.cbsp.c00125000..\..\bsp.hbsp.h00135000..\..\dpp.hdpp.h00141000..\..\main.cmain.c00151000..\..\philo.cphilo.c00161000..\..\table.ctable.c00nucleo-l053r81000275000..\..\..\..\..\3rd_party\nucleo-l053r8\stm32l0xx.hstm32l0xx.h00285000..\..\..\..\..\3rd_party\nucleo-l053r8\stm32l053xx.hstm32l053xx.h00291000..\..\..\..\..\3rd_party\nucleo-l053r8\system_stm32l0xx.csystem_stm32l0xx.c002105000..\..\..\..\..\3rd_party\nucleo-l053r8\system_stm32l0xx.hsystem_stm32l0xx.h002112000..\..\..\..\..\3rd_party\nucleo-l053r8\arm\startup_stm32l053xx.sstartup_stm32l053xx.s00QP10003121000..\..\..\..\..\src\qfn\qepn.cqepn.c003131000..\..\..\..\..\src\qfn\qfn.cqfn.c003141000..\..\..\..\..\src\qvn\qvn.cqvn.c00QP_port10004155000..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqfn_port.h004161000..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.cqvn_port.c00
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qv/armclang/dpp-qv.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwaredpp-dbg0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1STM32L053R8TxSTMicroelectronicsKeil.STM32L0xx_DFP.2.0.0http://www.keil.com/pack/IRAM(0x20000000,0x00002000) IROM(0x08000000,0x00010000) CPUTYPE("Cortex-M0+") CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32L0xx_64 -FS08000000 -FL010000 -FP0($$Device:STM32L053R8Tx$Flash\STM32L0xx_64.FLM))0$$Device:STM32L053R8Tx$Device\Include\stm32l0xx.h$$Device:STM32L053R8Tx$SVD\STM32L053x.svd0000001.\dbg\dpp-qv10011.\dbg\10000000000000010fromelf --bin --output .\dbg\dpp-qv.bin .\dbg\dpp-qv.axf00000000001000031SARMCM3.DLL -REMAP DARMCM1.DLL-pCM0+SARMCM3.DLLTARMCM1.DLL-pCM0+1000161001140961BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M0+"0001100000080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x200010x80000000x1000000x00x010x00x010x00x010x00x010x80000000x1000010x00x000x00x000x00x000x00x000x200000000x200000x00x007001000003010003311000..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\nucleo-l053r81000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerSource Codebsp.c1..\bsp.cbsp.h5..\..\bsp.hdpp.h5..\..\dpp.hmain.c1..\..\main.cphilo.c1..\..\philo.ctable.c1..\..\table.cnucleo-l053r8stm32l0xx.h5..\..\..\..\..\3rd_party\nucleo-l053r8\stm32l0xx.hstm32l053xx.h5..\..\..\..\..\3rd_party\nucleo-l053r8\stm32l053xx.hsystem_stm32l0xx.c1..\..\..\..\..\3rd_party\nucleo-l053r8\system_stm32l0xx.csystem_stm32l0xx.h5..\..\..\..\..\3rd_party\nucleo-l053r8\system_stm32l0xx.hstartup_stm32l053xx.s2..\..\..\..\..\3rd_party\nucleo-l053r8\arm\startup_stm32l053xx.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.cdpp-rel0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1STM32L053R8TxSTMicroelectronicsKeil.STM32L0xx_DFP.2.0.0http://www.keil.com/pack/IRAM(0x20000000,0x00002000) IROM(0x08000000,0x00010000) CPUTYPE("Cortex-M0+") CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32L0xx_64 -FS08000000 -FL010000 -FP0($$Device:STM32L053R8Tx$Flash\STM32L0xx_64.FLM))0$$Device:STM32L053R8Tx$Device\Include\stm32l0xx.h$$Device:STM32L053R8Tx$SVD\STM32L053x.svd0000001.\rel\dpp-qv10000.\rel\10000000000000010fromelf --bin --output .\rel\dpp-qv.bin .\rel\dpp-qv.axf00000000001000031SARMCM3.DLL -REMAP DARMCM1.DLL-pCM0+SARMCM3.DLLTARMCM1.DLL-pCM0+1000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M0+"0001100000080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x200010x80000000x1000000x00x010x00x010x00x010x00x010x80000000x1000010x00x000x00x000x00x000x00x000x200000000x200000x00x007001000003010003311000NDEBUG..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\nucleo-l053r81000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000dpp-qv.sct--entry Reset_HandlerSource Codebsp.c1..\bsp.cbsp.h5..\..\bsp.hdpp.h5..\..\dpp.hmain.c1..\..\main.cphilo.c1..\..\philo.ctable.c1..\..\table.cnucleo-l053r8stm32l0xx.h5..\..\..\..\..\3rd_party\nucleo-l053r8\stm32l0xx.hstm32l053xx.h5..\..\..\..\..\3rd_party\nucleo-l053r8\stm32l053xx.hsystem_stm32l0xx.c1..\..\..\..\..\3rd_party\nucleo-l053r8\system_stm32l0xx.csystem_stm32l0xx.h5..\..\..\..\..\3rd_party\nucleo-l053r8\system_stm32l0xx.hstartup_stm32l053xx.s2..\..\..\..\..\3rd_party\nucleo-l053r8\arm\startup_stm32l053xx.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.c
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qv/bsp.c
================================================
/*****************************************************************************
* Product: DPP on STM32 NUCLEO-L053R8 board, cooperative QV kernel
** Last Updated for Version: 5.5.1
* Date of the Last Update: 2015-10-05
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "dpp.h"
#include "bsp.h"
#include "stm32l0xx.h" /* CMSIS-compliant header file for the MCU used */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
enum KernelAwareISRs {
GPIOPORTA_PRIO = QF_AWARE_ISR_CMSIS_PRI, /* see NOTE00 */
SYSTICK_PRIO,
/* ... */
MAX_KERNEL_AWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-aware" interrupts should not overlap the PendSV priority */
Q_ASSERT_COMPILE(MAX_KERNEL_AWARE_CMSIS_PRI <= (0xFF >>(8-__NVIC_PRIO_BITS)));
/* ISRs defined in this BSP ------------------------------------------------*/
void SysTick_Handler(void);
/* Local-scope objects -----------------------------------------------------*/
/* LED pins available on the board (just one user LED LD2--Green on PA.5) */
#define LED_LD2 (1U << 5)
/* Button pins available on the board (just one user Button B1 on PC.13) */
#define BTN_B1 (1U << 13)
/* random seed */
static uint32_t l_rnd;
/* ISRs used in this project ===============================================*/
void SysTick_Handler(void) {
/* state of the button debouncing, see below */
static struct ButtonsDebouncing {
uint32_t depressed;
uint32_t previous;
} buttons = { ~0U, ~0U };
uint32_t current;
uint32_t tmp;
QF_tickXISR(0U); /* process time events for rate 0 */
/* Perform the debouncing of buttons. The algorithm for debouncing
* adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
* and Michael Barr, page 71.
*/
current = ~GPIOC->IDR; /* read Port C with the state of Button B1 */
tmp = buttons.depressed; /* save the debounced depressed buttons */
buttons.depressed |= (buttons.previous & current); /* set depressed */
buttons.depressed &= (buttons.previous | current); /* clear released */
buttons.previous = current; /* update the history */
tmp ^= buttons.depressed; /* changed debounced depressed */
if ((tmp & BTN_B1) != 0U) { /* debounced B1 state changed? */
if ((buttons.depressed & BTN_B1) != 0U) { /* is B1 depressed? */
QACTIVE_POST_ISR(&AO_Table, PAUSE_SIG, 0U);
}
else { /* the button is released */
QACTIVE_POST_ISR(&AO_Table, SERVE_SIG, 0U);
}
}
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* NOTE: SystemInit() has been already called from the startup code
* but SystemCoreClock needs to be updated
*/
SystemCoreClockUpdate();
/* enable GPIOA clock port for the LED LD2 */
RCC->IOPENR |= (1U << 0);
/* configure LED (PA.5) pin as push-pull output, no pull-up, pull-down */
GPIOA->MODER &= ~((3U << 2*5));
GPIOA->MODER |= ((1U << 2*5));
GPIOA->OTYPER &= ~((1U << 5));
GPIOA->OSPEEDR &= ~((3U << 2*5));
GPIOA->OSPEEDR |= ((1U << 2*5));
GPIOA->PUPDR &= ~((3U << 2*5));
/* enable GPIOC clock port for the Button B1 */
RCC->IOPENR |= (1U << 2);
/* configure Button (PC.13) pins as input, no pull-up, pull-down */
GPIOC->MODER &= ~(3U << 2*13);
GPIOC->OSPEEDR &= ~(3U << 2*13);
GPIOC->OSPEEDR |= (1U << 2*13);
GPIOC->PUPDR &= ~(3U << 2*13);
BSP_randomSeed(1234U); /* seed the random number generator */
}
/*..........................................................................*/
void BSP_displayPhilStat(uint8_t n, char const *stat) {
if (stat[0] == 'h') {
GPIOA->BSRR |= LED_LD2; /* turn LED on */
}
else {
GPIOA->BSRR |= (LED_LD2 << 16); /* turn LED off */
}
}
/*..........................................................................*/
void BSP_displayPaused(uint8_t paused) {
/* not enough LEDs to implement this feature */
if (paused != (uint8_t)0) {
//GPIOA->BSRR |= (LED_LD2); /* turn LED[n] on */
}
else {
//GPIOA->BSRR |= (LED_LD2 << 16); /* turn LED[n] off */
}
}
/*..........................................................................*/
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
l_rnd = l_rnd * (3U*7U*11U*13U*23U);
return l_rnd >> 8;
}
/*..........................................................................*/
void BSP_randomSeed(uint32_t seed) {
l_rnd = seed;
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
(void)result;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set up the SysTick timer to fire at BSP_TICKS_PER_SEC rate */
SysTick_Config(SystemCoreClock / BSP_TICKS_PER_SEC);
/* set priorities of ALL ISRs used in the system, see NOTE00
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
NVIC_SetPriority(SysTick_IRQn, SYSTICK_PRIO);
/* ... */
/* enable IRQs... */
}
/*..........................................................................*/
void QV_onIdle(void) { /* called with interrupts disabled, see NOTE1 */
/* toggle an LED on and then off (not enough LEDs, see NOTE2) */
//GPIOA->BSRR |= (LED_LD2); /* turn LED[n] on */
//GPIOA->BSRR |= (LED_LD2 << 16); /* turn LED[n] off */
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular Cortex-M3 MCU.
*/
/* !!!CAUTION!!!
* The WFI instruction stops the CPU clock, which unfortunately disables
* the JTAG port, so the ST-Link debugger can no longer connect to the
* board. For that reason, the call to __WFI() has to be used with CAUTION.
*
* NOTE: If you find your board "frozen" like this, strap BOOT0 to VDD and
* reset the board, then connect with ST-Link Utilities and erase the part.
* The trick with BOOT(0) is it gets the part to run the System Loader
* instead of your broken code. When done disconnect BOOT0, and start over.
*/
//QV_CPU_SLEEP(); /* atomically go to sleep and enable interrupts */
QF_INT_ENABLE(); /* for now, just enable interrupts */
#else
QF_INT_ENABLE(); /* just enable interrupts */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int loc) {
/*
* NOTE: add here your application-specific error handling
*/
(void)module;
(void)loc;
NVIC_SystemReset();
}
/*****************************************************************************
* NOTE1:
* The QV_onIdle() callback is called with interrupts disabled, because the
* determination of the idle condition might change by any interrupt posting
* an event. QV_onIdle() must internally enable interrupts, ideally
* atomically with putting the CPU to the power-saving mode.
*
* NOTE2:
* One of the LEDs is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qv/gnu/.cproject
================================================
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qv/gnu/.project
================================================
dpp-qv_nucleo-l053r8org.eclipse.cdt.managedbuilder.core.genmakebuilderclean,full,incremental,org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilderfull,incremental,org.eclipse.cdt.core.cnatureorg.eclipse.cdt.managedbuilder.core.managedBuildNatureorg.eclipse.cdt.managedbuilder.core.ScannerConfigNatureQP-nano2$%7BPARENT-5-PROJECT_LOC%7D/src/qfnQP_port2$%7BPARENT-5-PROJECT_LOC%7D/ports/arm-cm/qv/gnuQV-nano2$%7BPARENT-5-PROJECT_LOC%7D/src/qvnbsp.c1$%7BPARENT-1-PROJECT_LOC%7D/bsp.cbsp.h1$%7BPARENT-2-PROJECT_LOC%7D/bsp.hdpp.h1$%7BPARENT-2-PROJECT_LOC%7D/dpp.hmain.c1$%7BPARENT-2-PROJECT_LOC%7D/main.cnucleo-l053r82$%7BPARENT-5-PROJECT_LOC%7D/3rd_party/nucleo-l053r8philo.c1$%7BPARENT-2-PROJECT_LOC%7D/philo.cqstamp.c1$%7BPARENT-5-PROJECT_LOC%7D/include/qstamp.ctable.c1$%7BPARENT-2-PROJECT_LOC%7D/table.c
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qv/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano on NUCLEO-L053R8, QV-nano kernel, GNU-ARM
# Last Updated for Version: 6.5.0
# Date of the Last Update: 2019-04-15
#
# Q u a n t u m L e a P s
# ------------------------
# Modern Embedded Software
#
# Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# https://www.state-machine.com
# mailto:info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := dpp-qv
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/arm-cm/qv/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qvn \
$(QP_PORT_DIR) \
$(QPN)/3rd_party/nucleo-l053r8 \
$(QPN)/3rd_party/nucleo-l053r8/gnu
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR) \
-I$(QPN)/3rd_party/CMSIS/Include \
-I$(QPN)/3rd_party/nucleo-l053r8
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
bsp.c \
main.c \
philo.c \
table.c \
system_stm32l0xx.c \
startup_stm32l053xx.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qepn.c \
qfn.c \
qvn.c
QP_ASMS :=
LIB_DIRS :=
LIBS :=
# defines
DEFINES :=
# ARM CPU, ARCH, FPU, and Float-ABI types...
# ARM_CPU: [cortex-m0 | cortex-m0plus | cortex-m1 | cortex-m3 | cortex-m4]
# ARM_ARCH: [6 | 7] (NOTE: must match ARM_CPU!)
# ARM_FPU: [ | vfp]
# FLOAT_ABI: [ | soft | softfp | hard]
#
ARM_CPU := -mcpu=cortex-m0plus
ARM_ARCH := 6 # NOTE: must match the ARM_CPU!
ARM_FPU :=
FLOAT_ABI :=
#-----------------------------------------------------------------------------
# GNU-ARM toolset (NOTE: You need to adjust to your machine)
# see https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
#
ifeq ($(GNU_ARM),)
GNU_ARM := $(QTOOLS)/gnu_arm-none-eabi
endif
# make sure that the GNU-ARM toolset exists...
ifeq ("$(wildcard $(GNU_ARM))","")
$(error GNU_ARM toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_ARM)/bin/arm-none-eabi-gcc
CPP := $(GNU_ARM)/bin/arm-none-eabi-g++
AS := $(GNU_ARM)/bin/arm-none-eabi-as
LINK := $(GNU_ARM)/bin/arm-none-eabi-g++
BIN := $(GNU_ARM)/bin/arm-none-eabi-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M
#
# combine all the soruces...
C_SRCS += $(QP_SRCS)
ASM_SRCS += $(QP_ASMS)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS = $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O2 $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O2 $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration ..........................................
BIN_DIR := dbg
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O2 $(INCLUDES) $(DEFINES)
CPPFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O2 $(INCLUDES) $(DEFINES)
endif # ......................................................................
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
-specs=nosys.specs -specs=nano.specs \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_BIN := $(BIN_DIR)/$(OUTPUT).bin
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_BIN)
#all: $(TARGET_ELF)
$(TARGET_BIN): $(TARGET_ELF)
$(BIN) -O binary $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(CC) $(CFLAGS) $(QPN)/include/qstamp.c -o $(BIN_DIR)/qstamp.o
$(LINK) $(LINKFLAGS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.bin \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qv/gnu/dpp-qv.ld
================================================
/*****************************************************************************
* Product: Linker script for for STM32L053R8, GNU-ARM linker
* Last Updated for Version: 5.9.8
* Date of the Last Update: 2017-09-13
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* https://state-machine.com
* mailto:info@state-machine.com
*****************************************************************************/
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(Reset_Handler) /* entry Point */
MEMORY { /* memory map of STM32L053R8 */
ROM (rx) : ORIGIN = 0x08000000, LENGTH = 64K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 8K
}
/* The size of the stack used by the application. NOTE: you need to adjust */
STACK_SIZE = 1024;
/* The size of the heap used by the application. NOTE: you need to adjust */
HEAP_SIZE = 0;
SECTIONS {
.isr_vector : { /* the vector table goes FIRST into ROM */
KEEP(*(.isr_vector)) /* vector table */
. = ALIGN(4);
} >ROM
.text : { /* code and constants */
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} >ROM
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >ROM
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >ROM
.fini_array : {
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array*))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >ROM
_etext = .; /* global symbols at end of code */
.stack : {
__stack_start__ = .;
. = . + STACK_SIZE;
. = ALIGN(4);
__stack_end__ = .;
} >RAM
.data : AT (_etext) {
__data_load = LOADADDR (.data);
__data_start = .;
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
__data_end__ = .;
_edata = __data_end__;
} >RAM
.bss : {
__bss_start__ = .;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = .;
} >RAM
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >RAM
__exidx_end = .;
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );
PROVIDE ( __end__ = _ebss );
.heap : {
__heap_start__ = .;
. = . + HEAP_SIZE;
. = ALIGN(4);
__heap_end__ = .;
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ : {
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
}
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qv/iar/dpp-qv.ewd
================================================
3DebugARM1C-SPY22811ARMSIM_ID2111CADI_ID2011CMSISDAP_ID2411GDBSERVER_ID2011IJET_ID2811JLINK_ID21611LMIFTDI_ID2211PEMICRO_ID2311STLINK_ID2411THIRDPARTY_ID2011TIFET_ID2111XDS100_ID2611$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseARM0C-SPY22810ARMSIM_ID2110CADI_ID2010CMSISDAP_ID2410GDBSERVER_ID2010IJET_ID2810JLINK_ID21610LMIFTDI_ID2210PEMICRO_ID2310STLINK_ID2410THIRDPARTY_ID2010TIFET_ID2110XDS100_ID2610$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qv/iar/dpp-qv.ewp
================================================
3DebugARM1General32811ICCARM23411AARM21011OBJCOPY0111CUSTOM30BICOMP0BUILDACTION1ILINK02011IARCHIVE0011BILINK0Coder0ReleaseARM0General32810ICCARM23410AARM21010OBJCOPY0110CUSTOM30BICOMP0BUILDACTION1ILINK02010IARCHIVE0010BILINK0Coder0Application$PROJ_DIR$\..\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\dpp.h$PROJ_DIR$\..\..\main.c$PROJ_DIR$\..\..\philo.c$PROJ_DIR$\..\..\table.cnucleo-l053r8$PROJ_DIR$\..\..\..\..\..\3rd_party\nucleo-l053r8\iar\startup_stm32l053xx.s$PROJ_DIR$\..\..\..\..\..\3rd_party\nucleo-l053r8\stm32l053xx.h$PROJ_DIR$\..\..\..\..\..\3rd_party\nucleo-l053r8\stm32l0xx.h$PROJ_DIR$\..\..\..\..\..\3rd_party\nucleo-l053r8\system_stm32l0xx.c$PROJ_DIR$\..\..\..\..\..\3rd_party\nucleo-l053r8\system_stm32l0xx.hQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qvn\qvn.cQP_port$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qv\iar\qfn_port.h$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qv\iar\qvn_port.c
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qv/iar/dpp-qv.eww
================================================
$WS_DIR$\dpp-qv.ewp
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/qv/iar/dpp-qv.icf
================================================
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0800FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20001FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 1024;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place in RAM_region { readwrite,
block CSTACK, block HEAP };
define symbol __region_EEPROM_start__ = 0x08080000;
define symbol __region_EEPROM_end__ = 0x080807FF;
define region EEPROM_region = mem:[from __region_EEPROM_start__ to __region_EEPROM_end__];
place in EEPROM_region { section .eeprom };
================================================
FILE: examples/arm-cm/dpp_nucleo-l053r8/table.c
================================================
/*.$file${.::table.c} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: dpp.qm
* File: ${.::table.c}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::table.c} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("table")
/* Active object class -----------------------------------------------------*/
/*.$declare${AOs::Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table} ...........................................................*/
typedef struct Table {
/* protected: */
QActive super;
/* private: */
uint8_t fork[N_PHILO];
uint8_t isHungry[N_PHILO];
} Table;
/* protected: */
static QState Table_initial(Table * const me);
static QState Table_active(Table * const me);
static QState Table_serving(Table * const me);
static QState Table_paused(Table * const me);
/*.$enddecl${AOs::Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Global objects ----------------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*. Check for the minimum required QP version */
#if (QP_VERSION < 650U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpn version 6.5.0 or higher required
#endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Table} ........................................................*/
struct Table AO_Table;
/*.$enddef${AOs::AO_Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#define RIGHT(n_) ((uint8_t)(((n_) + (N_PHILO - 1U)) % N_PHILO))
#define LEFT(n_) ((uint8_t)(((n_) + 1U) % N_PHILO))
#define FREE ((uint8_t)0)
#define USED ((uint8_t)1)
/*..........................................................................*/
/*.$define${AOs::Table_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table_ctor} ......................................................*/
void Table_ctor(void) {
uint8_t n;
Table *me = &AO_Table;
QActive_ctor(&me->super, Q_STATE_CAST(&Table_initial));
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
}
}
/*.$enddef${AOs::Table_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table} ...........................................................*/
/*.${AOs::Table::SM} .......................................................*/
static QState Table_initial(Table * const me) {
/*.${AOs::Table::SM::initial} */
uint8_t n;
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "thinking");
}
return Q_TRAN(&Table_serving);
}
/*.${AOs::Table::SM::active} ...............................................*/
static QState Table_active(Table * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Table::SM::active::TERMINATE} */
case TERMINATE_SIG: {
BSP_terminate(0);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::EAT} */
case EAT_SIG: {
Q_ERROR();
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Table::SM::active::serving} ......................................*/
static QState Table_serving(Table * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Table::SM::active::serving} */
case Q_ENTRY_SIG: {
uint8_t n;
for (n = 0U; n < N_PHILO; ++n) { /* give permissions to eat... */
if ((me->isHungry[n] != 0U)
&& (me->fork[LEFT(n)] == FREE)
&& (me->fork[n] == FREE))
{
QActive *philo;
me->fork[LEFT(n)] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "eating ");
}
}
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::serving::HUNGRY} */
case HUNGRY_SIG: {
uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "hungry ");
m = LEFT(n);
/*.${AOs::Table::SM::active::serving::HUNGRY::[bothfree]} */
if ((me->fork[m] == FREE) && (me->fork[n] == FREE)) {
me->fork[m] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
BSP_displayPhilStat(n, "eating ");
status_ = Q_HANDLED();
}
/*.${AOs::Table::SM::active::serving::HUNGRY::[else]} */
else {
me->isHungry[n] = 1U;
status_ = Q_HANDLED();
}
break;
}
/*.${AOs::Table::SM::active::serving::DONE} */
case DONE_SIG: {
uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;
m = RIGHT(n); /* check the right neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[m] == FREE)) {
me->fork[n] = USED;
me->fork[m] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}
m = LEFT(n); /* check the left neighbor */
n = LEFT(m); /* left fork of the left neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[n] == FREE)) {
me->fork[m] = USED;
me->fork[n] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::serving::EAT} */
case EAT_SIG: {
Q_ERROR();
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::serving::PAUSE} */
case PAUSE_SIG: {
status_ = Q_TRAN(&Table_paused);
break;
}
default: {
status_ = Q_SUPER(&Table_active);
break;
}
}
return status_;
}
/*.${AOs::Table::SM::active::paused} .......................................*/
static QState Table_paused(Table * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Table::SM::active::paused} */
case Q_ENTRY_SIG: {
BSP_displayPaused(1U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::paused} */
case Q_EXIT_SIG: {
BSP_displayPaused(0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::paused::SERVE} */
case SERVE_SIG: {
status_ = Q_TRAN(&Table_serving);
break;
}
/*.${AOs::Table::SM::active::paused::HUNGRY} */
case HUNGRY_SIG: {
uint8_t n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* philo ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
me->isHungry[n] = 1U;
BSP_displayPhilStat(n, "hungry ");
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::paused::DONE} */
case DONE_SIG: {
uint8_t n, m;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&Table_active);
break;
}
}
return status_;
}
/*.$enddef${AOs::Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/README.txt
================================================
About this Example
==================
This directory contains the "Dining Philosophers Problem" (DPP) example
for CMSIS-RTOS RTX application running on the STM32 NUCLEO-L152RE board
(ARM Cortex-M3). This directory contains portable code that should
compile with any C compiler for ARM Cortex-M.
The sub-directories contain code and project files, which are specific to
the particular ARM toolchains, such as ARM (MDK-ARM) and IAR.
Please refer to the README files in the sub-directories for specific
instructions how to use and customize the example to your needs.
Support Code for NUCLEO-L152RE Board
====================================
The directory qpc\3rd_party\nucleo-l152re contains the CMSIS-compliant
device code for the STM32L152xx MCUs (ARM Cortex-M3). Please see the
README.txt file in this folder for more details.
Adjusting the CPU Clock Speed
=============================
The current setting is to run at 2MHz from the MSI (internal oscillator),
but the CPU clock speed can be modified by editing the file
system_stm32l1xx.c. Ther file system_stm32l1xx_pll.c provides an example
of clock setting using the PLL driven from the MSE.
***
NOTE:
The NUCLEO boards have a wide range of possible clock selections, depending
on the solder bridge configuration. Please see Chapter 5.7 "OSC clock" in
the STM32 NUCLEO Boards User Manual (ST document UM1724) for more information.
***
QS Software Tracing Instrumentation
===================================
This example provides the "Spy" build configuration, which outputs the QS
(Quantum Spy) software tracing data through UART2, which is connected to
the virtual COM port of the ST-Link debugger.
The output is generated at 115200 baud rate.
Here is an example invocation of the QSPY host application to receive
the QS data from NUCLEO-L152RE:
qspy -cCOM20
The actual COM port number might be different on your Windows machine.
Please check the Device Manager to find the COM port number.
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/README.url
================================================
[InternetShortcut]
URL=http://www.state-machine.com/qpn/arm-cm_dpp_nucleo-l152re.html
IconFile=http://www.state-machine.com/qp.ico
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/bsp.h
================================================
/*****************************************************************************
* Product: DPP example
* Last Updated for Version: 5.4.0
* Date of the Last Update: 2015-03-07
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* Web : www.state-machine.com
*
*****************************************************************************/
#ifndef BSP_H
#define BSP_H
#define BSP_TICKS_PER_SEC 100U
void BSP_init(void);
void BSP_displayPaused(uint8_t paused);
void BSP_displayPhilStat(uint8_t n, char_t const *stat);
void BSP_terminate(int16_t result);
void BSP_randomSeed(uint32_t seed); /* random seed */
uint32_t BSP_random(void); /* pseudo-random generator */
#endif /* BSP_H */
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/dpp.h
================================================
/*.$file${.::dpp.h} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: dpp.qm
* File: ${.::dpp.h}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::dpp.h} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#ifndef DPP_H
#define DPP_H
enum DPPSignals {
EAT_SIG = Q_USER_SIG, /* published by Table to let a philosopher eat */
DONE_SIG, /* published by Philosopher when done eating */
PAUSE_SIG, /* published by BSP to pause the application */
SERVE_SIG, /* published by BSP to pause the application */
TERMINATE_SIG, /* published by BSP to terminate the application */
HUNGRY_SIG, /* posted direclty to Table from hungry Philo */
MAX_SIG /* the last signal */
};
/* number of philosophers */
#define N_PHILO ((uint8_t)5)
#define PHILO_0_PRIO 1
/*.$declare${AOs::AO_Philo0} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo0;
/*.$enddecl${AOs::AO_Philo0} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo1} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo1;
/*.$enddecl${AOs::AO_Philo1} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo2} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo2;
/*.$enddecl${AOs::AO_Philo2} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo3} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo3;
/*.$enddecl${AOs::AO_Philo3} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo4} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo4;
/*.$enddecl${AOs::AO_Philo4} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Table AO_Table;
/*.$enddecl${AOs::AO_Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::Philo_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo_ctor} ......................................................*/
void Philo_ctor(void);
/*.$enddecl${AOs::Philo_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::Table_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table_ctor} ......................................................*/
void Table_ctor(void);
/*.$enddecl${AOs::Table_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#endif /* DPP_H */
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/dpp.qm
================================================
Dining Philosopher Problem example with QActiveQActive_armX(&me->super, 0U, THINK_TIME, 0U);QActive_disarmX(&me->super, 0U);Q_ERROR(); /* these events should never arrive in this state */QACTIVE_POST(&AO_Table, HUNGRY_SIG, me->super.prio);Q_ERROR(); /* this event should never arrive in this state */QActive_armX(&me->super, 0U, EAT_TIME, 0U);QActive_disarmX(&me->super, 0U);
QACTIVE_POST(QF_ACTIVE_CAST(&AO_Table), DONE_SIG, me->super.prio);Q_ERROR(); /* these events should never arrive in this state */uint8_t n;
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "thinking");
}BSP_terminate(0);Q_ERROR();uint8_t n;
for (n = 0U; n < N_PHILO; ++n) { /* give permissions to eat... */
if ((me->isHungry[n] != 0U)
&& (me->fork[LEFT(n)] == FREE)
&& (me->fork[n] == FREE))
{
QActive *philo;
me->fork[LEFT(n)] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "eating ");
}
}uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "hungry ");
m = LEFT(n);(me->fork[m] == FREE) && (me->fork[n] == FREE)me->fork[m] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
BSP_displayPhilStat(n, "eating ");elseme->isHungry[n] = 1U;uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;
m = RIGHT(n); /* check the right neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[m] == FREE)) {
me->fork[n] = USED;
me->fork[m] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}
m = LEFT(n); /* check the left neighbor */
n = LEFT(m); /* left fork of the left neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[n] == FREE)) {
me->fork[m] = USED;
me->fork[n] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}Q_ERROR();BSP_displayPaused(1U);BSP_displayPaused(0U);uint8_t n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* philo ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
me->isHungry[n] = 1U;
BSP_displayPhilStat(n, "hungry ");uint8_t n, m;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;QActive_ctor(&AO_Philo0.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo1.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo2.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo3.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo4.super, Q_STATE_CAST(&Philo_initial));
BSP_randomSeed(123U);uint8_t n;
Table *me = &AO_Table;
QActive_ctor(&me->super, Q_STATE_CAST(&Table_initial));
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
}#ifndef DPP_H
#define DPP_H
enum DPPSignals {
EAT_SIG = Q_USER_SIG, /* published by Table to let a philosopher eat */
DONE_SIG, /* published by Philosopher when done eating */
PAUSE_SIG, /* published by BSP to pause the application */
SERVE_SIG, /* published by BSP to pause the application */
TERMINATE_SIG, /* published by BSP to terminate the application */
HUNGRY_SIG, /* posted direclty to Table from hungry Philo */
MAX_SIG /* the last signal */
};
/* number of philosophers */
#define N_PHILO ((uint8_t)5)
#define PHILO_0_PRIO 1
$declare${AOs::AO_Philo0}
$declare${AOs::AO_Philo1}
$declare${AOs::AO_Philo2}
$declare${AOs::AO_Philo3}
$declare${AOs::AO_Philo4}
$declare${AOs::AO_Table}
$declare${AOs::Philo_ctor}
$declare${AOs::Table_ctor}
#endif /* DPP_H */
#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("philo")
/* Active object class -----------------------------------------------------*/
$declare${AOs::Philo}
/* Global objects ----------------------------------------------------------*/
$define${AOs::AO_Philo0}
$define${AOs::AO_Philo1}
$define${AOs::AO_Philo2}
$define${AOs::AO_Philo3}
$define${AOs::AO_Philo4}
/* Local objects -----------------------------------------------------------*/
#define THINK_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + (BSP_TICKS_PER_SEC/2U))
#define EAT_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + BSP_TICKS_PER_SEC)
/* Philo definition --------------------------------------------------------*/
$define${AOs::Philo_ctor}
$define${AOs::Philo}#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("table")
/* Active object class -----------------------------------------------------*/
$declare${AOs::Table}
/* Global objects ----------------------------------------------------------*/
$define${AOs::AO_Table}
#define RIGHT(n_) ((uint8_t)(((n_) + (N_PHILO - 1U)) % N_PHILO))
#define LEFT(n_) ((uint8_t)(((n_) + 1U) % N_PHILO))
#define FREE ((uint8_t)0)
#define USED ((uint8_t)1)
/*..........................................................................*/
$define${AOs::Table_ctor}
$define${AOs::Table}
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/main.c
================================================
/*****************************************************************************
* Product: DPP example
* Last Updated for Version: 5.8.0
* Date of the Last Update: 2016-11-06
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h" /* QP-nano */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
/*..........................................................................*/
static QEvt l_philoQueue[N_PHILO][N_PHILO];
static QEvt l_tableQueue[2];
/* QF_active[] array defines all active object control blocks --------------*/
QActiveCB const Q_ROM QF_active[] = {
{ (QActive *)0, (QEvt *)0, 0U },
{ (QActive *)&AO_Philo0, l_philoQueue[0], Q_DIM(l_philoQueue[0]) },
{ (QActive *)&AO_Philo1, l_philoQueue[1], Q_DIM(l_philoQueue[1]) },
{ (QActive *)&AO_Philo2, l_philoQueue[2], Q_DIM(l_philoQueue[2]) },
{ (QActive *)&AO_Philo3, l_philoQueue[3], Q_DIM(l_philoQueue[3]) },
{ (QActive *)&AO_Philo4, l_philoQueue[4], Q_DIM(l_philoQueue[4]) },
{ (QActive *)&AO_Table, l_tableQueue, Q_DIM(l_tableQueue) }
};
/*..........................................................................*/
int_t main() {
Philo_ctor(); /* instantiate all Philo AOs */
Table_ctor(); /* instantiate the Table AO */
QF_init(Q_DIM(QF_active)); /* initialize the QF-nano framework */
BSP_init(); /* initialize the Board Support Package */
return QF_run(); /* transfer control to QF-nano */
}
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/philo.c
================================================
/*.$file${.::philo.c} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: dpp.qm
* File: ${.::philo.c}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::philo.c} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("philo")
/* Active object class -----------------------------------------------------*/
/*.$declare${AOs::Philo} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo} ...........................................................*/
typedef struct Philo {
/* protected: */
QActive super;
} Philo;
/* protected: */
static QState Philo_initial(Philo * const me);
static QState Philo_thinking(Philo * const me);
static QState Philo_hungry(Philo * const me);
static QState Philo_eating(Philo * const me);
/*.$enddecl${AOs::Philo} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Global objects ----------------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*. Check for the minimum required QP version */
#if (QP_VERSION < 650U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpn version 6.5.0 or higher required
#endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo0} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo0} .......................................................*/
struct Philo AO_Philo0;
/*.$enddef${AOs::AO_Philo0} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo1} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo1} .......................................................*/
struct Philo AO_Philo1;
/*.$enddef${AOs::AO_Philo1} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo2} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo2} .......................................................*/
struct Philo AO_Philo2;
/*.$enddef${AOs::AO_Philo2} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo3} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo3} .......................................................*/
struct Philo AO_Philo3;
/*.$enddef${AOs::AO_Philo3} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo4} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo4} .......................................................*/
struct Philo AO_Philo4;
/*.$enddef${AOs::AO_Philo4} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Local objects -----------------------------------------------------------*/
#define THINK_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + (BSP_TICKS_PER_SEC/2U))
#define EAT_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + BSP_TICKS_PER_SEC)
/* Philo definition --------------------------------------------------------*/
/*.$define${AOs::Philo_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo_ctor} ......................................................*/
void Philo_ctor(void) {
QActive_ctor(&AO_Philo0.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo1.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo2.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo3.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo4.super, Q_STATE_CAST(&Philo_initial));
BSP_randomSeed(123U);
}
/*.$enddef${AOs::Philo_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Philo} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo} ...........................................................*/
/*.${AOs::Philo::SM} .......................................................*/
static QState Philo_initial(Philo * const me) {
/*.${AOs::Philo::SM::initial} */
return Q_TRAN(&Philo_thinking);
}
/*.${AOs::Philo::SM::thinking} .............................................*/
static QState Philo_thinking(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Philo::SM::thinking} */
case Q_ENTRY_SIG: {
QActive_armX(&me->super, 0U, THINK_TIME, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::thinking} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::thinking::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Philo_hungry);
break;
}
/*.${AOs::Philo::SM::thinking::EAT, DONE} */
case EAT_SIG: /* intentionally fall through */
case DONE_SIG: {
Q_ERROR(); /* these events should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Philo::SM::hungry} ...............................................*/
static QState Philo_hungry(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Philo::SM::hungry} */
case Q_ENTRY_SIG: {
QACTIVE_POST(&AO_Table, HUNGRY_SIG, me->super.prio);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::hungry::EAT} */
case EAT_SIG: {
status_ = Q_TRAN(&Philo_eating);
break;
}
/*.${AOs::Philo::SM::hungry::DONE} */
case DONE_SIG: {
Q_ERROR(); /* this event should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Philo::SM::eating} ...............................................*/
static QState Philo_eating(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Philo::SM::eating} */
case Q_ENTRY_SIG: {
QActive_armX(&me->super, 0U, EAT_TIME, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::eating} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
QACTIVE_POST(QF_ACTIVE_CAST(&AO_Table), DONE_SIG, me->super.prio);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::eating::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Philo_thinking);
break;
}
/*.${AOs::Philo::SM::eating::EAT, DONE} */
case EAT_SIG: /* intentionally fall through */
case DONE_SIG: {
Q_ERROR(); /* these events should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.$enddef${AOs::Philo} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qk/armclang/README.txt
================================================
About this Example
==================
This example demonstrates how to use the uVision IDE together with
the MDK-ARM toolchain.
***
NOTE: This example requires installing the following Software Pack
in the Keil uVision: Keil::STM32L152_DFP.
***
uVision Project File
====================
The MDK-ARM uVision project file provided with this example uses
relative paths to the QP/C framework location (includes, port, and
libraries. These relative paths must be modified when the project
is moved to different relative location.
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the
command-line options for the ARM assembler (see the Asm tab in
the "Options for Target" dialog box in uVision). Specifically,
you should define symbols: Stack_Size=xxx Heap_Size=yyy, where
xxx represents a numerical value of stack size and yyy the
numberical value of the heap size.
Startup Code
============
The startup code for the STM32L1xx MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\nucleo-l152re\arm\startup_stm32l1xx.s
The file startup_stm32l1xx.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
Adjusting the CPU Clock Speed
=============================
The current setting is to run at 2MHz from the MSI (internal oscillator),
but the CPU clock speed can be modified by editing the file
system_stm32l1xx.c. Ther file system_stm32l1xx_pll.c provides an example
of clock setting using the PLL driven from the MSE.
***
NOTE:
The NUCLEO boards have a wide range of possible clock selections, depending
on the solder bridge configuration. Please see Chapter 5.7 "OSC clock" in
the STM32 NUCLEO Boards User Manual (ST document UM1724) for more information.
***
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qk/armclang/dpp-qk.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj; *.o*.lib*.txt; *.h; *.inc*.plm*.cpp000dpp-dbg0x4ARM-ADS120000001101016553500079668.\dbg\111011010000111111100101180111111111111101011001005STLink\ST-LINKIII-KEIL_SWO.dll0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0DLGUARM(105=-1,-1,-1,-1,0)0ST-LINKIII-KEIL_SWO-U066EFF495056805087184715 -I0 -O8398 -S1 -C0 -A0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32L1xx_512.FLM -FS08000000 -FL080000 -FP0($$Device:STM32L152RE$Flash\STM32L1xx_512.FLM)0UL2CM3UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32L1xx_512 -FS08000000 -FL080000 -FP0($$Device:STM32L152RE$Flash\STM32L1xx_512.FLM))002141
0
000000..\bsp.c120x200002000200x40000001000010000000000000000000dpp-rel0x4ARM-ADS120000001101016553500079668.\rel\111011010000111111100100180111111111111101011001005STLink\ST-LINKIII-KEIL_SWO.dll0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0DLGUARM(105=-1,-1,-1,-1,0)0ST-LINKIII-KEIL_SWO-U066EFF495056805087184715 -I0 -O8430 -S1 -C0 -A0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32L1xx_512.FLM -FS08000000 -FL080000 -FP0($$Device:STM32L152RE$Flash\STM32L1xx_512.FLM)0UL2CM3UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32L1xx_512 -FS08000000 -FL080000 -FP0($$Device:STM32L152RE$Flash\STM32L1xx_512.FLM))002141
0
000000..\bsp.c120x200002000200x40000001000010000000000000000000Application1000111000..\bsp.cbsp.c00125000..\..\bsp.hbsp.h00135000..\..\dpp.hdpp.h00141000..\..\main.cmain.c00151000..\..\philo.cphilo.c00165000..\..\README.txtREADME.txt00171000..\..\table.ctable.c00nucleo-l152re1000285000..\..\..\..\..\3rd_party\nucleo-l152re\README.txtREADME.txt00295000..\..\..\..\..\3rd_party\nucleo-l152re\stm32l1xx.hstm32l1xx.h002101000..\..\..\..\..\3rd_party\nucleo-l152re\system_stm32l1xx.csystem_stm32l1xx.c002115000..\..\..\..\..\3rd_party\nucleo-l152re\system_stm32l1xx.hsystem_stm32l1xx.h002122000..\..\..\..\..\3rd_party\nucleo-l152re\arm\startup_stm32l1xx.sstartup_stm32l1xx.s00QP10003131000..\..\..\..\..\src\qfn\qepn.cqepn.c003141000..\..\..\..\..\src\qfn\qfn.cqfn.c003151000..\..\..\..\..\src\qkn\qkn.cqkn.c00QP_port10004165000..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqfn_port.h004171000..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.cqkn_port.c00
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qk/armclang/dpp-qk.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwaredpp-dbg0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1STM32L152RESTMicroelectronicsKeil.STM32L1xx_DFP.1.0.2http://www.keil.com/pack/IROM(0x08000000,0x80000) IRAM(0x20000000,0x14000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32L1xx_512 -FS08000000 -FL080000 -FP0($$Device:STM32L152RE$Flash\STM32L1xx_512.FLM))0$$Device:STM32L152RE$Device\Include\STM32L1xx.h$$Device:STM32L152RE$SVD\STM32L1xx.svd0000001.\dbg\dpp-qk10011.\dbg\10000000000000010fromelf --bin --output .\dbg\dpp-qk.bin .\dbg\dpp-qk.axf00000000001000031SARMCM3.DLL -REMAP -MPUDCM.DLL-pCM3SARMCM3.DLL -MPUTCM.DLL-pCM31000161001140961BIN\UL2CM3.DLL"" ()0011111110110000011111111100"Cortex-M3"0001100000080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x1400010x80000000x8000000x00x010x00x010x00x010x00x010x80000000x8000010x00x000x00x000x00x000x00x000x200000000x1400000x00x007001000003010003311000HSE_VALUE=4000000..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\armclang;..\..\..\..\..\3rd_party\CMSIS\Include; ..\..\..\..\..\3rd_party\nucleo-l152re1000000100Stack_Size=512 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerApplicationbsp.c1..\bsp.cbsp.h5..\..\bsp.hdpp.h5..\..\dpp.hmain.c1..\..\main.cphilo.c1..\..\philo.cREADME.txt5..\..\README.txttable.c1..\..\table.cnucleo-l152reREADME.txt5..\..\..\..\..\3rd_party\nucleo-l152re\README.txtstm32l1xx.h5..\..\..\..\..\3rd_party\nucleo-l152re\stm32l1xx.hsystem_stm32l1xx.c1..\..\..\..\..\3rd_party\nucleo-l152re\system_stm32l1xx.csystem_stm32l1xx.h5..\..\..\..\..\3rd_party\nucleo-l152re\system_stm32l1xx.hstartup_stm32l1xx.s2..\..\..\..\..\3rd_party\nucleo-l152re\arm\startup_stm32l1xx.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.cdpp-rel0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1STM32L152RESTMicroelectronicsKeil.STM32L1xx_DFP.1.0.2http://www.keil.com/pack/IROM(0x08000000,0x80000) IRAM(0x20000000,0x14000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32L1xx_512 -FS08000000 -FL080000 -FP0($$Device:STM32L152RE$Flash\STM32L1xx_512.FLM))0$$Device:STM32L152RE$Device\Include\STM32L1xx.h$$Device:STM32L152RE$SVD\STM32L1xx.svd0000001.\rel\dpp-qk10000.\rel\10000000000000010fromelf --bin --output .\rel\dpp-qk.bin .\rel\dpp-qk.axf00000000001000031SARMCM3.DLL -REMAP -MPUDCM.DLL-pCM3SARMCM3.DLL -MPUTCM.DLL-pCM31000161001140961BIN\UL2CM3.DLL"" ()0011111110110000011111111100"Cortex-M3"0001100000080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x1400010x80000000x8000000x00x010x00x010x00x010x00x010x80000000x8000010x00x000x00x000x00x000x00x000x200000000x1400000x00x007001000003010003311000NDEBUG..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\armclang;..\..\..\..\..\3rd_party\CMSIS\Include; ..\..\..\..\..\3rd_party\nucleo-l152re1000000100Stack_Size=512 Heap_Size=01000100x000000000x20000000dpp-qk.sct--entry Reset_HandlerApplicationbsp.c1..\bsp.cbsp.h5..\..\bsp.hdpp.h5..\..\dpp.hmain.c1..\..\main.cphilo.c1..\..\philo.cREADME.txt5..\..\README.txttable.c1..\..\table.cnucleo-l152reREADME.txt5..\..\..\..\..\3rd_party\nucleo-l152re\README.txtstm32l1xx.h5..\..\..\..\..\3rd_party\nucleo-l152re\stm32l1xx.hsystem_stm32l1xx.c1..\..\..\..\..\3rd_party\nucleo-l152re\system_stm32l1xx.csystem_stm32l1xx.h5..\..\..\..\..\3rd_party\nucleo-l152re\system_stm32l1xx.hstartup_stm32l1xx.s2..\..\..\..\..\3rd_party\nucleo-l152re\arm\startup_stm32l1xx.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.c
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qk/bsp.c
================================================
/*****************************************************************************
* Product: DPP on STM32 NUCLEO-L152RE board, preemptive QK kernel
* Last Updated for Version: 6.1.0
* Date of the Last Update: 2018-02-14
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "dpp.h"
#include "bsp.h"
#include "stm32l1xx.h" /* CMSIS-compliant header file for the MCU used */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
enum KernelUnawareISRs { /* see NOTE00 */
/* ... */
MAX_KERNEL_UNAWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-unaware" interrupts can't overlap "kernel-aware" interrupts */
Q_ASSERT_COMPILE(MAX_KERNEL_UNAWARE_CMSIS_PRI <= QF_AWARE_ISR_CMSIS_PRI);
enum KernelAwareISRs {
GPIOPORTA_PRIO = QF_AWARE_ISR_CMSIS_PRI, /* see NOTE00 */
SYSTICK_PRIO,
/* ... */
MAX_KERNEL_AWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-aware" interrupts should not overlap the PendSV priority */
Q_ASSERT_COMPILE(MAX_KERNEL_AWARE_CMSIS_PRI <= (0xFF >>(8-__NVIC_PRIO_BITS)));
/* ISRs defined in this BSP ------------------------------------------------*/
void SysTick_Handler(void);
/* Local-scope objects -----------------------------------------------------*/
/* LED pins available on the board (just one user LED LD2--Green on PA.5) */
#define LED_LD2 (1U << 5)
/* Button pins available on the board (just one user Button B1 on PC.13) */
#define BTN_B1 (1U << 13)
/* random seed */
static uint32_t l_rnd;
/* ISRs used in this project ===============================================*/
void SysTick_Handler(void) {
/* state of the button debouncing, see below */
static struct ButtonsDebouncing {
uint32_t depressed;
uint32_t previous;
} buttons = { ~0U, ~0U };
uint32_t current;
uint32_t tmp;
QK_ISR_ENTRY(); /* inform QK about entering an ISR */
QF_tickXISR(0U); /* process time events for rate 0 */
/* Perform the debouncing of buttons. The algorithm for debouncing
* adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
* and Michael Barr, page 71.
*/
current = ~GPIOC->IDR; /* read Port C with the state of Button B1 */
tmp = buttons.depressed; /* save the debounced depressed buttons */
buttons.depressed |= (buttons.previous & current); /* set depressed */
buttons.depressed &= (buttons.previous | current); /* clear released */
buttons.previous = current; /* update the history */
tmp ^= buttons.depressed; /* changed debounced depressed */
if ((tmp & BTN_B1) != 0U) { /* debounced B1 state changed? */
if ((buttons.depressed & BTN_B1) != 0U) { /* is B1 depressed? */
QACTIVE_POST_ISR(&AO_Table, PAUSE_SIG, 0U);
}
else { /* the button is released */
QACTIVE_POST_ISR(&AO_Table, SERVE_SIG, 0U);
}
}
QK_ISR_EXIT(); /* inform QK about exiting an ISR */
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* NOTE: SystemInit() has been already called from the startup code
* but SystemCoreClock needs to be updated
*/
SystemCoreClockUpdate();
/* enable GPIOA clock port for the LED LD2 */
RCC->AHBENR |= (1U << 0);
/* configure LED (PA.5) pin as push-pull output, no pull-up, pull-down */
GPIOA->MODER &= ~((3U << 2*5));
GPIOA->MODER |= ((1U << 2*5));
GPIOA->OTYPER &= ~((1U << 5));
GPIOA->OSPEEDR &= ~((3U << 2*5));
GPIOA->OSPEEDR |= ((1U << 2*5));
GPIOA->PUPDR &= ~((3U << 2*5));
/* enable GPIOC clock port for the Button B1 */
RCC->AHBENR |= (1U << 2);
/* configure Button (PC.13) pins as input, no pull-up, pull-down */
GPIOC->MODER &= ~(3U << 2*13);
GPIOC->OSPEEDR &= ~(3U << 2*13);
GPIOC->OSPEEDR |= (1U << 2*13);
GPIOC->PUPDR &= ~(3U << 2*13);
BSP_randomSeed(1234U); /* seed the random number generator */
}
/*..........................................................................*/
void BSP_displayPhilStat(uint8_t n, char const *stat) {
if (stat[0] == 'h') {
GPIOA->BSRRL |= LED_LD2; /* turn LED on */
}
else {
GPIOA->BSRRH |= LED_LD2; /* turn LED off */
}
}
/*..........................................................................*/
void BSP_displayPaused(uint8_t paused) {
/* not enough LEDs to implement this feature */
if (paused != (uint8_t)0) {
//GPIOA->BSRRL |= LED_LD2; /* turn LED on */
}
else {
//GPIOA->BSRRH |= LED_LD2; /* turn LED off */
}
}
/*..........................................................................*/
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
l_rnd = l_rnd * (3U*7U*11U*13U*23U);
return l_rnd >> 8;
}
/*..........................................................................*/
void BSP_randomSeed(uint32_t seed) {
l_rnd = seed;
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
(void)result;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set up the SysTick timer to fire at BSP_TICKS_PER_SEC rate */
SysTick_Config(SystemCoreClock / BSP_TICKS_PER_SEC);
/* set priorities of ALL ISRs used in the system, see NOTE00
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
NVIC_SetPriority(SysTick_IRQn, SYSTICK_PRIO);
/* ... */
/* enable IRQs... */
}
/*..........................................................................*/
void QK_onIdle(void) {
/* toggle an LED on and then off (not enough LEDs, see NOTE01) */
QF_INT_DISABLE();
//GPIOA->BSRRL |= LED_LD2; /* turn LED on */
//GPIOA->BSRRH |= LED_LD2; /* turn LED off */
QF_INT_ENABLE();
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular Cortex-M3 MCU.
*/
/* !!!CAUTION!!!
* The WFI instruction stops the CPU clock, which unfortunately disables
* the JTAG port, so the ST-Link debugger can no longer connect to the
* board. For that reason, the call to __WFI() has to be used with CAUTION.
*
* NOTE: If you find your board "frozen" like this, strap BOOT0 to VDD and
* reset the board, then connect with ST-Link Utilities and erase the part.
* The trick with BOOT(0) is it gets the part to run the System Loader
* instead of your broken code. When done disconnect BOOT0, and start over.
*/
//__WFI(); /* Wait-For-Interrupt */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int loc) {
/*
* NOTE: add here your application-specific error handling
*/
(void)module;
(void)loc;
NVIC_SystemReset();
}
/*****************************************************************************
* NOTE00:
* The QF_AWARE_ISR_CMSIS_PRI constant from the QF port specifies the highest
* ISR priority that is disabled by the QF framework. The value is suitable
* for the NVIC_SetPriority() CMSIS function.
*
* Only ISRs prioritized at or below the QF_AWARE_ISR_CMSIS_PRI level (i.e.,
* with the numerical values of priorities equal or higher than
* QF_AWARE_ISR_CMSIS_PRI) are allowed to call any QF services. These ISRs
* are "QF-aware".
*
* Conversely, any ISRs prioritized above the QF_AWARE_ISR_CMSIS_PRI priority
* level (i.e., with the numerical values of priorities less than
* QF_AWARE_ISR_CMSIS_PRI) are never disabled and are not aware of the kernel.
* Such "QF-unaware" ISRs cannot call any QF services. The only mechanism
* by which a "QF-unaware" ISR can communicate with the QF framework is by
* triggering a "QF-aware" ISR, which can post/publish events.
*
* NOTE01:
* One of the LEDs is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qk/gnu/.cproject
================================================
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qk/gnu/.project
================================================
dpp-qk_nucleo-l152reorg.eclipse.cdt.managedbuilder.core.genmakebuilderclean,full,incremental,org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilderfull,incremental,org.eclipse.cdt.core.cnatureorg.eclipse.cdt.managedbuilder.core.managedBuildNatureorg.eclipse.cdt.managedbuilder.core.ScannerConfigNatureQK2PARENT-5-PROJECT_LOC/src/qknQP2PARENT-5-PROJECT_LOC/src/qfnQP_port2PARENT-5-PROJECT_LOC/ports/arm-cm/qk/gnubsp.c1PARENT-1-PROJECT_LOC/bsp.cbsp.h1PARENT-2-PROJECT_LOC/bsp.hdpp.h1PARENT-2-PROJECT_LOC/dpp.hmain.c1PARENT-2-PROJECT_LOC/main.cnucleo-l152re2PARENT-5-PROJECT_LOC/3rd_party/nucleo-l152rephilo.c1PARENT-2-PROJECT_LOC/philo.cqstamp.c1PARENT-5-PROJECT_LOC/include/qstamp.ctable.c1PARENT-2-PROJECT_LOC/table.c
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qk/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano on NUCLEO-L152RE, QK-nano kernel, GNU-ARM
# Last Updated for Version: 6.5.0
# Date of the Last Update: 2019-04-15
#
# Q u a n t u m L e a P s
# ------------------------
# Modern Embedded Software
#
# Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# https://www.state-machine.com
# mailto:info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := dpp-qk
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/arm-cm/qk/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qkn \
$(QP_PORT_DIR) \
$(QPN)/3rd_party/nucleo-l152re \
$(QPN)/3rd_party/nucleo-l152re/gnu
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR) \
-I$(QPN)/3rd_party/CMSIS/Include \
-I$(QPN)/3rd_party/nucleo-l152re
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
bsp.c \
main.c \
philo.c \
table.c \
system_stm32l1xx.c \
startup_stm32l1xx.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qepn.c \
qfn.c \
qkn.c \
qkn_port.c
QP_ASMS :=
LIB_DIRS :=
LIBS :=
# defines
DEFINES :=
# ARM CPU, ARCH, FPU, and Float-ABI types...
# ARM_CPU: [cortex-m0 | cortex-m0plus | cortex-m1 | cortex-m3 | cortex-m4]
# ARM_ARCH: [6 | 7] (NOTE: must match ARM_CPU!)
# ARM_FPU: [ | vfp]
# FLOAT_ABI: [ | soft | softfp | hard]
#
ARM_CPU := -mcpu=cortex-m3
ARM_ARCH := 7 # NOTE: must match the ARM_CPU!
ARM_FPU :=
FLOAT_ABI :=
#-----------------------------------------------------------------------------
# GNU-ARM toolset (NOTE: You need to adjust to your machine)
# see https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
#
ifeq ($(GNU_ARM),)
GNU_ARM := $(QTOOLS)/gnu_arm-none-eabi
endif
# make sure that the GNU-ARM toolset exists...
ifeq ("$(wildcard $(GNU_ARM))","")
$(error GNU_ARM toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_ARM)/bin/arm-none-eabi-gcc
CPP := $(GNU_ARM)/bin/arm-none-eabi-g++
AS := $(GNU_ARM)/bin/arm-none-eabi-as
LINK := $(GNU_ARM)/bin/arm-none-eabi-g++
BIN := $(GNU_ARM)/bin/arm-none-eabi-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M
#
# combine all the soruces...
C_SRCS += $(QP_SRCS)
ASM_SRCS += $(QP_ASMS)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS = $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration ..........................................
BIN_DIR := dbg
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O $(INCLUDES) $(DEFINES)
CPPFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES)
endif # ......................................................................
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
-specs=nosys.specs -specs=nano.specs \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_BIN := $(BIN_DIR)/$(OUTPUT).bin
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_BIN)
#all: $(TARGET_ELF)
$(TARGET_BIN): $(TARGET_ELF)
$(BIN) -O binary $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(CC) $(CFLAGS) $(QPN)/include/qstamp.c -o $(BIN_DIR)/qstamp.o
$(LINK) $(LINKFLAGS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.bin \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qk/gnu/dpp-qk.ld
================================================
/*****************************************************************************
* Product: Linker script for for STM32L152RET6, GNU-ARM linker
* Last Updated for Version: 5.9.8
* Date of the Last Update: 2017-09-13
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* https://state-machine.com
* mailto:info@state-machine.com
*****************************************************************************/
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(Reset_Handler) /* entry Point */
MEMORY { /* memory map of STM32L152RET6 */
ROM (rx) : ORIGIN = 0x08000000, LENGTH = 512K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 80K
}
/* The size of the stack used by the application. NOTE: you need to adjust */
STACK_SIZE = 1024;
/* The size of the heap used by the application. NOTE: you need to adjust */
HEAP_SIZE = 0;
SECTIONS {
.isr_vector : { /* the vector table goes FIRST into ROM */
KEEP(*(.isr_vector)) /* vector table */
. = ALIGN(4);
} >ROM
.text : { /* code and constants */
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} >ROM
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >ROM
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >ROM
.fini_array : {
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array*))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >ROM
_etext = .; /* global symbols at end of code */
.stack : {
__stack_start__ = .;
. = . + STACK_SIZE;
. = ALIGN(4);
__stack_end__ = .;
} >RAM
.data : AT (_etext) {
__data_load = LOADADDR (.data);
__data_start = .;
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
__data_end__ = .;
_edata = __data_end__;
} >RAM
.bss : {
__bss_start__ = .;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = .;
} >RAM
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >RAM
__exidx_end = .;
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );
PROVIDE ( __end__ = _ebss );
.heap : {
__heap_start__ = .;
. = . + HEAP_SIZE;
. = ALIGN(4);
__heap_end__ = .;
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ : {
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
}
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qk/iar/dpp-qk.ewd
================================================
2DebugARM1C-SPY22611ARMSIM_ID2111ANGEL_ID2011CMSISDAP_ID2211GDBSERVER_ID2011IARROM_ID2111IJET_ID2611JLINK_ID21511LMIFTDI_ID2211MACRAIGOR_ID2311PEMICRO_ID2111RDI_ID2211STLINK_ID2211THIRDPARTY_ID2011XDS100_ID2211$TOOLKIT_DIR$\plugins\middleware\HCCWare\HCCWare.ewplugin0$TOOLKIT_DIR$\plugins\rtos\AVIX\AVIX.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\MQX\MQXRtosPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\Quadros\Quadros_EWB7_Plugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin1$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseARM0C-SPY22610ARMSIM_ID2110ANGEL_ID2010CMSISDAP_ID2210GDBSERVER_ID2010IARROM_ID2110IJET_ID2610JLINK_ID21510LMIFTDI_ID2210MACRAIGOR_ID2310PEMICRO_ID2110RDI_ID2210STLINK_ID2210THIRDPARTY_ID2010XDS100_ID2210$TOOLKIT_DIR$\plugins\middleware\HCCWare\HCCWare.ewplugin0$TOOLKIT_DIR$\plugins\rtos\AVIX\AVIX.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\MQX\MQXRtosPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\Quadros\Quadros_EWB7_Plugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin1$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qk/iar/dpp-qk.ewp
================================================
2DebugARM1General32211ICCARM23111AARM2911OBJCOPY0111CUSTOM30BICOMP0BUILDACTION1ILINK01611IARCHIVE0011BILINK0Coder0ReleaseARM0General32210ICCARM23110AARM2910OBJCOPY0110CUSTOM30BICOMP0BUILDACTION1ILINK01610IARCHIVE0010BILINK0Coder0Application$PROJ_DIR$\..\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\dpp.h$PROJ_DIR$\..\..\main.c$PROJ_DIR$\..\..\philo.c$PROJ_DIR$\..\..\table.cnucleo-l152re$PROJ_DIR$\..\..\..\..\..\3rd_party\nucleo-l152re\iar\startup_stm32l1xx.s$PROJ_DIR$\..\..\..\..\..\3rd_party\nucleo-l152re\stm32l1xx.h$PROJ_DIR$\..\..\..\..\..\3rd_party\nucleo-l152re\system_stm32l1xx.c$PROJ_DIR$\..\..\..\..\..\3rd_party\nucleo-l152re\system_stm32l1xx.hQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qkn\qkn.cQP_port$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qk\iar\qfn_port.h$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qk\iar\qkn_port.c
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qk/iar/dpp-qk.eww
================================================
$WS_DIR$\dpp-qk.ewp
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qk/iar/dpp-qk.icf
================================================
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0807FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20013FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 1024;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place in RAM_region { readwrite,
block CSTACK, block HEAP };
define symbol __region_EEPROM_start__ = 0x08080000;
define symbol __region_EEPROM_end__ = 0x08083FFF;
define region EEPROM_region = mem:[from __region_EEPROM_start__ to __region_EEPROM_end__];
place in EEPROM_region { section .eeprom };
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qpn_conf.h
================================================
/*****************************************************************************
* Product: QP-nano configuration for the Blinky example
* Last Updated for Version: 5.6.2
* Date of the Last Update: 2016-04-05
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef QPN_CONF_H
#define QPN_CONF_H
#define Q_PARAM_SIZE 4U
#define QF_MAX_TICK_RATE 1U
#define QF_TIMEEVT_CTR_SIZE 2U
#define QF_TIMEEVT_PERIODIC
#endif /* QPN_CONF_H */
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qv/armclang/README.txt
================================================
About this Example
==================
This example demonstrates how to use the uVision IDE together with
the MDK-ARM toolchain.
***
NOTE: This example requires installing the following Software Pack
in the Keil uVision: Keil::STM32L152_DFP.
***
uVision Project File
====================
The MDK-ARM uVision project file provided with this example uses
relative paths to the QP/C framework location (includes, port, and
libraries. These relative paths must be modified when the project
is moved to different relative location.
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the
command-line options for the ARM assembler (see the Asm tab in
the "Options for Target" dialog box in uVision). Specifically,
you should define symbols: Stack_Size=xxx Heap_Size=yyy, where
xxx represents a numerical value of stack size and yyy the
numberical value of the heap size.
Startup Code
============
The startup code for the STM32L1xx MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\nucleo-l152re\arm\startup_stm32l1xx.s
The file startup_stm32l1xx.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
Adjusting the CPU Clock Speed
=============================
The current setting is to run at 2MHz from the MSI (internal oscillator),
but the CPU clock speed can be modified by editing the file
system_stm32l1xx.c. Ther file system_stm32l1xx_pll.c provides an example
of clock setting using the PLL driven from the MSE.
***
NOTE:
The NUCLEO boards have a wide range of possible clock selections, depending
on the solder bridge configuration. Please see Chapter 5.7 "OSC clock" in
the STM32 NUCLEO Boards User Manual (ST document UM1724) for more information.
***
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qv/armclang/dpp-qv.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj; *.o*.lib*.txt; *.h; *.inc*.plm*.cpp000dpp-dbg0x4ARM-ADS120000001101016553500079668.\dbg\111011010000111111100101180111111111111101011001005STLink\ST-LINKIII-KEIL_SWO.dll0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0DLGUARM(105=-1,-1,-1,-1,0)0ST-LINKIII-KEIL_SWO-U066EFF495056805087184715 -I0 -O8398 -S1 -C0 -A0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32L1xx_512.FLM -FS08000000 -FL080000 -FP0($$Device:STM32L152RE$Flash\STM32L1xx_512.FLM)0UL2CM3UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32L1xx_512 -FS08000000 -FL080000 -FP0($$Device:STM32L152RE$Flash\STM32L1xx_512.FLM))120x200002000200x40000001000010000000000000000000dpp-rel0x4ARM-ADS120000001101016553500079668.\rel\111011010000111111100100180111111111111101011001005STLink\ST-LINKIII-KEIL_SWO.dll0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0DLGUARM(105=-1,-1,-1,-1,0)0ST-LINKIII-KEIL_SWO-U066EFF495056805087184715 -I0 -O8430 -S1 -C0 -A0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32L1xx_512.FLM -FS08000000 -FL080000 -FP0($$Device:STM32L152RE$Flash\STM32L1xx_512.FLM)0UL2CM3UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32L1xx_512 -FS08000000 -FL080000 -FP0($$Device:STM32L152RE$Flash\STM32L1xx_512.FLM))120x200002000200x40000001000010000000000000000000Application1000115000..\..\bsp.hbsp.h00125000..\..\dpp.hdpp.h00131000..\..\main.cmain.c00141000..\..\philo.cphilo.c00155000..\..\README.txtREADME.txt00161000..\..\table.ctable.c00171000..\bsp.cbsp.c00nucleo-l152re1000285000..\..\..\..\..\3rd_party\nucleo-l152re\README.txtREADME.txt00295000..\..\..\..\..\3rd_party\nucleo-l152re\stm32l1xx.hstm32l1xx.h002101000..\..\..\..\..\3rd_party\nucleo-l152re\system_stm32l1xx.csystem_stm32l1xx.c002115000..\..\..\..\..\3rd_party\nucleo-l152re\system_stm32l1xx.hsystem_stm32l1xx.h002122000..\..\..\..\..\3rd_party\nucleo-l152re\arm\startup_stm32l1xx.sstartup_stm32l1xx.s00QP10003131000..\..\..\..\..\src\qfn\qepn.cqepn.c003141000..\..\..\..\..\src\qfn\qfn.cqfn.c003151000..\..\..\..\..\src\qvn\qvn.cqvn.c00QP_port10004165000..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqfn_port.h004171000..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.cqvn_port.c00
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qv/armclang/dpp-qv.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwaredpp-dbg0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1STM32L152RESTMicroelectronicsKeil.STM32L1xx_DFP.1.0.2http://www.keil.com/pack/IROM(0x08000000,0x80000) IRAM(0x20000000,0x14000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32L1xx_512 -FS08000000 -FL080000 -FP0($$Device:STM32L152RE$Flash\STM32L1xx_512.FLM))0$$Device:STM32L152RE$Device\Include\STM32L1xx.h$$Device:STM32L152RE$SVD\STM32L1xx.svd0000001.\dbg\dpp-qv10011.\dbg\10000000000000010fromelf --bin --output .\dbg\dpp-qv.bin .\dbg\dpp-qv.axf00000000001000031SARMCM3.DLL -REMAP -MPUDCM.DLL-pCM3SARMCM3.DLL -MPUTCM.DLL-pCM31000161001140961BIN\UL2CM3.DLL"" ()0011111110110000011111111100"Cortex-M3"0001100000080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x1400010x80000000x8000000x00x010x00x010x00x010x00x010x80000000x8000010x00x000x00x000x00x000x00x000x200000000x1400000x00x007001000003010003311000..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\armclang;..\..\..\..\..\3rd_party\CMSIS\Include; ..\..\..\..\..\3rd_party\nucleo-l152re1000000100Stack_Size=512 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerApplicationbsp.h5..\..\bsp.hdpp.h5..\..\dpp.hmain.c1..\..\main.cphilo.c1..\..\philo.cREADME.txt5..\..\README.txttable.c1..\..\table.cbsp.c1..\bsp.cnucleo-l152reREADME.txt5..\..\..\..\..\3rd_party\nucleo-l152re\README.txtstm32l1xx.h5..\..\..\..\..\3rd_party\nucleo-l152re\stm32l1xx.hsystem_stm32l1xx.c1..\..\..\..\..\3rd_party\nucleo-l152re\system_stm32l1xx.csystem_stm32l1xx.h5..\..\..\..\..\3rd_party\nucleo-l152re\system_stm32l1xx.hstartup_stm32l1xx.s2..\..\..\..\..\3rd_party\nucleo-l152re\arm\startup_stm32l1xx.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.cdpp-rel0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1STM32L152RESTMicroelectronicsKeil.STM32L1xx_DFP.1.0.2http://www.keil.com/pack/IROM(0x08000000,0x80000) IRAM(0x20000000,0x14000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32L1xx_512 -FS08000000 -FL080000 -FP0($$Device:STM32L152RE$Flash\STM32L1xx_512.FLM))0$$Device:STM32L152RE$Device\Include\STM32L1xx.h$$Device:STM32L152RE$SVD\STM32L1xx.svd0000001.\rel\dpp-qv10000.\rel\10000000000000010fromelf --bin --output .\rel\dpp-qv.bin .\rel\dpp-qv.axf00000000001000031SARMCM3.DLL -REMAP -MPUDCM.DLL-pCM3SARMCM3.DLL -MPUTCM.DLL-pCM31000161001140961BIN\UL2CM3.DLL"" ()0011111110110000011111111100"Cortex-M3"0001100000080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x1400010x80000000x8000000x00x010x00x010x00x010x00x010x80000000x8000010x00x000x00x000x00x000x00x000x200000000x1400000x00x007001000003010003311000NDEBUG..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\armclang;..\..\..\..\..\3rd_party\CMSIS\Include; ..\..\..\..\..\3rd_party\nucleo-l152re1000000100Stack_Size=512 Heap_Size=01000100x000000000x20000000dpp-qv.sct--entry Reset_HandlerApplicationbsp.h5..\..\bsp.hdpp.h5..\..\dpp.hmain.c1..\..\main.cphilo.c1..\..\philo.cREADME.txt5..\..\README.txttable.c1..\..\table.cbsp.c1..\bsp.cnucleo-l152reREADME.txt5..\..\..\..\..\3rd_party\nucleo-l152re\README.txtstm32l1xx.h5..\..\..\..\..\3rd_party\nucleo-l152re\stm32l1xx.hsystem_stm32l1xx.c1..\..\..\..\..\3rd_party\nucleo-l152re\system_stm32l1xx.csystem_stm32l1xx.h5..\..\..\..\..\3rd_party\nucleo-l152re\system_stm32l1xx.hstartup_stm32l1xx.s2..\..\..\..\..\3rd_party\nucleo-l152re\arm\startup_stm32l1xx.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.c
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qv/bsp.c
================================================
/*****************************************************************************
* Product: DPP on STM32 NUCLEO-L152RE board, cooperative QV kernel
* Last Updated for Version: 5.5.1
* Date of the Last Update: 2015-10-05
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "dpp.h"
#include "bsp.h"
#include "stm32l1xx.h" /* CMSIS-compliant header file for the MCU used */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
enum KernelUnawareISRs { /* see NOTE00 */
/* ... */
MAX_KERNEL_UNAWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-unaware" interrupts can't overlap "kernel-aware" interrupts */
Q_ASSERT_COMPILE(MAX_KERNEL_UNAWARE_CMSIS_PRI <= QF_AWARE_ISR_CMSIS_PRI);
enum KernelAwareISRs {
GPIOPORTA_PRIO = QF_AWARE_ISR_CMSIS_PRI, /* see NOTE00 */
SYSTICK_PRIO,
/* ... */
MAX_KERNEL_AWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-aware" interrupts should not overlap the PendSV priority */
Q_ASSERT_COMPILE(MAX_KERNEL_AWARE_CMSIS_PRI <= (0xFF >>(8-__NVIC_PRIO_BITS)));
/* ISRs defined in this BSP ------------------------------------------------*/
void SysTick_Handler(void);
/* Local-scope objects -----------------------------------------------------*/
/* LED pins available on the board (just one user LED LD2--Green on PA.5) */
#define LED_LD2 (1U << 5)
/* Button pins available on the board (just one user Button B1 on PC.13) */
#define BTN_B1 (1U << 13)
/* random seed */
static uint32_t l_rnd;
/* ISRs used in this project ===============================================*/
void SysTick_Handler(void) {
/* state of the button debouncing, see below */
static struct ButtonsDebouncing {
uint32_t depressed;
uint32_t previous;
} buttons = { ~0U, ~0U };
uint32_t current;
uint32_t tmp;
QF_tickXISR(0U); /* process time events for rate 0 */
/* Perform the debouncing of buttons. The algorithm for debouncing
* adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
* and Michael Barr, page 71.
*/
current = ~GPIOC->IDR; /* read Port C with the state of Button B1 */
tmp = buttons.depressed; /* save the debounced depressed buttons */
buttons.depressed |= (buttons.previous & current); /* set depressed */
buttons.depressed &= (buttons.previous | current); /* clear released */
buttons.previous = current; /* update the history */
tmp ^= buttons.depressed; /* changed debounced depressed */
if ((tmp & BTN_B1) != 0U) { /* debounced B1 state changed? */
if ((buttons.depressed & BTN_B1) != 0U) { /* is B1 depressed? */
QACTIVE_POST_ISR(&AO_Table, PAUSE_SIG, 0U);
}
else { /* the button is released */
QACTIVE_POST_ISR(&AO_Table, SERVE_SIG, 0U);
}
}
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* NOTE: SystemInit() has been already called from the startup code
* but SystemCoreClock needs to be updated
*/
SystemCoreClockUpdate();
/* enable GPIOA clock port for the LED LD2 */
RCC->AHBENR |= (1U << 0);
/* configure LED (PA.5) pin as push-pull output, no pull-up, pull-down */
GPIOA->MODER &= ~((3U << 2*5));
GPIOA->MODER |= ((1U << 2*5));
GPIOA->OTYPER &= ~((1U << 5));
GPIOA->OSPEEDR &= ~((3U << 2*5));
GPIOA->OSPEEDR |= ((1U << 2*5));
GPIOA->PUPDR &= ~((3U << 2*5));
/* enable GPIOC clock port for the Button B1 */
RCC->AHBENR |= (1U << 2);
/* configure Button (PC.13) pins as input, no pull-up, pull-down */
GPIOC->MODER &= ~(3U << 2*13);
GPIOC->OSPEEDR &= ~(3U << 2*13);
GPIOC->OSPEEDR |= (1U << 2*13);
GPIOC->PUPDR &= ~(3U << 2*13);
BSP_randomSeed(1234U); /* seed the random number generator */
}
/*..........................................................................*/
void BSP_displayPhilStat(uint8_t n, char const *stat) {
if (stat[0] == 'h') {
GPIOA->BSRRL |= LED_LD2; /* turn LED on */
}
else {
GPIOA->BSRRH |= LED_LD2; /* turn LED off */
}
}
/*..........................................................................*/
void BSP_displayPaused(uint8_t paused) {
/* not enough LEDs to implement this feature */
if (paused != (uint8_t)0) {
//GPIOA->BSRRL |= LED_LD2; /* turn LED on */
}
else {
//GPIOA->BSRRH |= LED_LD2; /* turn LED off */
}
}
/*..........................................................................*/
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
l_rnd = l_rnd * (3U*7U*11U*13U*23U);
return l_rnd >> 8;
}
/*..........................................................................*/
void BSP_randomSeed(uint32_t seed) {
l_rnd = seed;
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
(void)result;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set up the SysTick timer to fire at BSP_TICKS_PER_SEC rate */
SysTick_Config(SystemCoreClock / BSP_TICKS_PER_SEC);
/* set priorities of ALL ISRs used in the system, see NOTE00
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
NVIC_SetPriority(SysTick_IRQn, SYSTICK_PRIO);
/* ... */
/* enable IRQs... */
}
/*..........................................................................*/
void QV_onIdle(void) { /* called with interrupts disabled, see NOTE01 */
/* toggle an LED on and then off (not enough LEDs, see NOTE01) */
//GPIOA->BSRRL |= LED_LD2; /* turn LED on */
//GPIOA->BSRRH |= LED_LD2; /* turn LED off */
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular Cortex-M3 MCU.
*/
/* !!!CAUTION!!!
* The WFI instruction stops the CPU clock, which unfortunately disables
* the JTAG port, so the ST-Link debugger can no longer connect to the
* board. For that reason, the call to __WFI() has to be used with CAUTION.
*
* NOTE: If you find your board "frozen" like this, strap BOOT0 to VDD and
* reset the board, then connect with ST-Link Utilities and erase the part.
* The trick with BOOT(0) is it gets the part to run the System Loader
* instead of your broken code. When done disconnect BOOT0, and start over.
*/
//QV_CPU_SLEEP(); /* atomically go to sleep and enable interrupts */
QF_INT_ENABLE(); /* for now, just enable interrupts */
#else
QF_INT_ENABLE(); /* just enable interrupts */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int loc) {
/*
* NOTE: add here your application-specific error handling
*/
(void)module;
(void)loc;
NVIC_SystemReset();
}
/*****************************************************************************
* NOTE00:
* The QF_AWARE_ISR_CMSIS_PRI constant from the QF port specifies the highest
* ISR priority that is disabled by the QF framework. The value is suitable
* for the NVIC_SetPriority() CMSIS function.
*
* Only ISRs prioritized at or below the QF_AWARE_ISR_CMSIS_PRI level (i.e.,
* with the numerical values of priorities equal or higher than
* QF_AWARE_ISR_CMSIS_PRI) are allowed to call any QF services. These ISRs
* are "QF-aware".
*
* Conversely, any ISRs prioritized above the QF_AWARE_ISR_CMSIS_PRI priority
* level (i.e., with the numerical values of priorities less than
* QF_AWARE_ISR_CMSIS_PRI) are never disabled and are not aware of the kernel.
* Such "QF-unaware" ISRs cannot call any QF services. The only mechanism
* by which a "QF-unaware" ISR can communicate with the QF framework is by
* triggering a "QF-aware" ISR, which can post/publish events.
*
* NOTE01:
* One of the LEDs is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qv/gnu/.cproject
================================================
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qv/gnu/.project
================================================
dpp-qv_nucleo-l152reorg.eclipse.cdt.managedbuilder.core.genmakebuilderclean,full,incremental,org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilderfull,incremental,org.eclipse.cdt.core.cnatureorg.eclipse.cdt.managedbuilder.core.managedBuildNatureorg.eclipse.cdt.managedbuilder.core.ScannerConfigNatureQP2PARENT-5-PROJECT_LOC/src/qfnQP_port2PARENT-5-PROJECT_LOC/ports/arm-cm/qv/gnuQV2PARENT-5-PROJECT_LOC/src/qvnbsp.c1PARENT-1-PROJECT_LOC/bsp.cbsp.h1PARENT-2-PROJECT_LOC/bsp.hdpp.h1PARENT-2-PROJECT_LOC/dpp.hmain.c1PARENT-2-PROJECT_LOC/main.cnucleo-l152re2PARENT-5-PROJECT_LOC/3rd_party/nucleo-l152rephilo.c1PARENT-2-PROJECT_LOC/philo.cqstamp.c1PARENT-5-PROJECT_LOC/include/qstamp.ctable.c1PARENT-2-PROJECT_LOC/table.c
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qv/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano on NUCLEO-L152RE, QV-nano kernel, GNU-ARM
# Last Updated for Version: 6.5.0
# Date of the Last Update: 2019-04-15
#
# Q u a n t u m L e a P s
# ------------------------
# Modern Embedded Software
#
# Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# https://www.state-machine.com
# mailto:info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := dpp-qv
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/arm-cm/qv/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qvn \
$(QP_PORT_DIR) \
$(QPN)/3rd_party/nucleo-l152re \
$(QPN)/3rd_party/nucleo-l152re/gnu
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR) \
-I$(QPN)/3rd_party/CMSIS/Include \
-I$(QPN)/3rd_party/nucleo-l152re
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
bsp.c \
main.c \
philo.c \
table.c \
system_stm32l1xx.c \
startup_stm32l1xx.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qepn.c \
qfn.c \
qvn.c \
qvn_port.c
QP_ASMS :=
LIB_DIRS :=
LIBS :=
# defines
DEFINES :=
# ARM CPU, ARCH, FPU, and Float-ABI types...
# ARM_CPU: [cortex-m0 | cortex-m0plus | cortex-m1 | cortex-m3 | cortex-m4]
# ARM_ARCH: [6 | 7] (NOTE: must match ARM_CPU!)
# ARM_FPU: [ | vfp]
# FLOAT_ABI: [ | soft | softfp | hard]
#
ARM_CPU := -mcpu=cortex-m3
ARM_ARCH := 7 # NOTE: must match the ARM_CPU!
ARM_FPU :=
FLOAT_ABI :=
#-----------------------------------------------------------------------------
# GNU-ARM toolset (NOTE: You need to adjust to your machine)
# see https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
#
ifeq ($(GNU_ARM),)
GNU_ARM := $(QTOOLS)/gnu_arm-none-eabi
endif
# make sure that the GNU-ARM toolset exists...
ifeq ("$(wildcard $(GNU_ARM))","")
$(error GNU_ARM toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_ARM)/bin/arm-none-eabi-gcc
CPP := $(GNU_ARM)/bin/arm-none-eabi-g++
AS := $(GNU_ARM)/bin/arm-none-eabi-as
LINK := $(GNU_ARM)/bin/arm-none-eabi-g++
BIN := $(GNU_ARM)/bin/arm-none-eabi-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M
#
# combine all the soruces...
C_SRCS += $(QP_SRCS)
ASM_SRCS += $(QP_ASMS)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS = $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration ..........................................
BIN_DIR := dbg
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O $(INCLUDES) $(DEFINES)
CPPFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES)
endif # ......................................................................
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
-specs=nosys.specs -specs=nano.specs \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_BIN := $(BIN_DIR)/$(OUTPUT).bin
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_BIN)
#all: $(TARGET_ELF)
$(TARGET_BIN): $(TARGET_ELF)
$(BIN) -O binary $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(CC) $(CFLAGS) $(QPN)/include/qstamp.c -o $(BIN_DIR)/qstamp.o
$(LINK) $(LINKFLAGS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.bin \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qv/gnu/dpp-qv.ld
================================================
/*****************************************************************************
* Product: Linker script for for STM32L152RET6, GNU-ARM linker
* Last Updated for Version: 5.9.8
* Date of the Last Update: 2017-09-13
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* https://state-machine.com
* mailto:info@state-machine.com
*****************************************************************************/
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(Reset_Handler) /* entry Point */
MEMORY { /* memory map of STM32L152RET6 */
ROM (rx) : ORIGIN = 0x08000000, LENGTH = 512K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 80K
}
/* The size of the stack used by the application. NOTE: you need to adjust */
STACK_SIZE = 1024;
/* The size of the heap used by the application. NOTE: you need to adjust */
HEAP_SIZE = 0;
SECTIONS {
.isr_vector : { /* the vector table goes FIRST into ROM */
KEEP(*(.isr_vector)) /* vector table */
. = ALIGN(4);
} >ROM
.text : { /* code and constants */
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} >ROM
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >ROM
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >ROM
.fini_array : {
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array*))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >ROM
_etext = .; /* global symbols at end of code */
.stack : {
__stack_start__ = .;
. = . + STACK_SIZE;
. = ALIGN(4);
__stack_end__ = .;
} >RAM
.data : AT (_etext) {
__data_load = LOADADDR (.data);
__data_start = .;
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
__data_end__ = .;
_edata = __data_end__;
} >RAM
.bss : {
__bss_start__ = .;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = .;
} >RAM
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >RAM
__exidx_end = .;
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );
PROVIDE ( __end__ = _ebss );
.heap : {
__heap_start__ = .;
. = . + HEAP_SIZE;
. = ALIGN(4);
__heap_end__ = .;
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ : {
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
}
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qv/iar/dpp-qv.ewd
================================================
3DebugARM1C-SPY22811ARMSIM_ID2111CADI_ID2011CMSISDAP_ID2411GDBSERVER_ID2011IJET_ID2811JLINK_ID21611LMIFTDI_ID2211PEMICRO_ID2311STLINK_ID2411THIRDPARTY_ID2011TIFET_ID2111XDS100_ID2611$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseARM0C-SPY22810ARMSIM_ID2110CADI_ID2010CMSISDAP_ID2410GDBSERVER_ID2010IJET_ID2810JLINK_ID21610LMIFTDI_ID2210PEMICRO_ID2310STLINK_ID2410THIRDPARTY_ID2010TIFET_ID2110XDS100_ID2610$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qv/iar/dpp-qv.ewp
================================================
3DebugARM1General32811ICCARM23411AARM21011OBJCOPY0111CUSTOM30BICOMP0BUILDACTION1ILINK02011IARCHIVE0011BILINK0Coder0ReleaseARM0General32810ICCARM23410AARM21010OBJCOPY0110CUSTOM30BICOMP0BUILDACTION1ILINK02010IARCHIVE0010BILINK0Coder0Application$PROJ_DIR$\..\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\dpp.h$PROJ_DIR$\..\..\main.c$PROJ_DIR$\..\..\philo.c$PROJ_DIR$\..\..\table.cnucleo-l152re$PROJ_DIR$\..\..\..\..\..\3rd_party\nucleo-l152re\iar\startup_stm32l1xx.s$PROJ_DIR$\..\..\..\..\..\3rd_party\nucleo-l152re\stm32l1xx.h$PROJ_DIR$\..\..\..\..\..\3rd_party\nucleo-l152re\system_stm32l1xx.c$PROJ_DIR$\..\..\..\..\..\3rd_party\nucleo-l152re\system_stm32l1xx.hQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qvn\qvn.cQP_port$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qv\iar\qfn_port.h$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qv\iar\qvn_port.c
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qv/iar/dpp-qv.eww
================================================
$WS_DIR$\dpp-qv.ewp
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/qv/iar/dpp-qv.icf
================================================
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0807FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20013FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 1024;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place in RAM_region { readwrite,
block CSTACK, block HEAP };
define symbol __region_EEPROM_start__ = 0x08080000;
define symbol __region_EEPROM_end__ = 0x08083FFF;
define region EEPROM_region = mem:[from __region_EEPROM_start__ to __region_EEPROM_end__];
place in EEPROM_region { section .eeprom };
================================================
FILE: examples/arm-cm/dpp_nucleo-l152re/table.c
================================================
/*.$file${.::table.c} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: dpp.qm
* File: ${.::table.c}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::table.c} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("table")
/* Active object class -----------------------------------------------------*/
/*.$declare${AOs::Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table} ...........................................................*/
typedef struct Table {
/* protected: */
QActive super;
/* private: */
uint8_t fork[N_PHILO];
uint8_t isHungry[N_PHILO];
} Table;
/* protected: */
static QState Table_initial(Table * const me);
static QState Table_active(Table * const me);
static QState Table_serving(Table * const me);
static QState Table_paused(Table * const me);
/*.$enddecl${AOs::Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Global objects ----------------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*. Check for the minimum required QP version */
#if (QP_VERSION < 650U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpn version 6.5.0 or higher required
#endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Table} ........................................................*/
struct Table AO_Table;
/*.$enddef${AOs::AO_Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#define RIGHT(n_) ((uint8_t)(((n_) + (N_PHILO - 1U)) % N_PHILO))
#define LEFT(n_) ((uint8_t)(((n_) + 1U) % N_PHILO))
#define FREE ((uint8_t)0)
#define USED ((uint8_t)1)
/*..........................................................................*/
/*.$define${AOs::Table_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table_ctor} ......................................................*/
void Table_ctor(void) {
uint8_t n;
Table *me = &AO_Table;
QActive_ctor(&me->super, Q_STATE_CAST(&Table_initial));
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
}
}
/*.$enddef${AOs::Table_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table} ...........................................................*/
/*.${AOs::Table::SM} .......................................................*/
static QState Table_initial(Table * const me) {
/*.${AOs::Table::SM::initial} */
uint8_t n;
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "thinking");
}
return Q_TRAN(&Table_serving);
}
/*.${AOs::Table::SM::active} ...............................................*/
static QState Table_active(Table * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Table::SM::active::TERMINATE} */
case TERMINATE_SIG: {
BSP_terminate(0);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::EAT} */
case EAT_SIG: {
Q_ERROR();
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Table::SM::active::serving} ......................................*/
static QState Table_serving(Table * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Table::SM::active::serving} */
case Q_ENTRY_SIG: {
uint8_t n;
for (n = 0U; n < N_PHILO; ++n) { /* give permissions to eat... */
if ((me->isHungry[n] != 0U)
&& (me->fork[LEFT(n)] == FREE)
&& (me->fork[n] == FREE))
{
QActive *philo;
me->fork[LEFT(n)] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "eating ");
}
}
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::serving::HUNGRY} */
case HUNGRY_SIG: {
uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "hungry ");
m = LEFT(n);
/*.${AOs::Table::SM::active::serving::HUNGRY::[bothfree]} */
if ((me->fork[m] == FREE) && (me->fork[n] == FREE)) {
me->fork[m] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
BSP_displayPhilStat(n, "eating ");
status_ = Q_HANDLED();
}
/*.${AOs::Table::SM::active::serving::HUNGRY::[else]} */
else {
me->isHungry[n] = 1U;
status_ = Q_HANDLED();
}
break;
}
/*.${AOs::Table::SM::active::serving::DONE} */
case DONE_SIG: {
uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;
m = RIGHT(n); /* check the right neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[m] == FREE)) {
me->fork[n] = USED;
me->fork[m] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}
m = LEFT(n); /* check the left neighbor */
n = LEFT(m); /* left fork of the left neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[n] == FREE)) {
me->fork[m] = USED;
me->fork[n] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::serving::EAT} */
case EAT_SIG: {
Q_ERROR();
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::serving::PAUSE} */
case PAUSE_SIG: {
status_ = Q_TRAN(&Table_paused);
break;
}
default: {
status_ = Q_SUPER(&Table_active);
break;
}
}
return status_;
}
/*.${AOs::Table::SM::active::paused} .......................................*/
static QState Table_paused(Table * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Table::SM::active::paused} */
case Q_ENTRY_SIG: {
BSP_displayPaused(1U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::paused} */
case Q_EXIT_SIG: {
BSP_displayPaused(0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::paused::SERVE} */
case SERVE_SIG: {
status_ = Q_TRAN(&Table_serving);
break;
}
/*.${AOs::Table::SM::active::paused::HUNGRY} */
case HUNGRY_SIG: {
uint8_t n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* philo ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
me->isHungry[n] = 1U;
BSP_displayPhilStat(n, "hungry ");
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::paused::DONE} */
case DONE_SIG: {
uint8_t n, m;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&Table_active);
break;
}
}
return status_;
}
/*.$enddef${AOs::Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/README.txt
================================================
About this Example
==================
This directory contains the "Fly 'n' Shoot" game example application for
the EFM32-SLSTK3401A board (Pearl Gecko evaluation kit) board. This
directory contains portable code that should compile with any C compiler
for ARM Cortex-M.
The sub-directories contain code and project files, which are specific to
the particular ARM toolchains, such as ARM (MDK-ARM), GCC, and IAR.
Please refer to the README files in the sub-directories for specific
instructions how to use and customize the example to your needs.
Support Code for EFM32-SLSTK3401A Board
=======================================
The directory qpc\3rd_party\efm32pg1b\ contains the CMSIS-compliant
device code for the LM3S811 MCU. Please see the README file in this
folder for more details.
QS Software Tracing Instrumentation
-----------------------------------
The Blinky example provides the "Spy" build configuration, which
outputs the QS (Quantum Spy) software tracing data through UART0,
which is connected to the virtual COM port of the TI Stellaris debugger.
The output is generated at 115200 baud rate.
Here is an example invocation of the QSPY host application to receive
the QS data from EFM32-SLSTK3401A:
qspy -cCOM1
The actual COM port number might be different on your Windows machine.
Please check the Device Manager to find the COM port number.
Win32 Emulations
================
The sub-directorie win32 and win32-qv provide the emulations of the example
on Windows GUI (with regular Win32 threads and with cooperative QV scheduler,
respectively. These sub-directories contain the Makefiles for the MinGW
toolset and Visual Studio solution files (game-gui.sln) for Visual C++.
The Win32 emulations use exactly the same code as the embedded board and
differ only in the Board Support Package (bsp.c). This examples demonstrate
the "dual targeting" development approach, where most of the embedded code
is developed on the desktop machine (Windows), but is intended for a deeply
embedded target (EFM32-SLSTK3401A here).
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/README.url
================================================
[InternetShortcut]
URL=http://www.state-machine.com/qpn/arm-cm_game_efm32-slstk3401a.html
IconFile=http://www.state-machine.com/qp.ico
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/bsp.h
================================================
/*****************************************************************************
* Product: "Fly 'n' Shoot" game example on EFM32-SLSTK3401A board
* Last updated for version 5.6.5
* Last updated on 2016-06-02
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef BSP_H
#define BSP_H
#define BSP_TICKS_PER_SEC 33U
#define BSP_SCREEN_WIDTH 128U
#define BSP_SCREEN_HEIGHT 128U
void BSP_init(void);
void BSP_terminate(int16_t result);
void BSP_updateScreen(void);
void BSP_clearFB(void);
void BSP_clearWalls(void);
void BSP_paintString(uint8_t x, uint8_t y, char const *str);
void BSP_paintBitmap(uint8_t x, uint8_t y, uint8_t bmp_id);
void BSP_advanceWalls(uint8_t top, uint8_t bottom);
void BSP_updateScore(uint16_t score);
bool BSP_isThrottle(void); /* is the throttle button depressed? */
bool BSP_doBitmapsOverlap(uint8_t bmp_id1, uint8_t x1, uint8_t y1,
uint8_t bmp_id2, uint8_t x2, uint8_t y2);
bool BSP_isWallHit(uint8_t bmp_id, uint8_t x, uint8_t y);
void BSP_displayOn(void);
void BSP_displayOff(void);
void BSP_randomSeed(uint32_t seed); /* random seed */
uint32_t BSP_random(void); /* pseudo-random generator */
#endif /* BSP_H */
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/game.h
================================================
/*.$file${.::game.h} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: game.qm
* File: ${.::game.h}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::game.h} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#ifndef GAME_H
#define GAME_H
enum GameSignals { /* signals used in the game */
TIME_TICK_SIG = Q_USER_SIG, /* published from tick ISR */
PLAYER_TRIGGER_SIG, /* posted by Player (ISR) to trigger the Missile */
PLAYER_QUIT_SIG, /* posted by Player (ISR) to quit the game */
GAME_OVER_SIG, /* posted by Ship when it finishes exploding */
PLAYER_SHIP_MOVE_SIG, /* posted by Player (ISR) to the Ship to move it */
TAKE_OFF_SIG, /* from Tunnel to Ship to grant permission to take off */
HIT_WALL_SIG, /* from Tunnel to Ship when Ship hits the wall */
HIT_MINE_SIG, /* from Mine to Ship or Missile when it hits the mine */
SHIP_IMG_SIG, /* from Ship to the Tunnel to draw and check for hits */
MISSILE_IMG_SIG, /* from Missile the Tunnel to draw and check for hits */
MINE_IMG_SIG, /* posted by Mine to the Tunnel to draw the mine */
MISSILE_FIRE_SIG, /* posted by Ship to the Missile to fire */
DESTROYED_MINE_SIG, /* from Missile to Ship when Missile destroyed Mine */
EXPLOSION_SIG, /* from any exploding object to render the explosion */
MINE_PLANT_SIG, /* from Tunnel to the Mine to plant it */
MINE_DISABLED_SIG,/* from Mine to Tunnel when it becomes disabled */
MINE_RECYCLE_SIG, /* posted by Tunnel to Mine to recycle the mine */
SCORE_SIG /* from Ship to Tunnel to adjust game level based on score */
};
/* active objects ..........................................................*/
extern struct Tunnel AO_Tunnel;
extern struct Ship AO_Ship;
extern struct Missile AO_Missile;
/*.$declare${AOs::Tunnel_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Tunnel_ctor} .....................................................*/
void Tunnel_ctor(void);
/*.$enddecl${AOs::Tunnel_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::Ship_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Ship_ctor} .......................................................*/
void Ship_ctor(void);
/*.$enddecl${AOs::Ship_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::Missile_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Missile_ctor} ....................................................*/
void Missile_ctor(uint8_t speed);
/*.$enddecl${AOs::Missile_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* common constants and shared helper functions ............................*/
#define GAME_TUNNEL_WIDTH BSP_SCREEN_WIDTH
#define GAME_TUNNEL_HEIGHT (BSP_SCREEN_HEIGHT - 10U)
#define GAME_MINES_MAX 5U
#define GAME_MINES_DIST_MIN 10U
#define GAME_SPEED_X 1U
#define GAME_MISSILE_SPEED_X 2U
#define GAME_SHIP_X 10U
#define GAME_SHIP_Y (GAME_TUNNEL_HEIGHT / 2U)
#define GAME_WALLS_GAP_Y 50U
#define GAME_WALLS_MIN_GAP_Y 20U
enum GameBitmapIds {
SHIP_BMP,
MISSILE_BMP,
MINE1_BMP,
MINE2_BMP,
MINE2_MISSILE_BMP,
EXPLOSION0_BMP,
EXPLOSION1_BMP,
EXPLOSION2_BMP,
EXPLOSION3_BMP,
MAX_BMP
};
/* instantiation of the Mines orthogonal components */
/*.$declare${AOs::Mine1_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Mine1_ctor} ......................................................*/
QHsm * Mine1_ctor(uint8_t id);
/*.$enddecl${AOs::Mine1_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::Mine2_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Mine2_ctor} ......................................................*/
QHsm * Mine2_ctor(uint8_t id);
/*.$enddecl${AOs::Mine2_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#endif /* GAME_H */
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/game.qm
================================================
"Fly 'n' Shoot" game model from Chapters 1 & 9 of PSiCC2
NOTE: Requries QP5.Tunnel Active Objectuint32_t rnd;
rnd = (BSP_random() & 0xFFU);
/* reduce the top wall thickness 18.75% of the time */
if ((rnd < 48U) && (me->wall_thickness_top > 0U)) {
--me->wall_thickness_top;
}
/* reduce the bottom wall thickness 18.75% of the time */
if ((rnd > 208U) && (me->wall_thickness_bottom > 0U)) {
--me->wall_thickness_bottom;
}
rnd = (BSP_random() & 0xFFU);
/* grow the bottom wall thickness 19.14% of the time */
if ((rnd < 49U)
&& ((GAME_TUNNEL_HEIGHT
- me->wall_thickness_top
- me->wall_thickness_bottom) > me->wall_gap))
{
++me->wall_thickness_bottom;
}
/* grow the top wall thickness 19.14% of the time */
if ((rnd > 207U)
&& ((GAME_TUNNEL_HEIGHT
- me->wall_thickness_top
- me->wall_thickness_bottom) > me->wall_gap))
{
++me->wall_thickness_top;
}
/* advance the Tunnel by 1 game step to the left
* and copy the Tunnel layer to the main frame buffer
*/
BSP_advanceWalls(me->wall_thickness_top, me->wall_thickness_bottom);uint32_t rnd = (BSP_random() & 0xFFU);
if (me->last_mine_x > 0U) {
--me->last_mine_x; /* shift the last Mine 1 position to the left */
}
/* last mine far enough? */
if ((me->last_mine_x + GAME_MINES_DIST_MIN < GAME_TUNNEL_WIDTH)
&& (rnd < 8U)) /* place the mines only 5% of the time */
{
uint8_t n;
for (n = 0U; n < Q_DIM(me->mines); ++n) { /*look for disabled mines */
if (me->mines[n] == (QHsm *)0) {
break;
}
}
if (n < Q_DIM(me->mines)) { /* a disabled Mine found? */
rnd = (BSP_random() & 0xFFFFU);
if ((rnd & 1U) == 0U) { /* choose the type of the mine */
me->mines[n] = me->mine1_pool[n];
}
else {
me->mines[n] = me->mine2_pool[n];
}
/* new Mine is planted by the end of the tunnel */
me->last_mine_x = GAME_TUNNEL_WIDTH - 8U;
/* choose a random y-position for the Mine in the Tunnel */
rnd %= (GAME_TUNNEL_HEIGHT
- me->wall_thickness_top
- me->wall_thickness_bottom - 4U);
me->last_mine_y = (uint8_t)(me->wall_thickness_top + 2U + rnd);
Q_SIG(me->mines[n]) = MINE_PLANT_SIG;
Q_PAR(me->mines[n]) = (me->last_mine_x | (me->last_mine_y << 8));
QHSM_DISPATCH(me->mines[n]); /* direct dispatch */
}
}uint8_t n;
for (n = 0; n < GAME_MINES_MAX; ++n) {
if (me->mines[n] != (QHsm *)0) { /* is the mine used? */
Q_SIG(me->mines[n]) = sig;
Q_PAR(me->mines[n]) = par;
QHSM_DISPATCH(me->mines[n]);
}
}uint8_t n;
for (n = 0; n < GAME_MINES_MAX; ++n) {
QHSM_INIT(me->mine1_pool[n]); /* initial tran. for Mine1 */
QHSM_INIT(me->mine2_pool[n]); /* initial tran. for Mine2 */
}
BSP_randomSeed(1234U); /* seed the pseudo-random generator */Q_ASSERT((Q_PAR(me) < GAME_MINES_MAX)
&& (me->mines[Q_PAR(me)] != (QHsm *)0));
me->mines[Q_PAR(me)] = (QHsm *)0;QActive_armX(&me->super, 0U,
BSP_TICKS_PER_SEC/2U, BSP_TICKS_PER_SEC/2U); /* periodic */
me->blink_ctr = 10U;
BSP_paintString(24U, (GAME_TUNNEL_HEIGHT / 2U) - 8U, "Quantum LeAps");
BSP_paintString(16U, (GAME_TUNNEL_HEIGHT / 2U) + 0U, "state-machine.com");
BSP_paintString(1U, GAME_TUNNEL_HEIGHT - 18U, "Fire missile: BTN0");
BSP_paintString(1U, GAME_TUNNEL_HEIGHT - 10U, "Fly ship up: BTN1");
BSP_updateScreen();QActive_disarmX(&me->super, 0U);--me->blink_ctr; /* toggle the blink couner */me->blink_ctr == 0UelseBSP_paintString(24U + 8U*6U, (GAME_TUNNEL_HEIGHT / 2U) - 8U,
"LeaPs");
BSP_updateScreen();(me->blink_ctr & 1U) != 0UBSP_paintString(24U + 8U*6U, (GAME_TUNNEL_HEIGHT / 2U) - 8U,
"LeAps");
BSP_updateScreen();me->last_mine_x = 0U; /* last mine at right edge of the tunnel */
me->last_mine_y = 0U;
/* set the tunnel properties... */
me->wall_thickness_top = 0U;
me->wall_thickness_bottom = 0U;
me->wall_gap = GAME_WALLS_GAP_Y;
/* clear the tunnel walls */
BSP_clearWalls();
QActive_armX(&me->super, 0U,
BSP_TICKS_PER_SEC/2U, BSP_TICKS_PER_SEC/2U); /* periodic */
me->blink_ctr = 20U*2U; /* 20s timeout total */QActive_disarmX(&me->super, 0U);Tunnel_advance(me);
if (me->blink_ctr != 0U) {
/* add the text bitmap into the frame buffer */
BSP_paintString((GAME_TUNNEL_WIDTH - 10U*6U)/2U,
(GAME_TUNNEL_HEIGHT - 4U)/2U,
"Press BTN0");
}
BSP_updateScreen();--me->blink_ctr;me->blink_ctr == 0me->wall_gap = GAME_WALLS_GAP_Y;
QACTIVE_POST(&AO_Ship, TAKE_OFF_SIG, 0);Tunnel_dispatchToAllMines(me, MINE_RECYCLE_SIG, 0);/* render this frame on the display */
BSP_updateScreen();
Tunnel_advance(me);
Tunnel_plantMine(me);
Tunnel_dispatchToAllMines(me, Q_SIG(me), Q_PAR(me));uint8_t x = (uint8_t)Q_PAR(me);
uint8_t y = (uint8_t)(Q_PAR(me) >> 8);
uint8_t bmp = (uint8_t)(Q_PAR(me) >> 16);
/* did the Ship/Missile hit the tunnel wall? */
if (BSP_isWallHit(bmp, x, y)) {
QACTIVE_POST(&AO_Ship, HIT_WALL_SIG, 0);
}
BSP_paintBitmap(x, y, bmp);
Tunnel_dispatchToAllMines(me, Q_SIG(me), Q_PAR(me));uint8_t x = (uint8_t)Q_PAR(me);
uint8_t y = (uint8_t)(Q_PAR(me) >> 8);
uint8_t bmp = (uint8_t)(Q_PAR(me) >> 16);
/* did the Ship/Missile hit the tunnel wall? */
if (BSP_isWallHit(bmp, x, y)) {
QACTIVE_POST(&AO_Missile, HIT_WALL_SIG, 0);
}
BSP_paintBitmap(x, y, bmp);
Tunnel_dispatchToAllMines(me, Q_SIG(me), Q_PAR(me));BSP_paintBitmap((uint8_t)Q_PAR(me),
(uint8_t)(Q_PAR(me) >> 8),
(uint8_t)(Q_PAR(me) >> 16));BSP_paintBitmap((uint8_t)Q_PAR(me),
(uint8_t)(Q_PAR(me) >> 8),
(uint8_t)(Q_PAR(me) >> 16));BSP_updateScore((uint16_t)Q_PAR(me));
/* increase difficulty of the game:
* the tunnel gets narrower as the score goes up
*/
me->wall_gap = (uint8_t)(GAME_WALLS_GAP_Y
- (uint16_t)Q_PAR(me)/100U);
if (me->wall_gap < GAME_WALLS_MIN_GAP_Y) {
me->wall_gap = GAME_WALLS_MIN_GAP_Y;
}BSP_clearWalls();
BSP_updateScore((uint16_t)Q_PAR(me));
BSP_updateScreen();QActive_armX(&me->super, 0U,
BSP_TICKS_PER_SEC/2U, BSP_TICKS_PER_SEC/2U); /* periodic */
me->blink_ctr = 5U*2U; /* 5s timeout */
BSP_paintString((GAME_TUNNEL_WIDTH - 6U * 9U) / 2U,
(GAME_TUNNEL_HEIGHT / 2U) - 4U,
"Game Over");
BSP_updateScreen();QActive_disarmX(&me->super, 0U);
BSP_updateScore(0); /* update the score on the display */--me->blink_ctr;
BSP_paintString((GAME_TUNNEL_WIDTH - 6U*9U) / 2U,
(GAME_TUNNEL_HEIGHT / 2U) - 4U,
(((me->blink_ctr & 1) != 0)
? "Game Over"
: " "));
BSP_updateScreen();me->blink_ctr == 0BSP_displayOff(); /* power down the display */
QActive_armX(&me->super, 0U, BSP_TICKS_PER_SEC*3U, 0U); /* 3 sec */QActive_disarmX(&me->super, 0U);
BSP_displayOn(); /* power up the display */uint32_t rnd = BSP_random();
/* clear the screen frame buffer */
BSP_clearFB();
BSP_paintString((uint8_t)(rnd % (GAME_TUNNEL_WIDTH - 10U*6U)),
(uint8_t) (rnd % (GAME_TUNNEL_HEIGHT - 8U)),
"Press BTN0");
BSP_updateScreen();
QActive_armX(&me->super, 0U, BSP_TICKS_PER_SEC/3U, 0U);/* 1/3 sec */QActive_disarmX(&me->super, 0U);
BSP_clearFB();
BSP_updateScreen();/* clear the screen */
BSP_clearFB();
BSP_updateScreen();
QF_stop(); /* stop QF and cleanup */Ship Active Objectfixed point in 14s2 representationme->score = 0; /* reset the score */
QACTIVE_POST(&AO_Tunnel, SCORE_SIG, me->score);
/* lauch the ship from the initial position */
me->x = GAME_SHIP_X;
me->y = (GAME_SHIP_Y << 2);/* move the Ship up or down depending on the button state */
if (BSP_isThrottle()) {
if (me->y > 0) {
me->y -= 1U;
}
}
else {
if (me->y < (GAME_TUNNEL_HEIGHT << 2)) {
me->y += 1U;
}
}
/* tell the Tunnel to draw the Ship and test for hits */
QACTIVE_POST(&AO_Tunnel, SHIP_IMG_SIG,
(SHIP_BMP << 16)
| me->x
| ((me->y >> 2) << 8));
++me->score; /* increment the score for surviving another tick */
if ((me->score % 10) == 0) { /* is the score "round"? */
QACTIVE_POST(&AO_Tunnel, SCORE_SIG, me->score);
}QACTIVE_POST(&AO_Missile, MISSILE_FIRE_SIG,
me->x | (((me->y >> 2) - 1 + SHIP_HEIGHT) & 0xFFU) << 8);me->score += (uint16_t)Q_PAR(me);
/* the score will be sent to the Tunnel by the next TIME_TICK */me->exp_ctr = 0;me->exp_ctr < 15++me->exp_ctr;
/* tell the Tunnel to draw the current stage of Explosion */
QACTIVE_POST(&AO_Tunnel, EXPLOSION_SIG,
((EXPLOSION0_BMP + (me->exp_ctr >> 2)) << 16)
| me->x
| ((((me->y >> 2) - 4U + SHIP_HEIGHT) & 0xFFU) << 8));elseQACTIVE_POST(&AO_Tunnel, GAME_OVER_SIG, me->score);Missile Active Objectme->x = (uint8_t)Q_PAR(me); /* init position from the Ship */
me->y = (uint8_t)(Q_PAR(me) >> 8);me->x + GAME_MISSILE_SPEED_X < GAME_TUNNEL_WIDTHme->x += me->speed;
/*tell the Tunnel to draw the Missile and test for wall hits*/
QACTIVE_POST(&AO_Tunnel, MISSILE_IMG_SIG,
(MISSILE_BMP << 16)
| me->x
| (me->y << 8));else/* tell the Ship the score for destroing this Mine */
QACTIVE_POST(&AO_Ship, Q_SIG(me), Q_PAR(me));
/* re-arm immediately & let the destroyed Mine do the exploding */me->exp_ctr = 0;(me->x >= GAME_SPEED_X) && (me->exp_ctr < 15)++me->exp_ctr; /* advance the explosion counter */
me->x -= me->speed; /* move the explosion by one step */
/* tell the Tunnel to render the current stage of Explosion */
QACTIVE_POST(&AO_Tunnel, EXPLOSION_SIG,
((EXPLOSION0_BMP + (me->exp_ctr >> 2)) << 16)
| (me->x + 3)
| ((int)me->y - 4) << 8);else/* explosion finished or moved outside the game */The Mine1 orthogonal componentme->x = (uint8_t)Q_PAR(me);
me->y = (uint8_t)(Q_PAR(me) >> 8);/* tell the Tunnel that this mine is becoming disabled */
QACTIVE_POST(&AO_Tunnel, MINE_DISABLED_SIG, MINE_ID(me));me->x >= GAME_SPEED_Xme->x -= GAME_SPEED_X; /* move the mine 1 step */
/* tell the Tunnel to draw the Mine */
QACTIVE_POST(&AO_Tunnel, MINE_IMG_SIG,
(MINE1_BMP << 16)
| me->x
| (me->y << 8));elseuint8_t x = (uint8_t)Q_PAR(me);
uint8_t y = (uint8_t)(Q_PAR(me) >> 8);
uint8_t bmp = (uint8_t)(Q_PAR(me) >> 16);BSP_doBitmapsOverlap(MINE1_BMP, me->x, me->y, bmp, x, y)QACTIVE_POST(&AO_Ship, HIT_MINE_SIG, 1);
/* go straight to 'disabled' and let the Ship do
* the exploding
*/uint8_t x = (uint8_t)Q_PAR(me);
uint8_t y = (uint8_t)(Q_PAR(me) >> 8);
uint8_t bmp = (uint8_t)(Q_PAR(me) >> 16);BSP_doBitmapsOverlap(MINE1_BMP, me->x, me->y, bmp, x, y)/* post the score for destroying Mine type-1 */
QACTIVE_POST(&AO_Missile, DESTROYED_MINE_SIG, 25);me->exp_ctr = 0;(me->x >= GAME_SPEED_X) && (me->exp_ctr < 15)++me->exp_ctr; /* advance the explosion counter */
me->x -= GAME_SPEED_X; /* move explosion by 1 step */
/* tell the Game to render the current stage of Explosion */
QACTIVE_POST(&AO_Tunnel, EXPLOSION_SIG,
((EXPLOSION0_BMP + (me->exp_ctr >> 2)) << 16)
| (me->x + 1)
| (((int)me->y - 4 + 2)) << 8);elseThe Mine2 orthogonal componentme->x = (uint8_t)Q_PAR(me);
me->y = (uint8_t)(Q_PAR(me) >> 8);/* tell the Tunnel that this mine is becoming disabled */
QACTIVE_POST(&AO_Tunnel, MINE_DISABLED_SIG, MINE_ID(me));me->x >= GAME_SPEED_Xme->x -= GAME_SPEED_X; /* move the mine 1 step */
/* tell the Tunnel to draw the Mine */
QACTIVE_POST(&AO_Tunnel, MINE_IMG_SIG,
(MINE2_BMP << 16)
| me->x
| (me->y << 8));elseuint8_t x = (uint8_t)Q_PAR(me);
uint8_t y = (uint8_t)(Q_PAR(me) >> 8);
uint8_t bmp = (uint8_t)(Q_PAR(me) >> 16);BSP_doBitmapsOverlap(MINE2_BMP, me->x, me->y, bmp, x, y)QACTIVE_POST(&AO_Ship, HIT_MINE_SIG, 2);
/* go straight to 'disabled' and let the Ship do the exploding */uint8_t x = (uint8_t)Q_PAR(me);
uint8_t y = (uint8_t)(Q_PAR(me) >> 8);
uint8_t bmp = (uint8_t)(Q_PAR(me) >> 16);BSP_doBitmapsOverlap(MINE2_MISSILE_BMP, me->x, me->y, bmp, x, y)/* NOTE: Mine type-2 is nastier than Mine type-1.
* The type-2 mine can hit the Ship with any of its
* "tentacles". However, it can be destroyed by the
* Missile only by hitting its center, defined as
* a smaller bitmap MINE2_MISSILE_BMP.
*/
/* post the score for destroying Mine type-2 */
QACTIVE_POST(&AO_Missile, DESTROYED_MINE_SIG, 45);me->exp_ctr = 0;(me->x >= GAME_SPEED_X) && (me->exp_ctr < 15)++me->exp_ctr; /* advance the explosion counter */
me->x -= GAME_SPEED_X; /* move explosion by 1 step */
/* tell the Game to render the current stage of Explosion */
QACTIVE_POST(&AO_Tunnel, EXPLOSION_SIG,
((EXPLOSION0_BMP + (me->exp_ctr >> 2)) << 16)
| (me->x + 1)
| (((int)me->y - 4 + 2)) << 8);elseuint8_t n;
Tunnel *me = &AO_Tunnel;
QActive_ctor(&me->super, Q_STATE_CAST(&Tunnel_initial));
for (n = 0; n < GAME_MINES_MAX; ++n) {
me->mine1_pool[n] = Mine1_ctor(n); /* instantiate Mine1 in the pool */
me->mine2_pool[n] = Mine2_ctor(n); /* instantiate Mine2 in the pool */
me->mines[n] = (QHsm *)0; /* mine 'n' is unused */
}
me->last_mine_x = 0; /* the last mine at the right edge of the tunnel */
me->last_mine_y = 0;Ship *me = &AO_Ship;
QActive_ctor(&me->super, Q_STATE_CAST(&Ship_initial));
me->x = GAME_SHIP_X;
me->y = (GAME_SHIP_Y << 2);Missile *me = &AO_Missile;
QActive_ctor(&me->super, Q_STATE_CAST(&Missile_initial));
me->speed = speed;Mine1 *me;
Q_REQUIRE(id < GAME_MINES_MAX);
me = &l_mine1[id];
QHsm_ctor(&me->super, Q_STATE_CAST(&Mine1_initial));
return &me->super;Mine2 *me;
Q_REQUIRE(id < GAME_MINES_MAX);
me = &l_mine2[id];
QHsm_ctor(&me->super, Q_STATE_CAST(&Mine2_initial));
return &me->super;#ifndef GAME_H
#define GAME_H
enum GameSignals { /* signals used in the game */
TIME_TICK_SIG = Q_USER_SIG, /* published from tick ISR */
PLAYER_TRIGGER_SIG, /* posted by Player (ISR) to trigger the Missile */
PLAYER_QUIT_SIG, /* posted by Player (ISR) to quit the game */
GAME_OVER_SIG, /* posted by Ship when it finishes exploding */
PLAYER_SHIP_MOVE_SIG, /* posted by Player (ISR) to the Ship to move it */
TAKE_OFF_SIG, /* from Tunnel to Ship to grant permission to take off */
HIT_WALL_SIG, /* from Tunnel to Ship when Ship hits the wall */
HIT_MINE_SIG, /* from Mine to Ship or Missile when it hits the mine */
SHIP_IMG_SIG, /* from Ship to the Tunnel to draw and check for hits */
MISSILE_IMG_SIG, /* from Missile the Tunnel to draw and check for hits */
MINE_IMG_SIG, /* posted by Mine to the Tunnel to draw the mine */
MISSILE_FIRE_SIG, /* posted by Ship to the Missile to fire */
DESTROYED_MINE_SIG, /* from Missile to Ship when Missile destroyed Mine */
EXPLOSION_SIG, /* from any exploding object to render the explosion */
MINE_PLANT_SIG, /* from Tunnel to the Mine to plant it */
MINE_DISABLED_SIG,/* from Mine to Tunnel when it becomes disabled */
MINE_RECYCLE_SIG, /* posted by Tunnel to Mine to recycle the mine */
SCORE_SIG /* from Ship to Tunnel to adjust game level based on score */
};
/* active objects ..........................................................*/
extern struct Tunnel AO_Tunnel;
extern struct Ship AO_Ship;
extern struct Missile AO_Missile;
$declare(AOs::Tunnel_ctor)
$declare(AOs::Ship_ctor)
$declare(AOs::Missile_ctor)
/* common constants and shared helper functions ............................*/
#define GAME_TUNNEL_WIDTH BSP_SCREEN_WIDTH
#define GAME_TUNNEL_HEIGHT (BSP_SCREEN_HEIGHT - 10U)
#define GAME_MINES_MAX 5U
#define GAME_MINES_DIST_MIN 10U
#define GAME_SPEED_X 1U
#define GAME_MISSILE_SPEED_X 2U
#define GAME_SHIP_X 10U
#define GAME_SHIP_Y (GAME_TUNNEL_HEIGHT / 2U)
#define GAME_WALLS_GAP_Y 50U
#define GAME_WALLS_MIN_GAP_Y 20U
enum GameBitmapIds {
SHIP_BMP,
MISSILE_BMP,
MINE1_BMP,
MINE2_BMP,
MINE2_MISSILE_BMP,
EXPLOSION0_BMP,
EXPLOSION1_BMP,
EXPLOSION2_BMP,
EXPLOSION3_BMP,
MAX_BMP
};
/* instantiation of the Mines orthogonal components */
$declare(AOs::Mine1_ctor)
$declare(AOs::Mine2_ctor)
#endif /* GAME_H */
#include "qpn.h"
#include "game.h"
#include "bsp.h"
/* Q_DEFINE_THIS_MODULE("missile") */
/* encapsulated delcaration of the Missile active object -------------------*/
$declare(AOs::Missile)
/* global objects ----------------------------------------------------------*/
Missile AO_Missile;
/* Active object definition ------------------------------------------------*/
$define(AOs::Missile_ctor)
$define(AOs::Missile)#include "qpn.h"
#include "game.h"
#include "bsp.h"
/* Q_DEFINE_THIS_MODULE(ship) */
#define SHIP_WIDTH 5U
#define SHIP_HEIGHT 3U
/* encapsulated delcaration of the Ship active object ----------------------*/
$declare(AOs::Ship)
/* global objects ----------------------------------------------------------*/
Ship AO_Ship;
/* Active object definition ------------------------------------------------*/
$define(AOs::Ship_ctor)
$define(AOs::Ship)#include "qpn.h"
#include "game.h"
#include "bsp.h"
Q_DEFINE_THIS_MODULE("tunnel")
/* local objects -----------------------------------------------------------*/
$declare(AOs::Tunnel)
/* global objects ----------------------------------------------------------*/
Tunnel AO_Tunnel;
/* Active object definition ================================================*/
$define(AOs::Tunnel_ctor)
$define(AOs::Tunnel)#include "qpn.h"
#include "game.h"
#include "bsp.h"
Q_DEFINE_THIS_MODULE("mine1")
/* encapsulated delcaration of the Mine1 HSM -------------------------------*/
$declare(AOs::Mine1)
/* local objects -----------------------------------------------------------*/
static Mine1 l_mine1[GAME_MINES_MAX]; /* a pool of type-1 mines */
/* helper macro to provide the ID of this mine */
#define MINE_ID(me_) ((me_) - l_mine1)
/* Mine1 class definition --------------------------------------------------*/
$define(AOs::Mine1_ctor)
$define(AOs::Mine1)#include "qpn.h"
#include "game.h"
#include "bsp.h"
Q_DEFINE_THIS_MODULE("mine2")
/* encapsulated delcaration of the Mine2 HSM -------------------------------*/
$declare(AOs::Mine2)
/* local objects -----------------------------------------------------------*/
static Mine2 l_mine2[GAME_MINES_MAX]; /* a pool of type-2 mines */
/* helper macro to provide the ID of this mine */
#define MINE_ID(me_) ((me_) - l_mine2)
/* Mine2 class definition --------------------------------------------------*/
$define(AOs::Mine2_ctor)
$define(AOs::Mine2)
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/main.c
================================================
/*****************************************************************************
* Product: "Fly 'n' Shoot" game example
* Last Updated for Version: 5.8.0
* Date of the Last Update: 2016-11-06
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h" /* QP-nano */
#include "game.h" /* Game application */
#include "bsp.h" /* Board Support Package */
/*..........................................................................*/
static QEvt l_tunnelQueue[GAME_MINES_MAX + 5];
static QEvt l_shipQueue[3];
static QEvt l_missileQueue[3];
/* QF_active[] array defines all active object control blocks --------------*/
QActiveCB const Q_ROM QF_active[] = {
{ (QActive *)0, (QEvt *)0, 0U },
{ (QActive *)&AO_Tunnel, l_tunnelQueue, Q_DIM(l_tunnelQueue) },
{ (QActive *)&AO_Ship, l_shipQueue, Q_DIM(l_shipQueue) },
{ (QActive *)&AO_Missile, l_missileQueue, Q_DIM(l_missileQueue) }
};
/*..........................................................................*/
int_t main() {
Tunnel_ctor();
Ship_ctor();
Missile_ctor(GAME_MISSILE_SPEED_X);
QF_init(Q_DIM(QF_active)); /* initialize the QF-nano framework */
BSP_init(); /* initialize the Board Support Package */
return QF_run(); /* transfer control to QF-nano */
}
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/mine1.c
================================================
/*.$file${.::mine1.c} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: game.qm
* File: ${.::mine1.c}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::mine1.c} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#include "qpn.h"
#include "game.h"
#include "bsp.h"
Q_DEFINE_THIS_MODULE("mine1")
/* encapsulated delcaration of the Mine1 HSM -------------------------------*/
/*.$declare${AOs::Mine1} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Mine1} ...........................................................*/
typedef struct Mine1 {
/* protected: */
QHsm super;
/* private: */
uint8_t x;
uint8_t y;
uint8_t exp_ctr;
} Mine1;
/* protected: */
static QState Mine1_initial(Mine1 * const me);
static QState Mine1_unused(Mine1 * const me);
static QState Mine1_used(Mine1 * const me);
static QState Mine1_planted(Mine1 * const me);
static QState Mine1_exploding(Mine1 * const me);
/*.$enddecl${AOs::Mine1} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* local objects -----------------------------------------------------------*/
static Mine1 l_mine1[GAME_MINES_MAX]; /* a pool of type-1 mines */
/* helper macro to provide the ID of this mine */
#define MINE_ID(me_) ((me_) - l_mine1)
/* Mine1 class definition --------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*. Check for the minimum required QP version */
#if (QP_VERSION < 650U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpn version 6.5.0 or higher required
#endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Mine1_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Mine1_ctor} ......................................................*/
QHsm * Mine1_ctor(uint8_t id) {
Mine1 *me;
Q_REQUIRE(id < GAME_MINES_MAX);
me = &l_mine1[id];
QHsm_ctor(&me->super, Q_STATE_CAST(&Mine1_initial));
return &me->super;
}
/*.$enddef${AOs::Mine1_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Mine1} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Mine1} ...........................................................*/
/*.${AOs::Mine1::SM} .......................................................*/
static QState Mine1_initial(Mine1 * const me) {
/*.${AOs::Mine1::SM::initial} */
return Q_TRAN(&Mine1_unused);
}
/*.${AOs::Mine1::SM::unused} ...............................................*/
static QState Mine1_unused(Mine1 * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Mine1::SM::unused::MINE_PLANT} */
case MINE_PLANT_SIG: {
me->x = (uint8_t)Q_PAR(me);
me->y = (uint8_t)(Q_PAR(me) >> 8);
status_ = Q_TRAN(&Mine1_planted);
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Mine1::SM::used} .................................................*/
static QState Mine1_used(Mine1 * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Mine1::SM::used} */
case Q_EXIT_SIG: {
/* tell the Tunnel that this mine is becoming disabled */
QACTIVE_POST(&AO_Tunnel, MINE_DISABLED_SIG, MINE_ID(me));
status_ = Q_HANDLED();
break;
}
/*.${AOs::Mine1::SM::used::MINE_RECYCLE} */
case MINE_RECYCLE_SIG: {
status_ = Q_TRAN(&Mine1_unused);
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Mine1::SM::used::planted} ........................................*/
static QState Mine1_planted(Mine1 * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Mine1::SM::used::planted::TIME_TICK} */
case TIME_TICK_SIG: {
/*.${AOs::Mine1::SM::used::planted::TIME_TICK::[me->x>=GAME_SPEED_X]} */
if (me->x >= GAME_SPEED_X) {
me->x -= GAME_SPEED_X; /* move the mine 1 step */
/* tell the Tunnel to draw the Mine */
QACTIVE_POST(&AO_Tunnel, MINE_IMG_SIG,
(MINE1_BMP << 16)
| me->x
| (me->y << 8));
status_ = Q_HANDLED();
}
/*.${AOs::Mine1::SM::used::planted::TIME_TICK::[else]} */
else {
status_ = Q_TRAN(&Mine1_unused);
}
break;
}
/*.${AOs::Mine1::SM::used::planted::SHIP_IMG} */
case SHIP_IMG_SIG: {
uint8_t x = (uint8_t)Q_PAR(me);
uint8_t y = (uint8_t)(Q_PAR(me) >> 8);
uint8_t bmp = (uint8_t)(Q_PAR(me) >> 16);
/*.${AOs::Mine1::SM::used::planted::SHIP_IMG::[BSP_doBitmapsOverlap(MINE1_BMP,~} */
if (BSP_doBitmapsOverlap(MINE1_BMP, me->x, me->y, bmp, x, y)) {
QACTIVE_POST(&AO_Ship, HIT_MINE_SIG, 1);
/* go straight to 'disabled' and let the Ship do
* the exploding
*/
status_ = Q_TRAN(&Mine1_unused);
}
else {
status_ = Q_UNHANDLED();
}
break;
}
/*.${AOs::Mine1::SM::used::planted::MISSILE_IMG} */
case MISSILE_IMG_SIG: {
uint8_t x = (uint8_t)Q_PAR(me);
uint8_t y = (uint8_t)(Q_PAR(me) >> 8);
uint8_t bmp = (uint8_t)(Q_PAR(me) >> 16);
/*.${AOs::Mine1::SM::used::planted::MISSILE_IMG::[BSP_doBitmapsOverlap(MINE1_BMP,~} */
if (BSP_doBitmapsOverlap(MINE1_BMP, me->x, me->y, bmp, x, y)) {
/* post the score for destroying Mine type-1 */
QACTIVE_POST(&AO_Missile, DESTROYED_MINE_SIG, 25);
status_ = Q_TRAN(&Mine1_exploding);
}
else {
status_ = Q_UNHANDLED();
}
break;
}
default: {
status_ = Q_SUPER(&Mine1_used);
break;
}
}
return status_;
}
/*.${AOs::Mine1::SM::used::exploding} ......................................*/
static QState Mine1_exploding(Mine1 * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Mine1::SM::used::exploding} */
case Q_ENTRY_SIG: {
me->exp_ctr = 0;
status_ = Q_HANDLED();
break;
}
/*.${AOs::Mine1::SM::used::exploding::TIME_TICK} */
case TIME_TICK_SIG: {
/*.${AOs::Mine1::SM::used::exploding::TIME_TICK::[(me->x>=GAME_SPEED_X)&&(me->exp~} */
if ((me->x >= GAME_SPEED_X) && (me->exp_ctr < 15)) {
++me->exp_ctr; /* advance the explosion counter */
me->x -= GAME_SPEED_X; /* move explosion by 1 step */
/* tell the Game to render the current stage of Explosion */
QACTIVE_POST(&AO_Tunnel, EXPLOSION_SIG,
((EXPLOSION0_BMP + (me->exp_ctr >> 2)) << 16)
| (me->x + 1)
| (((int)me->y - 4 + 2)) << 8);
status_ = Q_HANDLED();
}
/*.${AOs::Mine1::SM::used::exploding::TIME_TICK::[else]} */
else {
status_ = Q_TRAN(&Mine1_unused);
}
break;
}
default: {
status_ = Q_SUPER(&Mine1_used);
break;
}
}
return status_;
}
/*.$enddef${AOs::Mine1} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/mine2.c
================================================
/*.$file${.::mine2.c} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: game.qm
* File: ${.::mine2.c}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::mine2.c} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#include "qpn.h"
#include "game.h"
#include "bsp.h"
Q_DEFINE_THIS_MODULE("mine2")
/* encapsulated delcaration of the Mine2 HSM -------------------------------*/
/*.$declare${AOs::Mine2} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Mine2} ...........................................................*/
typedef struct Mine2 {
/* protected: */
QHsm super;
/* private: */
uint8_t x;
uint8_t y;
uint8_t exp_ctr;
} Mine2;
/* protected: */
static QState Mine2_initial(Mine2 * const me);
static QState Mine2_unused(Mine2 * const me);
static QState Mine2_used(Mine2 * const me);
static QState Mine2_planted(Mine2 * const me);
static QState Mine2_exploding(Mine2 * const me);
/*.$enddecl${AOs::Mine2} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* local objects -----------------------------------------------------------*/
static Mine2 l_mine2[GAME_MINES_MAX]; /* a pool of type-2 mines */
/* helper macro to provide the ID of this mine */
#define MINE_ID(me_) ((me_) - l_mine2)
/* Mine2 class definition --------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*. Check for the minimum required QP version */
#if (QP_VERSION < 650U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpn version 6.5.0 or higher required
#endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Mine2_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Mine2_ctor} ......................................................*/
QHsm * Mine2_ctor(uint8_t id) {
Mine2 *me;
Q_REQUIRE(id < GAME_MINES_MAX);
me = &l_mine2[id];
QHsm_ctor(&me->super, Q_STATE_CAST(&Mine2_initial));
return &me->super;
}
/*.$enddef${AOs::Mine2_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Mine2} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Mine2} ...........................................................*/
/*.${AOs::Mine2::SM} .......................................................*/
static QState Mine2_initial(Mine2 * const me) {
/*.${AOs::Mine2::SM::initial} */
return Q_TRAN(&Mine2_unused);
}
/*.${AOs::Mine2::SM::unused} ...............................................*/
static QState Mine2_unused(Mine2 * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Mine2::SM::unused::MINE_PLANT} */
case MINE_PLANT_SIG: {
me->x = (uint8_t)Q_PAR(me);
me->y = (uint8_t)(Q_PAR(me) >> 8);
status_ = Q_TRAN(&Mine2_planted);
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Mine2::SM::used} .................................................*/
static QState Mine2_used(Mine2 * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Mine2::SM::used} */
case Q_EXIT_SIG: {
/* tell the Tunnel that this mine is becoming disabled */
QACTIVE_POST(&AO_Tunnel, MINE_DISABLED_SIG, MINE_ID(me));
status_ = Q_HANDLED();
break;
}
/*.${AOs::Mine2::SM::used::MINE_RECYCLE} */
case MINE_RECYCLE_SIG: {
status_ = Q_TRAN(&Mine2_unused);
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Mine2::SM::used::planted} ........................................*/
static QState Mine2_planted(Mine2 * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Mine2::SM::used::planted::TIME_TICK} */
case TIME_TICK_SIG: {
/*.${AOs::Mine2::SM::used::planted::TIME_TICK::[me->x>=GAME_SPEED_X]} */
if (me->x >= GAME_SPEED_X) {
me->x -= GAME_SPEED_X; /* move the mine 1 step */
/* tell the Tunnel to draw the Mine */
QACTIVE_POST(&AO_Tunnel, MINE_IMG_SIG,
(MINE2_BMP << 16)
| me->x
| (me->y << 8));
status_ = Q_HANDLED();
}
/*.${AOs::Mine2::SM::used::planted::TIME_TICK::[else]} */
else {
status_ = Q_TRAN(&Mine2_unused);
}
break;
}
/*.${AOs::Mine2::SM::used::planted::SHIP_IMG} */
case SHIP_IMG_SIG: {
uint8_t x = (uint8_t)Q_PAR(me);
uint8_t y = (uint8_t)(Q_PAR(me) >> 8);
uint8_t bmp = (uint8_t)(Q_PAR(me) >> 16);
/*.${AOs::Mine2::SM::used::planted::SHIP_IMG::[BSP_doBitmapsOverlap(MINE2_BMP,~} */
if (BSP_doBitmapsOverlap(MINE2_BMP, me->x, me->y, bmp, x, y)) {
QACTIVE_POST(&AO_Ship, HIT_MINE_SIG, 2);
/* go straight to 'disabled' and let the Ship do the exploding */
status_ = Q_TRAN(&Mine2_unused);
}
else {
status_ = Q_UNHANDLED();
}
break;
}
/*.${AOs::Mine2::SM::used::planted::MISSILE_IMG} */
case MISSILE_IMG_SIG: {
uint8_t x = (uint8_t)Q_PAR(me);
uint8_t y = (uint8_t)(Q_PAR(me) >> 8);
uint8_t bmp = (uint8_t)(Q_PAR(me) >> 16);
/*.${AOs::Mine2::SM::used::planted::MISSILE_IMG::[BSP_doBitmapsOverlap(MINE2_MISS~} */
if (BSP_doBitmapsOverlap(MINE2_MISSILE_BMP, me->x, me->y, bmp, x, y)) {
/* NOTE: Mine type-2 is nastier than Mine type-1.
* The type-2 mine can hit the Ship with any of its
* "tentacles". However, it can be destroyed by the
* Missile only by hitting its center, defined as
* a smaller bitmap MINE2_MISSILE_BMP.
*/
/* post the score for destroying Mine type-2 */
QACTIVE_POST(&AO_Missile, DESTROYED_MINE_SIG, 45);
status_ = Q_TRAN(&Mine2_exploding);
}
else {
status_ = Q_UNHANDLED();
}
break;
}
default: {
status_ = Q_SUPER(&Mine2_used);
break;
}
}
return status_;
}
/*.${AOs::Mine2::SM::used::exploding} ......................................*/
static QState Mine2_exploding(Mine2 * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Mine2::SM::used::exploding} */
case Q_ENTRY_SIG: {
me->exp_ctr = 0;
status_ = Q_HANDLED();
break;
}
/*.${AOs::Mine2::SM::used::exploding::TIME_TICK} */
case TIME_TICK_SIG: {
/*.${AOs::Mine2::SM::used::exploding::TIME_TICK::[(me->x>=GAME_SPEED_X)&&(me->exp~} */
if ((me->x >= GAME_SPEED_X) && (me->exp_ctr < 15)) {
++me->exp_ctr; /* advance the explosion counter */
me->x -= GAME_SPEED_X; /* move explosion by 1 step */
/* tell the Game to render the current stage of Explosion */
QACTIVE_POST(&AO_Tunnel, EXPLOSION_SIG,
((EXPLOSION0_BMP + (me->exp_ctr >> 2)) << 16)
| (me->x + 1)
| (((int)me->y - 4 + 2)) << 8);
status_ = Q_HANDLED();
}
/*.${AOs::Mine2::SM::used::exploding::TIME_TICK::[else]} */
else {
status_ = Q_TRAN(&Mine2_unused);
}
break;
}
default: {
status_ = Q_SUPER(&Mine2_used);
break;
}
}
return status_;
}
/*.$enddef${AOs::Mine2} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/missile.c
================================================
/*.$file${.::missile.c} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: game.qm
* File: ${.::missile.c}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::missile.c} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#include "qpn.h"
#include "game.h"
#include "bsp.h"
/* Q_DEFINE_THIS_MODULE("missile") */
/* encapsulated delcaration of the Missile active object -------------------*/
/*.$declare${AOs::Missile} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Missile} .........................................................*/
typedef struct Missile {
/* protected: */
QActive super;
/* private: */
uint8_t x;
uint8_t y;
uint8_t exp_ctr;
/* public: */
uint8_t speed;
} Missile;
/* protected: */
static QState Missile_initial(Missile * const me);
static QState Missile_armed(Missile * const me);
static QState Missile_flying(Missile * const me);
static QState Missile_exploding(Missile * const me);
/*.$enddecl${AOs::Missile} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* global objects ----------------------------------------------------------*/
Missile AO_Missile;
/* Active object definition ------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*. Check for the minimum required QP version */
#if (QP_VERSION < 650U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpn version 6.5.0 or higher required
#endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Missile_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Missile_ctor} ....................................................*/
void Missile_ctor(uint8_t speed) {
Missile *me = &AO_Missile;
QActive_ctor(&me->super, Q_STATE_CAST(&Missile_initial));
me->speed = speed;
}
/*.$enddef${AOs::Missile_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Missile} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Missile} .........................................................*/
/*.${AOs::Missile::SM} .....................................................*/
static QState Missile_initial(Missile * const me) {
/*.${AOs::Missile::SM::initial} */
return Q_TRAN(&Missile_armed);
}
/*.${AOs::Missile::SM::armed} ..............................................*/
static QState Missile_armed(Missile * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Missile::SM::armed::MISSILE_FIRE} */
case MISSILE_FIRE_SIG: {
me->x = (uint8_t)Q_PAR(me); /* init position from the Ship */
me->y = (uint8_t)(Q_PAR(me) >> 8);
status_ = Q_TRAN(&Missile_flying);
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Missile::SM::flying} .............................................*/
static QState Missile_flying(Missile * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Missile::SM::flying::TIME_TICK} */
case TIME_TICK_SIG: {
/*.${AOs::Missile::SM::flying::TIME_TICK::[me->x+GAME_MISSILE_SPEED_Xx + GAME_MISSILE_SPEED_X < GAME_TUNNEL_WIDTH) {
me->x += me->speed;
/*tell the Tunnel to draw the Missile and test for wall hits*/
QACTIVE_POST(&AO_Tunnel, MISSILE_IMG_SIG,
(MISSILE_BMP << 16)
| me->x
| (me->y << 8));
status_ = Q_HANDLED();
}
/*.${AOs::Missile::SM::flying::TIME_TICK::[else]} */
else {
status_ = Q_TRAN(&Missile_armed);
}
break;
}
/*.${AOs::Missile::SM::flying::HIT_WALL} */
case HIT_WALL_SIG: {
status_ = Q_TRAN(&Missile_exploding);
break;
}
/*.${AOs::Missile::SM::flying::DESTROYED_MINE} */
case DESTROYED_MINE_SIG: {
/* tell the Ship the score for destroing this Mine */
QACTIVE_POST(&AO_Ship, Q_SIG(me), Q_PAR(me));
/* re-arm immediately & let the destroyed Mine do the exploding */
status_ = Q_TRAN(&Missile_armed);
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Missile::SM::exploding} ..........................................*/
static QState Missile_exploding(Missile * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Missile::SM::exploding} */
case Q_ENTRY_SIG: {
me->exp_ctr = 0;
status_ = Q_HANDLED();
break;
}
/*.${AOs::Missile::SM::exploding::TIME_TICK} */
case TIME_TICK_SIG: {
/*.${AOs::Missile::SM::exploding::TIME_TICK::[(me->x>=GAME_SPEED_X)&&(me->exp~} */
if ((me->x >= GAME_SPEED_X) && (me->exp_ctr < 15)) {
++me->exp_ctr; /* advance the explosion counter */
me->x -= me->speed; /* move the explosion by one step */
/* tell the Tunnel to render the current stage of Explosion */
QACTIVE_POST(&AO_Tunnel, EXPLOSION_SIG,
((EXPLOSION0_BMP + (me->exp_ctr >> 2)) << 16)
| (me->x + 3)
| ((int)me->y - 4) << 8);
status_ = Q_HANDLED();
}
/*.${AOs::Missile::SM::exploding::TIME_TICK::[else]} */
else {
/* explosion finished or moved outside the game */
status_ = Q_TRAN(&Missile_armed);
}
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.$enddef${AOs::Missile} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qk/armclang/README.txt
================================================
About this Example
==================
This example demonstrates how to use the uVision IDE together with
the MDK-ARM toolchain.
uVision Project File
====================
The MDK-ARM uVision project file provided with this example uses
relative paths to the QP framework location (includes, port, and
libraries. These relative paths must be modified when the project
is moved to different relative location.
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the
command-line options for the ARM assembler (see the Asm tab in
the "Options for Target" dialog box in uVision). Specifically,
you should define symbols: Stack_Size=xxx Heap_Size=yyy, where
xxx represents a numerical value of stack size and yyy the
numerical value of the heap size (for most embedded projects
yyy should be 0, as the using the heap is not recommended).
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\efm32pg1b\arm\startup_efm32pg1b.s
The file startup_efm32pg1b.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qk/armclang/game-qk.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj; *.o*.lib*.txt; *.h; *.inc*.plm*.cpp000game-dbg0x4ARM-ADS120000001110016553500079668.\dbg\11101101000011111110010130111111111111101011001003Segger\JL2CM3.dll0DLGUARM/0JL2CM3-U440060969 -O207 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO7 -FD20000000 -FC8000 -FN1 -FF0GECKOP2.FLM -FS00 -FL040000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10UL2CM3UL2CM3(-O207 -S0 -C0 -FO7 -FN1 -FC8000 -FD20000000 -FF0GECKOP2 -FL020000 -FS00 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)0DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E2006F4 -O4622 -S4 -FO61120x200002000200x40000001000010000000000000000000game-rel0x4ARM-ADS120000001110016553500079668.\rel\11101101000011111110010030111111111111101011001003Segger\JL2CM3.dll0JL2CM3-U440060969 -O207 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO7 -FD20000000 -FC8000 -FN1 -FF0GECKOP2.FLM -FS00 -FL020000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)0DLGUARM/0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E10259B -O4622 -S4 -FO610UL2CM3-O207 -S0 -C0 -FO7 -FN1 -FC8000 -FD20000000 -FF0GECKOP2 -FL020000 -FS00 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)120x200002000200x40000001000010000000000000000000Applicatioin0000111000..\bsp.cbsp.c00121000..\..\main.cmain.c00135000..\..\game.hgame.h00141000..\..\..\..\..\include\qstamp.cqstamp.c00151000..\..\mine1.cmine1.c00161000..\..\mine2.cmine2.c00171000..\..\missile.cmissile.c00181000..\..\ship.cship.c00191000..\..\tunnel.ctunnel.c00efm32pg1b10002101000..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.cem_cmu.c002111000..\..\..\..\..\3rd_party\efm32pg1b\em_emu.cem_emu.c002121000..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.cem_gpio.c002131000..\..\..\..\..\3rd_party\efm32pg1b\em_int.cem_int.c002141000..\..\..\..\..\3rd_party\efm32pg1b\em_rtcc.cem_rtcc.c002151000..\..\..\..\..\3rd_party\efm32pg1b\em_system.cem_system.c002161000..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.csystem_efm32pg1b.c002171000..\..\..\..\..\3rd_party\efm32pg1b\display_ls013b7dh03.cdisplay_ls013b7dh03.c002181000..\..\..\..\..\3rd_party\efm32pg1b\displaypalemlib.cdisplaypalemlib.c002191000..\..\..\..\..\3rd_party\efm32pg1b\em_prs.cem_prs.c002201000..\..\..\..\..\3rd_party\efm32pg1b\em_usart.cem_usart.c002211000..\..\..\..\..\3rd_party\efm32pg1b\udelay.cudelay.c002222000..\..\..\..\..\3rd_party\efm32pg1b\arm\startup_efm32pg1b.sstartup_efm32pg1b.s00QP10003231000..\..\..\..\..\src\qfn\qepn.cqepn.c003241000..\..\..\..\..\src\qfn\qfn.cqfn.c003251000..\..\..\..\..\src\qkn\qkn.cqkn.c00QP_port10004265000..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqfn_port.h004271000..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.cqkn_port.c00
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qk/armclang/game-qk.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwaregame-dbg0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1EFM32PG1B200F256GM48Silicon LabsSiliconLabs.EFM32PG1B_DFP.5.5.0https://www.silabs.com/documents/public/cmsis-packs/IRAM(0x20000000,0x00008000) IROM(0x00000000,0x00020000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC8000 -FN1 -FF0GECKOP2 -FS00 -FL020000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM))0$$Device:EFM32PG1B200F256GM48$Device\EFM32PG1B\Include\em_device.h$$Device:EFM32PG1B200F256GM48$SVD\EFM32PG1B\EFM32PG1B200F256GM48.svd0000001.\dbg\game-qk10011.\dbg\10000000010cmd /c "del .\dbg\qstamp.o"000010fromelf --bin --output .\dbg\game-qk.bin .\dbg\game-qk.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140961BIN\UL2CM3.DLL"" ()0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x2000000x00x010x00x010x00x010x00x010x00x2000010x00x000x00x000x00x000x00x000x200000000x800000x00x007001000003011003300000EFM32PG1B200F256GM48=1 __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\efm32pg1b1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cmain.c1..\..\main.cgame.h5..\..\game.hqstamp.c1..\..\..\..\..\include\qstamp.cmine1.c1..\..\mine1.cmine2.c1..\..\mine2.cmissile.c1..\..\missile.cship.c1..\..\ship.ctunnel.c1..\..\tunnel.cefm32pg1bem_cmu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.cem_emu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_emu.cem_gpio.c1..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.cem_int.c1..\..\..\..\..\3rd_party\efm32pg1b\em_int.cem_rtcc.c1..\..\..\..\..\3rd_party\efm32pg1b\em_rtcc.cem_system.c1..\..\..\..\..\3rd_party\efm32pg1b\em_system.csystem_efm32pg1b.c1..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.cdisplay_ls013b7dh03.c1..\..\..\..\..\3rd_party\efm32pg1b\display_ls013b7dh03.cdisplaypalemlib.c1..\..\..\..\..\3rd_party\efm32pg1b\displaypalemlib.cem_prs.c1..\..\..\..\..\3rd_party\efm32pg1b\em_prs.cem_usart.c1..\..\..\..\..\3rd_party\efm32pg1b\em_usart.cudelay.c1..\..\..\..\..\3rd_party\efm32pg1b\udelay.cstartup_efm32pg1b.s2..\..\..\..\..\3rd_party\efm32pg1b\arm\startup_efm32pg1b.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.cgame-rel0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1EFM32PG1B200F256GM48Silicon LabsSiliconLabs.EFM32PG1B_DFP.5.5.0https://www.silabs.com/documents/public/cmsis-packs/IRAM(0x20000000,0x00008000) IROM(0x00000000,0x00020000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC8000 -FN1 -FF0GECKOP2 -FS00 -FL020000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM))0$$Device:EFM32PG1B200F256GM48$Device\EFM32PG1B\Include\em_device.h$$Device:EFM32PG1B200F256GM48$SVD\EFM32PG1B\EFM32PG1B200F256GM48.svd0000001.\rel\game-qk10000.\rel\10000000010cmd /c "del .\rel\qstamp.o"000010fromelf --bin --output .\rel\game-qk.bin .\rel\game-qk.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140961BIN\UL2CM3.DLL"" ()0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x2000000x00x010x00x010x00x010x00x010x00x2000010x00x000x00x000x00x000x00x000x200000000x800000x00x007001000003011003300000NDEBUG EFM32PG1B200F256GM48=1 __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\efm32pg1b1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000game-qk.sct--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cmain.c1..\..\main.cgame.h5..\..\game.hqstamp.c1..\..\..\..\..\include\qstamp.cmine1.c1..\..\mine1.cmine2.c1..\..\mine2.cmissile.c1..\..\missile.cship.c1..\..\ship.ctunnel.c1..\..\tunnel.cefm32pg1bem_cmu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.cem_emu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_emu.cem_gpio.c1..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.cem_int.c1..\..\..\..\..\3rd_party\efm32pg1b\em_int.cem_rtcc.c1..\..\..\..\..\3rd_party\efm32pg1b\em_rtcc.cem_system.c1..\..\..\..\..\3rd_party\efm32pg1b\em_system.csystem_efm32pg1b.c1..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.cdisplay_ls013b7dh03.c1..\..\..\..\..\3rd_party\efm32pg1b\display_ls013b7dh03.cdisplaypalemlib.c1..\..\..\..\..\3rd_party\efm32pg1b\displaypalemlib.cem_prs.c1..\..\..\..\..\3rd_party\efm32pg1b\em_prs.cem_usart.c1..\..\..\..\..\3rd_party\efm32pg1b\em_usart.cudelay.c1..\..\..\..\..\3rd_party\efm32pg1b\udelay.cstartup_efm32pg1b.s2..\..\..\..\..\3rd_party\efm32pg1b\arm\startup_efm32pg1b.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.c
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qk/bsp.c
================================================
/*****************************************************************************
* Product: "Fly 'n' Shoot" game example, EFM32-SLSTK3401A board, QK kernel
* Last updated for version 5.8.0
* Last updated on 2016-11-06
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "game.h"
#include "bsp.h"
#include "em_device.h" /* the device specific header (SiLabs) */
#include "em_chip.h" /* Chip errata (SiLabs) */
#include "em_cmu.h" /* Clock Management Unit (SiLabs) */
#include "em_gpio.h" /* GPIO (SiLabs) */
#include "em_usart.h" /* USART (SiLabs) */
#include "display_ls013b7dh03.h" /* LS013b7DH03 display (SiLabs/QL) */
/* add other drivers if necessary... */
Q_DEFINE_THIS_FILE
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
enum KernelUnawareISRs { /* see NOTE00 */
/* ... */
MAX_KERNEL_UNAWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-unaware" interrupts can't overlap "kernel-aware" interrupts */
Q_ASSERT_COMPILE(MAX_KERNEL_UNAWARE_CMSIS_PRI <= QF_AWARE_ISR_CMSIS_PRI);
enum KernelAwareISRs {
GPIO_EVEN_PRIO = QF_AWARE_ISR_CMSIS_PRI, /* see NOTE00 */
SYSTICK_PRIO,
/* ... */
MAX_KERNEL_AWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-aware" interrupts should not overlap the PendSV priority */
Q_ASSERT_COMPILE(MAX_KERNEL_AWARE_CMSIS_PRI <= (0xFF >>(8-__NVIC_PRIO_BITS)));
/* ISRs defined in this BSP ------------------------------------------------*/
void SysTick_Handler(void);
void GPIO_EVEN_IRQHandler(void);
void USART0_RX_IRQHandler(void);
/* Local-scope objects -----------------------------------------------------*/
#define LED_PORT gpioPortF
#define LED0_PIN 4
#define LED1_PIN 5
#define PB_PORT gpioPortF
#define PB0_PIN 6
#define PB1_PIN 7
/* LCD geometry and frame buffer */
static uint32_t l_fb[BSP_SCREEN_HEIGHT + 1][BSP_SCREEN_WIDTH / 32U];
/* the walls buffer */
static uint32_t l_walls[GAME_TUNNEL_HEIGHT + 1][BSP_SCREEN_WIDTH / 32U];
static unsigned l_rnd; /* random seed */
static void paintBits(uint8_t x, uint8_t y, uint8_t const *bits, uint8_t h);
static void paintBitsClear(uint8_t x, uint8_t y,
uint8_t const *bits, uint8_t h);
/* ISRs used in the application ==========================================*/
void SysTick_Handler(void) {
QK_ISR_ENTRY(); /* inform QK about entering an ISR */
QF_tickXISR(0U); /* process time events for rate 0 */
/* post TIME_TICK events to all interested active objects... */
QACTIVE_POST_ISR((QActive *)&AO_Tunnel, TIME_TICK_SIG, 0);
QACTIVE_POST_ISR((QActive *)&AO_Ship, TIME_TICK_SIG, 0);
QACTIVE_POST_ISR((QActive *)&AO_Missile, TIME_TICK_SIG, 0);
{
/* state of the button debouncing, see below */
static struct ButtonsDebouncing {
uint32_t depressed;
uint32_t previous;
} buttons = { ~0U, ~0U };
uint32_t current;
uint32_t tmp;
/* Perform the debouncing of buttons. The algorithm for debouncing
* adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
* and Michael Barr, page 71.
*/
current = ~GPIO->P[PB_PORT].DIN; /* read PB0 and BP1 */
tmp = buttons.depressed; /* save the debounced depressed buttons */
buttons.depressed |= (buttons.previous & current); /* set depressed */
buttons.depressed &= (buttons.previous | current); /* clear released */
buttons.previous = current; /* update the history */
tmp ^= buttons.depressed; /* changed debounced depressed */
if ((tmp & (1U << PB0_PIN)) != 0U) { /* debounced PB0 state changed? */
if ((buttons.depressed & (1U << PB0_PIN)) != 0U) {/*PB0 depressed?*/
QACTIVE_POST_ISR((QActive *)&AO_Ship, PLAYER_TRIGGER_SIG, 0U);
QACTIVE_POST_ISR((QActive *)&AO_Tunnel, PLAYER_TRIGGER_SIG, 0U);
}
}
}
QK_ISR_EXIT(); /* inform QK about exiting an ISR */
}
/*..........................................................................*/
void GPIO_EVEN_IRQHandler(void) {
QK_ISR_ENTRY(); /* inform QK about entering an ISR */
QACTIVE_POST_ISR((QActive *)&AO_Tunnel, TAKE_OFF_SIG, 0U);
QK_ISR_EXIT(); /* inform QK about exiting an ISR */
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* Chip errata */
CHIP_Init();
/* NOTE: SystemInit() already called from startup_TM4C123GH6PM.s
* but SystemCoreClock needs to be updated
*/
SystemCoreClockUpdate();
/* configure the FPU usage by choosing one of the options... */
#if 1
/* OPTION 1:
* Use the automatic FPU state preservation and the FPU lazy stacking.
*
* NOTE:
* Use the following setting when FPU is used in more than one task or
* in any ISRs. This setting is the safest and recommended, but requires
* extra stack space and CPU cycles.
*/
FPU->FPCCR |= (1U << FPU_FPCCR_ASPEN_Pos) | (1U << FPU_FPCCR_LSPEN_Pos);
#else
/* OPTION 2:
* Do NOT to use the automatic FPU state preservation and
* do NOT to use the FPU lazy stacking.
*
* NOTE:
* Use the following setting when FPU is used in ONE task only and not
* in any ISR. This setting is very efficient, but if more than one task
* (or ISR) start using the FPU, this can lead to corruption of the
* FPU registers. This option should be used with CAUTION.
*/
FPU->FPCCR &= ~((1U << FPU_FPCCR_ASPEN_Pos) | (1U << FPU_FPCCR_LSPEN_Pos));
#endif
/* enable clock for to the peripherals used by this application... */
CMU_ClockEnable(cmuClock_HFPER, true);
CMU_ClockEnable(cmuClock_GPIO, true);
CMU_ClockEnable(cmuClock_HFPER, true);
CMU_ClockEnable(cmuClock_GPIO, true);
/* configure the LEDs */
GPIO_PinModeSet(LED_PORT, LED0_PIN, gpioModePushPull, 0);
GPIO_PinModeSet(LED_PORT, LED1_PIN, gpioModePushPull, 0);
GPIO_PinOutClear(LED_PORT, LED0_PIN);
GPIO_PinOutClear(LED_PORT, LED1_PIN);
/* configure the Buttons */
GPIO_PinModeSet(PB_PORT, PB0_PIN, gpioModeInputPull, 1);
GPIO_PinModeSet(PB_PORT, PB1_PIN, gpioModeInputPull, 1);
/* Initialize the DISPLAY driver. */
if (!Display_init()) {
Q_ERROR();
}
}
/*..........................................................................*/
void BSP_updateScreen(void) {
GPIO->P[LED_PORT].DOUT |= (1U << LED1_PIN);
Display_sendPA(&l_fb[0][0], 0, LS013B7DH03_HEIGHT);
GPIO->P[LED_PORT].DOUT &= ~(1U << LED1_PIN);
}
/*..........................................................................*/
void BSP_clearFB() {
uint_fast8_t y;
for (y = 0U; y < BSP_SCREEN_HEIGHT; ++y) {
l_fb[y][0] = 0U;
l_fb[y][1] = 0U;
l_fb[y][2] = 0U;
l_fb[y][3] = 0U;
}
}
/*..........................................................................*/
void BSP_clearWalls() {
uint_fast8_t y;
for (y = 0U; y < GAME_TUNNEL_HEIGHT; ++y) {
l_walls[y][0] = 0U;
l_walls[y][1] = 0U;
l_walls[y][2] = 0U;
l_walls[y][3] = 0U;
}
}
/*..........................................................................*/
bool BSP_isThrottle(void) { /* is the throttle button depressed? */
return (GPIO->P[PB_PORT].DIN & (1U << PB1_PIN)) == 0U;
}
/*..........................................................................*/
void BSP_paintString(uint8_t x, uint8_t y, char const *str) {
static uint8_t const font5x7[95][7] = {
{ 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U }, /* */
{ 0x04U, 0x04U, 0x04U, 0x04U, 0x00U, 0x00U, 0x04U }, /* ! */
{ 0x0AU, 0x0AU, 0x0AU, 0x00U, 0x00U, 0x00U, 0x00U }, /* " */
{ 0x0AU, 0x0AU, 0x1FU, 0x0AU, 0x1FU, 0x0AU, 0x0AU }, /* # */
{ 0x04U, 0x1EU, 0x05U, 0x0EU, 0x14U, 0x0FU, 0x04U }, /* $ */
{ 0x03U, 0x13U, 0x08U, 0x04U, 0x02U, 0x19U, 0x18U }, /* % */
{ 0x06U, 0x09U, 0x05U, 0x02U, 0x15U, 0x09U, 0x16U }, /* & */
{ 0x06U, 0x04U, 0x02U, 0x00U, 0x00U, 0x00U, 0x00U }, /* ' */
{ 0x08U, 0x04U, 0x02U, 0x02U, 0x02U, 0x04U, 0x08U }, /* ( */
{ 0x02U, 0x04U, 0x08U, 0x08U, 0x08U, 0x04U, 0x02U }, /* ) */
{ 0x00U, 0x04U, 0x15U, 0x0EU, 0x15U, 0x04U, 0x00U }, /* * */
{ 0x00U, 0x04U, 0x04U, 0x1FU, 0x04U, 0x04U, 0x00U }, /* + */
{ 0x00U, 0x00U, 0x00U, 0x00U, 0x06U, 0x04U, 0x02U }, /* , */
{ 0x00U, 0x00U, 0x00U, 0x1FU, 0x00U, 0x00U, 0x00U }, /* - */
{ 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x06U, 0x06U }, /* . */
{ 0x00U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U, 0x00U }, /* / */
{ 0x0EU, 0x11U, 0x19U, 0x15U, 0x13U, 0x11U, 0x0EU }, /* 0 */
{ 0x04U, 0x06U, 0x04U, 0x04U, 0x04U, 0x04U, 0x0EU }, /* 1 */
{ 0x0EU, 0x11U, 0x10U, 0x08U, 0x04U, 0x02U, 0x1FU }, /* 2 */
{ 0x1FU, 0x08U, 0x04U, 0x08U, 0x10U, 0x11U, 0x0EU }, /* 3 */
{ 0x08U, 0x0CU, 0x0AU, 0x09U, 0x1FU, 0x08U, 0x08U }, /* 4 */
{ 0x1FU, 0x01U, 0x0FU, 0x10U, 0x10U, 0x11U, 0x0EU }, /* 5 */
{ 0x0CU, 0x02U, 0x01U, 0x0FU, 0x11U, 0x11U, 0x0EU }, /* 6 */
{ 0x1FU, 0x10U, 0x08U, 0x04U, 0x02U, 0x02U, 0x02U }, /* 7 */
{ 0x0EU, 0x11U, 0x11U, 0x0EU, 0x11U, 0x11U, 0x0EU }, /* 8 */
{ 0x0EU, 0x11U, 0x11U, 0x1EU, 0x10U, 0x08U, 0x06U }, /* 9 */
{ 0x00U, 0x06U, 0x06U, 0x00U, 0x06U, 0x06U, 0x00U }, /* : */
{ 0x00U, 0x06U, 0x06U, 0x00U, 0x06U, 0x04U, 0x02U }, /* ; */
{ 0x08U, 0x04U, 0x02U, 0x01U, 0x02U, 0x04U, 0x08U }, /* < */
{ 0x00U, 0x00U, 0x1FU, 0x00U, 0x1FU, 0x00U, 0x00U }, /* = */
{ 0x02U, 0x04U, 0x08U, 0x10U, 0x08U, 0x04U, 0x02U }, /* > */
{ 0x0EU, 0x11U, 0x10U, 0x08U, 0x04U, 0x00U, 0x04U }, /* ? */
{ 0x0EU, 0x11U, 0x10U, 0x16U, 0x15U, 0x15U, 0x0EU }, /* @ */
{ 0x0EU, 0x11U, 0x11U, 0x11U, 0x1FU, 0x11U, 0x11U }, /* A */
{ 0x0FU, 0x11U, 0x11U, 0x0FU, 0x11U, 0x11U, 0x0FU }, /* B */
{ 0x0EU, 0x11U, 0x01U, 0x01U, 0x01U, 0x11U, 0x0EU }, /* C */
{ 0x07U, 0x09U, 0x11U, 0x11U, 0x11U, 0x09U, 0x07U }, /* D */
{ 0x1FU, 0x01U, 0x01U, 0x0FU, 0x01U, 0x01U, 0x1FU }, /* E */
{ 0x1FU, 0x01U, 0x01U, 0x0FU, 0x01U, 0x01U, 0x01U }, /* F */
{ 0x0EU, 0x11U, 0x01U, 0x1DU, 0x11U, 0x11U, 0x1EU }, /* G */
{ 0x11U, 0x11U, 0x11U, 0x1FU, 0x11U, 0x11U, 0x11U }, /* H */
{ 0x0EU, 0x04U, 0x04U, 0x04U, 0x04U, 0x04U, 0x0EU }, /* I */
{ 0x1CU, 0x08U, 0x08U, 0x08U, 0x08U, 0x09U, 0x06U }, /* J */
{ 0x11U, 0x09U, 0x05U, 0x03U, 0x05U, 0x09U, 0x11U }, /* K */
{ 0x01U, 0x01U, 0x01U, 0x01U, 0x01U, 0x01U, 0x1FU }, /* L */
{ 0x11U, 0x1BU, 0x15U, 0x15U, 0x11U, 0x11U, 0x11U }, /* M */
{ 0x11U, 0x11U, 0x13U, 0x15U, 0x19U, 0x11U, 0x11U }, /* N */
{ 0x0EU, 0x11U, 0x11U, 0x11U, 0x11U, 0x11U, 0x0EU }, /* O */
{ 0x0FU, 0x11U, 0x11U, 0x0FU, 0x01U, 0x01U, 0x01U }, /* P */
{ 0x0EU, 0x11U, 0x11U, 0x11U, 0x15U, 0x09U, 0x16U }, /* Q */
{ 0x0FU, 0x11U, 0x11U, 0x0FU, 0x05U, 0x09U, 0x11U }, /* R */
{ 0x1EU, 0x01U, 0x01U, 0x0EU, 0x10U, 0x10U, 0x0FU }, /* S */
{ 0x1FU, 0x04U, 0x04U, 0x04U, 0x04U, 0x04U, 0x04U }, /* T */
{ 0x11U, 0x11U, 0x11U, 0x11U, 0x11U, 0x11U, 0x0EU }, /* U */
{ 0x11U, 0x11U, 0x11U, 0x11U, 0x11U, 0x0AU, 0x04U }, /* V */
{ 0x11U, 0x11U, 0x11U, 0x15U, 0x15U, 0x15U, 0x0AU }, /* W */
{ 0x11U, 0x11U, 0x0AU, 0x04U, 0x0AU, 0x11U, 0x11U }, /* X */
{ 0x11U, 0x11U, 0x11U, 0x0AU, 0x04U, 0x04U, 0x04U }, /* Y */
{ 0x1FU, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U, 0x1FU }, /* Z */
{ 0x0EU, 0x02U, 0x02U, 0x02U, 0x02U, 0x02U, 0x0EU }, /* [ */
{ 0x00U, 0x01U, 0x02U, 0x04U, 0x08U, 0x10U, 0x00U }, /* \ */
{ 0x0EU, 0x08U, 0x08U, 0x08U, 0x08U, 0x08U, 0x0EU }, /* ] */
{ 0x04U, 0x0AU, 0x11U, 0x00U, 0x00U, 0x00U, 0x00U }, /* ^ */
{ 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x1FU }, /* _ */
{ 0x02U, 0x04U, 0x08U, 0x00U, 0x00U, 0x00U, 0x00U }, /* ` */
{ 0x00U, 0x00U, 0x0EU, 0x10U, 0x1EU, 0x11U, 0x1EU }, /* a */
{ 0x01U, 0x01U, 0x0DU, 0x13U, 0x11U, 0x11U, 0x0FU }, /* b */
{ 0x00U, 0x00U, 0x0EU, 0x01U, 0x01U, 0x11U, 0x0EU }, /* c */
{ 0x10U, 0x10U, 0x16U, 0x19U, 0x11U, 0x11U, 0x1EU }, /* d */
{ 0x00U, 0x00U, 0x0EU, 0x11U, 0x1FU, 0x01U, 0x0EU }, /* e */
{ 0x0CU, 0x12U, 0x02U, 0x07U, 0x02U, 0x02U, 0x02U }, /* f */
{ 0x00U, 0x1EU, 0x11U, 0x11U, 0x1EU, 0x10U, 0x0EU }, /* g */
{ 0x01U, 0x01U, 0x0DU, 0x13U, 0x11U, 0x11U, 0x11U }, /* h */
{ 0x04U, 0x00U, 0x06U, 0x04U, 0x04U, 0x04U, 0x0EU }, /* i */
{ 0x08U, 0x00U, 0x0CU, 0x08U, 0x08U, 0x09U, 0x06U }, /* j */
{ 0x01U, 0x01U, 0x09U, 0x05U, 0x03U, 0x05U, 0x09U }, /* k */
{ 0x06U, 0x04U, 0x04U, 0x04U, 0x04U, 0x04U, 0x0EU }, /* l */
{ 0x00U, 0x00U, 0x0BU, 0x15U, 0x15U, 0x11U, 0x11U }, /* m */
{ 0x00U, 0x00U, 0x0DU, 0x13U, 0x11U, 0x11U, 0x11U }, /* n */
{ 0x00U, 0x00U, 0x0EU, 0x11U, 0x11U, 0x11U, 0x0EU }, /* o */
{ 0x00U, 0x00U, 0x0FU, 0x11U, 0x0FU, 0x01U, 0x01U }, /* p */
{ 0x00U, 0x00U, 0x16U, 0x19U, 0x1EU, 0x10U, 0x10U }, /* q */
{ 0x00U, 0x00U, 0x0DU, 0x13U, 0x01U, 0x01U, 0x01U }, /* r */
{ 0x00U, 0x00U, 0x0EU, 0x01U, 0x0EU, 0x10U, 0x0FU }, /* s */
{ 0x02U, 0x02U, 0x07U, 0x02U, 0x02U, 0x12U, 0x0CU }, /* t */
{ 0x00U, 0x00U, 0x11U, 0x11U, 0x11U, 0x19U, 0x16U }, /* u */
{ 0x00U, 0x00U, 0x11U, 0x11U, 0x11U, 0x0AU, 0x04U }, /* v */
{ 0x00U, 0x00U, 0x11U, 0x11U, 0x15U, 0x15U, 0x0AU }, /* w */
{ 0x00U, 0x00U, 0x11U, 0x0AU, 0x04U, 0x0AU, 0x11U }, /* x */
{ 0x00U, 0x00U, 0x11U, 0x11U, 0x1EU, 0x10U, 0x0EU }, /* y */
{ 0x00U, 0x00U, 0x1FU, 0x08U, 0x04U, 0x02U, 0x1FU }, /* z */
{ 0x08U, 0x04U, 0x04U, 0x02U, 0x04U, 0x04U, 0x08U }, /* { */
{ 0x04U, 0x04U, 0x04U, 0x04U, 0x04U, 0x04U, 0x04U }, /* | */
{ 0x02U, 0x04U, 0x04U, 0x08U, 0x04U, 0x04U, 0x02U }, /* } */
{ 0x02U, 0x15U, 0x08U, 0x00U, 0x00U, 0x00U, 0x00U }, /* ~ */
};
for (; *str != '\0'; ++str, x += 6) {
uint8_t const *ch = &font5x7[*str - ' '][0];
paintBitsClear(x, y, ch, 7);
}
}
/*==========================================================================*/
typedef struct { /* the auxiliary structure to hold const bitmaps */
uint8_t const *bits; /* the bits in the bitmap */
uint8_t height; /* the height of the bitmap */
} Bitmap;
/* bitmap of the Ship:
*
* x....
* xxx..
* xxxxx
*/
static uint8_t const ship_bits[] = {
0x01U, 0x07U, 0x1FU
};
/* bitmap of the Missile:
*
* xxxx
*/
static uint8_t const missile_bits[] = {
0x0FU
};
/* bitmap of the Mine type-1:
*
* .x.
* xxx
* .x.
*/
static uint8_t const mine1_bits[] = {
0x02U, 0x07U, 0x02U
};
/* bitmap of the Mine type-2:
*
* x..x
* .xx.
* .xx.
* x..x
*/
static uint8_t const mine2_bits[] = {
0x09U, 0x06U, 0x06U, 0x09U
};
/* Mine type-2 is nastier than Mine type-1. The type-2 mine can
* hit the Ship with any of its "tentacles". However, it can be
* destroyed by the Missile only by hitting its center, defined as
* the following bitmap:
*
* ....
* .xx.
* .xx.
*/
static uint8_t const mine2_missile_bits[] = {
0x00U, 0x06U, 0x06U
};
/*
* The bitmap of the explosion stage 0:
*
* .......
* ...x...
* ..x.x..
* ...x...
*/
static uint8_t const explosion0_bits[] = {
0x00U, 0x08U, 0x14U, 0x08U
};
/*
* The bitmap of the explosion stage 1:
*
* .......
* ..x.x..
* ...x...
* ..x.x..
*/
static uint8_t const explosion1_bits[] = {
0x00U, 0x14U, 0x08U, 0x14U
};
/*
* The bitmap of the explosion stage 2:
*
* .x...x.
* ..x.x..
* ...x...
* ..x.x..
* .x...x.
*/
static uint8_t const explosion2_bits[] = {
0x11U, 0x0AU, 0x04U, 0x0AU, 0x11U
};
/*
* The bitmap of the explosion stage 3:
*
* x..x..x
* .x.x.x.
* ..x.x..
* xx.x.xx
* ..x.x..
* .x.x.x.
* x..x..x
*/
static uint8_t const explosion3_bits[] = {
0x49, 0x2A, 0x14, 0x6B, 0x14, 0x2A, 0x49
};
static Bitmap const l_bitmap[MAX_BMP] = {
{ ship_bits, Q_DIM(ship_bits) },
{ missile_bits, Q_DIM(missile_bits) },
{ mine1_bits, Q_DIM(mine1_bits) },
{ mine2_bits, Q_DIM(mine2_bits) },
{ mine2_missile_bits, Q_DIM(mine2_missile_bits) },
{ explosion0_bits, Q_DIM(explosion0_bits) },
{ explosion1_bits, Q_DIM(explosion1_bits) },
{ explosion2_bits, Q_DIM(explosion2_bits) },
{ explosion3_bits, Q_DIM(explosion3_bits) }
};
/*..........................................................................*/
void BSP_paintBitmap(uint8_t x, uint8_t y, uint8_t bmp_id) {
Bitmap const *bmp = &l_bitmap[bmp_id];
paintBits(x, y, bmp->bits, bmp->height);
}
/*..........................................................................*/
void BSP_advanceWalls(uint8_t top, uint8_t bottom) {
uint_fast8_t y;
for (y = 0U; y < GAME_TUNNEL_HEIGHT; ++y) {
/* shift the walls one pixel to the left */
l_walls[y][0] = (l_walls[y][0] >> 1) | (l_walls[y][1] << 31);
l_walls[y][1] = (l_walls[y][1] >> 1) | (l_walls[y][2] << 31);
l_walls[y][2] = (l_walls[y][2] >> 1) | (l_walls[y][3] << 31);
l_walls[y][3] = (l_walls[y][3] >> 1);
/* add new column of walls at the end */
if (y <= top) {
l_walls[y][3] |= (1U << 31);
}
if (y >= (GAME_TUNNEL_HEIGHT - bottom)) {
l_walls[y][3] |= (1U << 31);
}
/* copy the walls to the frame buffer */
l_fb[y][0] = l_walls[y][0];
l_fb[y][1] = l_walls[y][1];
l_fb[y][2] = l_walls[y][2];
l_fb[y][3] = l_walls[y][3];
}
}
/*..........................................................................*/
bool BSP_doBitmapsOverlap(uint8_t bmp_id1, uint8_t x1, uint8_t y1,
uint8_t bmp_id2, uint8_t x2, uint8_t y2)
{
uint8_t y;
uint8_t y0;
uint8_t h;
uint32_t bits1;
uint32_t bits2;
Bitmap const *bmp1;
Bitmap const *bmp2;
Q_REQUIRE((bmp_id1 < Q_DIM(l_bitmap)) && (bmp_id2 < Q_DIM(l_bitmap)));
/* are the bitmaps close enough in x? */
if (x1 >= x2) {
if (x1 > x2 + 8U) {
return false;
}
x1 -= x2;
x2 = 0U;
}
else {
if (x2 > x1 + 8U) {
return false;
}
x2 -= x1;
x1 = 0U;
}
bmp1 = &l_bitmap[bmp_id1];
bmp2 = &l_bitmap[bmp_id2];
if ((y1 <= y2) && (y1 + bmp1->height > y2)) {
y0 = y2 - y1;
h = y1 + bmp1->height - y2;
if (h > bmp2->height) {
h = bmp2->height;
}
for (y = 0; y < h; ++y) { /* scan over the overlapping rows */
bits1 = ((uint32_t)bmp1->bits[y + y0] << x1);
bits2 = ((uint32_t)bmp2->bits[y] << x2);
if ((bits1 & bits2) != 0U) { /* do the bits overlap? */
return true; /* yes! */
}
}
}
else {
if ((y1 > y2) && (y2 + bmp2->height > y1)) {
y0 = y1 - y2;
h = y2 + bmp2->height - y1;
if (h > bmp1->height) {
h = bmp1->height;
}
for (y = 0; y < h; ++y) { /* scan over the overlapping rows */
bits1 = ((uint32_t)bmp1->bits[y] << x1);
bits2 = ((uint32_t)bmp2->bits[y + y0] << x2);
if ((bits1 & bits2) != 0U) { /* do the bits overlap? */
return true; /* yes! */
}
}
}
}
return false; /* the bitmaps do not overlap */
}
/*..........................................................................*/
bool BSP_isWallHit(uint8_t bmp_id, uint8_t x, uint8_t y) {
Bitmap const *bmp = &l_bitmap[bmp_id];
uint32_t shft = (x & 0x1FU);
uint32_t *walls = &l_walls[y][x >> 5];
for (y = 0; y < bmp->height; ++y, walls += (BSP_SCREEN_WIDTH >> 5)) {
if (*walls & ((uint32_t)bmp->bits[y] << shft)) {
return true;
}
if (shft > 24U) {
if (*(walls + 1) & ((uint32_t)bmp->bits[y] >> (32U - shft))) {
return true;
}
}
}
return false;
}
/*..........................................................................*/
void BSP_updateScore(uint16_t score) {
char str[5];
uint16_t s = score;
if (score == 0U) {
BSP_paintString(1U, BSP_SCREEN_HEIGHT - 8U, "SCORE:");
}
/* update the SCORE area on the screeen */
str[4] = '\0';
str[3] = (s % 10U) + '0'; s /= 10U;
str[2] = (s % 10U) + '0'; s /= 10U;
str[1] = (s % 10U) + '0'; s /= 10U;
str[0] = (s % 10U) + '0';
BSP_paintString(6U*6U, BSP_SCREEN_HEIGHT - 8U, str);
}
/*..........................................................................*/
void BSP_displayOn(void) {
Display_enable(true);
}
/*..........................................................................*/
void BSP_displayOff(void) {
Display_enable(false);
}
/*..........................................................................*/
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
l_rnd = l_rnd * (3U*7U*11U*13U*23U);
return l_rnd >> 8;
}
/*..........................................................................*/
void BSP_randomSeed(uint32_t seed) {
l_rnd = seed;
}
/*--------------------------------------------------------------------------*/
/*..........................................................................*/
static void paintBits(uint8_t x, uint8_t y, uint8_t const *bits, uint8_t h) {
uint32_t *fb = &l_fb[y][x >> 5];
uint32_t shft = (x & 0x1FU);
for (y = 0; y < h; ++y, fb += (BSP_SCREEN_WIDTH >> 5)) {
*fb |= ((uint32_t)bits[y] << shft);
if (shft > 24U) {
*(fb + 1) |= ((uint32_t)bits[y] >> (32U - shft));
}
}
}
/*..........................................................................*/
static void paintBitsClear(uint8_t x, uint8_t y,
uint8_t const *bits, uint8_t h)
{
uint32_t *fb = &l_fb[y][x >> 5];
uint32_t shft = (x & 0x1FU);
uint32_t mask1 = ~((uint32_t)0xFFU << shft);
uint32_t mask2;
if (shft > 24U) {
mask2 = ~(0xFFU >> (32U - shft));
}
for (y = 0; y < h; ++y, fb += (BSP_SCREEN_WIDTH >> 5)) {
*fb = ((*fb & mask1) | ((uint32_t)bits[y] << shft));
if (shft > 24U) {
*(fb + 1) = ((*(fb + 1) & mask2)
| ((uint32_t)bits[y] >> (32U - shft)));
}
}
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set up the SysTick timer to fire at BSP_TICKS_PER_SEC rate */
SysTick_Config(SystemCoreClock / BSP_TICKS_PER_SEC);
/* assing all priority bits for preemption-prio. and none to sub-prio. */
NVIC_SetPriorityGrouping(0U);
/* set priorities of ALL ISRs used in the system, see NOTE00
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
NVIC_SetPriority(SysTick_IRQn, SYSTICK_PRIO);
NVIC_SetPriority(GPIO_EVEN_IRQn, GPIO_EVEN_PRIO);
/* ... */
/* enable IRQs... */
NVIC_EnableIRQ(GPIO_EVEN_IRQn);
}
/*..........................................................................*/
void QF_stop(void) {
}
/*..........................................................................*/
void QK_onIdle(void) {
/* toggle the User LED on and then off, see NOTE01 */
QF_INT_DISABLE();
GPIO->P[LED_PORT].DOUT |= (1U << LED1_PIN);
GPIO->P[LED_PORT].DOUT &= ~(1U << LED1_PIN);
QF_INT_ENABLE();
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular Cortex-M3 MCU.
*/
__WFI(); /* Wait-For-Interrupt */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int loc) {
/*
* NOTE: add here your application-specific error handling
*/
(void)module;
(void)loc;
#ifndef NDEBUG
/* light up both LEDs */
GPIO->P[LED_PORT].DOUT |= ((1U << LED0_PIN) | (1U << LED1_PIN));
/* for debugging, hang on in an endless loop until PB1 is pressed... */
while ((GPIO->P[PB_PORT].DIN & (1U << PB1_PIN)) != 0) {
}
#endif
NVIC_SystemReset();
}
/*****************************************************************************
* NOTE00:
* The QF_AWARE_ISR_CMSIS_PRI constant from the QF port specifies the highest
* ISR priority that is disabled by the QF framework. The value is suitable
* for the NVIC_SetPriority() CMSIS function.
*
* Only ISRs prioritized at or below the QF_AWARE_ISR_CMSIS_PRI level (i.e.,
* with the numerical values of priorities equal or higher than
* QF_AWARE_ISR_CMSIS_PRI) are allowed to call the QK_ISR_ENTRY/QK_ISR_ENTRY
* macros or any other QF/QK services. These ISRs are "QF-aware".
*
* Conversely, any ISRs prioritized above the QF_AWARE_ISR_CMSIS_PRI priority
* level (i.e., with the numerical values of priorities less than
* QF_AWARE_ISR_CMSIS_PRI) are never disabled and are not aware of the kernel.
* Such "QF-unaware" ISRs cannot call any QF/QK services. In particular they
* can NOT call the macros QK_ISR_ENTRY/QK_ISR_ENTRY. The only mechanism
* by which a "QF-unaware" ISR can communicate with the QF framework is by
* triggering a "QF-aware" ISR, which can post/publish events.
*
* NOTE01:
* The User LED is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qk/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano on EMF32-SLSTK3401A, QK-nano kernel, GNU-ARM
# Last Updated for Version: 6.5.0
# Date of the Last Update: 2019-04-15
#
# Q u a n t u m L e a P s
# ------------------------
# Modern Embedded Software
#
# Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# https://www.state-machine.com
# mailto:info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := game-qk
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/arm-cm/qk/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qkn \
$(QP_PORT_DIR) \
$(QPN)/3rd_party/efm32pg1b \
$(QPN)/3rd_party/efm32pg1b/gnu
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR) \
-I$(QPN)/3rd_party/CMSIS/Include \
-I$(QPN)/3rd_party/efm32pg1b
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
bsp.c \
main.c \
mine1.c \
mine2.c \
missile.c \
ship.c \
tunnel.c \
startup_efm32pg1b.c \
system_efm32pg1b.c \
em_cmu.c \
em_emu.c \
em_gpio.c \
em_int.c \
em_prs.c \
em_rtcc.c \
em_system.c \
em_usart.c \
udelay.c \
display_ls013b7dh03.c \
displaypalemlib.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qepn.c \
qfn.c \
qkn.c \
qkn_port.c
QP_ASMS :=
LIB_DIRS :=
LIBS :=
# defines
DEFINES := -DEFM32PG1B200F256GM48=1
# ARM CPU, ARCH, FPU, and Float-ABI types...
# ARM_CPU: [cortex-m0 | cortex-m0plus | cortex-m1 | cortex-m3 | cortex-m4]
# ARM_ARCH: [6 | 7] (NOTE: must match ARM_CPU!)
# ARM_FPU: [ | vfp]
# FLOAT_ABI: [ | soft | softfp | hard]
#
ARM_CPU := -mcpu=cortex-m4
ARM_ARCH := 7 # NOTE: must match the ARM_CPU!
ARM_FPU := -mfpu=vfp
FLOAT_ABI := -mfloat-abi=softfp
#-----------------------------------------------------------------------------
# GNU-ARM toolset (NOTE: You need to adjust to your machine)
# see https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
#
ifeq ($(GNU_ARM),)
GNU_ARM := $(QTOOLS)/gnu_arm-none-eabi
endif
# make sure that the GNU-ARM toolset exists...
ifeq ("$(wildcard $(GNU_ARM))","")
$(error GNU_ARM toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_ARM)/bin/arm-none-eabi-gcc
CPP := $(GNU_ARM)/bin/arm-none-eabi-g++
AS := $(GNU_ARM)/bin/arm-none-eabi-as
LINK := $(GNU_ARM)/bin/arm-none-eabi-g++
BIN := $(GNU_ARM)/bin/arm-none-eabi-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M
#
# combine all the soruces...
C_SRCS += $(QP_SRCS)
ASM_SRCS += $(QP_ASMS)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS = $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration ..........................................
BIN_DIR := dbg
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O $(INCLUDES) $(DEFINES)
CPPFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES)
endif # ......................................................................
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
-specs=nosys.specs -specs=nano.specs \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_BIN := $(BIN_DIR)/$(OUTPUT).bin
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_BIN)
#all: $(TARGET_ELF)
$(TARGET_BIN): $(TARGET_ELF)
$(BIN) -O binary $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(CC) $(CFLAGS) $(QPN)/include/qstamp.c -o $(BIN_DIR)/qstamp.o
$(LINK) $(LINKFLAGS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.bin \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qk/gnu/README.txt
================================================
About this Example
==================
This example can be built from the command prompt with the provided
Makefile. The example can also be imported as a Makefile-based
project into Eclipse-based IDEs.
The Makefile
============
The provided Makefile should be easy to adapt for your own projects.
It contains three build configurations: Debug (default), Release, and
Spy.
Also, the Makefile has been specifically designed to work as an external
Makefile with the Eclipse CDT.
The various build configurations are built as follows:
make
make CONF=rel
make CONF=spy
make clean
make CONF=rel clean
make CONF=spy clean
***
NOTE:
The installation folder of the GNU-ARM toolset on YOUR machine needs
to be adjusted in the provided Makefile, by editing the symbol: GNU_ARM.
As described in the comment for this symbol, the GNU-ARM toolset is taken
from: http://gnutoolchains.com/arm-eabi
It is highly recommened to use the same GNU-ARM distribution, especially
for ARM Cortex-M4F projects, due to the support for the hardware FPU
(float-abi=hard).
***
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the GCC linker
script (.ld file), which provides a template of the recommended GCC linker
script for QP applications.
Startup Code
============
The startup code for the EFM32PG1B200F256GM48 MCU used in this project
is located in the "3rd_party" folder in the following location:
3rd_party\efm32pg1b\gnu\startup_efm32pg1b.c
The file startup_efm32pg1b.c provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qk/gnu/flash.bat
================================================
::============================================================================
:: Batch file to program the flash of EFM32-SLSTK3401A board
::
:: NOTE: requires the J-Link commander (JLink.exe) from SEGGER, see:
:: https://www.segger.com/j-link-commander.html
::
setlocal
@echo off
@echo Load a given binary file to the flash of EFM32-SLSTK3401A
@echo usage: flash bin-file
@echo example: flash dbg\blinky-qk.bin
::----------------------------------------------------------------------------
:: NOTE: Adjust the following symbol to the location of the
:: JLink utility on your machine
::
if [%JLINK%] EQU [] set JLINK=%QTOOLS%\..\JLink
if not exist "%JLINK%\JLink.exe" (
@echo The JLink tool not found. Please adjust flash.bat
@goto end
)
if ["%~1"]==[""] (
@echo The binary file missing
@goto end
)
if not exist %~s1 (
@echo The binary file '%1' does not exist
@goto end
)
:: generate the Jlink command file depending on the first parameter %1
@echo si 1 >flash.jlink
@echo speed 4000 >>flash.jlink
@echo r >>flash.jlink
@echo h >>flash.jlink
@echo loadbin %1, 0 >>flash.jlink
@echo exit >>flash.jlink
@echo on
%JLINK%\JLink.exe -device EFM32PG1B200F256GM48 flash.jlink
@echo off
@del flash.jlink
:end
endlocal
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qk/gnu/game-qk.ld
================================================
/*****************************************************************************
* Product: Linker script for EFM32-SLSTK3401A, GNU-ARM linker
* Last Updated for Version: 5.9.8
* Date of the Last Update: 2017-09-13
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* https://state-machine.com
* mailto:info@state-machine.com
*****************************************************************************/
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(Reset_Handler) /* entry Point */
MEMORY { /* memory map of Pearl Gecko EFM32PG1B200F256GM48 */
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 256K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
}
/* The size of the stack used by the application. NOTE: you need to adjust */
STACK_SIZE = 1024;
/* The size of the heap used by the application. NOTE: you need to adjust */
HEAP_SIZE = 0;
SECTIONS {
.isr_vector : { /* the vector table goes FIRST into ROM */
KEEP(*(.isr_vector)) /* vector table */
. = ALIGN(4);
} >ROM
.text : { /* code and constants */
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} >ROM
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >ROM
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >ROM
.fini_array : {
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array*))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >ROM
_etext = .; /* global symbols at end of code */
.stack : {
__stack_start__ = .;
. = . + STACK_SIZE;
. = ALIGN(4);
__stack_end__ = .;
} >RAM
.data : AT (_etext) {
__data_load = LOADADDR (.data);
__data_start = .;
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
__data_end__ = .;
_edata = __data_end__;
} >RAM
.bss : {
__bss_start__ = .;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = .;
} >RAM
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >RAM
__exidx_end = .;
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );
PROVIDE ( __end__ = _ebss );
.heap : {
__heap_start__ = .;
. = . + HEAP_SIZE;
. = ALIGN(4);
__heap_end__ = .;
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ : {
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
}
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qk/iar/README.txt
================================================
About this Example
==================
This example demonstrates how to use the IAR EWARM IDE to build
a QP application.
IAR Project File
----------------
The IAR EWARM project file provided with this example uses relative paths
to the QP/C framework location (includes, port, and libraries. These
relative paths must be modified when the project is moved to different
relative location.
Stack Size and Heap Size
------------------------
In this project, the size of the C stack and heap are determined in
the linker script blinky-qk.icf (see the next section).
Linker Script
-------------
The IAR linker script provides a template of the recommended linker script
for QP applications. This file needs to be customized to set the
application-specific sizes of the Stack and Heap. This file can be edited
from the IAR EWARM IDE via the Project Options/Linker settings.
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\efm32pg1b\iar\startup_efm32pg1b.s
The file startup_efm32pg1b.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qk/iar/game-qk.ewd
================================================
2DebugARM1C-SPY22811ARMSIM_ID2111ANGEL_ID2011CMSISDAP_ID2411GDBSERVER_ID2011IARROM_ID2111IJET_ID2811JLINK_ID21611LMIFTDI_ID2211MACRAIGOR_ID2311PEMICRO_ID2311RDI_ID2211STLINK_ID2311THIRDPARTY_ID2011TIFET_ID2111XDS100_ID2511$TOOLKIT_DIR$\plugins\middleware\HCCWare\HCCWare.ewplugin0$TOOLKIT_DIR$\plugins\middleware\PercepioTraceExporter\PercepioTraceExportPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\AVIX\AVIX.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\MQX\MQXRtosPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\Quadros\Quadros_EWB7_Plugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseARM0C-SPY22810ARMSIM_ID2110ANGEL_ID2010CMSISDAP_ID2410GDBSERVER_ID2010IARROM_ID2110IJET_ID2810JLINK_ID21610LMIFTDI_ID2210MACRAIGOR_ID2310PEMICRO_ID2310RDI_ID2210STLINK_ID2310THIRDPARTY_ID2010TIFET_ID2110XDS100_ID2510$TOOLKIT_DIR$\plugins\middleware\HCCWare\HCCWare.ewplugin0$TOOLKIT_DIR$\plugins\middleware\PercepioTraceExporter\PercepioTraceExportPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\AVIX\AVIX.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\MQX\MQXRtosPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\Quadros\Quadros_EWB7_Plugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qk/iar/game-qk.ewp
================================================
2DebugARM1General32411ICCARM23111AARM2911OBJCOPY0111CUSTOM30BICOMP0BUILDACTION1cmd /c "if exist $OBJ_DIR$\qstamp.o del $OBJ_DIR$\qstamp.o"ILINK01711IARCHIVE0011BILINK0Coder0ReleaseARM0General32410ICCARM23110AARM2910OBJCOPY0110CUSTOM30BICOMP0BUILDACTION1cmd /c "if exist $OBJ_DIR$\qstamp.o del $OBJ_DIR$\qstamp.o"ILINK01710IARCHIVE0010BILINK0Coder0Application$PROJ_DIR$\..\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\game.h$PROJ_DIR$\..\..\main.c$PROJ_DIR$\..\..\mine1.c$PROJ_DIR$\..\..\mine2.c$PROJ_DIR$\..\..\missile.c$PROJ_DIR$\..\..\qpn_conf.h$PROJ_DIR$\..\..\..\..\..\include\qstamp.c$PROJ_DIR$\..\..\ship.c$PROJ_DIR$\..\..\tunnel.cefm32pg1b$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\display_ls013b7dh03.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\displaypalemlib.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_assert.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_emu.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_int.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_prs.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_rtcc.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_system.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_usart.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\iar\startup_efm32pg1b.s$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\udelay.cQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qkn\qkn.cQP_port$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qk\iar\qkn_port.c
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qk/iar/game-qk.eww
================================================
$WS_DIR$\game-qk.ewp
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qk/iar/game-qk.icf
================================================
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0003FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 1024;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place at start of RAM_region {block CSTACK };
place in RAM_region { readwrite, block HEAP };
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qpn_conf.h
================================================
/*****************************************************************************
* Product: QP-nano configuration for the "Fly 'n' Shoot" game
* Last Updated for Version: 5.8.0
* Date of the Last Update: 2016-11-18
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef QPN_CONF_H
#define QPN_CONF_H
#define Q_PARAM_SIZE 4U
#define QF_MAX_TICK_RATE 2
#define QF_TIMEEVT_CTR_SIZE 2U
#define QF_TIMEEVT_PERIODIC
#endif /* QPN_CONF_H */
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qv/armclang/README.txt
================================================
About this Example
==================
This example demonstrates how to use the uVision IDE together with
the MDK-ARM toolchain.
uVision Project File
====================
The MDK-ARM uVision project file provided with this example uses
relative paths to the QP framework location (includes, port, and
libraries. These relative paths must be modified when the project
is moved to different relative location.
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the
command-line options for the ARM assembler (see the Asm tab in
the "Options for Target" dialog box in uVision). Specifically,
you should define symbols: Stack_Size=xxx Heap_Size=yyy, where
xxx represents a numerical value of stack size and yyy the
numerical value of the heap size (for most embedded projects
yyy should be 0, as the using the heap is not recommended).
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\efm32pg1b\arm\startup_efm32pg1b.s
The file startup_efm32pg1b.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qv/armclang/game-qv.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj; *.o*.lib*.txt; *.h; *.inc*.plm*.cpp000game-dbg0x4ARM-ADS120000001110016553500079668.\dbg\11101101000011111110010130111111111111101011001003Segger\JL2CM3.dll0DLGUARM/0JL2CM3-U440060969 -O207 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO7 -FD20000000 -FC8000 -FN1 -FF0GECKOP2.FLM -FS00 -FL040000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10UL2CM3UL2CM3(-O207 -S0 -C0 -FO7 -FN1 -FC8000 -FD20000000 -FF0GECKOP2 -FL020000 -FS00 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)0DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E2006F4 -O4622 -S4 -FO61120x200002000200x40000001000010000000000000000000game-rel0x4ARM-ADS120000001110016553500079668.\rel\11101101000011111110010030111111111111101011001003Segger\JL2CM3.dll0JL2CM3-U440060969 -O207 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO7 -FD20000000 -FC8000 -FN1 -FF0GECKOP2.FLM -FS00 -FL020000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)0DLGUARM/0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E10259B -O4622 -S4 -FO610UL2CM3-O207 -S0 -C0 -FO7 -FN1 -FC8000 -FD20000000 -FF0GECKOP2 -FL020000 -FS00 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM)120x200002000200x40000001000010000000000000000000Applicatioin1000111000..\bsp.cbsp.c00121000..\..\main.cmain.c00135000..\..\game.hgame.h00141000..\..\..\..\..\include\qstamp.cqstamp.c00151000..\..\mine1.cmine1.c00161000..\..\mine2.cmine2.c00171000..\..\missile.cmissile.c00181000..\..\ship.cship.c00191000..\..\tunnel.ctunnel.c00efm32pg1b10002101000..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.cem_cmu.c002111000..\..\..\..\..\3rd_party\efm32pg1b\em_emu.cem_emu.c002121000..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.cem_gpio.c002131000..\..\..\..\..\3rd_party\efm32pg1b\em_int.cem_int.c002141000..\..\..\..\..\3rd_party\efm32pg1b\em_rtcc.cem_rtcc.c002151000..\..\..\..\..\3rd_party\efm32pg1b\em_system.cem_system.c002161000..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.csystem_efm32pg1b.c002171000..\..\..\..\..\3rd_party\efm32pg1b\display_ls013b7dh03.cdisplay_ls013b7dh03.c002181000..\..\..\..\..\3rd_party\efm32pg1b\displaypalemlib.cdisplaypalemlib.c002191000..\..\..\..\..\3rd_party\efm32pg1b\em_prs.cem_prs.c002201000..\..\..\..\..\3rd_party\efm32pg1b\em_usart.cem_usart.c002211000..\..\..\..\..\3rd_party\efm32pg1b\udelay.cudelay.c002222000..\..\..\..\..\3rd_party\efm32pg1b\arm\startup_efm32pg1b.sstartup_efm32pg1b.s00QP10003231000..\..\..\..\..\src\qfn\qepn.cqepn.c003241000..\..\..\..\..\src\qfn\qfn.cqfn.c003251000..\..\..\..\..\src\qvn\qvn.cqvn.c00QP_port10004265000..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqfn_port.h004271000..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.cqvn_port.c00
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qv/armclang/game-qv.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwaregame-dbg0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1EFM32PG1B200F256GM48Silicon LabsSiliconLabs.EFM32PG1B_DFP.5.5.0https://www.silabs.com/documents/public/cmsis-packs/IRAM(0x20000000,0x00008000) IROM(0x00000000,0x00020000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC8000 -FN1 -FF0GECKOP2 -FS00 -FL020000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM))0$$Device:EFM32PG1B200F256GM48$Device\EFM32PG1B\Include\em_device.h$$Device:EFM32PG1B200F256GM48$SVD\EFM32PG1B\EFM32PG1B200F256GM48.svd0000001.\dbg\game-qv10011.\dbg\10000000010cmd /c "del .\dbg\qstamp.o"000010fromelf --bin --output .\dbg\game-qv.bin .\dbg\game-qv.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140961BIN\UL2CM3.DLL"" ()0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x2000000x00x010x00x010x00x010x00x010x00x2000010x00x000x00x000x00x000x00x000x200000000x800000x00x007001000003011003300000EFM32PG1B200F256GM48=1 __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\efm32pg1b1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cmain.c1..\..\main.cgame.h5..\..\game.hqstamp.c1..\..\..\..\..\include\qstamp.cmine1.c1..\..\mine1.cmine2.c1..\..\mine2.cmissile.c1..\..\missile.cship.c1..\..\ship.ctunnel.c1..\..\tunnel.cefm32pg1bem_cmu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.cem_emu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_emu.cem_gpio.c1..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.cem_int.c1..\..\..\..\..\3rd_party\efm32pg1b\em_int.cem_rtcc.c1..\..\..\..\..\3rd_party\efm32pg1b\em_rtcc.cem_system.c1..\..\..\..\..\3rd_party\efm32pg1b\em_system.csystem_efm32pg1b.c1..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.cdisplay_ls013b7dh03.c1..\..\..\..\..\3rd_party\efm32pg1b\display_ls013b7dh03.cdisplaypalemlib.c1..\..\..\..\..\3rd_party\efm32pg1b\displaypalemlib.cem_prs.c1..\..\..\..\..\3rd_party\efm32pg1b\em_prs.cem_usart.c1..\..\..\..\..\3rd_party\efm32pg1b\em_usart.cudelay.c1..\..\..\..\..\3rd_party\efm32pg1b\udelay.cstartup_efm32pg1b.s2..\..\..\..\..\3rd_party\efm32pg1b\arm\startup_efm32pg1b.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.cgame-rel0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1EFM32PG1B200F256GM48Silicon LabsSiliconLabs.EFM32PG1B_DFP.5.5.0https://www.silabs.com/documents/public/cmsis-packs/IRAM(0x20000000,0x00008000) IROM(0x00000000,0x00020000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC8000 -FN1 -FF0GECKOP2 -FS00 -FL020000 -FP0($$Device:EFM32PG1B200F256GM48$Flash\GECKOP2.FLM))0$$Device:EFM32PG1B200F256GM48$Device\EFM32PG1B\Include\em_device.h$$Device:EFM32PG1B200F256GM48$SVD\EFM32PG1B\EFM32PG1B200F256GM48.svd0000001.\rel\game-qv10000.\rel\10000000010cmd /c "del .\rel\qstamp.o"000010fromelf --bin --output .\rel\game-qv.bin .\rel\game-qv.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140961BIN\UL2CM3.DLL"" ()0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x2000000x00x010x00x010x00x010x00x010x00x2000010x00x000x00x000x00x000x00x000x200000000x800000x00x007001000003011003300000NDEBUG EFM32PG1B200F256GM48=1 __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\efm32pg1b1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000game-qv.sct--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cmain.c1..\..\main.cgame.h5..\..\game.hqstamp.c1..\..\..\..\..\include\qstamp.cmine1.c1..\..\mine1.cmine2.c1..\..\mine2.cmissile.c1..\..\missile.cship.c1..\..\ship.ctunnel.c1..\..\tunnel.cefm32pg1bem_cmu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.cem_emu.c1..\..\..\..\..\3rd_party\efm32pg1b\em_emu.cem_gpio.c1..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.cem_int.c1..\..\..\..\..\3rd_party\efm32pg1b\em_int.cem_rtcc.c1..\..\..\..\..\3rd_party\efm32pg1b\em_rtcc.cem_system.c1..\..\..\..\..\3rd_party\efm32pg1b\em_system.csystem_efm32pg1b.c1..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.cdisplay_ls013b7dh03.c1..\..\..\..\..\3rd_party\efm32pg1b\display_ls013b7dh03.cdisplaypalemlib.c1..\..\..\..\..\3rd_party\efm32pg1b\displaypalemlib.cem_prs.c1..\..\..\..\..\3rd_party\efm32pg1b\em_prs.cem_usart.c1..\..\..\..\..\3rd_party\efm32pg1b\em_usart.cudelay.c1..\..\..\..\..\3rd_party\efm32pg1b\udelay.cstartup_efm32pg1b.s2..\..\..\..\..\3rd_party\efm32pg1b\arm\startup_efm32pg1b.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.c
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qv/bsp.c
================================================
/*****************************************************************************
* Product: "Fly 'n' Shoot" game example, EFM32-SLSTK3401A board, QV kernel
* Last updated for version 5.8.0
* Last updated on 2016-11-06
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "game.h"
#include "bsp.h"
#include "em_device.h" /* the device specific header (SiLabs) */
#include "em_chip.h" /* Chip errata (SiLabs) */
#include "em_cmu.h" /* Clock Management Unit (SiLabs) */
#include "em_gpio.h" /* GPIO (SiLabs) */
#include "em_usart.h" /* USART (SiLabs) */
#include "display_ls013b7dh03.h" /* LS013b7DH03 display (SiLabs/QL) */
/* add other drivers if necessary... */
Q_DEFINE_THIS_FILE
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
enum KernelUnawareISRs { /* see NOTE00 */
/* ... */
MAX_KERNEL_UNAWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-unaware" interrupts can't overlap "kernel-aware" interrupts */
Q_ASSERT_COMPILE(MAX_KERNEL_UNAWARE_CMSIS_PRI <= QF_AWARE_ISR_CMSIS_PRI);
enum KernelAwareISRs {
GPIO_EVEN_PRIO = QF_AWARE_ISR_CMSIS_PRI, /* see NOTE00 */
SYSTICK_PRIO,
/* ... */
MAX_KERNEL_AWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-aware" interrupts should not overlap the PendSV priority */
Q_ASSERT_COMPILE(MAX_KERNEL_AWARE_CMSIS_PRI <= (0xFF >>(8-__NVIC_PRIO_BITS)));
/* ISRs defined in this BSP ------------------------------------------------*/
void SysTick_Handler(void);
void GPIO_EVEN_IRQHandler(void);
void USART0_RX_IRQHandler(void);
/* Local-scope objects -----------------------------------------------------*/
#define LED_PORT gpioPortF
#define LED0_PIN 4
#define LED1_PIN 5
#define PB_PORT gpioPortF
#define PB0_PIN 6
#define PB1_PIN 7
/* LCD geometry and frame buffer */
static uint32_t l_fb[BSP_SCREEN_HEIGHT + 1][BSP_SCREEN_WIDTH / 32U];
/* the walls buffer */
static uint32_t l_walls[GAME_TUNNEL_HEIGHT + 1][BSP_SCREEN_WIDTH / 32U];
static unsigned l_rnd; /* random seed */
static void paintBits(uint8_t x, uint8_t y, uint8_t const *bits, uint8_t h);
static void paintBitsClear(uint8_t x, uint8_t y,
uint8_t const *bits, uint8_t h);
/* ISRs used in the application ==========================================*/
void SysTick_Handler(void) {
QF_tickXISR(0U); /* process time events for rate 0 */
/* post TIME_TICK events to all interested active objects... */
QACTIVE_POST_ISR((QActive *)&AO_Tunnel, TIME_TICK_SIG, 0);
QACTIVE_POST_ISR((QActive *)&AO_Ship, TIME_TICK_SIG, 0);
QACTIVE_POST_ISR((QActive *)&AO_Missile, TIME_TICK_SIG, 0);
{
/* state of the button debouncing, see below */
static struct ButtonsDebouncing {
uint32_t depressed;
uint32_t previous;
} buttons = { ~0U, ~0U };
uint32_t current;
uint32_t tmp;
/* Perform the debouncing of buttons. The algorithm for debouncing
* adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
* and Michael Barr, page 71.
*/
current = ~GPIO->P[PB_PORT].DIN; /* read PB0 and BP1 */
tmp = buttons.depressed; /* save the debounced depressed buttons */
buttons.depressed |= (buttons.previous & current); /* set depressed */
buttons.depressed &= (buttons.previous | current); /* clear released */
buttons.previous = current; /* update the history */
tmp ^= buttons.depressed; /* changed debounced depressed */
if ((tmp & (1U << PB0_PIN)) != 0U) { /* debounced PB0 state changed? */
if ((buttons.depressed & (1U << PB0_PIN)) != 0U) {/*PB0 depressed?*/
QACTIVE_POST_ISR((QActive *)&AO_Ship, PLAYER_TRIGGER_SIG, 0U);
QACTIVE_POST_ISR((QActive *)&AO_Tunnel, PLAYER_TRIGGER_SIG, 0U);
}
}
}
}
/*..........................................................................*/
void GPIO_EVEN_IRQHandler(void) {
QACTIVE_POST_ISR((QActive *)&AO_Tunnel, TAKE_OFF_SIG, 0U);
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* Chip errata */
CHIP_Init();
/* NOTE: SystemInit() already called from startup_TM4C123GH6PM.s
* but SystemCoreClock needs to be updated
*/
SystemCoreClockUpdate();
/* Do NOT to use the automatic FPU state preservation and
* do NOT to use the FPU lazy stacking.
*
* NOTE:
* Use the following setting when FPU is NOT used in any ISR.
*/
FPU->FPCCR &= ~((1U << FPU_FPCCR_ASPEN_Pos) | (1U << FPU_FPCCR_LSPEN_Pos));
/* enable clock for to the peripherals used by this application... */
CMU_ClockEnable(cmuClock_HFPER, true);
CMU_ClockEnable(cmuClock_GPIO, true);
CMU_ClockEnable(cmuClock_HFPER, true);
CMU_ClockEnable(cmuClock_GPIO, true);
/* configure the LEDs */
GPIO_PinModeSet(LED_PORT, LED0_PIN, gpioModePushPull, 0);
GPIO_PinModeSet(LED_PORT, LED1_PIN, gpioModePushPull, 0);
GPIO_PinOutClear(LED_PORT, LED0_PIN);
GPIO_PinOutClear(LED_PORT, LED1_PIN);
/* configure the Buttons */
GPIO_PinModeSet(PB_PORT, PB0_PIN, gpioModeInputPull, 1);
GPIO_PinModeSet(PB_PORT, PB1_PIN, gpioModeInputPull, 1);
/* Initialize the DISPLAY driver. */
if (!Display_init()) {
Q_ERROR();
}
}
/*..........................................................................*/
void BSP_updateScreen(void) {
GPIO->P[LED_PORT].DOUT |= (1U << LED1_PIN);
Display_sendPA(&l_fb[0][0], 0, LS013B7DH03_HEIGHT);
GPIO->P[LED_PORT].DOUT &= ~(1U << LED1_PIN);
}
/*..........................................................................*/
void BSP_clearFB() {
uint_fast8_t y;
for (y = 0U; y < BSP_SCREEN_HEIGHT; ++y) {
l_fb[y][0] = 0U;
l_fb[y][1] = 0U;
l_fb[y][2] = 0U;
l_fb[y][3] = 0U;
}
}
/*..........................................................................*/
void BSP_clearWalls() {
uint_fast8_t y;
for (y = 0U; y < GAME_TUNNEL_HEIGHT; ++y) {
l_walls[y][0] = 0U;
l_walls[y][1] = 0U;
l_walls[y][2] = 0U;
l_walls[y][3] = 0U;
}
}
/*..........................................................................*/
bool BSP_isThrottle(void) { /* is the throttle button depressed? */
return (GPIO->P[PB_PORT].DIN & (1U << PB1_PIN)) == 0U;
}
/*..........................................................................*/
void BSP_paintString(uint8_t x, uint8_t y, char const *str) {
static uint8_t const font5x7[95][7] = {
{ 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U }, /* */
{ 0x04U, 0x04U, 0x04U, 0x04U, 0x00U, 0x00U, 0x04U }, /* ! */
{ 0x0AU, 0x0AU, 0x0AU, 0x00U, 0x00U, 0x00U, 0x00U }, /* " */
{ 0x0AU, 0x0AU, 0x1FU, 0x0AU, 0x1FU, 0x0AU, 0x0AU }, /* # */
{ 0x04U, 0x1EU, 0x05U, 0x0EU, 0x14U, 0x0FU, 0x04U }, /* $ */
{ 0x03U, 0x13U, 0x08U, 0x04U, 0x02U, 0x19U, 0x18U }, /* % */
{ 0x06U, 0x09U, 0x05U, 0x02U, 0x15U, 0x09U, 0x16U }, /* & */
{ 0x06U, 0x04U, 0x02U, 0x00U, 0x00U, 0x00U, 0x00U }, /* ' */
{ 0x08U, 0x04U, 0x02U, 0x02U, 0x02U, 0x04U, 0x08U }, /* ( */
{ 0x02U, 0x04U, 0x08U, 0x08U, 0x08U, 0x04U, 0x02U }, /* ) */
{ 0x00U, 0x04U, 0x15U, 0x0EU, 0x15U, 0x04U, 0x00U }, /* * */
{ 0x00U, 0x04U, 0x04U, 0x1FU, 0x04U, 0x04U, 0x00U }, /* + */
{ 0x00U, 0x00U, 0x00U, 0x00U, 0x06U, 0x04U, 0x02U }, /* , */
{ 0x00U, 0x00U, 0x00U, 0x1FU, 0x00U, 0x00U, 0x00U }, /* - */
{ 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x06U, 0x06U }, /* . */
{ 0x00U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U, 0x00U }, /* / */
{ 0x0EU, 0x11U, 0x19U, 0x15U, 0x13U, 0x11U, 0x0EU }, /* 0 */
{ 0x04U, 0x06U, 0x04U, 0x04U, 0x04U, 0x04U, 0x0EU }, /* 1 */
{ 0x0EU, 0x11U, 0x10U, 0x08U, 0x04U, 0x02U, 0x1FU }, /* 2 */
{ 0x1FU, 0x08U, 0x04U, 0x08U, 0x10U, 0x11U, 0x0EU }, /* 3 */
{ 0x08U, 0x0CU, 0x0AU, 0x09U, 0x1FU, 0x08U, 0x08U }, /* 4 */
{ 0x1FU, 0x01U, 0x0FU, 0x10U, 0x10U, 0x11U, 0x0EU }, /* 5 */
{ 0x0CU, 0x02U, 0x01U, 0x0FU, 0x11U, 0x11U, 0x0EU }, /* 6 */
{ 0x1FU, 0x10U, 0x08U, 0x04U, 0x02U, 0x02U, 0x02U }, /* 7 */
{ 0x0EU, 0x11U, 0x11U, 0x0EU, 0x11U, 0x11U, 0x0EU }, /* 8 */
{ 0x0EU, 0x11U, 0x11U, 0x1EU, 0x10U, 0x08U, 0x06U }, /* 9 */
{ 0x00U, 0x06U, 0x06U, 0x00U, 0x06U, 0x06U, 0x00U }, /* : */
{ 0x00U, 0x06U, 0x06U, 0x00U, 0x06U, 0x04U, 0x02U }, /* ; */
{ 0x08U, 0x04U, 0x02U, 0x01U, 0x02U, 0x04U, 0x08U }, /* < */
{ 0x00U, 0x00U, 0x1FU, 0x00U, 0x1FU, 0x00U, 0x00U }, /* = */
{ 0x02U, 0x04U, 0x08U, 0x10U, 0x08U, 0x04U, 0x02U }, /* > */
{ 0x0EU, 0x11U, 0x10U, 0x08U, 0x04U, 0x00U, 0x04U }, /* ? */
{ 0x0EU, 0x11U, 0x10U, 0x16U, 0x15U, 0x15U, 0x0EU }, /* @ */
{ 0x0EU, 0x11U, 0x11U, 0x11U, 0x1FU, 0x11U, 0x11U }, /* A */
{ 0x0FU, 0x11U, 0x11U, 0x0FU, 0x11U, 0x11U, 0x0FU }, /* B */
{ 0x0EU, 0x11U, 0x01U, 0x01U, 0x01U, 0x11U, 0x0EU }, /* C */
{ 0x07U, 0x09U, 0x11U, 0x11U, 0x11U, 0x09U, 0x07U }, /* D */
{ 0x1FU, 0x01U, 0x01U, 0x0FU, 0x01U, 0x01U, 0x1FU }, /* E */
{ 0x1FU, 0x01U, 0x01U, 0x0FU, 0x01U, 0x01U, 0x01U }, /* F */
{ 0x0EU, 0x11U, 0x01U, 0x1DU, 0x11U, 0x11U, 0x1EU }, /* G */
{ 0x11U, 0x11U, 0x11U, 0x1FU, 0x11U, 0x11U, 0x11U }, /* H */
{ 0x0EU, 0x04U, 0x04U, 0x04U, 0x04U, 0x04U, 0x0EU }, /* I */
{ 0x1CU, 0x08U, 0x08U, 0x08U, 0x08U, 0x09U, 0x06U }, /* J */
{ 0x11U, 0x09U, 0x05U, 0x03U, 0x05U, 0x09U, 0x11U }, /* K */
{ 0x01U, 0x01U, 0x01U, 0x01U, 0x01U, 0x01U, 0x1FU }, /* L */
{ 0x11U, 0x1BU, 0x15U, 0x15U, 0x11U, 0x11U, 0x11U }, /* M */
{ 0x11U, 0x11U, 0x13U, 0x15U, 0x19U, 0x11U, 0x11U }, /* N */
{ 0x0EU, 0x11U, 0x11U, 0x11U, 0x11U, 0x11U, 0x0EU }, /* O */
{ 0x0FU, 0x11U, 0x11U, 0x0FU, 0x01U, 0x01U, 0x01U }, /* P */
{ 0x0EU, 0x11U, 0x11U, 0x11U, 0x15U, 0x09U, 0x16U }, /* Q */
{ 0x0FU, 0x11U, 0x11U, 0x0FU, 0x05U, 0x09U, 0x11U }, /* R */
{ 0x1EU, 0x01U, 0x01U, 0x0EU, 0x10U, 0x10U, 0x0FU }, /* S */
{ 0x1FU, 0x04U, 0x04U, 0x04U, 0x04U, 0x04U, 0x04U }, /* T */
{ 0x11U, 0x11U, 0x11U, 0x11U, 0x11U, 0x11U, 0x0EU }, /* U */
{ 0x11U, 0x11U, 0x11U, 0x11U, 0x11U, 0x0AU, 0x04U }, /* V */
{ 0x11U, 0x11U, 0x11U, 0x15U, 0x15U, 0x15U, 0x0AU }, /* W */
{ 0x11U, 0x11U, 0x0AU, 0x04U, 0x0AU, 0x11U, 0x11U }, /* X */
{ 0x11U, 0x11U, 0x11U, 0x0AU, 0x04U, 0x04U, 0x04U }, /* Y */
{ 0x1FU, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U, 0x1FU }, /* Z */
{ 0x0EU, 0x02U, 0x02U, 0x02U, 0x02U, 0x02U, 0x0EU }, /* [ */
{ 0x00U, 0x01U, 0x02U, 0x04U, 0x08U, 0x10U, 0x00U }, /* \ */
{ 0x0EU, 0x08U, 0x08U, 0x08U, 0x08U, 0x08U, 0x0EU }, /* ] */
{ 0x04U, 0x0AU, 0x11U, 0x00U, 0x00U, 0x00U, 0x00U }, /* ^ */
{ 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x1FU }, /* _ */
{ 0x02U, 0x04U, 0x08U, 0x00U, 0x00U, 0x00U, 0x00U }, /* ` */
{ 0x00U, 0x00U, 0x0EU, 0x10U, 0x1EU, 0x11U, 0x1EU }, /* a */
{ 0x01U, 0x01U, 0x0DU, 0x13U, 0x11U, 0x11U, 0x0FU }, /* b */
{ 0x00U, 0x00U, 0x0EU, 0x01U, 0x01U, 0x11U, 0x0EU }, /* c */
{ 0x10U, 0x10U, 0x16U, 0x19U, 0x11U, 0x11U, 0x1EU }, /* d */
{ 0x00U, 0x00U, 0x0EU, 0x11U, 0x1FU, 0x01U, 0x0EU }, /* e */
{ 0x0CU, 0x12U, 0x02U, 0x07U, 0x02U, 0x02U, 0x02U }, /* f */
{ 0x00U, 0x1EU, 0x11U, 0x11U, 0x1EU, 0x10U, 0x0EU }, /* g */
{ 0x01U, 0x01U, 0x0DU, 0x13U, 0x11U, 0x11U, 0x11U }, /* h */
{ 0x04U, 0x00U, 0x06U, 0x04U, 0x04U, 0x04U, 0x0EU }, /* i */
{ 0x08U, 0x00U, 0x0CU, 0x08U, 0x08U, 0x09U, 0x06U }, /* j */
{ 0x01U, 0x01U, 0x09U, 0x05U, 0x03U, 0x05U, 0x09U }, /* k */
{ 0x06U, 0x04U, 0x04U, 0x04U, 0x04U, 0x04U, 0x0EU }, /* l */
{ 0x00U, 0x00U, 0x0BU, 0x15U, 0x15U, 0x11U, 0x11U }, /* m */
{ 0x00U, 0x00U, 0x0DU, 0x13U, 0x11U, 0x11U, 0x11U }, /* n */
{ 0x00U, 0x00U, 0x0EU, 0x11U, 0x11U, 0x11U, 0x0EU }, /* o */
{ 0x00U, 0x00U, 0x0FU, 0x11U, 0x0FU, 0x01U, 0x01U }, /* p */
{ 0x00U, 0x00U, 0x16U, 0x19U, 0x1EU, 0x10U, 0x10U }, /* q */
{ 0x00U, 0x00U, 0x0DU, 0x13U, 0x01U, 0x01U, 0x01U }, /* r */
{ 0x00U, 0x00U, 0x0EU, 0x01U, 0x0EU, 0x10U, 0x0FU }, /* s */
{ 0x02U, 0x02U, 0x07U, 0x02U, 0x02U, 0x12U, 0x0CU }, /* t */
{ 0x00U, 0x00U, 0x11U, 0x11U, 0x11U, 0x19U, 0x16U }, /* u */
{ 0x00U, 0x00U, 0x11U, 0x11U, 0x11U, 0x0AU, 0x04U }, /* v */
{ 0x00U, 0x00U, 0x11U, 0x11U, 0x15U, 0x15U, 0x0AU }, /* w */
{ 0x00U, 0x00U, 0x11U, 0x0AU, 0x04U, 0x0AU, 0x11U }, /* x */
{ 0x00U, 0x00U, 0x11U, 0x11U, 0x1EU, 0x10U, 0x0EU }, /* y */
{ 0x00U, 0x00U, 0x1FU, 0x08U, 0x04U, 0x02U, 0x1FU }, /* z */
{ 0x08U, 0x04U, 0x04U, 0x02U, 0x04U, 0x04U, 0x08U }, /* { */
{ 0x04U, 0x04U, 0x04U, 0x04U, 0x04U, 0x04U, 0x04U }, /* | */
{ 0x02U, 0x04U, 0x04U, 0x08U, 0x04U, 0x04U, 0x02U }, /* } */
{ 0x02U, 0x15U, 0x08U, 0x00U, 0x00U, 0x00U, 0x00U }, /* ~ */
};
for (; *str != '\0'; ++str, x += 6) {
uint8_t const *ch = &font5x7[*str - ' '][0];
paintBitsClear(x, y, ch, 7);
}
}
/*==========================================================================*/
typedef struct { /* the auxiliary structure to hold const bitmaps */
uint8_t const *bits; /* the bits in the bitmap */
uint8_t height; /* the height of the bitmap */
} Bitmap;
/* bitmap of the Ship:
*
* x....
* xxx..
* xxxxx
*/
static uint8_t const ship_bits[] = {
0x01U, 0x07U, 0x1FU
};
/* bitmap of the Missile:
*
* xxxx
*/
static uint8_t const missile_bits[] = {
0x0FU
};
/* bitmap of the Mine type-1:
*
* .x.
* xxx
* .x.
*/
static uint8_t const mine1_bits[] = {
0x02U, 0x07U, 0x02U
};
/* bitmap of the Mine type-2:
*
* x..x
* .xx.
* .xx.
* x..x
*/
static uint8_t const mine2_bits[] = {
0x09U, 0x06U, 0x06U, 0x09U
};
/* Mine type-2 is nastier than Mine type-1. The type-2 mine can
* hit the Ship with any of its "tentacles". However, it can be
* destroyed by the Missile only by hitting its center, defined as
* the following bitmap:
*
* ....
* .xx.
* .xx.
*/
static uint8_t const mine2_missile_bits[] = {
0x00U, 0x06U, 0x06U
};
/*
* The bitmap of the explosion stage 0:
*
* .......
* ...x...
* ..x.x..
* ...x...
*/
static uint8_t const explosion0_bits[] = {
0x00U, 0x08U, 0x14U, 0x08U
};
/*
* The bitmap of the explosion stage 1:
*
* .......
* ..x.x..
* ...x...
* ..x.x..
*/
static uint8_t const explosion1_bits[] = {
0x00U, 0x14U, 0x08U, 0x14U
};
/*
* The bitmap of the explosion stage 2:
*
* .x...x.
* ..x.x..
* ...x...
* ..x.x..
* .x...x.
*/
static uint8_t const explosion2_bits[] = {
0x11U, 0x0AU, 0x04U, 0x0AU, 0x11U
};
/*
* The bitmap of the explosion stage 3:
*
* x..x..x
* .x.x.x.
* ..x.x..
* xx.x.xx
* ..x.x..
* .x.x.x.
* x..x..x
*/
static uint8_t const explosion3_bits[] = {
0x49, 0x2A, 0x14, 0x6B, 0x14, 0x2A, 0x49
};
static Bitmap const l_bitmap[MAX_BMP] = {
{ ship_bits, Q_DIM(ship_bits) },
{ missile_bits, Q_DIM(missile_bits) },
{ mine1_bits, Q_DIM(mine1_bits) },
{ mine2_bits, Q_DIM(mine2_bits) },
{ mine2_missile_bits, Q_DIM(mine2_missile_bits) },
{ explosion0_bits, Q_DIM(explosion0_bits) },
{ explosion1_bits, Q_DIM(explosion1_bits) },
{ explosion2_bits, Q_DIM(explosion2_bits) },
{ explosion3_bits, Q_DIM(explosion3_bits) }
};
/*..........................................................................*/
void BSP_paintBitmap(uint8_t x, uint8_t y, uint8_t bmp_id) {
Bitmap const *bmp = &l_bitmap[bmp_id];
paintBits(x, y, bmp->bits, bmp->height);
}
/*..........................................................................*/
void BSP_advanceWalls(uint8_t top, uint8_t bottom) {
uint_fast8_t y;
for (y = 0U; y < GAME_TUNNEL_HEIGHT; ++y) {
/* shift the walls one pixel to the left */
l_walls[y][0] = (l_walls[y][0] >> 1) | (l_walls[y][1] << 31);
l_walls[y][1] = (l_walls[y][1] >> 1) | (l_walls[y][2] << 31);
l_walls[y][2] = (l_walls[y][2] >> 1) | (l_walls[y][3] << 31);
l_walls[y][3] = (l_walls[y][3] >> 1);
/* add new column of walls at the end */
if (y <= top) {
l_walls[y][3] |= (1U << 31);
}
if (y >= (GAME_TUNNEL_HEIGHT - bottom)) {
l_walls[y][3] |= (1U << 31);
}
/* copy the walls to the frame buffer */
l_fb[y][0] = l_walls[y][0];
l_fb[y][1] = l_walls[y][1];
l_fb[y][2] = l_walls[y][2];
l_fb[y][3] = l_walls[y][3];
}
}
/*..........................................................................*/
bool BSP_doBitmapsOverlap(uint8_t bmp_id1, uint8_t x1, uint8_t y1,
uint8_t bmp_id2, uint8_t x2, uint8_t y2)
{
uint8_t y;
uint8_t y0;
uint8_t h;
uint32_t bits1;
uint32_t bits2;
Bitmap const *bmp1;
Bitmap const *bmp2;
Q_REQUIRE((bmp_id1 < Q_DIM(l_bitmap)) && (bmp_id2 < Q_DIM(l_bitmap)));
/* are the bitmaps close enough in x? */
if (x1 >= x2) {
if (x1 > x2 + 8U) {
return false;
}
x1 -= x2;
x2 = 0U;
}
else {
if (x2 > x1 + 8U) {
return false;
}
x2 -= x1;
x1 = 0U;
}
bmp1 = &l_bitmap[bmp_id1];
bmp2 = &l_bitmap[bmp_id2];
if ((y1 <= y2) && (y1 + bmp1->height > y2)) {
y0 = y2 - y1;
h = y1 + bmp1->height - y2;
if (h > bmp2->height) {
h = bmp2->height;
}
for (y = 0; y < h; ++y) { /* scan over the overlapping rows */
bits1 = ((uint32_t)bmp1->bits[y + y0] << x1);
bits2 = ((uint32_t)bmp2->bits[y] << x2);
if ((bits1 & bits2) != 0U) { /* do the bits overlap? */
return true; /* yes! */
}
}
}
else {
if ((y1 > y2) && (y2 + bmp2->height > y1)) {
y0 = y1 - y2;
h = y2 + bmp2->height - y1;
if (h > bmp1->height) {
h = bmp1->height;
}
for (y = 0; y < h; ++y) { /* scan over the overlapping rows */
bits1 = ((uint32_t)bmp1->bits[y] << x1);
bits2 = ((uint32_t)bmp2->bits[y + y0] << x2);
if ((bits1 & bits2) != 0U) { /* do the bits overlap? */
return true; /* yes! */
}
}
}
}
return false; /* the bitmaps do not overlap */
}
/*..........................................................................*/
bool BSP_isWallHit(uint8_t bmp_id, uint8_t x, uint8_t y) {
Bitmap const *bmp = &l_bitmap[bmp_id];
uint32_t shft = (x & 0x1FU);
uint32_t *walls = &l_walls[y][x >> 5];
for (y = 0; y < bmp->height; ++y, walls += (BSP_SCREEN_WIDTH >> 5)) {
if (*walls & ((uint32_t)bmp->bits[y] << shft)) {
return true;
}
if (shft > 24U) {
if (*(walls + 1) & ((uint32_t)bmp->bits[y] >> (32U - shft))) {
return true;
}
}
}
return false;
}
/*..........................................................................*/
void BSP_updateScore(uint16_t score) {
char str[5];
uint16_t s = score;
if (score == 0U) {
BSP_paintString(1U, BSP_SCREEN_HEIGHT - 8U, "SCORE:");
}
/* update the SCORE area on the screeen */
str[4] = '\0';
str[3] = (s % 10U) + '0'; s /= 10U;
str[2] = (s % 10U) + '0'; s /= 10U;
str[1] = (s % 10U) + '0'; s /= 10U;
str[0] = (s % 10U) + '0';
BSP_paintString(6U*6U, BSP_SCREEN_HEIGHT - 8U, str);
}
/*..........................................................................*/
void BSP_displayOn(void) {
Display_enable(true);
}
/*..........................................................................*/
void BSP_displayOff(void) {
Display_enable(false);
}
/*..........................................................................*/
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
l_rnd = l_rnd * (3U*7U*11U*13U*23U);
return l_rnd >> 8;
}
/*..........................................................................*/
void BSP_randomSeed(uint32_t seed) {
l_rnd = seed;
}
/*--------------------------------------------------------------------------*/
/*..........................................................................*/
static void paintBits(uint8_t x, uint8_t y, uint8_t const *bits, uint8_t h) {
uint32_t *fb = &l_fb[y][x >> 5];
uint32_t shft = (x & 0x1FU);
for (y = 0; y < h; ++y, fb += (BSP_SCREEN_WIDTH >> 5)) {
*fb |= ((uint32_t)bits[y] << shft);
if (shft > 24U) {
*(fb + 1) |= ((uint32_t)bits[y] >> (32U - shft));
}
}
}
/*..........................................................................*/
static void paintBitsClear(uint8_t x, uint8_t y,
uint8_t const *bits, uint8_t h)
{
uint32_t *fb = &l_fb[y][x >> 5];
uint32_t shft = (x & 0x1FU);
uint32_t mask1 = ~((uint32_t)0xFFU << shft);
uint32_t mask2;
if (shft > 24U) {
mask2 = ~(0xFFU >> (32U - shft));
}
for (y = 0; y < h; ++y, fb += (BSP_SCREEN_WIDTH >> 5)) {
*fb = ((*fb & mask1) | ((uint32_t)bits[y] << shft));
if (shft > 24U) {
*(fb + 1) = ((*(fb + 1) & mask2)
| ((uint32_t)bits[y] >> (32U - shft)));
}
}
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set up the SysTick timer to fire at BSP_TICKS_PER_SEC rate */
SysTick_Config(SystemCoreClock / BSP_TICKS_PER_SEC);
/* assing all priority bits for preemption-prio. and none to sub-prio. */
NVIC_SetPriorityGrouping(0U);
/* set priorities of ALL ISRs used in the system, see NOTE00
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
NVIC_SetPriority(SysTick_IRQn, SYSTICK_PRIO);
NVIC_SetPriority(GPIO_EVEN_IRQn, GPIO_EVEN_PRIO);
/* ... */
/* enable IRQs... */
NVIC_EnableIRQ(GPIO_EVEN_IRQn);
#ifdef Q_SPY
NVIC_EnableIRQ(USART0_RX_IRQn); /* UART0 interrupt used for QS-RX */
#endif
}
/*..........................................................................*/
void QF_stop(void) {
}
/*..........................................................................*/
void QV_onIdle(void) { /* called with interrupts disabled, see NOTE01 */
/* toggle the User LED on and then off, see NOTE02 */
GPIO->P[LED_PORT].DOUT |= (1U << LED0_PIN);
GPIO->P[LED_PORT].DOUT &= ~(1U << LED0_PIN);
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular Cortex-M MCU.
*/
QV_CPU_SLEEP(); /* atomically go to sleep and enable interrupts */
#else
QF_INT_ENABLE(); /* just enable interrupts */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const *module, int loc) {
/*
* NOTE: add here your application-specific error handling
*/
(void)module;
(void)loc;
#ifndef NDEBUG
/* light up both LEDs */
GPIO->P[LED_PORT].DOUT |= ((1U << LED0_PIN) | (1U << LED1_PIN));
/* for debugging, hang on in an endless loop until PB1 is pressed... */
while ((GPIO->P[PB_PORT].DIN & (1U << PB1_PIN)) != 0) {
}
#endif
NVIC_SystemReset();
}
/*****************************************************************************
* NOTE00:
* The QF_AWARE_ISR_CMSIS_PRI constant from the QF port specifies the highest
* ISR priority that is disabled by the QF framework. The value is suitable
* for the NVIC_SetPriority() CMSIS function.
*
* Only ISRs prioritized at or below the QF_AWARE_ISR_CMSIS_PRI level (i.e.,
* with the numerical values of priorities equal or higher than
* QF_AWARE_ISR_CMSIS_PRI) are allowed to call the QK_ISR_ENTRY/QK_ISR_ENTRY
* macros or any other QF/QK services. These ISRs are "QF-aware".
*
* Conversely, any ISRs prioritized above the QF_AWARE_ISR_CMSIS_PRI priority
* level (i.e., with the numerical values of priorities less than
* QF_AWARE_ISR_CMSIS_PRI) are never disabled and are not aware of the kernel.
* Such "QF-unaware" ISRs cannot call any QF/QK services. In particular they
* can NOT call the macros QK_ISR_ENTRY/QK_ISR_ENTRY. The only mechanism
* by which a "QF-unaware" ISR can communicate with the QF framework is by
* triggering a "QF-aware" ISR, which can post/publish events.
*
* NOTE01:
* The QV_onIdle() callback is called with interrupts disabled, because the
* determination of the idle condition might change by any interrupt posting
* an event. QV_onIdle() must internally enable interrupts, ideally
* atomically with putting the CPU to the power-saving mode.
*
* NOTE02:
* The User LED is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qv/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano on EMF32-SLSTK3401A, QV-nano kernel, GNU-ARM
# Last Updated for Version: 6.5.0
# Date of the Last Update: 2019-04-15
#
# Q u a n t u m L e a P s
# ------------------------
# Modern Embedded Software
#
# Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# https://www.state-machine.com
# mailto:info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := game-qv
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/arm-cm/qv/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qvn \
$(QP_PORT_DIR) \
$(QPN)/3rd_party/efm32pg1b \
$(QPN)/3rd_party/efm32pg1b/gnu
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR) \
-I$(QPN)/3rd_party/CMSIS/Include \
-I$(QPN)/3rd_party/efm32pg1b
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
bsp.c \
main.c \
mine1.c \
mine2.c \
missile.c \
ship.c \
tunnel.c \
startup_efm32pg1b.c \
system_efm32pg1b.c \
em_cmu.c \
em_emu.c \
em_gpio.c \
em_int.c \
em_prs.c \
em_rtcc.c \
em_system.c \
em_usart.c \
udelay.c \
display_ls013b7dh03.c \
displaypalemlib.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qepn.c \
qfn.c \
qvn.c \
qvn_port.c
QP_ASMS := \
LIB_DIRS :=
LIBS :=
# defines
DEFINES := -DEFM32PG1B200F256GM48=1
# ARM CPU, ARCH, FPU, and Float-ABI types...
# ARM_CPU: [cortex-m0 | cortex-m0plus | cortex-m1 | cortex-m3 | cortex-m4]
# ARM_ARCH: [6 | 7] (NOTE: must match ARM_CPU!)
# ARM_FPU: [ | vfp]
# FLOAT_ABI: [ | soft | softfp | hard]
#
ARM_CPU := -mcpu=cortex-m4
ARM_ARCH := 7 # NOTE: must match the ARM_CPU!
ARM_FPU := -mfpu=vfp
FLOAT_ABI := -mfloat-abi=softfp
#-----------------------------------------------------------------------------
# GNU-ARM toolset (NOTE: You need to adjust to your machine)
# see https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
#
ifeq ($(GNU_ARM),)
GNU_ARM := $(QTOOLS)/gnu_arm-none-eabi
endif
# make sure that the GNU-ARM toolset exists...
ifeq ("$(wildcard $(GNU_ARM))","")
$(error GNU_ARM toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_ARM)/bin/arm-none-eabi-gcc
CPP := $(GNU_ARM)/bin/arm-none-eabi-g++
AS := $(GNU_ARM)/bin/arm-none-eabi-as
LINK := $(GNU_ARM)/bin/arm-none-eabi-g++
BIN := $(GNU_ARM)/bin/arm-none-eabi-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M
#
# combine all the soruces...
C_SRCS += $(QP_SRCS)
ASM_SRCS += $(QP_ASMS)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS = $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration ..........................................
BIN_DIR := dbg
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O $(INCLUDES) $(DEFINES)
CPPFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES)
endif # ......................................................................
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
-specs=nosys.specs -specs=nano.specs \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_BIN := $(BIN_DIR)/$(OUTPUT).bin
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_BIN)
#all: $(TARGET_ELF)
$(TARGET_BIN): $(TARGET_ELF)
$(BIN) -O binary $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(CC) $(CFLAGS) $(QPN)/include/qstamp.c -o $(BIN_DIR)/qstamp.o
$(LINK) $(LINKFLAGS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.bin \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qv/gnu/README.txt
================================================
About this Example
==================
This example can be built from the command prompt with the provided
Makefile. The example can also be imported as a Makefile-based
project into Eclipse-based IDEs.
The Makefile
============
The provided Makefile should be easy to adapt for your own projects.
It contains three build configurations: Debug (default), Release, and
Spy.
Also, the Makefile has been specifically designed to work as an external
Makefile with the Eclipse CDT.
The various build configurations are built as follows:
make
make CONF=rel
make CONF=spy
make clean
make CONF=rel clean
make CONF=spy clean
***
NOTE:
The installation folder of the GNU-ARM toolset on YOUR machine needs
to be adjusted in the provided Makefile, by editing the symbol: GNU_ARM.
As described in the comment for this symbol, the GNU-ARM toolset is taken
from: http://gnutoolchains.com/arm-eabi
It is highly recommened to use the same GNU-ARM distribution, especially
for ARM Cortex-M4F projects, due to the support for the hardware FPU
(float-abi=hard).
***
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the GCC linker
script (.ld file), which provides a template of the recommended GCC linker
script for QP applications.
Startup Code
============
The startup code for the EFM32PG1B200F256GM48 MCU used in this project
is located in the "3rd_party" folder in the following location:
3rd_party\efm32pg1b\gnu\startup_efm32pg1b.c
The file startup_efm32pg1b.c provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qv/gnu/flash.bat
================================================
::============================================================================
:: Batch file to program the flash of EFM32-SLSTK3401A board
::
:: NOTE: requires the J-Link commander (JLink.exe) from SEGGER, see:
:: https://www.segger.com/j-link-commander.html
::
setlocal
@echo off
@echo Load a given binary file to the flash of EFM32-SLSTK3401A
@echo usage: flash bin-file
@echo example: flash dbg\blinky-qk.bin
::----------------------------------------------------------------------------
:: NOTE: Adjust the following symbol to the location of the
:: JLink utility on your machine
::
if [%JLINK%] EQU [] set JLINK=%QTOOLS%\..\JLink
if not exist "%JLINK%\JLink.exe" (
@echo The JLink tool not found. Please adjust flash.bat
@goto end
)
if ["%~1"]==[""] (
@echo The binary file missing
@goto end
)
if not exist %~s1 (
@echo The binary file '%1' does not exist
@goto end
)
:: generate the Jlink command file depending on the first parameter %1
@echo si 1 >flash.jlink
@echo speed 4000 >>flash.jlink
@echo r >>flash.jlink
@echo h >>flash.jlink
@echo loadbin %1, 0 >>flash.jlink
@echo exit >>flash.jlink
@echo on
%JLINK%\JLink.exe -device EFM32PG1B200F256GM48 flash.jlink
@echo off
@del flash.jlink
:end
endlocal
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qv/gnu/game-qv.ld
================================================
/*****************************************************************************
* Product: Linker script for EFM32-SLSTK3401A, GNU-ARM linker
* Last Updated for Version: 5.9.8
* Date of the Last Update: 2017-09-13
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* https://state-machine.com
* mailto:info@state-machine.com
*****************************************************************************/
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(Reset_Handler) /* entry Point */
MEMORY { /* memory map of Pearl Gecko EFM32PG1B200F256GM48 */
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 256K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
}
/* The size of the stack used by the application. NOTE: you need to adjust */
STACK_SIZE = 1024;
/* The size of the heap used by the application. NOTE: you need to adjust */
HEAP_SIZE = 0;
SECTIONS {
.isr_vector : { /* the vector table goes FIRST into ROM */
KEEP(*(.isr_vector)) /* vector table */
. = ALIGN(4);
} >ROM
.text : { /* code and constants */
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} >ROM
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >ROM
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >ROM
.fini_array : {
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array*))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >ROM
_etext = .; /* global symbols at end of code */
.stack : {
__stack_start__ = .;
. = . + STACK_SIZE;
. = ALIGN(4);
__stack_end__ = .;
} >RAM
.data : AT (_etext) {
__data_load = LOADADDR (.data);
__data_start = .;
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
__data_end__ = .;
_edata = __data_end__;
} >RAM
.bss : {
__bss_start__ = .;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = .;
} >RAM
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >RAM
__exidx_end = .;
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );
PROVIDE ( __end__ = _ebss );
.heap : {
__heap_start__ = .;
. = . + HEAP_SIZE;
. = ALIGN(4);
__heap_end__ = .;
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ : {
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
}
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qv/iar/README.txt
================================================
About this Example
==================
This example demonstrates how to use the IAR EWARM IDE to build
a QP application.
IAR Project File
----------------
The IAR EWARM project file provided with this example uses relative paths
to the QP/C framework location (includes, port, and libraries. These
relative paths must be modified when the project is moved to different
relative location.
Stack Size and Heap Size
------------------------
In this project, the size of the C stack and heap are determined in
the linker script blinky-qk.icf (see the next section).
Linker Script
-------------
The IAR linker script provides a template of the recommended linker script
for QP applications. This file needs to be customized to set the
application-specific sizes of the Stack and Heap. This file can be edited
from the IAR EWARM IDE via the Project Options/Linker settings.
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\efm32pg1b\iar\startup_efm32pg1b.s
The file startup_efm32pg1b.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qv/iar/game-qv.ewd
================================================
3DebugARM1C-SPY22811ARMSIM_ID2111CADI_ID2011CMSISDAP_ID2411GDBSERVER_ID2011IJET_ID2811JLINK_ID21611LMIFTDI_ID2211PEMICRO_ID2311STLINK_ID2411THIRDPARTY_ID2011TIFET_ID2111XDS100_ID2611$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseARM0C-SPY22810ARMSIM_ID2110CADI_ID2010CMSISDAP_ID2410GDBSERVER_ID2010IJET_ID2810JLINK_ID21610LMIFTDI_ID2210PEMICRO_ID2310STLINK_ID2410THIRDPARTY_ID2010TIFET_ID2110XDS100_ID2610$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qv/iar/game-qv.ewp
================================================
3DebugARM1General32811ICCARM23411AARM21011OBJCOPY0111CUSTOM30BICOMP0BUILDACTION1cmd /c "if exist $OBJ_DIR$\qstamp.o del $OBJ_DIR$\qstamp.o"ILINK02011IARCHIVE0011BILINK0Coder0ReleaseARM0General32810ICCARM23410AARM21010OBJCOPY0110CUSTOM30BICOMP0BUILDACTION1cmd /c "if exist $OBJ_DIR$\qstamp.o del $OBJ_DIR$\qstamp.o"ILINK02010IARCHIVE0010BILINK0Coder0Application$PROJ_DIR$\..\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\game.h$PROJ_DIR$\..\..\main.c$PROJ_DIR$\..\..\mine1.c$PROJ_DIR$\..\..\mine2.c$PROJ_DIR$\..\..\missile.c$PROJ_DIR$\..\..\qpn_conf.h$PROJ_DIR$\..\..\..\..\..\include\qstamp.c$PROJ_DIR$\..\..\ship.c$PROJ_DIR$\..\..\tunnel.cefm32pg1b$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\display_ls013b7dh03.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\displaypalemlib.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_assert.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_cmu.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_emu.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_gpio.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_int.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_prs.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_rtcc.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_system.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\em_usart.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\iar\startup_efm32pg1b.s$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\system_efm32pg1b.c$PROJ_DIR$\..\..\..\..\..\3rd_party\efm32pg1b\udelay.cQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qvn\qvn.cQP_port$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qv\iar\qfn_port.h$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qv\iar\qvn_port.c
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qv/iar/game-qv.eww
================================================
$WS_DIR$\game-qv.ewp
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/qv/iar/game-qv.icf
================================================
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0003FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 1024;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place at start of RAM_region {block CSTACK };
place in RAM_region { readwrite, block HEAP };
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/ship.c
================================================
/*.$file${.::ship.c} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: game.qm
* File: ${.::ship.c}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::ship.c} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#include "qpn.h"
#include "game.h"
#include "bsp.h"
/* Q_DEFINE_THIS_MODULE(ship) */
#define SHIP_WIDTH 5U
#define SHIP_HEIGHT 3U
/* encapsulated delcaration of the Ship active object ----------------------*/
/*.$declare${AOs::Ship} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Ship} ............................................................*/
typedef struct Ship {
/* protected: */
QActive super;
/* private: */
uint8_t x;
uint16_t y;
uint8_t exp_ctr;
uint16_t score;
} Ship;
/* protected: */
static QState Ship_initial(Ship * const me);
static QState Ship_active(Ship * const me);
static QState Ship_parked(Ship * const me);
static QState Ship_flying(Ship * const me);
static QState Ship_exploding(Ship * const me);
/*.$enddecl${AOs::Ship} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* global objects ----------------------------------------------------------*/
Ship AO_Ship;
/* Active object definition ------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*. Check for the minimum required QP version */
#if (QP_VERSION < 650U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpn version 6.5.0 or higher required
#endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Ship_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Ship_ctor} .......................................................*/
void Ship_ctor(void) {
Ship *me = &AO_Ship;
QActive_ctor(&me->super, Q_STATE_CAST(&Ship_initial));
me->x = GAME_SHIP_X;
me->y = (GAME_SHIP_Y << 2);
}
/*.$enddef${AOs::Ship_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Ship} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Ship} ............................................................*/
/*.${AOs::Ship::SM} ........................................................*/
static QState Ship_initial(Ship * const me) {
/*.${AOs::Ship::SM::initial} */
return Q_TRAN(&Ship_active);
}
/*.${AOs::Ship::SM::active} ................................................*/
static QState Ship_active(Ship * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Ship::SM::active::initial} */
case Q_INIT_SIG: {
status_ = Q_TRAN(&Ship_parked);
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Ship::SM::active::parked} ........................................*/
static QState Ship_parked(Ship * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Ship::SM::active::parked::TAKE_OFF} */
case TAKE_OFF_SIG: {
status_ = Q_TRAN(&Ship_flying);
break;
}
default: {
status_ = Q_SUPER(&Ship_active);
break;
}
}
return status_;
}
/*.${AOs::Ship::SM::active::flying} ........................................*/
static QState Ship_flying(Ship * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Ship::SM::active::flying} */
case Q_ENTRY_SIG: {
me->score = 0; /* reset the score */
QACTIVE_POST(&AO_Tunnel, SCORE_SIG, me->score);
/* lauch the ship from the initial position */
me->x = GAME_SHIP_X;
me->y = (GAME_SHIP_Y << 2);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Ship::SM::active::flying::TIME_TICK} */
case TIME_TICK_SIG: {
/* move the Ship up or down depending on the button state */
if (BSP_isThrottle()) {
if (me->y > 0) {
me->y -= 1U;
}
}
else {
if (me->y < (GAME_TUNNEL_HEIGHT << 2)) {
me->y += 1U;
}
}
/* tell the Tunnel to draw the Ship and test for hits */
QACTIVE_POST(&AO_Tunnel, SHIP_IMG_SIG,
(SHIP_BMP << 16)
| me->x
| ((me->y >> 2) << 8));
++me->score; /* increment the score for surviving another tick */
if ((me->score % 10) == 0) { /* is the score "round"? */
QACTIVE_POST(&AO_Tunnel, SCORE_SIG, me->score);
}
status_ = Q_HANDLED();
break;
}
/*.${AOs::Ship::SM::active::flying::PLAYER_TRIGGER} */
case PLAYER_TRIGGER_SIG: {
QACTIVE_POST(&AO_Missile, MISSILE_FIRE_SIG,
me->x | (((me->y >> 2) - 1 + SHIP_HEIGHT) & 0xFFU) << 8);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Ship::SM::active::flying::DESTROYED_MINE} */
case DESTROYED_MINE_SIG: {
me->score += (uint16_t)Q_PAR(me);
/* the score will be sent to the Tunnel by the next TIME_TICK */
status_ = Q_HANDLED();
break;
}
/*.${AOs::Ship::SM::active::flying::HIT_WALL} */
case HIT_WALL_SIG: {
status_ = Q_TRAN(&Ship_exploding);
break;
}
/*.${AOs::Ship::SM::active::flying::HIT_MINE} */
case HIT_MINE_SIG: {
status_ = Q_TRAN(&Ship_exploding);
break;
}
default: {
status_ = Q_SUPER(&Ship_active);
break;
}
}
return status_;
}
/*.${AOs::Ship::SM::active::exploding} .....................................*/
static QState Ship_exploding(Ship * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Ship::SM::active::exploding} */
case Q_ENTRY_SIG: {
me->exp_ctr = 0;
status_ = Q_HANDLED();
break;
}
/*.${AOs::Ship::SM::active::exploding::TIME_TICK} */
case TIME_TICK_SIG: {
/*.${AOs::Ship::SM::active::exploding::TIME_TICK::[me->exp_ctr<15]} */
if (me->exp_ctr < 15) {
++me->exp_ctr;
/* tell the Tunnel to draw the current stage of Explosion */
QACTIVE_POST(&AO_Tunnel, EXPLOSION_SIG,
((EXPLOSION0_BMP + (me->exp_ctr >> 2)) << 16)
| me->x
| ((((me->y >> 2) - 4U + SHIP_HEIGHT) & 0xFFU) << 8));
status_ = Q_HANDLED();
}
/*.${AOs::Ship::SM::active::exploding::TIME_TICK::[else]} */
else {
QACTIVE_POST(&AO_Tunnel, GAME_OVER_SIG, me->score);
status_ = Q_TRAN(&Ship_parked);
}
break;
}
default: {
status_ = Q_SUPER(&Ship_active);
break;
}
}
return status_;
}
/*.$enddef${AOs::Ship} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/tunnel.c
================================================
/*.$file${.::tunnel.c} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: game.qm
* File: ${.::tunnel.c}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::tunnel.c} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#include "qpn.h"
#include "game.h"
#include "bsp.h"
Q_DEFINE_THIS_MODULE("tunnel")
/* local objects -----------------------------------------------------------*/
/*.$declare${AOs::Tunnel} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Tunnel} ..........................................................*/
typedef struct Tunnel {
/* protected: */
QActive super;
/* private: */
QHsm * mines[GAME_MINES_MAX];
QHsm * mine1_pool[GAME_MINES_MAX];
QHsm * mine2_pool[GAME_MINES_MAX];
uint8_t blink_ctr;
uint8_t last_mine_x;
uint8_t last_mine_y;
uint8_t wall_thickness_top;
uint8_t wall_thickness_bottom;
uint8_t wall_gap;
} Tunnel;
/* private: */
static void Tunnel_advance(Tunnel * const me);
static void Tunnel_plantMine(Tunnel * const me);
static void Tunnel_dispatchToAllMines(Tunnel * const me, QSignal sig, QParam par);
/* protected: */
static QState Tunnel_initial(Tunnel * const me);
static QState Tunnel_active(Tunnel * const me);
static QState Tunnel_show_logo(Tunnel * const me);
static QState Tunnel_demo(Tunnel * const me);
static QState Tunnel_playing(Tunnel * const me);
static QState Tunnel_game_over(Tunnel * const me);
static QState Tunnel_screen_saver(Tunnel * const me);
static QState Tunnel_screen_saver_hide(Tunnel * const me);
static QState Tunnel_screen_saver_show(Tunnel * const me);
static QState Tunnel_final(Tunnel * const me);
/*.$enddecl${AOs::Tunnel} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* global objects ----------------------------------------------------------*/
Tunnel AO_Tunnel;
/* Active object definition ================================================*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*. Check for the minimum required QP version */
#if (QP_VERSION < 650U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpn version 6.5.0 or higher required
#endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Tunnel_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Tunnel_ctor} .....................................................*/
void Tunnel_ctor(void) {
uint8_t n;
Tunnel *me = &AO_Tunnel;
QActive_ctor(&me->super, Q_STATE_CAST(&Tunnel_initial));
for (n = 0; n < GAME_MINES_MAX; ++n) {
me->mine1_pool[n] = Mine1_ctor(n); /* instantiate Mine1 in the pool */
me->mine2_pool[n] = Mine2_ctor(n); /* instantiate Mine2 in the pool */
me->mines[n] = (QHsm *)0; /* mine 'n' is unused */
}
me->last_mine_x = 0; /* the last mine at the right edge of the tunnel */
me->last_mine_y = 0;
}
/*.$enddef${AOs::Tunnel_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Tunnel} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Tunnel} ..........................................................*/
/*.${AOs::Tunnel::advance} .................................................*/
static void Tunnel_advance(Tunnel * const me) {
uint32_t rnd;
rnd = (BSP_random() & 0xFFU);
/* reduce the top wall thickness 18.75% of the time */
if ((rnd < 48U) && (me->wall_thickness_top > 0U)) {
--me->wall_thickness_top;
}
/* reduce the bottom wall thickness 18.75% of the time */
if ((rnd > 208U) && (me->wall_thickness_bottom > 0U)) {
--me->wall_thickness_bottom;
}
rnd = (BSP_random() & 0xFFU);
/* grow the bottom wall thickness 19.14% of the time */
if ((rnd < 49U)
&& ((GAME_TUNNEL_HEIGHT
- me->wall_thickness_top
- me->wall_thickness_bottom) > me->wall_gap))
{
++me->wall_thickness_bottom;
}
/* grow the top wall thickness 19.14% of the time */
if ((rnd > 207U)
&& ((GAME_TUNNEL_HEIGHT
- me->wall_thickness_top
- me->wall_thickness_bottom) > me->wall_gap))
{
++me->wall_thickness_top;
}
/* advance the Tunnel by 1 game step to the left
* and copy the Tunnel layer to the main frame buffer
*/
BSP_advanceWalls(me->wall_thickness_top, me->wall_thickness_bottom);
}
/*.${AOs::Tunnel::plantMine} ...............................................*/
static void Tunnel_plantMine(Tunnel * const me) {
uint32_t rnd = (BSP_random() & 0xFFU);
if (me->last_mine_x > 0U) {
--me->last_mine_x; /* shift the last Mine 1 position to the left */
}
/* last mine far enough? */
if ((me->last_mine_x + GAME_MINES_DIST_MIN < GAME_TUNNEL_WIDTH)
&& (rnd < 8U)) /* place the mines only 5% of the time */
{
uint8_t n;
for (n = 0U; n < Q_DIM(me->mines); ++n) { /*look for disabled mines */
if (me->mines[n] == (QHsm *)0) {
break;
}
}
if (n < Q_DIM(me->mines)) { /* a disabled Mine found? */
rnd = (BSP_random() & 0xFFFFU);
if ((rnd & 1U) == 0U) { /* choose the type of the mine */
me->mines[n] = me->mine1_pool[n];
}
else {
me->mines[n] = me->mine2_pool[n];
}
/* new Mine is planted by the end of the tunnel */
me->last_mine_x = GAME_TUNNEL_WIDTH - 8U;
/* choose a random y-position for the Mine in the Tunnel */
rnd %= (GAME_TUNNEL_HEIGHT
- me->wall_thickness_top
- me->wall_thickness_bottom - 4U);
me->last_mine_y = (uint8_t)(me->wall_thickness_top + 2U + rnd);
Q_SIG(me->mines[n]) = MINE_PLANT_SIG;
Q_PAR(me->mines[n]) = (me->last_mine_x | (me->last_mine_y << 8));
QHSM_DISPATCH(me->mines[n]); /* direct dispatch */
}
}
}
/*.${AOs::Tunnel::dispatchToAllMines} ......................................*/
static void Tunnel_dispatchToAllMines(Tunnel * const me, QSignal sig, QParam par) {
uint8_t n;
for (n = 0; n < GAME_MINES_MAX; ++n) {
if (me->mines[n] != (QHsm *)0) { /* is the mine used? */
Q_SIG(me->mines[n]) = sig;
Q_PAR(me->mines[n]) = par;
QHSM_DISPATCH(me->mines[n]);
}
}
}
/*.${AOs::Tunnel::SM} ......................................................*/
static QState Tunnel_initial(Tunnel * const me) {
/*.${AOs::Tunnel::SM::initial} */
uint8_t n;
for (n = 0; n < GAME_MINES_MAX; ++n) {
QHSM_INIT(me->mine1_pool[n]); /* initial tran. for Mine1 */
QHSM_INIT(me->mine2_pool[n]); /* initial tran. for Mine2 */
}
BSP_randomSeed(1234U); /* seed the pseudo-random generator */
return Q_TRAN(&Tunnel_show_logo);
}
/*.${AOs::Tunnel::SM::active} ..............................................*/
static QState Tunnel_active(Tunnel * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Tunnel::SM::active::MINE_DISABLED} */
case MINE_DISABLED_SIG: {
Q_ASSERT((Q_PAR(me) < GAME_MINES_MAX)
&& (me->mines[Q_PAR(me)] != (QHsm *)0));
me->mines[Q_PAR(me)] = (QHsm *)0;
status_ = Q_HANDLED();
break;
}
/*.${AOs::Tunnel::SM::active::PLAYER_QUIT} */
case PLAYER_QUIT_SIG: {
status_ = Q_TRAN(&Tunnel_final);
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Tunnel::SM::active::show_logo} ...................................*/
static QState Tunnel_show_logo(Tunnel * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Tunnel::SM::active::show_logo} */
case Q_ENTRY_SIG: {
QActive_armX(&me->super, 0U,
BSP_TICKS_PER_SEC/2U, BSP_TICKS_PER_SEC/2U); /* periodic */
me->blink_ctr = 10U;
BSP_paintString(24U, (GAME_TUNNEL_HEIGHT / 2U) - 8U, "Quantum LeAps");
BSP_paintString(16U, (GAME_TUNNEL_HEIGHT / 2U) + 0U, "state-machine.com");
BSP_paintString(1U, GAME_TUNNEL_HEIGHT - 18U, "Fire missile: BTN0");
BSP_paintString(1U, GAME_TUNNEL_HEIGHT - 10U, "Fly ship up: BTN1");
BSP_updateScreen();
status_ = Q_HANDLED();
break;
}
/*.${AOs::Tunnel::SM::active::show_logo} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Tunnel::SM::active::show_logo::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
--me->blink_ctr; /* toggle the blink couner */
/*.${AOs::Tunnel::SM::active::show_logo::Q_TIMEOUT::[me->blink_ctr==0U]} */
if (me->blink_ctr == 0U) {
status_ = Q_TRAN(&Tunnel_demo);
}
/*.${AOs::Tunnel::SM::active::show_logo::Q_TIMEOUT::[else]} */
else {
/*.${AOs::Tunnel::SM::active::show_logo::Q_TIMEOUT::[else]::[(me->blink_ctr&1U)!=0U]} */
if ((me->blink_ctr & 1U) != 0U) {
BSP_paintString(24U + 8U*6U, (GAME_TUNNEL_HEIGHT / 2U) - 8U,
"LeAps");
BSP_updateScreen();
status_ = Q_HANDLED();
}
/*.${AOs::Tunnel::SM::active::show_logo::Q_TIMEOUT::[else]::[else]} */
else {
BSP_paintString(24U + 8U*6U, (GAME_TUNNEL_HEIGHT / 2U) - 8U,
"LeaPs");
BSP_updateScreen();
status_ = Q_HANDLED();
}
}
break;
}
default: {
status_ = Q_SUPER(&Tunnel_active);
break;
}
}
return status_;
}
/*.${AOs::Tunnel::SM::active::demo} ........................................*/
static QState Tunnel_demo(Tunnel * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Tunnel::SM::active::demo} */
case Q_ENTRY_SIG: {
me->last_mine_x = 0U; /* last mine at right edge of the tunnel */
me->last_mine_y = 0U;
/* set the tunnel properties... */
me->wall_thickness_top = 0U;
me->wall_thickness_bottom = 0U;
me->wall_gap = GAME_WALLS_GAP_Y;
/* clear the tunnel walls */
BSP_clearWalls();
QActive_armX(&me->super, 0U,
BSP_TICKS_PER_SEC/2U, BSP_TICKS_PER_SEC/2U); /* periodic */
me->blink_ctr = 20U*2U; /* 20s timeout total */
status_ = Q_HANDLED();
break;
}
/*.${AOs::Tunnel::SM::active::demo} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Tunnel::SM::active::demo::TIME_TICK} */
case TIME_TICK_SIG: {
Tunnel_advance(me);
if (me->blink_ctr != 0U) {
/* add the text bitmap into the frame buffer */
BSP_paintString((GAME_TUNNEL_WIDTH - 10U*6U)/2U,
(GAME_TUNNEL_HEIGHT - 4U)/2U,
"Press BTN0");
}
BSP_updateScreen();
status_ = Q_HANDLED();
break;
}
/*.${AOs::Tunnel::SM::active::demo::PLAYER_TRIGGER} */
case PLAYER_TRIGGER_SIG: {
status_ = Q_TRAN(&Tunnel_playing);
break;
}
/*.${AOs::Tunnel::SM::active::demo::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
--me->blink_ctr;
/*.${AOs::Tunnel::SM::active::demo::Q_TIMEOUT::[me->blink_ctr==0]} */
if (me->blink_ctr == 0) {
status_ = Q_TRAN(&Tunnel_screen_saver);
}
else {
status_ = Q_UNHANDLED();
}
break;
}
default: {
status_ = Q_SUPER(&Tunnel_active);
break;
}
}
return status_;
}
/*.${AOs::Tunnel::SM::active::playing} .....................................*/
static QState Tunnel_playing(Tunnel * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Tunnel::SM::active::playing} */
case Q_ENTRY_SIG: {
me->wall_gap = GAME_WALLS_GAP_Y;
QACTIVE_POST(&AO_Ship, TAKE_OFF_SIG, 0);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Tunnel::SM::active::playing} */
case Q_EXIT_SIG: {
Tunnel_dispatchToAllMines(me, MINE_RECYCLE_SIG, 0);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Tunnel::SM::active::playing::TIME_TICK} */
case TIME_TICK_SIG: {
/* render this frame on the display */
BSP_updateScreen();
Tunnel_advance(me);
Tunnel_plantMine(me);
Tunnel_dispatchToAllMines(me, Q_SIG(me), Q_PAR(me));
status_ = Q_HANDLED();
break;
}
/*.${AOs::Tunnel::SM::active::playing::SHIP_IMG} */
case SHIP_IMG_SIG: {
uint8_t x = (uint8_t)Q_PAR(me);
uint8_t y = (uint8_t)(Q_PAR(me) >> 8);
uint8_t bmp = (uint8_t)(Q_PAR(me) >> 16);
/* did the Ship/Missile hit the tunnel wall? */
if (BSP_isWallHit(bmp, x, y)) {
QACTIVE_POST(&AO_Ship, HIT_WALL_SIG, 0);
}
BSP_paintBitmap(x, y, bmp);
Tunnel_dispatchToAllMines(me, Q_SIG(me), Q_PAR(me));
status_ = Q_HANDLED();
break;
}
/*.${AOs::Tunnel::SM::active::playing::MISSILE_IMG} */
case MISSILE_IMG_SIG: {
uint8_t x = (uint8_t)Q_PAR(me);
uint8_t y = (uint8_t)(Q_PAR(me) >> 8);
uint8_t bmp = (uint8_t)(Q_PAR(me) >> 16);
/* did the Ship/Missile hit the tunnel wall? */
if (BSP_isWallHit(bmp, x, y)) {
QACTIVE_POST(&AO_Missile, HIT_WALL_SIG, 0);
}
BSP_paintBitmap(x, y, bmp);
Tunnel_dispatchToAllMines(me, Q_SIG(me), Q_PAR(me));
status_ = Q_HANDLED();
break;
}
/*.${AOs::Tunnel::SM::active::playing::MINE_IMG} */
case MINE_IMG_SIG: {
BSP_paintBitmap((uint8_t)Q_PAR(me),
(uint8_t)(Q_PAR(me) >> 8),
(uint8_t)(Q_PAR(me) >> 16));
status_ = Q_HANDLED();
break;
}
/*.${AOs::Tunnel::SM::active::playing::EXPLOSION} */
case EXPLOSION_SIG: {
BSP_paintBitmap((uint8_t)Q_PAR(me),
(uint8_t)(Q_PAR(me) >> 8),
(uint8_t)(Q_PAR(me) >> 16));
status_ = Q_HANDLED();
break;
}
/*.${AOs::Tunnel::SM::active::playing::SCORE} */
case SCORE_SIG: {
BSP_updateScore((uint16_t)Q_PAR(me));
/* increase difficulty of the game:
* the tunnel gets narrower as the score goes up
*/
me->wall_gap = (uint8_t)(GAME_WALLS_GAP_Y
- (uint16_t)Q_PAR(me)/100U);
if (me->wall_gap < GAME_WALLS_MIN_GAP_Y) {
me->wall_gap = GAME_WALLS_MIN_GAP_Y;
}
status_ = Q_HANDLED();
break;
}
/*.${AOs::Tunnel::SM::active::playing::GAME_OVER} */
case GAME_OVER_SIG: {
BSP_clearWalls();
BSP_updateScore((uint16_t)Q_PAR(me));
BSP_updateScreen();
status_ = Q_TRAN(&Tunnel_game_over);
break;
}
default: {
status_ = Q_SUPER(&Tunnel_active);
break;
}
}
return status_;
}
/*.${AOs::Tunnel::SM::active::game_over} ...................................*/
static QState Tunnel_game_over(Tunnel * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Tunnel::SM::active::game_over} */
case Q_ENTRY_SIG: {
QActive_armX(&me->super, 0U,
BSP_TICKS_PER_SEC/2U, BSP_TICKS_PER_SEC/2U); /* periodic */
me->blink_ctr = 5U*2U; /* 5s timeout */
BSP_paintString((GAME_TUNNEL_WIDTH - 6U * 9U) / 2U,
(GAME_TUNNEL_HEIGHT / 2U) - 4U,
"Game Over");
BSP_updateScreen();
status_ = Q_HANDLED();
break;
}
/*.${AOs::Tunnel::SM::active::game_over} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
BSP_updateScore(0); /* update the score on the display */
status_ = Q_HANDLED();
break;
}
/*.${AOs::Tunnel::SM::active::game_over::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
--me->blink_ctr;
BSP_paintString((GAME_TUNNEL_WIDTH - 6U*9U) / 2U,
(GAME_TUNNEL_HEIGHT / 2U) - 4U,
(((me->blink_ctr & 1) != 0)
? "Game Over"
: " "));
BSP_updateScreen();
/*.${AOs::Tunnel::SM::active::game_over::Q_TIMEOUT::[me->blink_ctr==0]} */
if (me->blink_ctr == 0) {
status_ = Q_TRAN(&Tunnel_demo);
}
else {
status_ = Q_UNHANDLED();
}
break;
}
default: {
status_ = Q_SUPER(&Tunnel_active);
break;
}
}
return status_;
}
/*.${AOs::Tunnel::SM::active::screen_saver} ................................*/
static QState Tunnel_screen_saver(Tunnel * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Tunnel::SM::active::screen_saver::initial} */
case Q_INIT_SIG: {
status_ = Q_TRAN(&Tunnel_screen_saver_hide);
break;
}
/*.${AOs::Tunnel::SM::active::screen_saver::PLAYER_TRIGGER} */
case PLAYER_TRIGGER_SIG: {
status_ = Q_TRAN(&Tunnel_demo);
break;
}
default: {
status_ = Q_SUPER(&Tunnel_active);
break;
}
}
return status_;
}
/*.${AOs::Tunnel::SM::active::screen_saver::screen_saver_hide} .............*/
static QState Tunnel_screen_saver_hide(Tunnel * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Tunnel::SM::active::screen_saver::screen_saver_hide} */
case Q_ENTRY_SIG: {
BSP_displayOff(); /* power down the display */
QActive_armX(&me->super, 0U, BSP_TICKS_PER_SEC*3U, 0U); /* 3 sec */
status_ = Q_HANDLED();
break;
}
/*.${AOs::Tunnel::SM::active::screen_saver::screen_saver_hide} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
BSP_displayOn(); /* power up the display */
status_ = Q_HANDLED();
break;
}
/*.${AOs::Tunnel::SM::active::screen_saver::screen_saver_hid~::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Tunnel_screen_saver_show);
break;
}
default: {
status_ = Q_SUPER(&Tunnel_screen_saver);
break;
}
}
return status_;
}
/*.${AOs::Tunnel::SM::active::screen_saver::screen_saver_show} .............*/
static QState Tunnel_screen_saver_show(Tunnel * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Tunnel::SM::active::screen_saver::screen_saver_show} */
case Q_ENTRY_SIG: {
uint32_t rnd = BSP_random();
/* clear the screen frame buffer */
BSP_clearFB();
BSP_paintString((uint8_t)(rnd % (GAME_TUNNEL_WIDTH - 10U*6U)),
(uint8_t) (rnd % (GAME_TUNNEL_HEIGHT - 8U)),
"Press BTN0");
BSP_updateScreen();
QActive_armX(&me->super, 0U, BSP_TICKS_PER_SEC/3U, 0U);/* 1/3 sec */
status_ = Q_HANDLED();
break;
}
/*.${AOs::Tunnel::SM::active::screen_saver::screen_saver_show} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
BSP_clearFB();
BSP_updateScreen();
status_ = Q_HANDLED();
break;
}
/*.${AOs::Tunnel::SM::active::screen_saver::screen_saver_sho~::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Tunnel_screen_saver_hide);
break;
}
default: {
status_ = Q_SUPER(&Tunnel_screen_saver);
break;
}
}
return status_;
}
/*.${AOs::Tunnel::SM::final} ...............................................*/
static QState Tunnel_final(Tunnel * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Tunnel::SM::final} */
case Q_ENTRY_SIG: {
/* clear the screen */
BSP_clearFB();
BSP_updateScreen();
QF_stop(); /* stop QF and cleanup */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.$enddef${AOs::Tunnel} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/win32-gui/bsp.c
================================================
/*****************************************************************************
* Product: "Fly 'n' Shoot" game example, EFM32-SLSTK3401A, Win32-GUI
* Last Updated for Version: 6.7.0
* Date of the Last Update: 2020-01-06
*
* Q u a n t u m L e a P s
* ------------------------
* Modern Embedded Software
*
* Copyright (C) 2005-2020 Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "game.h"
#include "bsp.h"
#include "qwin_gui.h" /* QWIN GUI */
#include "resource.h" /* GUI resource IDs generated by the resource editior */
#include "safe_std.h" /* portable "safe" / facilities */
Q_DEFINE_THIS_FILE
/* local variables ---------------------------------------------------------*/
static HINSTANCE l_hInst; /* this application instance */
static HWND l_hWnd; /* main window handle */
static LPSTR l_cmdLine; /* the command line string */
static GraphicDisplay l_lcd; /* LCD display on EFM32-SLSTK3401A */
static SegmentDisplay l_userLED0; /* USER LED0 on EFM32-SLSTK3401A */
static SegmentDisplay l_userLED1; /* USER LED1 on EFM32-SLSTK3401A */
static SegmentDisplay l_scoreBoard; /* segment display for the score */
static OwnerDrawnButton l_userBtn0; /* USER Button0 on EFM32-SLSTK3401A */
static OwnerDrawnButton l_userBtn1; /* USER Button1 on EFM32-SLSTK3401A */
/* (R,G,B) colors for the LCD display */
static BYTE const c_onColor[3] = { 0x07U, 0x07U, 0x07U }; /* dark grey */
static BYTE const c_offColor[3] = { 0xA0U, 0xA0U, 0xA0U }; /* light grey */
/* LCD geometry and frame buffer */
static uint32_t l_fb[BSP_SCREEN_HEIGHT + 1][BSP_SCREEN_WIDTH / 32U];
/* the walls buffer */
static uint32_t l_walls[GAME_TUNNEL_HEIGHT + 1][BSP_SCREEN_WIDTH / 32U];
static unsigned l_rnd; /* random seed */
static void paintBits(uint8_t x, uint8_t y, uint8_t const *bits, uint8_t h);
static void paintBitsClear(uint8_t x, uint8_t y,
uint8_t const *bits, uint8_t h);
/* Local functions ---------------------------------------------------------*/
static LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg,
WPARAM wParam, LPARAM lParam);
/*..........................................................................*/
static void playerTrigger(void) {
QACTIVE_POST((QActive *)&AO_Ship, PLAYER_TRIGGER_SIG, 0U);
QACTIVE_POST((QActive *)&AO_Tunnel, PLAYER_TRIGGER_SIG, 0U);
}
/*..........................................................................*/
void BSP_init(void) {
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
QF_stop(); /* stop the main QF application and the ticker thread */
/* cleanup all QWIN resources... */
OwnerDrawnButton_xtor(&l_userBtn0); /* cleanup the l_userBtn0 resources */
OwnerDrawnButton_xtor(&l_userBtn1); /* cleanup the l_userBtn1 resources */
SegmentDisplay_xtor(&l_userLED0); /* cleanup the l_userLED0 resources */
SegmentDisplay_xtor(&l_userLED1); /* cleanup the l_userLED1 resources */
SegmentDisplay_xtor(&l_scoreBoard); /* cleanup the scoreBoard resources */
GraphicDisplay_xtor(&l_lcd); /* cleanup the l_lcd resources */
/* end the main dialog */
EndDialog(l_hWnd, result);
}
/*..........................................................................*/
void BSP_updateScreen(void) {
UINT x, y;
/* turn LED1 on */
SegmentDisplay_setSegment(&l_userLED1, 0U, 1U);
/* map the LCD pixels to the GraphicDisplay pixels... */
for (y = 0; y < BSP_SCREEN_HEIGHT; ++y) {
for (x = 0; x < BSP_SCREEN_WIDTH; ++x) {
uint32_t bits = l_fb[y][x >> 5];
if ((bits & (1U << (x & 0x1FU))) != 0U) {
GraphicDisplay_setPixel(&l_lcd, x, y, c_onColor);
}
else {
GraphicDisplay_clearPixel(&l_lcd, x, y);
}
}
}
GraphicDisplay_redraw(&l_lcd); /* redraw the updated display */
/* turn LED1 off */
SegmentDisplay_setSegment(&l_userLED1, 0U, 0U);
}
/*..........................................................................*/
void BSP_clearFB() {
uint_fast8_t y;
for (y = 0U; y < BSP_SCREEN_HEIGHT; ++y) {
l_fb[y][0] = 0U;
l_fb[y][1] = 0U;
l_fb[y][2] = 0U;
l_fb[y][3] = 0U;
}
}
/*..........................................................................*/
void BSP_clearWalls() {
uint_fast8_t y;
for (y = 0U; y < GAME_TUNNEL_HEIGHT; ++y) {
l_walls[y][0] = 0U;
l_walls[y][1] = 0U;
l_walls[y][2] = 0U;
l_walls[y][3] = 0U;
}
}
/*..........................................................................*/
bool BSP_isThrottle(void) { /* is the throttle button depressed? */
return OwnerDrawnButton_isDepressed(&l_userBtn1) != 0;
}
/*..........................................................................*/
void BSP_paintString(uint8_t x, uint8_t y, char const *str) {
static uint8_t const font5x7[95][7] = {
{ 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U }, /* */
{ 0x04U, 0x04U, 0x04U, 0x04U, 0x00U, 0x00U, 0x04U }, /* ! */
{ 0x0AU, 0x0AU, 0x0AU, 0x00U, 0x00U, 0x00U, 0x00U }, /* " */
{ 0x0AU, 0x0AU, 0x1FU, 0x0AU, 0x1FU, 0x0AU, 0x0AU }, /* # */
{ 0x04U, 0x1EU, 0x05U, 0x0EU, 0x14U, 0x0FU, 0x04U }, /* $ */
{ 0x03U, 0x13U, 0x08U, 0x04U, 0x02U, 0x19U, 0x18U }, /* % */
{ 0x06U, 0x09U, 0x05U, 0x02U, 0x15U, 0x09U, 0x16U }, /* & */
{ 0x06U, 0x04U, 0x02U, 0x00U, 0x00U, 0x00U, 0x00U }, /* ' */
{ 0x08U, 0x04U, 0x02U, 0x02U, 0x02U, 0x04U, 0x08U }, /* ( */
{ 0x02U, 0x04U, 0x08U, 0x08U, 0x08U, 0x04U, 0x02U }, /* ) */
{ 0x00U, 0x04U, 0x15U, 0x0EU, 0x15U, 0x04U, 0x00U }, /* * */
{ 0x00U, 0x04U, 0x04U, 0x1FU, 0x04U, 0x04U, 0x00U }, /* + */
{ 0x00U, 0x00U, 0x00U, 0x00U, 0x06U, 0x04U, 0x02U }, /* , */
{ 0x00U, 0x00U, 0x00U, 0x1FU, 0x00U, 0x00U, 0x00U }, /* - */
{ 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x06U, 0x06U }, /* . */
{ 0x00U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U, 0x00U }, /* / */
{ 0x0EU, 0x11U, 0x19U, 0x15U, 0x13U, 0x11U, 0x0EU }, /* 0 */
{ 0x04U, 0x06U, 0x04U, 0x04U, 0x04U, 0x04U, 0x0EU }, /* 1 */
{ 0x0EU, 0x11U, 0x10U, 0x08U, 0x04U, 0x02U, 0x1FU }, /* 2 */
{ 0x1FU, 0x08U, 0x04U, 0x08U, 0x10U, 0x11U, 0x0EU }, /* 3 */
{ 0x08U, 0x0CU, 0x0AU, 0x09U, 0x1FU, 0x08U, 0x08U }, /* 4 */
{ 0x1FU, 0x01U, 0x0FU, 0x10U, 0x10U, 0x11U, 0x0EU }, /* 5 */
{ 0x0CU, 0x02U, 0x01U, 0x0FU, 0x11U, 0x11U, 0x0EU }, /* 6 */
{ 0x1FU, 0x10U, 0x08U, 0x04U, 0x02U, 0x02U, 0x02U }, /* 7 */
{ 0x0EU, 0x11U, 0x11U, 0x0EU, 0x11U, 0x11U, 0x0EU }, /* 8 */
{ 0x0EU, 0x11U, 0x11U, 0x1EU, 0x10U, 0x08U, 0x06U }, /* 9 */
{ 0x00U, 0x06U, 0x06U, 0x00U, 0x06U, 0x06U, 0x00U }, /* : */
{ 0x00U, 0x06U, 0x06U, 0x00U, 0x06U, 0x04U, 0x02U }, /* ; */
{ 0x08U, 0x04U, 0x02U, 0x01U, 0x02U, 0x04U, 0x08U }, /* < */
{ 0x00U, 0x00U, 0x1FU, 0x00U, 0x1FU, 0x00U, 0x00U }, /* = */
{ 0x02U, 0x04U, 0x08U, 0x10U, 0x08U, 0x04U, 0x02U }, /* > */
{ 0x0EU, 0x11U, 0x10U, 0x08U, 0x04U, 0x00U, 0x04U }, /* ? */
{ 0x0EU, 0x11U, 0x10U, 0x16U, 0x15U, 0x15U, 0x0EU }, /* @ */
{ 0x0EU, 0x11U, 0x11U, 0x11U, 0x1FU, 0x11U, 0x11U }, /* A */
{ 0x0FU, 0x11U, 0x11U, 0x0FU, 0x11U, 0x11U, 0x0FU }, /* B */
{ 0x0EU, 0x11U, 0x01U, 0x01U, 0x01U, 0x11U, 0x0EU }, /* C */
{ 0x07U, 0x09U, 0x11U, 0x11U, 0x11U, 0x09U, 0x07U }, /* D */
{ 0x1FU, 0x01U, 0x01U, 0x0FU, 0x01U, 0x01U, 0x1FU }, /* E */
{ 0x1FU, 0x01U, 0x01U, 0x0FU, 0x01U, 0x01U, 0x01U }, /* F */
{ 0x0EU, 0x11U, 0x01U, 0x1DU, 0x11U, 0x11U, 0x1EU }, /* G */
{ 0x11U, 0x11U, 0x11U, 0x1FU, 0x11U, 0x11U, 0x11U }, /* H */
{ 0x0EU, 0x04U, 0x04U, 0x04U, 0x04U, 0x04U, 0x0EU }, /* I */
{ 0x1CU, 0x08U, 0x08U, 0x08U, 0x08U, 0x09U, 0x06U }, /* J */
{ 0x11U, 0x09U, 0x05U, 0x03U, 0x05U, 0x09U, 0x11U }, /* K */
{ 0x01U, 0x01U, 0x01U, 0x01U, 0x01U, 0x01U, 0x1FU }, /* L */
{ 0x11U, 0x1BU, 0x15U, 0x15U, 0x11U, 0x11U, 0x11U }, /* M */
{ 0x11U, 0x11U, 0x13U, 0x15U, 0x19U, 0x11U, 0x11U }, /* N */
{ 0x0EU, 0x11U, 0x11U, 0x11U, 0x11U, 0x11U, 0x0EU }, /* O */
{ 0x0FU, 0x11U, 0x11U, 0x0FU, 0x01U, 0x01U, 0x01U }, /* P */
{ 0x0EU, 0x11U, 0x11U, 0x11U, 0x15U, 0x09U, 0x16U }, /* Q */
{ 0x0FU, 0x11U, 0x11U, 0x0FU, 0x05U, 0x09U, 0x11U }, /* R */
{ 0x1EU, 0x01U, 0x01U, 0x0EU, 0x10U, 0x10U, 0x0FU }, /* S */
{ 0x1FU, 0x04U, 0x04U, 0x04U, 0x04U, 0x04U, 0x04U }, /* T */
{ 0x11U, 0x11U, 0x11U, 0x11U, 0x11U, 0x11U, 0x0EU }, /* U */
{ 0x11U, 0x11U, 0x11U, 0x11U, 0x11U, 0x0AU, 0x04U }, /* V */
{ 0x11U, 0x11U, 0x11U, 0x15U, 0x15U, 0x15U, 0x0AU }, /* W */
{ 0x11U, 0x11U, 0x0AU, 0x04U, 0x0AU, 0x11U, 0x11U }, /* X */
{ 0x11U, 0x11U, 0x11U, 0x0AU, 0x04U, 0x04U, 0x04U }, /* Y */
{ 0x1FU, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U, 0x1FU }, /* Z */
{ 0x0EU, 0x02U, 0x02U, 0x02U, 0x02U, 0x02U, 0x0EU }, /* [ */
{ 0x00U, 0x01U, 0x02U, 0x04U, 0x08U, 0x10U, 0x00U }, /* \ */
{ 0x0EU, 0x08U, 0x08U, 0x08U, 0x08U, 0x08U, 0x0EU }, /* ] */
{ 0x04U, 0x0AU, 0x11U, 0x00U, 0x00U, 0x00U, 0x00U }, /* ^ */
{ 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x1FU }, /* _ */
{ 0x02U, 0x04U, 0x08U, 0x00U, 0x00U, 0x00U, 0x00U }, /* ` */
{ 0x00U, 0x00U, 0x0EU, 0x10U, 0x1EU, 0x11U, 0x1EU }, /* a */
{ 0x01U, 0x01U, 0x0DU, 0x13U, 0x11U, 0x11U, 0x0FU }, /* b */
{ 0x00U, 0x00U, 0x0EU, 0x01U, 0x01U, 0x11U, 0x0EU }, /* c */
{ 0x10U, 0x10U, 0x16U, 0x19U, 0x11U, 0x11U, 0x1EU }, /* d */
{ 0x00U, 0x00U, 0x0EU, 0x11U, 0x1FU, 0x01U, 0x0EU }, /* e */
{ 0x0CU, 0x12U, 0x02U, 0x07U, 0x02U, 0x02U, 0x02U }, /* f */
{ 0x00U, 0x1EU, 0x11U, 0x11U, 0x1EU, 0x10U, 0x0EU }, /* g */
{ 0x01U, 0x01U, 0x0DU, 0x13U, 0x11U, 0x11U, 0x11U }, /* h */
{ 0x04U, 0x00U, 0x06U, 0x04U, 0x04U, 0x04U, 0x0EU }, /* i */
{ 0x08U, 0x00U, 0x0CU, 0x08U, 0x08U, 0x09U, 0x06U }, /* j */
{ 0x01U, 0x01U, 0x09U, 0x05U, 0x03U, 0x05U, 0x09U }, /* k */
{ 0x06U, 0x04U, 0x04U, 0x04U, 0x04U, 0x04U, 0x0EU }, /* l */
{ 0x00U, 0x00U, 0x0BU, 0x15U, 0x15U, 0x11U, 0x11U }, /* m */
{ 0x00U, 0x00U, 0x0DU, 0x13U, 0x11U, 0x11U, 0x11U }, /* n */
{ 0x00U, 0x00U, 0x0EU, 0x11U, 0x11U, 0x11U, 0x0EU }, /* o */
{ 0x00U, 0x00U, 0x0FU, 0x11U, 0x0FU, 0x01U, 0x01U }, /* p */
{ 0x00U, 0x00U, 0x16U, 0x19U, 0x1EU, 0x10U, 0x10U }, /* q */
{ 0x00U, 0x00U, 0x0DU, 0x13U, 0x01U, 0x01U, 0x01U }, /* r */
{ 0x00U, 0x00U, 0x0EU, 0x01U, 0x0EU, 0x10U, 0x0FU }, /* s */
{ 0x02U, 0x02U, 0x07U, 0x02U, 0x02U, 0x12U, 0x0CU }, /* t */
{ 0x00U, 0x00U, 0x11U, 0x11U, 0x11U, 0x19U, 0x16U }, /* u */
{ 0x00U, 0x00U, 0x11U, 0x11U, 0x11U, 0x0AU, 0x04U }, /* v */
{ 0x00U, 0x00U, 0x11U, 0x11U, 0x15U, 0x15U, 0x0AU }, /* w */
{ 0x00U, 0x00U, 0x11U, 0x0AU, 0x04U, 0x0AU, 0x11U }, /* x */
{ 0x00U, 0x00U, 0x11U, 0x11U, 0x1EU, 0x10U, 0x0EU }, /* y */
{ 0x00U, 0x00U, 0x1FU, 0x08U, 0x04U, 0x02U, 0x1FU }, /* z */
{ 0x08U, 0x04U, 0x04U, 0x02U, 0x04U, 0x04U, 0x08U }, /* { */
{ 0x04U, 0x04U, 0x04U, 0x04U, 0x04U, 0x04U, 0x04U }, /* | */
{ 0x02U, 0x04U, 0x04U, 0x08U, 0x04U, 0x04U, 0x02U }, /* } */
{ 0x02U, 0x15U, 0x08U, 0x00U, 0x00U, 0x00U, 0x00U }, /* ~ */
};
for (; *str != '\0'; ++str, x += 6) {
uint8_t const *ch = &font5x7[*str - ' '][0];
paintBitsClear(x, y, ch, 7);
}
}
/*==========================================================================*/
typedef struct { /* the auxiliary structure to hold const bitmaps */
uint8_t const *bits; /* the bits in the bitmap */
uint8_t height; /* the height of the bitmap */
} Bitmap;
/* bitmap of the Ship:
*
* x....
* xxx..
* xxxxx
*/
static uint8_t const ship_bits[] = {
0x01U, 0x07U, 0x1FU
};
/* bitmap of the Missile:
*
* xxxx
*/
static uint8_t const missile_bits[] = {
0x0FU
};
/* bitmap of the Mine type-1:
*
* .x.
* xxx
* .x.
*/
static uint8_t const mine1_bits[] = {
0x02U, 0x07U, 0x02U
};
/* bitmap of the Mine type-2:
*
* x..x
* .xx.
* .xx.
* x..x
*/
static uint8_t const mine2_bits[] = {
0x09U, 0x06U, 0x06U, 0x09U
};
/* Mine type-2 is nastier than Mine type-1. The type-2 mine can
* hit the Ship with any of its "tentacles". However, it can be
* destroyed by the Missile only by hitting its center, defined as
* the following bitmap:
*
* ....
* .xx.
* .xx.
*/
static uint8_t const mine2_missile_bits[] = {
0x00U, 0x06U, 0x06U
};
/*
* The bitmap of the explosion stage 0:
*
* .......
* ...x...
* ..x.x..
* ...x...
*/
static uint8_t const explosion0_bits[] = {
0x00U, 0x08U, 0x14U, 0x08U
};
/*
* The bitmap of the explosion stage 1:
*
* .......
* ..x.x..
* ...x...
* ..x.x..
*/
static uint8_t const explosion1_bits[] = {
0x00U, 0x14U, 0x08U, 0x14U
};
/*
* The bitmap of the explosion stage 2:
*
* .x...x.
* ..x.x..
* ...x...
* ..x.x..
* .x...x.
*/
static uint8_t const explosion2_bits[] = {
0x11U, 0x0AU, 0x04U, 0x0AU, 0x11U
};
/*
* The bitmap of the explosion stage 3:
*
* x..x..x
* .x.x.x.
* ..x.x..
* xx.x.xx
* ..x.x..
* .x.x.x.
* x..x..x
*/
static uint8_t const explosion3_bits[] = {
0x49, 0x2A, 0x14, 0x6B, 0x14, 0x2A, 0x49
};
static Bitmap const l_bitmap[MAX_BMP] = {
{ ship_bits, Q_DIM(ship_bits) },
{ missile_bits, Q_DIM(missile_bits) },
{ mine1_bits, Q_DIM(mine1_bits) },
{ mine2_bits, Q_DIM(mine2_bits) },
{ mine2_missile_bits, Q_DIM(mine2_missile_bits) },
{ explosion0_bits, Q_DIM(explosion0_bits) },
{ explosion1_bits, Q_DIM(explosion1_bits) },
{ explosion2_bits, Q_DIM(explosion2_bits) },
{ explosion3_bits, Q_DIM(explosion3_bits) }
};
/*..........................................................................*/
void BSP_paintBitmap(uint8_t x, uint8_t y, uint8_t bmp_id) {
Bitmap const *bmp = &l_bitmap[bmp_id];
paintBits(x, y, bmp->bits, bmp->height);
}
/*..........................................................................*/
void BSP_advanceWalls(uint8_t top, uint8_t bottom) {
uint_fast8_t y;
for (y = 0U; y < GAME_TUNNEL_HEIGHT; ++y) {
/* shift the walls one pixel to the left */
l_walls[y][0] = (l_walls[y][0] >> 1) | (l_walls[y][1] << 31);
l_walls[y][1] = (l_walls[y][1] >> 1) | (l_walls[y][2] << 31);
l_walls[y][2] = (l_walls[y][2] >> 1) | (l_walls[y][3] << 31);
l_walls[y][3] = (l_walls[y][3] >> 1);
/* add new column of walls at the end */
if (y <= top) {
l_walls[y][3] |= (1U << 31);
}
if (y >= (GAME_TUNNEL_HEIGHT - bottom)) {
l_walls[y][3] |= (1U << 31);
}
/* copy the walls to the frame buffer */
l_fb[y][0] = l_walls[y][0];
l_fb[y][1] = l_walls[y][1];
l_fb[y][2] = l_walls[y][2];
l_fb[y][3] = l_walls[y][3];
}
}
/*..........................................................................*/
bool BSP_doBitmapsOverlap(uint8_t bmp_id1, uint8_t x1, uint8_t y1,
uint8_t bmp_id2, uint8_t x2, uint8_t y2)
{
uint8_t y;
uint8_t y0;
uint8_t h;
uint32_t bits1;
uint32_t bits2;
Bitmap const *bmp1;
Bitmap const *bmp2;
Q_REQUIRE((bmp_id1 < Q_DIM(l_bitmap)) && (bmp_id2 < Q_DIM(l_bitmap)));
/* are the bitmaps close enough in x? */
if (x1 >= x2) {
if (x1 > x2 + 8U) {
return false;
}
x1 -= x2;
x2 = 0U;
}
else {
if (x2 > x1 + 8U) {
return false;
}
x2 -= x1;
x1 = 0U;
}
bmp1 = &l_bitmap[bmp_id1];
bmp2 = &l_bitmap[bmp_id2];
if ((y1 <= y2) && (y1 + bmp1->height > y2)) {
y0 = y2 - y1;
h = y1 + bmp1->height - y2;
if (h > bmp2->height) {
h = bmp2->height;
}
for (y = 0; y < h; ++y) { /* scan over the overlapping rows */
bits1 = ((uint32_t)bmp1->bits[y + y0] << x1);
bits2 = ((uint32_t)bmp2->bits[y] << x2);
if ((bits1 & bits2) != 0U) { /* do the bits overlap? */
return true; /* yes! */
}
}
}
else {
if ((y1 > y2) && (y2 + bmp2->height > y1)) {
y0 = y1 - y2;
h = y2 + bmp2->height - y1;
if (h > bmp1->height) {
h = bmp1->height;
}
for (y = 0; y < h; ++y) { /* scan over the overlapping rows */
bits1 = ((uint32_t)bmp1->bits[y] << x1);
bits2 = ((uint32_t)bmp2->bits[y + y0] << x2);
if ((bits1 & bits2) != 0U) { /* do the bits overlap? */
return true; /* yes! */
}
}
}
}
return false; /* the bitmaps do not overlap */
}
/*..........................................................................*/
bool BSP_isWallHit(uint8_t bmp_id, uint8_t x, uint8_t y) {
Bitmap const *bmp = &l_bitmap[bmp_id];
uint32_t shft = (x & 0x1FU);
uint32_t *walls = &l_walls[y][x >> 5];
for (y = 0; y < bmp->height; ++y, walls += (BSP_SCREEN_WIDTH >> 5)) {
if (*walls & ((uint32_t)bmp->bits[y] << shft)) {
return true;
}
if (shft > 24U) {
if (*(walls + 1) & ((uint32_t)bmp->bits[y] >> (32U - shft))) {
return true;
}
}
}
return false;
}
/*..........................................................................*/
void BSP_updateScore(uint16_t score) {
uint8_t seg[5];
char str[5];
if (score == 0U) {
BSP_paintString(1U, BSP_SCREEN_HEIGHT - 8U, "SCORE:");
}
seg[0] = score % 10U; score /= 10U;
seg[1] = score % 10U; score /= 10U;
seg[2] = score % 10U; score /= 10U;
seg[3] = score % 10U;
/* update the SCORE area on the screeen */
str[0] = seg[3] + '0';
str[1] = seg[2] + '0';
str[2] = seg[1] + '0';
str[3] = seg[0] + '0';
str[4] = '\0';
BSP_paintString(6U*6U, BSP_SCREEN_HEIGHT - 8U, str);
/* update the score in the l_scoreBoard SegmentDisplay */
SegmentDisplay_setSegment(&l_scoreBoard, 0U, (UINT)seg[0]);
SegmentDisplay_setSegment(&l_scoreBoard, 1U, (UINT)seg[1]);
SegmentDisplay_setSegment(&l_scoreBoard, 2U, (UINT)seg[2]);
SegmentDisplay_setSegment(&l_scoreBoard, 3U, (UINT)seg[3]);
}
/*..........................................................................*/
void BSP_displayOn(void) {
SegmentDisplay_setSegment(&l_userLED0, 0U, 1U);
}
/*..........................................................................*/
void BSP_displayOff(void) {
SegmentDisplay_setSegment(&l_userLED0, 0U, 0U);
GraphicDisplay_clear(&l_lcd);
GraphicDisplay_redraw(&l_lcd);
}
/*..........................................................................*/
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
l_rnd = l_rnd * (3U*7U*11U*13U*23U);
return l_rnd >> 8;
}
/*..........................................................................*/
void BSP_randomSeed(uint32_t seed) {
l_rnd = seed;
}
/*--------------------------------------------------------------------------*/
void QF_onStartup(void) {
QF_setTickRate(BSP_TICKS_PER_SEC, 30U); /* set the desired tick rate */
}
/*..........................................................................*/
void QF_onCleanup(void) {
}
/*..........................................................................*/
void QF_onClockTickISR(void) {
QF_tickXISR(0U); /* perform the QF-nano clock tick processing */
/* post TIME_TICK events to all interested active objects... */
QACTIVE_POST_ISR((QActive *)&AO_Tunnel, TIME_TICK_SIG, 0U);
QACTIVE_POST_ISR((QActive *)&AO_Ship, TIME_TICK_SIG, 0U);
QACTIVE_POST_ISR((QActive *)&AO_Missile, TIME_TICK_SIG, 0U);
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const * const module, int_t loc) {
char message[80];
QF_stop(); /* stop ticking */
SNPRINTF_S(message, Q_DIM(message) - 1,
"Assertion failed in module %s location %d", module, loc);
MessageBox(l_hWnd, message, "!!! ASSERTION !!!",
MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL);
PostQuitMessage(-1);
}
/*--------------------------------------------------------------------------*/
/*..........................................................................*/
static void paintBits(uint8_t x, uint8_t y, uint8_t const *bits, uint8_t h) {
uint32_t *fb = &l_fb[y][x >> 5];
uint32_t shft = (x & 0x1FU);
for (y = 0; y < h; ++y, fb += (BSP_SCREEN_WIDTH >> 5)) {
*fb |= ((uint32_t)bits[y] << shft);
if (shft > 24U) {
*(fb + 1) |= ((uint32_t)bits[y] >> (32U - shft));
}
}
}
/*..........................................................................*/
static void paintBitsClear(uint8_t x, uint8_t y,
uint8_t const *bits, uint8_t h)
{
uint32_t *fb = &l_fb[y][x >> 5];
uint32_t shft = (x & 0x1FU);
uint32_t mask1 = ~((uint32_t)0xFFU << shft);
uint32_t mask2;
if (shft > 24U) {
mask2 = ~(0xFFU >> (32U - shft));
}
for (y = 0; y < h; ++y, fb += (BSP_SCREEN_WIDTH >> 5)) {
*fb = ((*fb & mask1) | ((uint32_t)bits[y] << shft));
if (shft > 24U) {
*(fb + 1) = ((*(fb + 1) & mask2)
| ((uint32_t)bits[y] >> (32U - shft)));
}
}
}
/*..........................................................................*/
/* thread function for running the application main_gui() */
static DWORD WINAPI appThread(LPVOID par) {
(void)par; /* unused parameter */
return (DWORD)main_gui(); /* run the QF application */
}
/*--------------------------------------------------------------------------*/
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
LPSTR cmdLine, int iCmdShow)
{
HWND hWnd;
MSG msg;
(void)hPrevInst; /* unused parameter */
l_hInst = hInst; /* save the application instance */
l_cmdLine = cmdLine; /* save the command line string */
//AllocConsole();
/* create the main custom dialog window */
hWnd = CreateCustDialog(hInst, IDD_APPLICATION, NULL,
&WndProc, "MY_CLASS");
ShowWindow(hWnd, iCmdShow); /* show the main window */
/* enter the message loop... */
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
//FreeConsole();
BSP_terminate(0);
return msg.wParam;
}
/*..........................................................................*/
static LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg,
WPARAM wParam, LPARAM lParam)
{
switch (iMsg) {
/* Perform initialization upon cration of the main dialog window
* NOTE: Any child-windows are NOT created yet at this time, so
* the GetDlgItem() function can't be used (it will return NULL).
*/
case WM_CREATE: {
l_hWnd = hWnd; /* save the window handle */
/* initialize the owner-drawn buttons...
* NOTE: must be done *before* the first drawing of the buttons,
* so WM_INITDIALOG is too late.
*/
OwnerDrawnButton_init(&l_userBtn0, IDC_USER0,
LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_BTN_UP)),
LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_BTN_DWN)),
LoadCursor(NULL, IDC_HAND));
OwnerDrawnButton_init(&l_userBtn1, IDC_USER1,
LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_BTN_UP)),
LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_BTN_DWN)),
LoadCursor(NULL, IDC_HAND));
return 0;
}
/* Perform initialization after all child windows have been created */
case WM_INITDIALOG: {
GraphicDisplay_init(&l_lcd, 128, 128, IDC_LCD, c_offColor);
SegmentDisplay_init(&l_userLED0,
1U, /* 1 "segment" (the LED0 itself) */
2U); /* 2 bitmaps (for LED0 OFF/ON states) */
SegmentDisplay_initSegment(&l_userLED0, 0U, IDC_LED0);
SegmentDisplay_initBitmap(&l_userLED0,
0U, LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_LED_OFF)));
SegmentDisplay_initBitmap(&l_userLED0,
1U, LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_LED_ON)));
SegmentDisplay_init(&l_userLED1,
1U, /* 1 "segment" (the LED1 itself) */
2U); /* 2 bitmaps (for LED1 OFF/ON states) */
SegmentDisplay_initSegment(&l_userLED1, 0U, IDC_LED1);
SegmentDisplay_initBitmap(&l_userLED1,
0U, LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_LED_OFF)));
SegmentDisplay_initBitmap(&l_userLED1,
1U, LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_LED_ON)));
SegmentDisplay_init(&l_scoreBoard,
4U, /* 4 "segments" (digits 0-3) */
10U); /* 10 bitmaps (for 0-9 states) */
SegmentDisplay_initSegment(&l_scoreBoard, 0U, IDC_SEG0);
SegmentDisplay_initSegment(&l_scoreBoard, 1U, IDC_SEG1);
SegmentDisplay_initSegment(&l_scoreBoard, 2U, IDC_SEG2);
SegmentDisplay_initSegment(&l_scoreBoard, 3U, IDC_SEG3);
SegmentDisplay_initBitmap(&l_scoreBoard,
0U, LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_SEG0)));
SegmentDisplay_initBitmap(&l_scoreBoard,
1U, LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_SEG1)));
SegmentDisplay_initBitmap(&l_scoreBoard,
2U, LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_SEG2)));
SegmentDisplay_initBitmap(&l_scoreBoard,
3U, LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_SEG3)));
SegmentDisplay_initBitmap(&l_scoreBoard,
4U, LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_SEG4)));
SegmentDisplay_initBitmap(&l_scoreBoard,
5U, LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_SEG5)));
SegmentDisplay_initBitmap(&l_scoreBoard,
6U, LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_SEG6)));
SegmentDisplay_initBitmap(&l_scoreBoard,
7U, LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_SEG7)));
SegmentDisplay_initBitmap(&l_scoreBoard,
8U, LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_SEG8)));
SegmentDisplay_initBitmap(&l_scoreBoard,
9U, LoadBitmap(l_hInst, MAKEINTRESOURCE(IDB_SEG9)));
BSP_updateScore(0U);
/* --> QP: spawn the application thread to run main_gui() */
Q_ALLEGE(CreateThread(NULL, 0, &appThread, NULL, 0, NULL)
!= (HANDLE)0);
return 0;
}
case WM_DESTROY: {
OutputDebugString("DESTROY\n");
PostQuitMessage(0);
return 0;
}
/* commands from regular buttons and menus... */
case WM_COMMAND: {
SetFocus(hWnd);
switch (wParam) {
case IDOK:
case IDCANCEL: {
OutputDebugString("QUIT\n");
PostQuitMessage(0);
break;
}
}
return 0;
}
/* owner-drawn buttons... */
case WM_DRAWITEM: {
LPDRAWITEMSTRUCT pdis = (LPDRAWITEMSTRUCT)lParam;
switch (pdis->CtlID) {
case IDC_USER0: { /* USER owner-drawn Button0 */
OutputDebugString("USER0\n");
switch (OwnerDrawnButton_draw(&l_userBtn0, pdis)) {
case BTN_DEPRESSED: {
playerTrigger();
SegmentDisplay_setSegment(&l_userLED0, 0U, 1U);
break;
}
case BTN_RELEASED: {
SegmentDisplay_setSegment(&l_userLED0, 0U, 0U);
break;
}
default: {
break;
}
}
break;
}
case IDC_USER1: { /* USER owner-drawn Button1 */
OutputDebugString("USER1\n");
switch (OwnerDrawnButton_draw(&l_userBtn1, pdis)) {
default: {
break;
}
}
break;
}
}
return 0;
}
/* mouse wheel input... */
case WM_MOUSEWHEEL: {
OutputDebugString("MOUSEWHEEL\n");
return 0;
}
/* keyboard input... */
case WM_KEYDOWN: {
OutputDebugString("KEYDOWN\n");
switch (wParam) {
case VK_SPACE:
playerTrigger();
OwnerDrawnButton_set(&l_userBtn0, 1);
break;
}
return 0;
}
case WM_KEYUP: {
OutputDebugString("KEYUP\n");
switch (wParam) {
case VK_SPACE:
OwnerDrawnButton_set(&l_userBtn0, 0);
break;
}
return 0;
}
}
return DefWindowProc(hWnd, iMsg, wParam, lParam);
}
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/win32-gui/game-gui.sln
================================================
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2013 for Windows Desktop
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "game-gui", "game-gui.vcxproj", "{79027B25-0949-4F66-9765-4EFBCBBEFB94}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{79027B25-0949-4F66-9765-4EFBCBBEFB94}.Debug|Win32.ActiveCfg = Debug|Win32
{79027B25-0949-4F66-9765-4EFBCBBEFB94}.Debug|Win32.Build.0 = Debug|Win32
{79027B25-0949-4F66-9765-4EFBCBBEFB94}.Release|Win32.ActiveCfg = Release|Win32
{79027B25-0949-4F66-9765-4EFBCBBEFB94}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/win32-gui/game-gui.vcxproj
================================================
DebugWin32ReleaseWin32{79027B25-0949-4F66-9765-4EFBCBBEFB94}game-gui10.0ApplicationfalseNotSetv142ApplicationfalseNotSetv142
<_ProjectFileVersion>10.0.40219.1
$(Configuration)\$(Configuration)\falsefalse$(Configuration)\$(Configuration)\falsefalseNDEBUG;%(PreprocessorDefinitions)truetrueWin32.\Release/game-gui.tlbMaxSpeedOnlyExplicitInline.;..;../../../../include;../../../../ports/win32-qvQWIN_GUI;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)falseMultiThreadedtrue$(IntDir)$(IntDir)$(IntDir)Level3trueDefaultNDEBUG;%(PreprocessorDefinitions)0x0409%(AdditionalDependencies)$(OutDir)$(ProjectName).exetrue%(AdditionalLibraryDirectories)WindowsfalseMachineX86true.\Release/game-gui.bsc_DEBUG;%(PreprocessorDefinitions)truetrueWin32.\Debug/game-gui.tlbDisabled.;..;../../../../include;../../../../ports/win32-qvQWIN_GUI;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)falseDefaultMultiThreaded$(IntDir)$(IntDir)$(IntDir)trueLevel3trueProgramDatabaseDefault_DEBUG;%(PreprocessorDefinitions)0x0409%(AdditionalDependencies)$(OutDir)$(ProjectName).exetrue%(AdditionalLibraryDirectories)truefalseWindowsfalseMachineX86true.\Debug/game-gui.bsc%(AdditionalIncludeDirectories)%(PreprocessorDefinitions)%(AdditionalIncludeDirectories)%(PreprocessorDefinitions)
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/win32-gui/game-gui.vcxproj.filters
================================================
QPQPQPQPQPResResResResResRes{382909e6-fb4e-4829-941e-d3461d9ce146}{cead428d-5be7-440c-b491-936bfc2a36a3}
================================================
FILE: examples/arm-cm/game_efm32-slstk3401a/win32-gui/resource.h
================================================
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Resource.rc
//
#define IDD_APPLICATION 101
#define IDC_LCD 111
#define IDC_LED0 112
#define IDC_LED1 113
#define IDC_USER0 114
#define IDC_USER1 115
#define IDB_BACKGROUND 120
#define IDB_BTN_UP 137
#define IDB_BTN_DWN 138
#define IDB_LCD 142
#define IDB_LED_OFF 144
#define IDB_LED_ON 145
#define IDB_SEG 146
#define IDB_SEG0 150
#define IDB_SEG1 151
#define IDB_SEG2 152
#define IDB_SEG3 153
#define IDB_SEG4 154
#define IDB_SEG5 155
#define IDB_SEG6 156
#define IDB_SEG7 157
#define IDB_SEG8 158
#define IDB_SEG9 159
#define IDC_SEG0 1020
#define IDC_SEG1 1021
#define IDC_SEG2 1022
#define IDC_SEG3 1023
#define IDS_APP_TITLE 40000
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 111
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1002
#define _APS_NEXT_SYMED_VALUE 123
#endif
#endif
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/README.url
================================================
[InternetShortcut]
URL=http://www.state-machine.com/qpn/arm-cm_pelican_ek-tm4c123gxl.html
IconFile=http://www.state-machine.com/qp.ico
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/bsp.h
================================================
/*****************************************************************************
* Product: BSP for PELICAN crossing example
* Last updated for version 5.4.0
* Last updated on 2015-05-18
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, www.state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef BSP_H
#define BSP_H
#define BSP_TICKS_PER_SEC 100U
enum BSP_CarsSignal {
CARS_RED, CARS_YELLOW, CARS_GREEN, CARS_BLANK
};
enum BSP_PedsSignal {
PEDS_DONT_WALK, PEDS_WALK, PEDS_BLANK
};
void BSP_init(void);
void BSP_showState(char_t const *state);
void BSP_signalCars(enum BSP_CarsSignal sig);
void BSP_signalPeds(enum BSP_PedsSignal sig);
#endif /* BSP_H */
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/main.c
================================================
/*****************************************************************************
* Product: PELICAN crossing example
* Last updated for version 5.8.0
* Last updated on 2016-11-06
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h" /* QP-nano */
#include "bsp.h" /* Board Support Package (BSP) */
#include "pelican.h" /* application interface */
/*..........................................................................*/
static QEvt l_pelicanQueue[3];
/* QF_active[] array defines all active object control blocks --------------*/
QActiveCB const Q_ROM QF_active[] = {
{ (QActive *)0, (QEvt *)0, 0U },
{ (QActive *)&AO_Pelican, l_pelicanQueue, Q_DIM(l_pelicanQueue) }
};
/*..........................................................................*/
int main (void) {
Pelican_ctor(); /* instantiate the Pelican AO */
QF_init(Q_DIM(QF_active)); /* initialize the QF-nano framework */
BSP_init(); /* initialize the Board Support Package */
return QF_run(); /* transfer control to QF-nano */
}
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/pelican.c
================================================
/*.$file${.::pelican.c} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: pelican.qm
* File: ${.::pelican.c}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::pelican.c} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#include "qpn.h" /* QP-nano */
#include "bsp.h" /* Board Support Package (BSP) */
#include "pelican.h" /* application interface */
/*Q_DEFINE_THIS_FILE*/
#define CARS_GREEN_MIN_TOUT (QTimeEvtCtr)(BSP_TICKS_PER_SEC * 8U)
#define CARS_YELLOW_TOUT (QTimeEvtCtr)(BSP_TICKS_PER_SEC * 3U)
#define PEDS_WALK_TOUT (QTimeEvtCtr)(BSP_TICKS_PER_SEC * 3U)
#define PEDS_FLASH_TOUT (QTimeEvtCtr)(BSP_TICKS_PER_SEC / 5U)
#define PEDS_FLASH_NUM (uint8_t)(5U * 2U)
#define OFF_FLASH_TOUT (QTimeEvtCtr)(BSP_TICKS_PER_SEC / 2U)
/* Pelican class declaration -----------------------------------------------*/
/*.$declare${components::Pelican} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${components::Pelican} ..................................................*/
typedef struct Pelican {
/* protected: */
QActive super;
/* private: */
uint8_t flashCtr;
} Pelican;
/* protected: */
static QState Pelican_initial(Pelican * const me);
static QState Pelican_operational(Pelican * const me);
static QState Pelican_carsEnabled(Pelican * const me);
static QState Pelican_carsGreen(Pelican * const me);
static QState Pelican_carsGreenNoPed(Pelican * const me);
static QState Pelican_carsGreenInt(Pelican * const me);
static QState Pelican_carsGreenPedWait(Pelican * const me);
static QState Pelican_carsYellow(Pelican * const me);
static QState Pelican_pedsEnabled(Pelican * const me);
static QState Pelican_pedsWalk(Pelican * const me);
static QState Pelican_pedsFlash(Pelican * const me);
static QState Pelican_offline(Pelican * const me);
/*.$enddecl${components::Pelican} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Global objects ----------------------------------------------------------*/
struct Pelican AO_Pelican; /* the single instance of the Pelican AO */
/* Pelican class definition ------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*. Check for the minimum required QP version */
#if (QP_VERSION < 650U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpn version 6.5.0 or higher required
#endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${components::Pelican_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${components::Pelican_ctor} .............................................*/
void Pelican_ctor(void) {
QActive_ctor(&AO_Pelican.super, Q_STATE_CAST(&Pelican_initial));
}
/*.$enddef${components::Pelican_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${components::Pelican} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${components::Pelican} ..................................................*/
/*.${components::Pelican::SM} ..............................................*/
static QState Pelican_initial(Pelican * const me) {
/*.${components::Pelican::SM::initial} */
return Q_TRAN(&Pelican_operational);
}
/*.${components::Pelican::SM::operational} .................................*/
static QState Pelican_operational(Pelican * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${components::Pelican::SM::operational} */
case Q_ENTRY_SIG: {
BSP_signalCars(CARS_RED);
BSP_signalPeds(PEDS_DONT_WALK);
status_ = Q_HANDLED();
break;
}
/*.${components::Pelican::SM::operational::initial} */
case Q_INIT_SIG: {
status_ = Q_TRAN(&Pelican_carsEnabled);
break;
}
/*.${components::Pelican::SM::operational::OFF} */
case OFF_SIG: {
status_ = Q_TRAN(&Pelican_offline);
break;
}
/*.${components::Pelican::SM::operational::TERMINATE} */
case TERMINATE_SIG: {
QF_stop();
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${components::Pelican::SM::operational::carsEnabled} ....................*/
static QState Pelican_carsEnabled(Pelican * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${components::Pelican::SM::operational::carsEnabled} */
case Q_EXIT_SIG: {
BSP_signalCars(CARS_RED);
status_ = Q_HANDLED();
break;
}
/*.${components::Pelican::SM::operational::carsEnabled::initial} */
case Q_INIT_SIG: {
status_ = Q_TRAN(&Pelican_carsGreen);
break;
}
default: {
status_ = Q_SUPER(&Pelican_operational);
break;
}
}
return status_;
}
/*.${components::Pelican::SM::operational::carsEnabled::carsGreen} .........*/
static QState Pelican_carsGreen(Pelican * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${components::Pelican::SM::operational::carsEnabled::carsGreen} */
case Q_ENTRY_SIG: {
BSP_signalCars(CARS_GREEN);
/* one-shot timeout in CARS_GREEN_MIN_TOUT ticks */
QActive_armX(&me->super, 0U, CARS_GREEN_MIN_TOUT, 0U);
status_ = Q_HANDLED();
break;
}
/*.${components::Pelican::SM::operational::carsEnabled::carsGreen} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
status_ = Q_HANDLED();
break;
}
/*.${components::Pelican::SM::operational::carsEnabled::carsGreen::initial} */
case Q_INIT_SIG: {
status_ = Q_TRAN(&Pelican_carsGreenNoPed);
break;
}
default: {
status_ = Q_SUPER(&Pelican_carsEnabled);
break;
}
}
return status_;
}
/*.${components::Pelican::SM::operational::carsEnabled::carsGreen::carsGreenNoPed} */
static QState Pelican_carsGreenNoPed(Pelican * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${components::Pelican::SM::operational::carsEnabled::carsGreen::carsGreenNoPed} */
case Q_ENTRY_SIG: {
BSP_showState("carsGreenNoPed");
status_ = Q_HANDLED();
break;
}
/*.${components::Pelican::SM::operational::carsEnabled::carsGreen::carsGreenNoPed::PEDS_WAITING} */
case PEDS_WAITING_SIG: {
status_ = Q_TRAN(&Pelican_carsGreenPedWait);
break;
}
/*.${components::Pelican::SM::operational::carsEnabled::carsGreen::carsGreenNoPed::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Pelican_carsGreenInt);
break;
}
default: {
status_ = Q_SUPER(&Pelican_carsGreen);
break;
}
}
return status_;
}
/*.${components::Pelican::SM::operational::carsEnabled::carsGreen::carsGreenInt} */
static QState Pelican_carsGreenInt(Pelican * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${components::Pelican::SM::operational::carsEnabled::carsGreen::carsGreenInt} */
case Q_ENTRY_SIG: {
BSP_showState("carsGreenInt");
status_ = Q_HANDLED();
break;
}
/*.${components::Pelican::SM::operational::carsEnabled::carsGreen::carsGreenInt::PEDS_WAITING} */
case PEDS_WAITING_SIG: {
status_ = Q_TRAN(&Pelican_carsYellow);
break;
}
default: {
status_ = Q_SUPER(&Pelican_carsGreen);
break;
}
}
return status_;
}
/*.${components::Pelican::SM::operational::carsEnabled::carsGreen::carsGreenPedWait} */
static QState Pelican_carsGreenPedWait(Pelican * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${components::Pelican::SM::operational::carsEnabled::carsGreen::carsGreenPedWait} */
case Q_ENTRY_SIG: {
BSP_showState("carsGreenPedWait");
status_ = Q_HANDLED();
break;
}
/*.${components::Pelican::SM::operational::carsEnabled::carsGreen::carsGreenPedWait::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Pelican_carsYellow);
break;
}
default: {
status_ = Q_SUPER(&Pelican_carsGreen);
break;
}
}
return status_;
}
/*.${components::Pelican::SM::operational::carsEnabled::carsYellow} ........*/
static QState Pelican_carsYellow(Pelican * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${components::Pelican::SM::operational::carsEnabled::carsYellow} */
case Q_ENTRY_SIG: {
BSP_showState("carsYellow");
BSP_signalCars(CARS_YELLOW);
/* one-shot timeout in CARS_YELLOW_TOUT ticks */
QActive_armX(&me->super, 0U, CARS_YELLOW_TOUT, 0U);
status_ = Q_HANDLED();
break;
}
/*.${components::Pelican::SM::operational::carsEnabled::carsYellow} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
status_ = Q_HANDLED();
break;
}
/*.${components::Pelican::SM::operational::carsEnabled::carsYellow::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Pelican_pedsEnabled);
break;
}
default: {
status_ = Q_SUPER(&Pelican_carsEnabled);
break;
}
}
return status_;
}
/*.${components::Pelican::SM::operational::pedsEnabled} ....................*/
static QState Pelican_pedsEnabled(Pelican * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${components::Pelican::SM::operational::pedsEnabled} */
case Q_EXIT_SIG: {
BSP_signalPeds(PEDS_DONT_WALK);
status_ = Q_HANDLED();
break;
}
/*.${components::Pelican::SM::operational::pedsEnabled::initial} */
case Q_INIT_SIG: {
status_ = Q_TRAN(&Pelican_pedsWalk);
break;
}
default: {
status_ = Q_SUPER(&Pelican_operational);
break;
}
}
return status_;
}
/*.${components::Pelican::SM::operational::pedsEnabled::pedsWalk} ..........*/
static QState Pelican_pedsWalk(Pelican * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${components::Pelican::SM::operational::pedsEnabled::pedsWalk} */
case Q_ENTRY_SIG: {
BSP_showState("pedsWalk");
BSP_signalPeds(PEDS_WALK);
/* one-shot timeout in PEDS_WALK_TOUT ticks */
QActive_armX(&me->super, 0U, PEDS_WALK_TOUT, 0U);
status_ = Q_HANDLED();
break;
}
/*.${components::Pelican::SM::operational::pedsEnabled::pedsWalk} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
status_ = Q_HANDLED();
break;
}
/*.${components::Pelican::SM::operational::pedsEnabled::pedsWalk::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Pelican_pedsFlash);
break;
}
default: {
status_ = Q_SUPER(&Pelican_pedsEnabled);
break;
}
}
return status_;
}
/*.${components::Pelican::SM::operational::pedsEnabled::pedsFlash} .........*/
static QState Pelican_pedsFlash(Pelican * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${components::Pelican::SM::operational::pedsEnabled::pedsFlash} */
case Q_ENTRY_SIG: {
BSP_showState("pedsFlash");
/* periodic timeout in PEDS_FLASH_TOUT and every PEDS_FLASH_TOUT ticks */
QActive_armX(&me->super, 0U, PEDS_FLASH_TOUT, PEDS_FLASH_TOUT);
me->flashCtr = (PEDS_FLASH_NUM * 2U) + 1U;
status_ = Q_HANDLED();
break;
}
/*.${components::Pelican::SM::operational::pedsEnabled::pedsFlash} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
status_ = Q_HANDLED();
break;
}
/*.${components::Pelican::SM::operational::pedsEnabled::pedsFlash::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
/*.${components::Pelican::SM::operational::pedsEnabled::pedsFlash::Q_TIMEOUT::[me->flashCtr!=0U]} */
if (me->flashCtr != 0U) {
--me->flashCtr;
/*.${components::Pelican::SM::operational::pedsEnabled::pedsFlash::Q_TIMEOUT::[me->flashCtr!=0~::[(me->flashCtr&1U)==0U]} */
if ((me->flashCtr & 1U) == 0U) {
BSP_signalPeds(PEDS_DONT_WALK);
status_ = Q_HANDLED();
}
/*.${components::Pelican::SM::operational::pedsEnabled::pedsFlash::Q_TIMEOUT::[me->flashCtr!=0~::[else]} */
else {
BSP_signalPeds(PEDS_BLANK);
status_ = Q_HANDLED();
}
}
/*.${components::Pelican::SM::operational::pedsEnabled::pedsFlash::Q_TIMEOUT::[else]} */
else {
status_ = Q_TRAN(&Pelican_carsEnabled);
}
break;
}
default: {
status_ = Q_SUPER(&Pelican_pedsEnabled);
break;
}
}
return status_;
}
/*.${components::Pelican::SM::offline} .....................................*/
static QState Pelican_offline(Pelican * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${components::Pelican::SM::offline} */
case Q_ENTRY_SIG: {
BSP_showState("offline");
/* periodic timeout in OFF_FLASH_TOUT and every OFF_FLASH_TOUT ticks */
QActive_armX(&me->super, 0U, OFF_FLASH_TOUT, OFF_FLASH_TOUT);
me->flashCtr = 0U;
status_ = Q_HANDLED();
break;
}
/*.${components::Pelican::SM::offline} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
status_ = Q_HANDLED();
break;
}
/*.${components::Pelican::SM::offline::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
me->flashCtr ^= 1U;
/*.${components::Pelican::SM::offline::Q_TIMEOUT::[(me->flashCtr&1U)==0U]} */
if ((me->flashCtr & 1U) == 0U) {
BSP_signalCars(CARS_RED);
BSP_signalPeds(PEDS_DONT_WALK);
status_ = Q_HANDLED();
}
/*.${components::Pelican::SM::offline::Q_TIMEOUT::[else]} */
else {
BSP_signalCars(CARS_BLANK);
BSP_signalPeds(PEDS_BLANK);
status_ = Q_HANDLED();
}
break;
}
/*.${components::Pelican::SM::offline::ON} */
case ON_SIG: {
status_ = Q_TRAN(&Pelican_operational);
break;
}
/*.${components::Pelican::SM::offline::TERMINATE} */
case TERMINATE_SIG: {
QF_stop();
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.$enddef${components::Pelican} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/pelican.h
================================================
/*.$file${.::pelican.h} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: pelican.qm
* File: ${.::pelican.h}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::pelican.h} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#ifndef PELICAN_H
#define PELICAN_H
enum PelicanSignals {
PEDS_WAITING_SIG = Q_USER_SIG,
OFF_SIG,
ON_SIG,
TERMINATE_SIG
};
/* active objects ................................................*/
/*.$declare${components::Pelican_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${components::Pelican_ctor} .............................................*/
void Pelican_ctor(void);
/*.$enddecl${components::Pelican_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
extern struct Pelican AO_Pelican;
#endif /* PELICAN_H */
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/pelican.qm
================================================
PEdestrian LIght CONtrolled (PELICAN) crossing examplePEdestrian LIght CONtrolled (PELICAN) crossingBSP_signalCars(CARS_RED);
BSP_signalPeds(PEDS_DONT_WALK);QF_stop();BSP_signalCars(CARS_RED);BSP_signalCars(CARS_GREEN);
/* one-shot timeout in CARS_GREEN_MIN_TOUT ticks */
QActive_armX(&me->super, 0U, CARS_GREEN_MIN_TOUT, 0U);QActive_disarmX(&me->super, 0U);BSP_showState("carsGreenNoPed");BSP_showState("carsGreenInt");BSP_showState("carsGreenPedWait");BSP_showState("carsYellow");
BSP_signalCars(CARS_YELLOW);
/* one-shot timeout in CARS_YELLOW_TOUT ticks */
QActive_armX(&me->super, 0U, CARS_YELLOW_TOUT, 0U);QActive_disarmX(&me->super, 0U);BSP_signalPeds(PEDS_DONT_WALK);BSP_showState("pedsWalk");
BSP_signalPeds(PEDS_WALK);
/* one-shot timeout in PEDS_WALK_TOUT ticks */
QActive_armX(&me->super, 0U, PEDS_WALK_TOUT, 0U);QActive_disarmX(&me->super, 0U);BSP_showState("pedsFlash");
/* periodic timeout in PEDS_FLASH_TOUT and every PEDS_FLASH_TOUT ticks */
QActive_armX(&me->super, 0U, PEDS_FLASH_TOUT, PEDS_FLASH_TOUT);
me->flashCtr = (PEDS_FLASH_NUM * 2U) + 1U;QActive_disarmX(&me->super, 0U);me->flashCtr != 0U--me->flashCtr;(me->flashCtr & 1U) == 0UBSP_signalPeds(PEDS_DONT_WALK);elseBSP_signalPeds(PEDS_BLANK);elseBSP_showState("offline");
/* periodic timeout in OFF_FLASH_TOUT and every OFF_FLASH_TOUT ticks */
QActive_armX(&me->super, 0U, OFF_FLASH_TOUT, OFF_FLASH_TOUT);
me->flashCtr = 0U;QActive_disarmX(&me->super, 0U);me->flashCtr ^= 1U;(me->flashCtr & 1U) == 0UBSP_signalCars(CARS_RED);
BSP_signalPeds(PEDS_DONT_WALK);elseBSP_signalCars(CARS_BLANK);
BSP_signalPeds(PEDS_BLANK);QF_stop();constructorQActive_ctor(&AO_Pelican.super, Q_STATE_CAST(&Pelican_initial));#ifndef PELICAN_H
#define PELICAN_H
enum PelicanSignals {
PEDS_WAITING_SIG = Q_USER_SIG,
OFF_SIG,
ON_SIG,
TERMINATE_SIG
};
/* active objects ................................................*/
$declare(components::Pelican_ctor)
extern struct Pelican AO_Pelican;
#endif /* PELICAN_H */
#include "qpn.h" /* QP-nano */
#include "bsp.h" /* Board Support Package (BSP) */
#include "pelican.h" /* application interface */
/*Q_DEFINE_THIS_FILE*/
#define CARS_GREEN_MIN_TOUT (QTimeEvtCtr)(BSP_TICKS_PER_SEC * 8U)
#define CARS_YELLOW_TOUT (QTimeEvtCtr)(BSP_TICKS_PER_SEC * 3U)
#define PEDS_WALK_TOUT (QTimeEvtCtr)(BSP_TICKS_PER_SEC * 3U)
#define PEDS_FLASH_TOUT (QTimeEvtCtr)(BSP_TICKS_PER_SEC / 5U)
#define PEDS_FLASH_NUM (uint8_t)(5U * 2U)
#define OFF_FLASH_TOUT (QTimeEvtCtr)(BSP_TICKS_PER_SEC / 2U)
/* Pelican class declaration -----------------------------------------------*/
$declare(components::Pelican)
/* Global objects ----------------------------------------------------------*/
struct Pelican AO_Pelican; /* the single instance of the Pelican AO */
/* Pelican class definition ------------------------------------------------*/
$define(components::Pelican_ctor)
$define(components::Pelican)
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qk/armclang/README.txt
================================================
About this Example
==================
This example demonstrates how to use the uVision IDE together with
the MDK-ARM toolchain.
***
NOTE: This example requires installing the following Software Pack
in the Keil uVision: Keil::TM4C_DFP.
***
uVision Project File
====================
The MDK-ARM uVision project file provided with this example uses
relative paths to the QP framework location (includes, port, and
libraries. These relative paths must be modified when the project
is moved to different relative location.
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the
command-line options for the ARM assembler (see the Asm tab in
the "Options for Target" dialog box in uVision). Specifically,
you should define symbols: Stack_Size=xxx Heap_Size=yyy, where
xxx represents a numerical value of stack size and yyy the
numerical value of the heap size (for most embedded projects
yyy should be 0, as the using the heap is not recommended).
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.s
The file startup_TM4C123GH6PM.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qk/armclang/pelican-qk.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj; *.o*.lib*.txt; *.h; *.inc*.plm*.cpp000pelican-dbg0x4ARM-ADS120000001110016553500079668.\dbg\11101101000011111110010140111111111111101011001008BIN\lmidk-agdi.dll0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10UL2CM3UL2CM3(-O207 -S0 -C0 -FO7 -FN1 -FC1000 -FD20000000 -FF0TM4C123_256 -FL040000 -FS00 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM)0DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E2006F4 -O4622 -S4 -FO61120x200002000200x40000001000010000000000000000000pelican-rel0x4ARM-ADS120000001110016553500079668.\rel\11101101000011111110010040111111111011101011001008BIN\lmidk-agdi.dll0DLGUARMÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÈ`»
´ª¤ô 0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E10259B -O4622 -S4 -FO610UL2CM3-O207 -S0 -C0 -FO7 -FN1 -FC1000 -FD20000000 -FF0TM4C123_256 -FL040000 -FS00 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM)120x200002000200x40000001000010000000000000000000Applicatioin1000111000..\bsp.cbsp.c00121000..\..\pelican.cpelican.c00131000..\..\main.cmain.c00145000..\..\pelican.hpelican.h00155000..\..\qpn_conf.hqpn_conf.h00ek-tm4c123gxl1000261000..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.csystem_TM4C123GH6PM.c00275000..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hTM4C123GH6PM.h00285000..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hgpio.h00295000..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hrom.h002105000..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsysctl.h002115000..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hsystem_TM4C123GH6PM.h002122000..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sstartup_TM4C123GH6PM.s00QP10003131000..\..\..\..\..\src\qfn\qepn.cqepn.c003141000..\..\..\..\..\src\qfn\qfn.cqfn.c003151000..\..\..\..\..\src\qkn\qkn.cqkn.c00QP_port10004165000..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqfn_port.h004171000..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.cqkn_port.c00
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qk/armclang/pelican-qk.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwarepelican-dbg0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1TM4C123GH6PMTexas InstrumentsKeil.TM4C_DFP.1.1.0http://www.keil.com/pack/IROM(0x00000000,0x040000) IRAM(0x20000000,0x008000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C123_256 -FS00 -FL040000 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM))0$$Device:TM4C123GH6PM$Device\Include\TM4C123\TM4C123.h$$Device:TM4C123GH6PM$SVD\TM4C123\TM4C123GH6PM.svd0000001.\dbg\pelican-qk10011.\dbg\10000000000000010fromelf --bin --output .\dbg\pelican-qk.bin .\dbg\pelican-qk.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x4000000x00x010x00x010x00x010x00x010x00x4000010x00x000x00x000x00x000x00x000x200000000x800000x00x007001000003010003311000__FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\ek-tm4c123gxl1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cpelican.c1..\..\pelican.cmain.c1..\..\main.cpelican.h5..\..\pelican.hqpn_conf.h5..\..\qpn_conf.hek-tm4c123gxlsystem_TM4C123GH6PM.c1..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.cTM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hgpio.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hrom.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hsysctl.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsystem_TM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hstartup_TM4C123GH6PM.s2..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.cpelican-rel0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1TM4C123GH6PMTexas InstrumentsKeil.TM4C_DFP.1.1.0http://www.keil.com/pack/IROM(0x00000000,0x040000) IRAM(0x20000000,0x008000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C123_256 -FS00 -FL040000 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM))0$$Device:TM4C123GH6PM$Device\Include\TM4C123\TM4C123.h$$Device:TM4C123GH6PM$SVD\TM4C123\TM4C123GH6PM.svd0000001.\rel\pelican-qk10000.\rel\10000000000000010fromelf --bin --output .\rel\pelican-qk.bin .\rel\pelican-qk.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x4000000x00x010x00x010x00x010x00x010x00x4000010x00x000x00x000x00x000x00x000x200000000x800000x00x007001000003010003311000NDEBUG __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qk\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\ek-tm4c123gxl1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000pelican-qk.sct--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cpelican.c1..\..\pelican.cmain.c1..\..\main.cpelican.h5..\..\pelican.hqpn_conf.h5..\..\qpn_conf.hek-tm4c123gxlsystem_TM4C123GH6PM.c1..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.cTM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hgpio.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hrom.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hsysctl.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsystem_TM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hstartup_TM4C123GH6PM.s2..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqkn.c1..\..\..\..\..\src\qkn\qkn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qk\armclang\qfn_port.hqkn_port.c1..\..\..\..\..\ports\arm-cm\qk\armclang\qkn_port.c
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qk/bsp.c
================================================
/*****************************************************************************
* Product: PELICAN on EK-TM4C123GXL board, preemptive QK kernel
* Last Updated for Version: 5.8.0
* Date of the Last Update: 2016-11-06
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "bsp.h"
#include "pelican.h"
#include "TM4C123GH6PM.h" /* the device specific header (TI) */
#include "rom.h" /* the built-in ROM functions (TI) */
#include "sysctl.h" /* system control driver (TI) */
#include "gpio.h" /* GPIO driver (TI) */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
enum KernelUnawareISRs { /* see NOTE00 */
/* ... */
MAX_KERNEL_UNAWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-unaware" interrupts can't overlap "kernel-aware" interrupts */
Q_ASSERT_COMPILE(MAX_KERNEL_UNAWARE_CMSIS_PRI <= QF_AWARE_ISR_CMSIS_PRI);
enum KernelAwareISRs {
SYSTICK_PRIO = QF_AWARE_ISR_CMSIS_PRI, /* see NOTE00 */
/* ... */
MAX_KERNEL_AWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-aware" interrupts should not overlap the PendSV priority */
Q_ASSERT_COMPILE(MAX_KERNEL_AWARE_CMSIS_PRI <= (0xFF >>(8-__NVIC_PRIO_BITS)));
/* ISRs defined in this BSP ------------------------------------------------*/
void SysTick_Handler(void);
void GPIOPortA_IRQHandler(void);
/* Local-scope objects -----------------------------------------------------*/
#define LED_RED (1U << 1)
#define LED_GREEN (1U << 3)
#define LED_BLUE (1U << 2)
#define BTN_SW1 (1U << 4)
#define BTN_SW2 (1U << 0)
/* ISRs used in this project ===============================================*/
void SysTick_Handler(void) {
/* state of the button debouncing, see below */
static struct ButtonsDebouncing {
uint32_t depressed;
uint32_t previous;
} buttons = { ~0U, ~0U };
uint32_t current;
uint32_t tmp;
QK_ISR_ENTRY(); /* inform QK about entering an ISR */
QF_tickXISR(0U); /* process time events for rate 0 */
/* Perform the debouncing of buttons. The algorithm for debouncing
* adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
* and Michael Barr, page 71.
*/
current = ~GPIOF->DATA_Bits[BTN_SW1 | BTN_SW2]; /* read SW1 and SW2 */
tmp = buttons.depressed; /* save the debounced depressed buttons */
buttons.depressed |= (buttons.previous & current); /* set depressed */
buttons.depressed &= (buttons.previous | current); /* clear released */
buttons.previous = current; /* update the history */
tmp ^= buttons.depressed; /* changed debounced depressed */
if ((tmp & BTN_SW1) != 0U) { /* debounced SW1 state changed? */
if ((buttons.depressed & BTN_SW1) != 0U) { /* is SW1 depressed? */
QACTIVE_POST_ISR((QActive *)&AO_Pelican, PEDS_WAITING_SIG, 0U);
}
else { /* the button is released */
}
}
QK_ISR_EXIT(); /* inform QK about exiting an ISR */
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* NOTE: SystemInit() already called from the startup code
* but SystemCoreClock needs to be updated
*/
SystemCoreClockUpdate();
/* configure the FPU usage by choosing one of the options...
*
* Do NOT to use the automatic FPU state preservation and
* do NOT to use the FPU lazy stacking.
*
* NOTE:
* Use the following setting when FPU is used only by active objects
* and NOT in any ISR. This setting is very efficient, but if any ISRs
* start using the FPU, this can lead to corruption of the FPU registers.
*/
FPU->FPCCR &= ~((1U << FPU_FPCCR_ASPEN_Pos) | (1U << FPU_FPCCR_LSPEN_Pos));
/* enable clock for to the peripherals used by this application... */
SYSCTL->RCGCGPIO |= (1U << 5); /* enable Run mode for GPIOF */
/* configure the LEDs and push buttons */
GPIOF->DIR |= (LED_RED | LED_GREEN | LED_BLUE);/* set direction: output */
GPIOF->DEN |= (LED_RED | LED_GREEN | LED_BLUE); /* digital enable */
GPIOF->DATA_Bits[LED_RED] = 0; /* turn the LED off */
GPIOF->DATA_Bits[LED_GREEN] = 0; /* turn the LED off */
GPIOF->DATA_Bits[LED_BLUE] = 0; /* turn the LED off */
/* configure the Buttons */
GPIOF->DIR &= ~(BTN_SW1 | BTN_SW2); /* set direction: input */
ROM_GPIOPadConfigSet(GPIOF_BASE, (BTN_SW1 | BTN_SW2),
GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
}
/*..........................................................................*/
void BSP_showState(char_t const *state) {
(void)state;
}
/*..........................................................................*/
void BSP_signalCars(enum BSP_CarsSignal sig) {
switch (sig) {
case CARS_RED: {
//GPIOF->DATA_Bits[LED_RED] = LED_RED;
break;
}
case CARS_YELLOW: {
//GPIOF->DATA_Bits[LED_RED | LED_GREEN] = (LED_RED | LED_GREEN);
break;
}
case CARS_GREEN: {
//GPIOF->DATA_Bits[LED_GREEN] = LED_GREEN;
break;
}
case CARS_BLANK: {
//GPIOF->DATA_Bits[LED_RED | LED_GREEN | LED_BLUE] = 0U;
break;
}
}
}
/*..........................................................................*/
void BSP_signalPeds(enum BSP_PedsSignal sig) {
switch (sig) {
case PEDS_DONT_WALK: {
GPIOF->DATA_Bits[LED_RED] = LED_RED;
break;
}
case PEDS_BLANK: {
GPIOF->DATA_Bits[LED_RED | LED_GREEN] = 0U;
break;
}
case PEDS_WALK: {
GPIOF->DATA_Bits[LED_RED | LED_GREEN] = LED_GREEN;
break;
}
}
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set up the SysTick timer to fire at BSP_TICKS_PER_SEC rate */
SysTick_Config(SystemCoreClock / BSP_TICKS_PER_SEC);
/* assing all priority bits for preemption-prio. and none to sub-prio. */
NVIC_SetPriorityGrouping(0U);
/* set priorities of ALL ISRs used in the system, see NOTE00
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
NVIC_SetPriority(SysTick_IRQn, SYSTICK_PRIO);
/* ... */
/* enable IRQs... */
}
/*..........................................................................*/
void QF_stop(void) {
}
/*..........................................................................*/
void QK_onIdle(void) {
/* toggle LED2 on and then off, see NOTE01 */
QF_INT_DISABLE();
GPIOF->DATA_Bits[LED_BLUE] = 0xFFU;
GPIOF->DATA_Bits[LED_BLUE] = 0x00U;
QF_INT_ENABLE();
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular Cortex-M3 MCU.
*/
__WFI(); /* Wait-For-Interrupt */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int loc) {
/*
* NOTE: add here your application-specific error handling
*/
(void)module;
(void)loc;
NVIC_SystemReset();
}
/*****************************************************************************
* NOTE00:
* The QF_AWARE_ISR_CMSIS_PRI constant from the QF port specifies the highest
* ISR priority that is disabled by the QF framework. The value is suitable
* for the NVIC_SetPriority() CMSIS function.
*
* Only ISRs prioritized at or below the QF_AWARE_ISR_CMSIS_PRI level (i.e.,
* with the numerical values of priorities equal or higher than
* QF_AWARE_ISR_CMSIS_PRI) are allowed to call any QF services. These ISRs
* are "QF-aware".
*
* Conversely, any ISRs prioritized above the QF_AWARE_ISR_CMSIS_PRI priority
* level (i.e., with the numerical values of priorities less than
* QF_AWARE_ISR_CMSIS_PRI) are never disabled and are not aware of the kernel.
* Such "QF-unaware" ISRs cannot call any QF services. The only mechanism
* by which a "QF-unaware" ISR can communicate with the QF framework is by
* triggering a "QF-aware" ISR, which can post/publish events.
*
* NOTE01:
* One of the LEDs is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qk/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano on EK-TM4C123GXL, QK-nano, GNU-ARM
# Last Updated for Version: 6.5.0
# Date of the Last Update: 2019-04-15
#
# Q u a n t u m L e a P s
# ------------------------
# Modern Embedded Software
#
# Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# https://www.state-machine.com
# mailto:info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := pelican-qk
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/arm-cm/qk/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qkn \
$(QP_PORT_DIR) \
$(QPN)/3rd_party/ek-tm4c123gxl \
$(QPN)/3rd_party/ek-tm4c123gxl/gnu
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR) \
-I$(QPN)/3rd_party/CMSIS/Include \
-I$(QPN)/3rd_party/ek-tm4c123gxl
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
pelican.c \
bsp.c \
main.c \
system_TM4C123GH6PM.c \
startup_TM4C123GH6PM.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qepn.c \
qfn.c \
qkn.c \
qkn_port.c
QP_ASMS :=
LIB_DIRS :=
LIBS :=
# defines
DEFINES :=
# ARM CPU, ARCH, FPU, and Float-ABI types...
# ARM_CPU: [cortex-m0 | cortex-m0plus | cortex-m1 | cortex-m3 | cortex-m4]
# ARM_ARCH: [6 | 7] (NOTE: must match ARM_CPU!)
# ARM_FPU: [ | vfp]
# FLOAT_ABI: [ | soft | softfp | hard]
#
ARM_CPU := -mcpu=cortex-m4
ARM_ARCH := 7 # NOTE: must match the ARM_CPU!
ARM_FPU := -mfpu=vfp
FLOAT_ABI := -mfloat-abi=softfp
#-----------------------------------------------------------------------------
# GNU-ARM toolset (NOTE: You need to adjust to your machine)
# see https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
#
ifeq ($(GNU_ARM),)
GNU_ARM := $(QTOOLS)/gnu_arm-none-eabi
endif
# make sure that the GNU-ARM toolset exists...
ifeq ("$(wildcard $(GNU_ARM))","")
$(error GNU_ARM toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_ARM)/bin/arm-none-eabi-gcc
CPP := $(GNU_ARM)/bin/arm-none-eabi-g++
AS := $(GNU_ARM)/bin/arm-none-eabi-as
LINK := $(GNU_ARM)/bin/arm-none-eabi-g++
BIN := $(GNU_ARM)/bin/arm-none-eabi-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M
#
# combine all the soruces...
C_SRCS += $(QP_SRCS)
ASM_SRCS += $(QP_ASMS)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS = $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration ..........................................
BIN_DIR := dbg
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O $(INCLUDES) $(DEFINES)
CPPFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES)
endif # ......................................................................
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
-specs=nosys.specs -specs=nano.specs \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_BIN := $(BIN_DIR)/$(OUTPUT).bin
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_BIN)
#all: $(TARGET_ELF)
$(TARGET_BIN): $(TARGET_ELF)
$(BIN) -O binary $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(CC) $(CFLAGS) $(QPN)/include/qstamp.c -o $(BIN_DIR)/qstamp.o
$(LINK) $(LINKFLAGS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.bin \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qk/gnu/README.txt
================================================
About this Example
==================
This example can be built from the command prompt with the provided
Makefile. The example can also be imported as a Makefile-based
project into Eclipse-based IDEs.
The Makefile
============
The provided Makefile should be easy to adapt for your own projects.
It contains three build configurations: Debug (default) and Release.
Also, the Makefile has been specifically designed to work as an external
Makefile with the Eclipse CDT.
The various build configurations are built as follows:
make
make CONF=rel
make clean
make CONF=rel clean
***
NOTE:
The installation folder of the GNU-ARM toolset on YOUR machine needs
to be adjusted in the provided Makefile, by editing the symbol: GNU_ARM.
As described in the comment for this symbol, the GNU-ARM toolset is taken
from: http://gnutoolchains.com/arm-eabi
It is highly recommened to use the same GNU-ARM distribution, especially
for ARM Cortex-M4F projects, due to the support for the hardware FPU
(float-abi=hard).
***
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the GCC linker
script (.ld file), which provides a template of the recommended GCC linker
script for QP applications.
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\gcc\startup_TM4C123GH6PM.c
The file startup_TM4C123GH6PM.c provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qk/gnu/flash.bat
================================================
::============================================================================
:: Batch file to program the flash of EK-TM4C123GXL
::
:: NOTE: requires the LMFlash programmer (included in QTools for Windows)
::
@echo off
setlocal
@echo Load a given binary file to the flash of EK-TM4C123GXL
@echo usage: flash binary-file
@echo example: flash dbg\blinky-qk.bin
::----------------------------------------------------------------------------
:: NOTE: The following symbol LMFLASH assumes that LMFlash.exe can
:: be found on the PATH. You might need to adjust this symbol to the
:: location of the LMFlash utility on your machine
::
set LMFLASH=LMFlash.exe
if ["%~1"]==[""] (
@echo The binary file missing
@goto end
)
if not exist %~s1 (
@echo The binary file '%1' does not exist
@goto end
)
%LMFLASH% -q ek-tm4c123gxl -e -v -r %1
:end
endlocal
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qk/gnu/pelican-qk.ld
================================================
/*****************************************************************************
* Product: Linker script for EK-TM4C123GXL, GNU-ARM linker
* Last Updated for Version: 5.9.8
* Date of the Last Update: 2017-09-13
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* Web : http://www.state-machine.com
* Email: info@state-machine.com
*****************************************************************************/
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(Reset_Handler) /* entry Point */
MEMORY { /* memory map of Tiva TM4C123GH6PM */
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 256K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
}
/* The size of the stack used by the application. NOTE: you need to adjust */
STACK_SIZE = 1024;
/* The size of the heap used by the application. NOTE: you need to adjust */
HEAP_SIZE = 0;
SECTIONS {
.isr_vector : { /* the vector table goes FIRST into ROM */
KEEP(*(.isr_vector)) /* vector table */
. = ALIGN(4);
} >ROM
.text : { /* code and constants */
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} >ROM
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >ROM
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >ROM
.fini_array : {
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array*))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >ROM
_etext = .; /* global symbols at end of code */
.stack : {
__stack_start__ = .;
. = . + STACK_SIZE;
. = ALIGN(4);
__stack_end__ = .;
} >RAM
.data : AT (_etext) {
__data_load = LOADADDR (.data);
__data_start = .;
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
__data_end__ = .;
_edata = __data_end__;
} >RAM
.bss : {
__bss_start__ = .;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = .;
} >RAM
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >RAM
__exidx_end = .;
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );
PROVIDE ( __end__ = _ebss );
.heap : {
__heap_start__ = .;
. = . + HEAP_SIZE;
. = ALIGN(4);
__heap_end__ = .;
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ : {
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
}
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qk/iar/README.txt
================================================
About this Example
==================
This example demonstrates how to use the IAR EWARM IDE to build
a QP application.
IAR Project File
----------------
The IAR EWARM project file provided with this example uses relative paths
to the QP/C framework location (includes, port, and libraries. These
relative paths must be modified when the project is moved to different
relative location.
Stack Size and Heap Size
------------------------
In this project, the size of the C stack and heap are determined in
the linker script pelican-qk.icf (see the next section).
Linker Script
-------------
The IAR linker script provides a template of the recommended linker script
for QP applications. This file needs to be customized to set the
application-specific sizes of the Stack and Heap. This file can be edited
from the IAR EWARM IDE via the Project Options/Linker settings.
Startup Code
------------
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\iar\startup_TM4C123GH6PM.s
The file startup_TM4C123GH6PM.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qk/iar/pelican-qk.ewd
================================================
2DebugARM1C-SPY22811ARMSIM_ID2111ANGEL_ID2011CADI_ID2011CMSISDAP_ID2411GDBSERVER_ID2011IARROM_ID2111IJET_ID2811JLINK_ID21611LMIFTDI_ID2211MACRAIGOR_ID2311PEMICRO_ID2311RDI_ID2211STLINK_ID2311THIRDPARTY_ID2011TIFET_ID2111XDS100_ID2511$TOOLKIT_DIR$\plugins\middleware\HCCWare\HCCWare.ewplugin0$TOOLKIT_DIR$\plugins\middleware\PercepioTraceExporter\PercepioTraceExportPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\AVIX\AVIX.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\MQX\MQXRtosPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\Quadros\Quadros_EWB7_Plugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseARM0C-SPY22810ARMSIM_ID2110ANGEL_ID2010CADI_ID2010CMSISDAP_ID2410GDBSERVER_ID2010IARROM_ID2110IJET_ID2810JLINK_ID21610LMIFTDI_ID2210MACRAIGOR_ID2310PEMICRO_ID2310RDI_ID2210STLINK_ID2310THIRDPARTY_ID2010TIFET_ID2110XDS100_ID2510$TOOLKIT_DIR$\plugins\middleware\HCCWare\HCCWare.ewplugin0$TOOLKIT_DIR$\plugins\middleware\PercepioTraceExporter\PercepioTraceExportPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\AVIX\AVIX.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\MQX\MQXRtosPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\Quadros\Quadros_EWB7_Plugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qk/iar/pelican-qk.ewp
================================================
2DebugARM1General32411ICCARM23111AARM2911OBJCOPY0111CUSTOM30BICOMP0BUILDACTION1ILINK01711IARCHIVE0011BILINK0Coder0ReleaseARM0General32410ICCARM23110AARM2910OBJCOPY0110CUSTOM30BICOMP0BUILDACTION1ILINK01710IARCHIVE0010BILINK0Coder0Application$PROJ_DIR$\..\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\main.c$PROJ_DIR$\..\..\pelican.c$PROJ_DIR$\..\..\pelican.hek-tm4c123gxl$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\iar\startup_TM4C123GH6PM.s$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.c$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.h$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qkn\qkn.cQP_port$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qk\iar\qkn_port.c
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qk/iar/pelican-qk.eww
================================================
$WS_DIR$\pelican-qk.ewp
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qk/iar/pelican-qk.icf
================================================
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0003FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 1024;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place at start of RAM_region {block CSTACK };
place in RAM_region { readwrite, block HEAP };
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qpn_conf.h
================================================
/*****************************************************************************
* Product: QP-nano configuration for the PELICAN example
* Last Updated for Version: 5.6.2
* Date of the Last Update: 2016-04-05
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef QPN_CONF_H
#define QPN_CONF_H
#define Q_PARAM_SIZE 4U
#define QF_MAX_TICK_RATE 1U
#define QF_TIMEEVT_CTR_SIZE 2U
#define QF_TIMEEVT_PERIODIC
#endif /* QPN_CONF_H */
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qv/armclang/README.txt
================================================
About this Example
==================
This example demonstrates how to use the uVision IDE together with
the MDK-ARM toolchain.
***
NOTE: This example requires installing the following Software Pack
in the Keil uVision: Keil::TM4C_DFP.
***
uVision Project File
====================
The MDK-ARM uVision project file provided with this example uses
relative paths to the QP framework location (includes, port, and
libraries. These relative paths must be modified when the project
is moved to different relative location.
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the
command-line options for the ARM assembler (see the Asm tab in
the "Options for Target" dialog box in uVision). Specifically,
you should define symbols: Stack_Size=xxx Heap_Size=yyy, where
xxx represents a numerical value of stack size and yyy the
numerical value of the heap size (for most embedded projects
yyy should be 0, as the using the heap is not recommended).
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.s
The file startup_TM4C123GH6PM.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qv/armclang/pelican-qv.uvoptx
================================================
1.0### uVision Project, (C) Keil Software*.c*.s*; *.src; *.a**.obj; *.o*.lib*.txt; *.h; *.inc*.plm*.cpp000pelican-dbg0x4ARM-ADS120000001110016553500079668.\dbg\11101101000011111110010140111111111111101011001008BIN\lmidk-agdi.dll0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10UL2CM3UL2CM3(-O207 -S0 -C0 -FO7 -FN1 -FC1000 -FD20000000 -FF0TM4C123_256 -FL040000 -FS00 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM)0DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E2006F4 -O4622 -S4 -FO61120x200002000200x40000001000010000000000000000000pelican-rel0x4ARM-ADS120000001110016553500079668.\rel\11101101000011111110010040111111111011101011001008BIN\lmidk-agdi.dll0DLGUARMÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÈ`»
´ª¤ô 0ARMRTXEVENTFLAGS-L70 -Z18 -C0 -M0 -T10DLGTARM(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)0ARMDBGFLAGS0lmidk-agdi-U0E10259B -O4622 -S4 -FO610UL2CM3-O207 -S0 -C0 -FO7 -FN1 -FC1000 -FD20000000 -FF0TM4C123_256 -FL040000 -FS00 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM)120x200002000200x40000001000010000000000000000000Applicatioin1000111000..\bsp.cbsp.c00121000..\..\main.cmain.c00131000..\..\pelican.cpelican.c00145000..\..\pelican.hpelican.h00155000..\..\qpn_conf.hqpn_conf.h00ek-tm4c123gxl1000261000..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.csystem_TM4C123GH6PM.c00275000..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hTM4C123GH6PM.h00285000..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hgpio.h00295000..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hrom.h002105000..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsysctl.h002115000..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hsystem_TM4C123GH6PM.h002122000..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sstartup_TM4C123GH6PM.s00QP10003131000..\..\..\..\..\src\qfn\qepn.cqepn.c003141000..\..\..\..\..\src\qfn\qfn.cqfn.c003151000..\..\..\..\..\src\qvn\qvn.cqvn.c00QP_port10004165000..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqfn_port.h004171000..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.cqvn_port.c00
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qv/armclang/pelican-qv.uvprojx
================================================
2.1### uVision Project, (C) Keil Softwarepelican-dbg0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1TM4C123GH6PMTexas InstrumentsKeil.TM4C_DFP.1.1.0http://www.keil.com/pack/IROM(0x00000000,0x040000) IRAM(0x20000000,0x008000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C123_256 -FS00 -FL040000 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM))0$$Device:TM4C123GH6PM$Device\Include\TM4C123\TM4C123.h$$Device:TM4C123GH6PM$SVD\TM4C123\TM4C123GH6PM.svd0000001.\dbg\pelican-qv10011.\dbg\10000000000000010fromelf --bin --output .\dbg\pelican-qv.bin .\dbg\pelican-qv.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x4000000x00x010x00x010x00x010x00x010x00x4000010x00x000x00x000x00x000x00x000x200000000x800000x00x007001000003010003311000__FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\ek-tm4c123gxl1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cmain.c1..\..\main.cpelican.c1..\..\pelican.cpelican.h5..\..\pelican.hqpn_conf.h5..\..\qpn_conf.hek-tm4c123gxlsystem_TM4C123GH6PM.c1..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.cTM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hgpio.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hrom.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hsysctl.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsystem_TM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hstartup_TM4C123GH6PM.s2..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.cpelican-rel0x4ARM-ADS6130001::V6.13.1::.\ARMCLANG1TM4C123GH6PMTexas InstrumentsKeil.TM4C_DFP.1.1.0http://www.keil.com/pack/IROM(0x00000000,0x040000) IRAM(0x20000000,0x008000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLEUL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TM4C123_256 -FS00 -FL040000 -FP0($$Device:TM4C123GH6PM$Flash\TM4C123_256.FLM))0$$Device:TM4C123GH6PM$Device\Include\TM4C123\TM4C123.h$$Device:TM4C123GH6PM$SVD\TM4C123\TM4C123GH6PM.svd0000001.\rel\pelican-qv10000.\rel\10000000000000010fromelf --bin --output .\rel\pelican-qv.bin .\rel\pelican-qv.axf00001000001000031SARMCM3.DLL -MPUDCM.DLL-pCM4SARMCM3.DLL -MPUTCM.DLL-pCM41000161001140971BIN\UL2CM3.DLL0011111110110000011111111100"Cortex-M4"0001100200080000330000000000100001000x00x000x00x000x00x000x00x000x00x000x00x000x200000000x800010x00x4000000x00x010x00x010x00x010x00x010x00x4000010x00x000x00x000x00x000x00x000x200000000x800000x00x007001000003010003311000NDEBUG __FPU_PRESENT..\..;..\..\..\..\..\include;..\..\..\..\..\ports\arm-cm\qv\armclang;..\..\..\..\..\3rd_party\CMSIS\Include;..\..\..\..\..\3rd_party\ek-tm4c123gxl1000000100Stack_Size=1024 Heap_Size=01000100x000000000x20000000pelican-qv.sct--entry Reset_HandlerApplicatioinbsp.c1..\bsp.cmain.c1..\..\main.cpelican.c1..\..\pelican.cpelican.h5..\..\pelican.hqpn_conf.h5..\..\qpn_conf.hek-tm4c123gxlsystem_TM4C123GH6PM.c1..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.cTM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hgpio.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\gpio.hrom.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\rom.hsysctl.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\sysctl.hsystem_TM4C123GH6PM.h5..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.hstartup_TM4C123GH6PM.s2..\..\..\..\..\3rd_party\ek-tm4c123gxl\arm\startup_TM4C123GH6PM.sQPqepn.c1..\..\..\..\..\src\qfn\qepn.cqfn.c1..\..\..\..\..\src\qfn\qfn.cqvn.c1..\..\..\..\..\src\qvn\qvn.cQP_portqfn_port.h5..\..\..\..\..\ports\arm-cm\qv\armclang\qfn_port.hqvn_port.c1..\..\..\..\..\ports\arm-cm\qv\armclang\qvn_port.c
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qv/bsp.c
================================================
/*****************************************************************************
* Product: PELICAN on EK-TM4C123GXL board, cooperative QV kernel
* Last Updated for Version: 5.6.0
* Date of the Last Update: 2016-11-06
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "bsp.h"
#include "pelican.h"
#include "TM4C123GH6PM.h" /* the device specific header (TI) */
#include "rom.h" /* the built-in ROM functions (TI) */
#include "sysctl.h" /* system control driver (TI) */
#include "gpio.h" /* GPIO driver (TI) */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
enum KernelUnawareISRs { /* see NOTE00 */
/* ... */
MAX_KERNEL_UNAWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-unaware" interrupts can't overlap "kernel-aware" interrupts */
Q_ASSERT_COMPILE(MAX_KERNEL_UNAWARE_CMSIS_PRI <= QF_AWARE_ISR_CMSIS_PRI);
enum KernelAwareISRs {
SYSTICK_PRIO = QF_AWARE_ISR_CMSIS_PRI, /* see NOTE00 */
/* ... */
MAX_KERNEL_AWARE_CMSIS_PRI /* keep always last */
};
/* "kernel-aware" interrupts should not overlap the PendSV priority */
Q_ASSERT_COMPILE(MAX_KERNEL_AWARE_CMSIS_PRI <= (0xFF >>(8-__NVIC_PRIO_BITS)));
/* ISRs defined in this BSP ------------------------------------------------*/
void SysTick_Handler(void);
void GPIOPortA_IRQHandler(void);
/* Local-scope objects -----------------------------------------------------*/
#define LED_RED (1U << 1)
#define LED_GREEN (1U << 3)
#define LED_BLUE (1U << 2)
#define BTN_SW1 (1U << 4)
#define BTN_SW2 (1U << 0)
/* ISRs used in this project ===============================================*/
void SysTick_Handler(void) {
/* state of the button debouncing, see below */
static struct ButtonsDebouncing {
uint32_t depressed;
uint32_t previous;
} buttons = { ~0U, ~0U };
uint32_t current;
uint32_t tmp;
QF_tickXISR(0U); /* process time events for rate 0 */
/* Perform the debouncing of buttons. The algorithm for debouncing
* adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
* and Michael Barr, page 71.
*/
current = ~GPIOF->DATA_Bits[BTN_SW1 | BTN_SW2]; /* read SW1 and SW2 */
tmp = buttons.depressed; /* save the debounced depressed buttons */
buttons.depressed |= (buttons.previous & current); /* set depressed */
buttons.depressed &= (buttons.previous | current); /* clear released */
buttons.previous = current; /* update the history */
tmp ^= buttons.depressed; /* changed debounced depressed */
if ((tmp & BTN_SW1) != 0U) { /* debounced SW1 state changed? */
if ((buttons.depressed & BTN_SW1) != 0U) { /* is SW1 depressed? */
QACTIVE_POST_ISR((QActive *)&AO_Pelican, PEDS_WAITING_SIG, 0U);
}
else { /* the button is released */
}
}
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* NOTE: SystemInit() already called from the startup code
* but SystemCoreClock needs to be updated
*/
SystemCoreClockUpdate();
/* configure the FPU usage by choosing one of the options...
*
* Do NOT to use the automatic FPU state preservation and
* do NOT to use the FPU lazy stacking.
*
* NOTE:
* Use the following setting when FPU is used only by active objects
* and NOT in any ISR. This setting is very efficient, but if any ISRs
* start using the FPU, this can lead to corruption of the FPU registers.
*/
FPU->FPCCR &= ~((1U << FPU_FPCCR_ASPEN_Pos) | (1U << FPU_FPCCR_LSPEN_Pos));
/* enable clock for to the peripherals used by this application... */
SYSCTL->RCGCGPIO |= (1U << 5); /* enable Run mode for GPIOF */
/* configure the LEDs and push buttons */
GPIOF->DIR |= (LED_RED | LED_GREEN | LED_BLUE);/* set direction: output */
GPIOF->DEN |= (LED_RED | LED_GREEN | LED_BLUE); /* digital enable */
GPIOF->DATA_Bits[LED_RED] = 0; /* turn the LED off */
GPIOF->DATA_Bits[LED_GREEN] = 0; /* turn the LED off */
GPIOF->DATA_Bits[LED_BLUE] = 0; /* turn the LED off */
/* configure the Buttons */
GPIOF->DIR &= ~(BTN_SW1 | BTN_SW2); /* set direction: input */
ROM_GPIOPadConfigSet(GPIOF_BASE, (BTN_SW1 | BTN_SW2),
GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
}
/*..........................................................................*/
void BSP_showState(char_t const *state) {
(void)state;
}
/*..........................................................................*/
void BSP_signalCars(enum BSP_CarsSignal sig) {
switch (sig) {
case CARS_RED: {
//GPIOF->DATA_Bits[LED_RED] = LED_RED;
break;
}
case CARS_YELLOW: {
//GPIOF->DATA_Bits[LED_RED | LED_GREEN] = (LED_RED | LED_GREEN);
break;
}
case CARS_GREEN: {
//GPIOF->DATA_Bits[LED_GREEN] = LED_GREEN;
break;
}
case CARS_BLANK: {
//GPIOF->DATA_Bits[LED_RED | LED_GREEN | LED_BLUE] = 0U;
break;
}
}
}
/*..........................................................................*/
void BSP_signalPeds(enum BSP_PedsSignal sig) {
switch (sig) {
case PEDS_DONT_WALK: {
GPIOF->DATA_Bits[LED_RED] = LED_RED;
break;
}
case PEDS_BLANK: {
GPIOF->DATA_Bits[LED_RED | LED_GREEN] = 0U;
break;
}
case PEDS_WALK: {
GPIOF->DATA_Bits[LED_RED | LED_GREEN] = LED_GREEN;
break;
}
}
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set up the SysTick timer to fire at BSP_TICKS_PER_SEC rate */
SysTick_Config(SystemCoreClock / BSP_TICKS_PER_SEC);
/* assing all priority bits for preemption-prio. and none to sub-prio. */
NVIC_SetPriorityGrouping(0U);
/* set priorities of ALL ISRs used in the system, see NOTE00
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* Assign a priority to EVERY ISR explicitly by calling NVIC_SetPriority().
* DO NOT LEAVE THE ISR PRIORITIES AT THE DEFAULT VALUE!
*/
NVIC_SetPriority(SysTick_IRQn, SYSTICK_PRIO);
/* ... */
/* enable IRQs... */
}
/*..........................................................................*/
void QF_stop(void) {
}
/*..........................................................................*/
void QV_onIdle(void) { /* CATION: called with interrupts DISABLED, NOTE01 */
/* toggle LED2 on and then off, see NOTE02 */
GPIOF->DATA_Bits[LED_BLUE] = 0xFFU;
GPIOF->DATA_Bits[LED_BLUE] = 0x00U;
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular Cortex-M MCU.
*/
QV_CPU_SLEEP(); /* atomically go to sleep and enable interrupts */
#else
QF_INT_ENABLE(); /* just enable interrupts */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int loc) {
/*
* NOTE: add here your application-specific error handling
*/
(void)module;
(void)loc;
NVIC_SystemReset();
}
/*****************************************************************************
* NOTE00:
* The QF_AWARE_ISR_CMSIS_PRI constant from the QF port specifies the highest
* ISR priority that is disabled by the QF framework. The value is suitable
* for the NVIC_SetPriority() CMSIS function.
*
* Only ISRs prioritized at or below the QF_AWARE_ISR_CMSIS_PRI level (i.e.,
* with the numerical values of priorities equal or higher than
* QF_AWARE_ISR_CMSIS_PRI) are allowed to call any QF services. These ISRs
* are "QF-aware".
*
* Conversely, any ISRs prioritized above the QF_AWARE_ISR_CMSIS_PRI priority
* level (i.e., with the numerical values of priorities less than
* QF_AWARE_ISR_CMSIS_PRI) are never disabled and are not aware of the kernel.
* Such "QF-unaware" ISRs cannot call any QF services. The only mechanism
* by which a "QF-unaware" ISR can communicate with the QF framework is by
* triggering a "QF-aware" ISR, which can post/publish events.
*
* NOTE01:
* The QV_onIdle() callback is called with interrupts disabled, because the
* determination of the idle condition might change by any interrupt posting
* an event. QV_onIdle() must internally enable interrupts, ideally
* atomically with putting the CPU to the power-saving mode.
*
* NOTE02:
* One of the LEDs is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qv/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano on EK-TM4C123GXL, QV-nano, GNU-ARM
# Last Updated for Version: 6.5.0
# Date of the Last Update: 2019-04-15
#
# Q u a n t u m L e a P s
# ------------------------
# Modern Embedded Software
#
# Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# https://www.state-machine.com
# mailto:info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := pelican-qv
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/arm-cm/qv/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qvn \
$(QP_PORT_DIR) \
$(QPN)/3rd_party/ek-tm4c123gxl \
$(QPN)/3rd_party/ek-tm4c123gxl/gnu
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR) \
-I$(QPN)/3rd_party/CMSIS/Include \
-I$(QPN)/3rd_party/ek-tm4c123gxl
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
pelican.c \
bsp.c \
main.c \
system_TM4C123GH6PM.c \
startup_TM4C123GH6PM.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qepn.c \
qfn.c \
qvn.c \
qvn_port.c
QP_ASMS :=
LIB_DIRS :=
LIBS :=
# defines
DEFINES :=
# ARM CPU, ARCH, FPU, and Float-ABI types...
# ARM_CPU: [cortex-m0 | cortex-m0plus | cortex-m1 | cortex-m3 | cortex-m4]
# ARM_ARCH: [6 | 7] (NOTE: must match ARM_CPU!)
# ARM_FPU: [ | vfp]
# FLOAT_ABI: [ | soft | softfp | hard]
#
ARM_CPU := -mcpu=cortex-m4
ARM_ARCH := 7 # NOTE: must match the ARM_CPU!
ARM_FPU := -mfpu=vfp
FLOAT_ABI := -mfloat-abi=softfp
#-----------------------------------------------------------------------------
# GNU-ARM toolset (NOTE: You need to adjust to your machine)
# see https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
#
ifeq ($(GNU_ARM),)
GNU_ARM := $(QTOOLS)/gnu_arm-none-eabi
endif
# make sure that the GNU-ARM toolset exists...
ifeq ("$(wildcard $(GNU_ARM))","")
$(error GNU_ARM toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_ARM)/bin/arm-none-eabi-gcc
CPP := $(GNU_ARM)/bin/arm-none-eabi-g++
AS := $(GNU_ARM)/bin/arm-none-eabi-as
LINK := $(GNU_ARM)/bin/arm-none-eabi-g++
BIN := $(GNU_ARM)/bin/arm-none-eabi-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M
#
# combine all the soruces...
C_SRCS += $(QP_SRCS)
ASM_SRCS += $(QP_ASMS)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS = $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration ..........................................
BIN_DIR := dbg
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
CFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections \
-O $(INCLUDES) $(DEFINES)
CPPFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES)
endif # ......................................................................
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
-specs=nosys.specs -specs=nano.specs \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_BIN := $(BIN_DIR)/$(OUTPUT).bin
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_BIN)
#all: $(TARGET_ELF)
$(TARGET_BIN): $(TARGET_ELF)
$(BIN) -O binary $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(CC) $(CFLAGS) $(QPN)/include/qstamp.c -o $(BIN_DIR)/qstamp.o
$(LINK) $(LINKFLAGS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.bin \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qv/gnu/README.txt
================================================
About this Example
==================
This example can be built from the command prompt with the provided
Makefile. The example can also be imported as a Makefile-based
project into Eclipse-based IDEs.
The Makefile
============
The provided Makefile should be easy to adapt for your own projects.
It contains three build configurations: Debug (default), Release, and
Spy.
Also, the Makefile has been specifically designed to work as an external
Makefile with the Eclipse CDT.
The various build configurations are built as follows:
make
make CONF=rel
make CONF=spy
make clean
make CONF=rel clean
make CONF=spy clean
***
NOTE:
The installation folder of the GNU-ARM toolset on YOUR machine needs
to be adjusted in the provided Makefile, by editing the symbol: GNU_ARM.
As described in the comment for this symbol, the GNU-ARM toolset is taken
from: http://gnutoolchains.com/arm-eabi
It is highly recommened to use the same GNU-ARM distribution, especially
for ARM Cortex-M4F projects, due to the support for the hardware FPU
(float-abi=hard).
***
Adjusting Stack and Heap Sizes
==============================
The stack and heap sizes are determined in this project by the GCC linker
script (.ld file), which provides a template of the recommended GCC linker
script for QP applications.
Startup Code
============
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\gcc\startup_TM4C123GH6PM.c
The file startup_TM4C123GH6PM.c provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qv/gnu/flash.bat
================================================
::============================================================================
:: Batch file to program the flash of EK-TM4C123GXL
::
:: NOTE: requires the LMFlash programmer (included in QTools for Windows)
::
@echo off
setlocal
@echo Load a given binary file to the flash of EK-TM4C123GXL
@echo usage: flash binary-file
@echo example: flash dbg\blinky-qk.bin
::----------------------------------------------------------------------------
:: NOTE: The following symbol LMFLASH assumes that LMFlash.exe can
:: be found on the PATH. You might need to adjust this symbol to the
:: location of the LMFlash utility on your machine
::
set LMFLASH=LMFlash.exe
if ["%~1"]==[""] (
@echo The binary file missing
@goto end
)
if not exist %~s1 (
@echo The binary file '%1' does not exist
@goto end
)
%LMFLASH% -q ek-tm4c123gxl -e -v -r %1
:end
endlocal
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qv/gnu/pelican-qv.ld
================================================
/*****************************************************************************
* Product: Linker script for EK-TM4C123GXL, GNU-ARM linker
* Last Updated for Version: 5.9.8
* Date of the Last Update: 2017-09-13
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* Web : http://www.state-machine.com
* Email: info@state-machine.com
*****************************************************************************/
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(Reset_Handler) /* entry Point */
MEMORY { /* memory map of Tiva TM4C123GH6PM */
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 256K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
}
/* The size of the stack used by the application. NOTE: you need to adjust */
STACK_SIZE = 1024;
/* The size of the heap used by the application. NOTE: you need to adjust */
HEAP_SIZE = 0;
SECTIONS {
.isr_vector : { /* the vector table goes FIRST into ROM */
KEEP(*(.isr_vector)) /* vector table */
. = ALIGN(4);
} >ROM
.text : { /* code and constants */
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} >ROM
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >ROM
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >ROM
.fini_array : {
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array*))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >ROM
_etext = .; /* global symbols at end of code */
.stack : {
__stack_start__ = .;
. = . + STACK_SIZE;
. = ALIGN(4);
__stack_end__ = .;
} >RAM
.data : AT (_etext) {
__data_load = LOADADDR (.data);
__data_start = .;
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
__data_end__ = .;
_edata = __data_end__;
} >RAM
.bss : {
__bss_start__ = .;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = .;
} >RAM
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >RAM
__exidx_end = .;
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );
PROVIDE ( __end__ = _ebss );
.heap : {
__heap_start__ = .;
. = . + HEAP_SIZE;
. = ALIGN(4);
__heap_end__ = .;
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ : {
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
}
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qv/iar/README.txt
================================================
About this Example
==================
This example demonstrates how to use the IAR EWARM IDE to build
a QP application.
IAR Project File
----------------
The IAR EWARM project file provided with this example uses relative paths
to the QP-nano framework location. These relative paths must be modified
when the project is moved to different relative location.
Stack Size and Heap Size
------------------------
In this project, the size of the C stack and heap are determined in
the linker script pelican-qv.icf (see the next section).
Linker Script
-------------
The IAR linker script provides a template of the recommended linker script
for QP applications. This file needs to be customized to set the
application-specific sizes of the Stack and Heap. This file can be edited
from the IAR EWARM IDE via the Project Options/Linker settings.
Startup Code
------------
The startup code for the TM4C123GH6PM MCU used in this project is
located in the "3rd_party" folder in the following location:
3rd_party\ek-tm4c123gxl\iar\startup_TM4C123GH6PM.s
The file startup_TM4C123GH6PM.s provides a template of the recommended
startup for QP applications and should be easily customizable for other
ARM Cortex-M microcontrollers.
The startup file typically does not need to be modified or adapted for
applications. It provides only weak definitions of all exception and
interrupt handlers, as well as the assert_failed() function.
The weak function assert_failed() defined in this file might be re-defined
in the application to customize it for the application-specific error-
handling policy.
***
NOTE: The function assert_failed() typically should NOT use the stack,
because stack might be corrupted by the time this function is called.
Also, assert_failed() is intended to handle catastrophic errors and
should NOT return.
***
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qv/iar/pelican-qv.ewd
================================================
3DebugARM1C-SPY22811ARMSIM_ID2111CADI_ID2011CMSISDAP_ID2411GDBSERVER_ID2011IJET_ID2811JLINK_ID21611LMIFTDI_ID2211PEMICRO_ID2311STLINK_ID2411THIRDPARTY_ID2011TIFET_ID2111XDS100_ID2611$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseARM0C-SPY22810ARMSIM_ID2110CADI_ID2010CMSISDAP_ID2410GDBSERVER_ID2010IJET_ID2810JLINK_ID21610LMIFTDI_ID2210PEMICRO_ID2310STLINK_ID2410THIRDPARTY_ID2010TIFET_ID2110XDS100_ID2610$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qv/iar/pelican-qv.ewp
================================================
3DebugARM1General32811ICCARM23411AARM21011OBJCOPY0111CUSTOM30BICOMP0BUILDACTION1ILINK02011IARCHIVE0011BILINK0Coder0ReleaseARM0General32810ICCARM23410AARM21010OBJCOPY0110CUSTOM30BICOMP0BUILDACTION1ILINK02010IARCHIVE0010BILINK0Coder0Application$PROJ_DIR$\..\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\main.c$PROJ_DIR$\..\..\pelican.c$PROJ_DIR$\..\..\pelican.h$PROJ_DIR$\..\..\qpn_conf.hek-tm4c123gxl$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\iar\startup_TM4C123GH6PM.s$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.c$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\system_TM4C123GH6PM.h$PROJ_DIR$\..\..\..\..\..\3rd_party\ek-tm4c123gxl\TM4C123GH6PM.hQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qvn\qvn.cQP_port$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qv\iar\qfn_port.h$PROJ_DIR$\..\..\..\..\..\ports\arm-cm\qv\iar\qvn_port.c
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qv/iar/pelican-qv.eww
================================================
$WS_DIR$\pelican-qv.ewp
================================================
FILE: examples/arm-cm/pelican_ek-tm4c123gxl/qv/iar/pelican-qv.icf
================================================
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0003FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 1024;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place at start of RAM_region {block CSTACK };
place in RAM_region { readwrite, block HEAP };
================================================
FILE: examples/arm7-9/README.url
================================================
[InternetShortcut]
URL=http://www.state-machine.com/qpn/exa_arm7-9.html
IconFile=http://www.state-machine.com/qp.ico
================================================
FILE: examples/arm7-9/dpp_at91sam7s-ek/README.url
================================================
[InternetShortcut]
URL=http://www.state-machine.com/qpn/arm7-9_dpp_at91sam7s-ek.html
IconFile=http://www.state-machine.com/qp.ico
================================================
FILE: examples/arm7-9/dpp_at91sam7s-ek/bsp.h
================================================
/*****************************************************************************
* Product: DPP example
* Last Updated for Version: 5.4.0
* Date of the Last Update: 2015-03-07
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* Web : www.state-machine.com
*
*****************************************************************************/
#ifndef BSP_H
#define BSP_H
#define BSP_TICKS_PER_SEC 100U
void BSP_init(void);
void BSP_displayPaused(uint8_t paused);
void BSP_displayPhilStat(uint8_t n, char_t const *stat);
void BSP_terminate(int16_t result);
void BSP_randomSeed(uint32_t seed); /* random seed */
uint32_t BSP_random(void); /* pseudo-random generator */
#endif /* BSP_H */
================================================
FILE: examples/arm7-9/dpp_at91sam7s-ek/dpp.h
================================================
/*.$file${.::dpp.h} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: dpp.qm
* File: ${.::dpp.h}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::dpp.h} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#ifndef DPP_H
#define DPP_H
enum DPPSignals {
EAT_SIG = Q_USER_SIG, /* published by Table to let a philosopher eat */
DONE_SIG, /* published by Philosopher when done eating */
PAUSE_SIG, /* published by BSP to pause the application */
SERVE_SIG, /* published by BSP to pause the application */
TERMINATE_SIG, /* published by BSP to terminate the application */
HUNGRY_SIG, /* posted direclty to Table from hungry Philo */
MAX_SIG /* the last signal */
};
/* number of philosophers */
#define N_PHILO ((uint8_t)5)
#define PHILO_0_PRIO 1
/*.$declare${AOs::AO_Philo0} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo0;
/*.$enddecl${AOs::AO_Philo0} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo1} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo1;
/*.$enddecl${AOs::AO_Philo1} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo2} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo2;
/*.$enddecl${AOs::AO_Philo2} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo3} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo3;
/*.$enddecl${AOs::AO_Philo3} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo4} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo4;
/*.$enddecl${AOs::AO_Philo4} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Table AO_Table;
/*.$enddecl${AOs::AO_Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::Philo_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo_ctor} ......................................................*/
void Philo_ctor(void);
/*.$enddecl${AOs::Philo_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::Table_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table_ctor} ......................................................*/
void Table_ctor(void);
/*.$enddecl${AOs::Table_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#endif /* DPP_H */
================================================
FILE: examples/arm7-9/dpp_at91sam7s-ek/dpp.qm
================================================
Dining Philosopher Problem example with QActiveQActive_armX(&me->super, 0U, THINK_TIME, 0U);QActive_disarmX(&me->super, 0U);Q_ERROR(); /* these events should never arrive in this state */QACTIVE_POST(&AO_Table, HUNGRY_SIG, me->super.prio);Q_ERROR(); /* this event should never arrive in this state */QActive_armX(&me->super, 0U, EAT_TIME, 0U);QActive_disarmX(&me->super, 0U);
QACTIVE_POST(QF_ACTIVE_CAST(&AO_Table), DONE_SIG, me->super.prio);Q_ERROR(); /* these events should never arrive in this state */uint8_t n;
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "thinking");
}BSP_terminate(0);Q_ERROR();uint8_t n;
for (n = 0U; n < N_PHILO; ++n) { /* give permissions to eat... */
if ((me->isHungry[n] != 0U)
&& (me->fork[LEFT(n)] == FREE)
&& (me->fork[n] == FREE))
{
QActive *philo;
me->fork[LEFT(n)] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "eating ");
}
}uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "hungry ");
m = LEFT(n);(me->fork[m] == FREE) && (me->fork[n] == FREE)me->fork[m] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
BSP_displayPhilStat(n, "eating ");elseme->isHungry[n] = 1U;uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;
m = RIGHT(n); /* check the right neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[m] == FREE)) {
me->fork[n] = USED;
me->fork[m] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}
m = LEFT(n); /* check the left neighbor */
n = LEFT(m); /* left fork of the left neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[n] == FREE)) {
me->fork[m] = USED;
me->fork[n] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}Q_ERROR();BSP_displayPaused(1U);BSP_displayPaused(0U);uint8_t n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* philo ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
me->isHungry[n] = 1U;
BSP_displayPhilStat(n, "hungry ");uint8_t n, m;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;QActive_ctor(&AO_Philo0.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo1.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo2.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo3.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo4.super, Q_STATE_CAST(&Philo_initial));
BSP_randomSeed(123U);uint8_t n;
Table *me = &AO_Table;
QActive_ctor(&me->super, Q_STATE_CAST(&Table_initial));
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
}#ifndef DPP_H
#define DPP_H
enum DPPSignals {
EAT_SIG = Q_USER_SIG, /* published by Table to let a philosopher eat */
DONE_SIG, /* published by Philosopher when done eating */
PAUSE_SIG, /* published by BSP to pause the application */
SERVE_SIG, /* published by BSP to pause the application */
TERMINATE_SIG, /* published by BSP to terminate the application */
HUNGRY_SIG, /* posted direclty to Table from hungry Philo */
MAX_SIG /* the last signal */
};
/* number of philosophers */
#define N_PHILO ((uint8_t)5)
#define PHILO_0_PRIO 1
$declare${AOs::AO_Philo0}
$declare${AOs::AO_Philo1}
$declare${AOs::AO_Philo2}
$declare${AOs::AO_Philo3}
$declare${AOs::AO_Philo4}
$declare${AOs::AO_Table}
$declare${AOs::Philo_ctor}
$declare${AOs::Table_ctor}
#endif /* DPP_H */
#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("philo")
/* Active object class -----------------------------------------------------*/
$declare${AOs::Philo}
/* Global objects ----------------------------------------------------------*/
$define${AOs::AO_Philo0}
$define${AOs::AO_Philo1}
$define${AOs::AO_Philo2}
$define${AOs::AO_Philo3}
$define${AOs::AO_Philo4}
/* Local objects -----------------------------------------------------------*/
#define THINK_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + (BSP_TICKS_PER_SEC/2U))
#define EAT_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + BSP_TICKS_PER_SEC)
/* Philo definition --------------------------------------------------------*/
$define${AOs::Philo_ctor}
$define${AOs::Philo}#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("table")
/* Active object class -----------------------------------------------------*/
$declare${AOs::Table}
/* Global objects ----------------------------------------------------------*/
$define${AOs::AO_Table}
#define RIGHT(n_) ((uint8_t)(((n_) + (N_PHILO - 1U)) % N_PHILO))
#define LEFT(n_) ((uint8_t)(((n_) + 1U) % N_PHILO))
#define FREE ((uint8_t)0)
#define USED ((uint8_t)1)
/*..........................................................................*/
$define${AOs::Table_ctor}
$define${AOs::Table}
================================================
FILE: examples/arm7-9/dpp_at91sam7s-ek/main.c
================================================
/*****************************************************************************
* Product: DPP example
* Last Updated for Version: 5.8.0
* Date of the Last Update: 2016-11-06
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h" /* QP-nano */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
/*..........................................................................*/
static QEvt l_philoQueue[N_PHILO][N_PHILO];
static QEvt l_tableQueue[2];
/* QF_active[] array defines all active object control blocks --------------*/
QActiveCB const Q_ROM QF_active[] = {
{ (QActive *)0, (QEvt *)0, 0U },
{ (QActive *)&AO_Philo0, l_philoQueue[0], Q_DIM(l_philoQueue[0]) },
{ (QActive *)&AO_Philo1, l_philoQueue[1], Q_DIM(l_philoQueue[1]) },
{ (QActive *)&AO_Philo2, l_philoQueue[2], Q_DIM(l_philoQueue[2]) },
{ (QActive *)&AO_Philo3, l_philoQueue[3], Q_DIM(l_philoQueue[3]) },
{ (QActive *)&AO_Philo4, l_philoQueue[4], Q_DIM(l_philoQueue[4]) },
{ (QActive *)&AO_Table, l_tableQueue, Q_DIM(l_tableQueue) }
};
/*..........................................................................*/
int_t main() {
Philo_ctor(); /* instantiate all Philo AOs */
Table_ctor(); /* instantiate the Table AO */
QF_init(Q_DIM(QF_active)); /* initialize the QF-nano framework */
BSP_init(); /* initialize the Board Support Package */
return QF_run(); /* transfer control to QF-nano */
}
================================================
FILE: examples/arm7-9/dpp_at91sam7s-ek/philo.c
================================================
/*.$file${.::philo.c} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: dpp.qm
* File: ${.::philo.c}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::philo.c} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("philo")
/* Active object class -----------------------------------------------------*/
/*.$declare${AOs::Philo} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo} ...........................................................*/
typedef struct Philo {
/* protected: */
QActive super;
} Philo;
/* protected: */
static QState Philo_initial(Philo * const me);
static QState Philo_thinking(Philo * const me);
static QState Philo_hungry(Philo * const me);
static QState Philo_eating(Philo * const me);
/*.$enddecl${AOs::Philo} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Global objects ----------------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*. Check for the minimum required QP version */
#if (QP_VERSION < 650U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpn version 6.5.0 or higher required
#endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo0} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo0} .......................................................*/
struct Philo AO_Philo0;
/*.$enddef${AOs::AO_Philo0} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo1} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo1} .......................................................*/
struct Philo AO_Philo1;
/*.$enddef${AOs::AO_Philo1} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo2} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo2} .......................................................*/
struct Philo AO_Philo2;
/*.$enddef${AOs::AO_Philo2} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo3} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo3} .......................................................*/
struct Philo AO_Philo3;
/*.$enddef${AOs::AO_Philo3} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo4} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo4} .......................................................*/
struct Philo AO_Philo4;
/*.$enddef${AOs::AO_Philo4} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Local objects -----------------------------------------------------------*/
#define THINK_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + (BSP_TICKS_PER_SEC/2U))
#define EAT_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + BSP_TICKS_PER_SEC)
/* Philo definition --------------------------------------------------------*/
/*.$define${AOs::Philo_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo_ctor} ......................................................*/
void Philo_ctor(void) {
QActive_ctor(&AO_Philo0.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo1.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo2.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo3.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo4.super, Q_STATE_CAST(&Philo_initial));
BSP_randomSeed(123U);
}
/*.$enddef${AOs::Philo_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Philo} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo} ...........................................................*/
/*.${AOs::Philo::SM} .......................................................*/
static QState Philo_initial(Philo * const me) {
/*.${AOs::Philo::SM::initial} */
return Q_TRAN(&Philo_thinking);
}
/*.${AOs::Philo::SM::thinking} .............................................*/
static QState Philo_thinking(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Philo::SM::thinking} */
case Q_ENTRY_SIG: {
QActive_armX(&me->super, 0U, THINK_TIME, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::thinking} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::thinking::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Philo_hungry);
break;
}
/*.${AOs::Philo::SM::thinking::EAT, DONE} */
case EAT_SIG: /* intentionally fall through */
case DONE_SIG: {
Q_ERROR(); /* these events should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Philo::SM::hungry} ...............................................*/
static QState Philo_hungry(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Philo::SM::hungry} */
case Q_ENTRY_SIG: {
QACTIVE_POST(&AO_Table, HUNGRY_SIG, me->super.prio);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::hungry::EAT} */
case EAT_SIG: {
status_ = Q_TRAN(&Philo_eating);
break;
}
/*.${AOs::Philo::SM::hungry::DONE} */
case DONE_SIG: {
Q_ERROR(); /* this event should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Philo::SM::eating} ...............................................*/
static QState Philo_eating(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Philo::SM::eating} */
case Q_ENTRY_SIG: {
QActive_armX(&me->super, 0U, EAT_TIME, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::eating} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
QACTIVE_POST(QF_ACTIVE_CAST(&AO_Table), DONE_SIG, me->super.prio);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::eating::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Philo_thinking);
break;
}
/*.${AOs::Philo::SM::eating::EAT, DONE} */
case EAT_SIG: /* intentionally fall through */
case DONE_SIG: {
Q_ERROR(); /* these events should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.$enddef${AOs::Philo} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
================================================
FILE: examples/arm7-9/dpp_at91sam7s-ek/qk/iar/at91SAM7S64.icf
================================================
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\a_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00100000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00100000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0010FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x00200000;
define symbol __ICFEDIT_region_RAM_end__ = 0x00203FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x400;
define symbol __ICFEDIT_size_svcstack__ = 0;
define symbol __ICFEDIT_size_irqstack__ = 0;
define symbol __ICFEDIT_size_fiqstack__ = 0;
define symbol __ICFEDIT_size_undstack__ = 0;
define symbol __ICFEDIT_size_abtstack__ = 0;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region VEC_region = mem:[from __ICFEDIT_region_RAM_start__ size 0x40];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ + 0x40 to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block SVC_STACK with alignment = 8, size = __ICFEDIT_size_svcstack__ { };
define block IRQ_STACK with alignment = 8, size = __ICFEDIT_size_irqstack__ { };
define block FIQ_STACK with alignment = 8, size = __ICFEDIT_size_fiqstack__ { };
define block UND_STACK with alignment = 8, size = __ICFEDIT_size_undstack__ { };
define block ABT_STACK with alignment = 8, size = __ICFEDIT_size_abtstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place in VEC_region { section .vectors };
place in RAM_region { readwrite,
block CSTACK, block SVC_STACK, block IRQ_STACK, block FIQ_STACK,
block UND_STACK, block ABT_STACK, block HEAP };
================================================
FILE: examples/arm7-9/dpp_at91sam7s-ek/qk/iar/bsp.c
================================================
/*****************************************************************************
* Product: DPP on AT91SAM7S-EK board, preemptive QK kernel
* Last Updated for Version: 5.5.1
* Date of the Last Update: 2015-10-05
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "dpp.h"
#include "bsp.h"
#include "AT91SAM7S64.h" /* Atmel AT91SAM7S64 MCU */
//Q_DEFINE_THIS_FILE
#pragma diag_suppress=Ta021 /* call __iar_disable_interrupt from __ramfunc */
#pragma diag_suppress=Ta022 /* possible ROM access from __ramfunc */
#pragma diag_suppress=Ta023 /* call to non __ramfunc from __ramfunc */
/* Local objects -----------------------------------------------------------*/
typedef void (*IntVector)(void); /* IntVector pointer-to-function */
uint32_t get_MCK_FREQ(void); /* CPU clock set up in __low_level_init() */
uint32_t const l_led[] = {
(1U << 0), /* LED D1 on AT91SAM7S-EK */
(1U << 1), /* LED D2 on AT91SAM7S-EK */
(1U << 2), /* LED D3 on AT91SAM7S-EK */
(1U << 3) /* LED D4 on AT91SAM7S-EK */
};
#define LED_ON(num_) (AT91C_BASE_PIOA->PIO_CODR = l_led[num_])
#define LED_OFF(num_) (AT91C_BASE_PIOA->PIO_SODR = l_led[num_])
uint32_t const l_btn[] = {
(1U << 19), /* BTN P1 on AT91SAM7S-EK */
(1U << 20), /* BTN P2 on AT91SAM7S-EK */
(1U << 14), /* BTN P3 on AT91SAM7S-EK */
(1U << 15) /* BTN P4 on AT91SAM7S-EK */
};
/* random seed */
static uint32_t l_rnd;
/* ISRs and ISR "wrappers" ================================================*/
__ramfunc
void BSP_irq(void) {
IntVector vect = (IntVector)AT91C_BASE_AIC->AIC_IVR; /* read the IVR */
AT91C_BASE_AIC->AIC_IVR = (AT91_REG)vect; /* write AIC_IVR if protected */
QF_INT_ENABLE(); /* allow nesting interrupts */
(*vect)(); /* call the IRQ ISR via the pointer to function */
QF_INT_DISABLE(); /* disable interrups for the exit sequence */
AT91C_BASE_AIC->AIC_EOICR = 0; /* write AIC_EOICR to clear interrupt */
}
/* ISRs --------------------------------------------------------------------*/
__ramfunc
static void ISR_tick(void) {
/* state of the button debouncing, see below */
static struct ButtonsDebouncing {
uint32_t depressed;
uint32_t previous;
} buttons = { ~0U, ~0U };
uint32_t current;
uint32_t volatile tmp;
/* clear the interrupt source */
tmp = AT91C_BASE_PITC->PITC_PIVR;
QF_tickXISR(0U); /* process time events for rate 0 */
/* Perform the debouncing of buttons. The algorithm for debouncing
* adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
* and Michael Barr, page 71.
*/
current = ~AT91C_BASE_PIOA->PIO_PDSR;/* read PIOA with state of Buttons */
tmp = buttons.depressed; /* save the debounced depressed buttons */
buttons.depressed |= (buttons.previous & current); /* set depressed */
buttons.depressed &= (buttons.previous | current); /* clear released */
buttons.previous = current; /* update the history */
tmp ^= buttons.depressed; /* changed debounced depressed */
if ((tmp & l_btn[0]) != 0U) { /* debounced BTN_P1 state changed? */
if ((buttons.depressed & l_btn[0]) != 0U) { /* is BTN_P1 depressed? */
QACTIVE_POST_ISR(&AO_Table, PAUSE_SIG, 0U);
}
else { /* the button is released */
QACTIVE_POST_ISR(&AO_Table, SERVE_SIG, 0U);
}
}
}
/*..........................................................................*/
__ramfunc
static void ISR_spur(void) {
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
uint32_t i;
/* When using the JTAG debugger the AIC might not be initialised
* to the correct default state. This line ensures that AIC does not
* mask all interrupts at the start.
*/
AT91C_BASE_AIC->AIC_EOICR = 0U;
/* enable peripheral clock for PIOA */
AT91C_BASE_PMC->PMC_PCER = (1U << AT91C_ID_PIOA);
/* initialize the LEDs... */
for (i = 0; i < Q_DIM(l_led); ++i) {
AT91C_BASE_PIOA->PIO_PER = l_led[i]; /* enable pin */
AT91C_BASE_PIOA->PIO_OER = l_led[i]; /* configure as output pin */
LED_OFF(i); /* extinguish the LED */
}
/* initialize the Buttons... */
for (i = 0; i < Q_DIM(l_btn); ++i) {
AT91C_BASE_PIOA->PIO_ODR = l_btn[i]; /* disable output (input pin) */
AT91C_BASE_PIOA->PIO_PER = l_btn[i]; /* enable pin */
}
/* configure Advanced Interrupt Controller (AIC) of AT91... */
AT91C_BASE_AIC->AIC_IDCR = ~0; /* disable all interrupts */
AT91C_BASE_AIC->AIC_ICCR = ~0; /* clear all interrupts */
for (i = 0; i < 8; ++i) {
AT91C_BASE_AIC->AIC_EOICR = 0; /* write AIC_EOICR 8 times */
}
/* set the desired ticking rate for the PIT... */
i = (get_MCK_FREQ() / 16U / BSP_TICKS_PER_SEC) - 1U;
AT91C_BASE_PITC->PITC_PIMR = (AT91C_PITC_PITEN | AT91C_PITC_PITIEN | i);
BSP_randomSeed(1234U); /* seed the random number generator */
}
/*..........................................................................*/
void BSP_displayPhilStat(uint8_t n, char const *stat) {
if (stat[0] == 'h') {
LED_ON(0); /* turn LED on */
}
else {
LED_OFF(0); /* turn LED off */
}
if (stat[0] == 'e') {
LED_ON(1); /* turn LED on */
}
else {
LED_OFF(1); /* turn LED off */
}
}
/*..........................................................................*/
void BSP_displayPaused(uint8_t paused) {
if (paused != (uint8_t)0) {
LED_ON(2); /* turn LED on */
}
else {
LED_OFF(2); /* turn LED off */
}
}
/*..........................................................................*/
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
l_rnd = l_rnd * (3U*7U*11U*13U*23U);
return l_rnd >> 8;
}
/*..........................................................................*/
void BSP_randomSeed(uint32_t seed) {
l_rnd = seed;
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
(void)result;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* hook the exception handlers from the QF port... */
*(uint32_t volatile *)0x24 = (uint32_t)&QF_undef;
*(uint32_t volatile *)0x28 = (uint32_t)&QF_swi;
*(uint32_t volatile *)0x2C = (uint32_t)&QF_pAbort;
*(uint32_t volatile *)0x30 = (uint32_t)&QF_dAbort;
*(uint32_t volatile *)0x34 = (uint32_t)&QF_reserved;
*(uint32_t volatile *)0x38 = (uint32_t)&QK_irq;
*(uint32_t volatile *)0x3C = (uint32_t)0; /* QK_fiq unimplemented! */
AT91C_BASE_AIC->AIC_SVR[AT91C_ID_SYS] = (uint32_t)&ISR_tick;
AT91C_BASE_AIC->AIC_SPU = (uint32_t)&ISR_spur; /* spurious IRQ */
AT91C_BASE_AIC->AIC_SMR[AT91C_ID_SYS] =
(AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL | AT91C_AIC_PRIOR_LOWEST);
AT91C_BASE_AIC->AIC_ICCR = (1 << AT91C_ID_SYS);
AT91C_BASE_AIC->AIC_IECR = (1 << AT91C_ID_SYS);
}
/*..........................................................................*/
__ramfunc
void QK_onIdle(void) {
/* toggle first LED on and off, see NOTE01 */
QF_INT_DISABLE();
LED_ON(3); /* turn LED on */
LED_OFF(3); /* turn LED off */
QF_INT_ENABLE();
#ifdef NDEBUG /* only if not debugging (idle mode hinders debugging) */
AT91C_BASE_PMC->PMC_SCDR = 1;/* Power-Management: disable the CPU clock */
/* NOTE: an interrupt starts the CPU clock again */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int loc) {
QF_INT_DISABLE(); /* disable all interrupts */
/*
* NOTE: add here your application-specific error handling
*/
(void)module;
(void)loc;
/* trip the Watchdog to reset the system */
AT91C_BASE_WDTC->WDTC_WDCR = (0xA5U << 24) | AT91C_WDTC_WDRSTT;
/* hang in here until the reset occurrs */
for (;;) {
}
}
/*****************************************************************************
* NOTE01:
* One of the LEDs is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/arm7-9/dpp_at91sam7s-ek/qk/iar/dpp-qk.ewd
================================================
3DebugARM1C-SPY22811ARMSIM_ID2111CADI_ID2011CMSISDAP_ID2411GDBSERVER_ID2011IJET_ID2811JLINK_ID21611LMIFTDI_ID2211PEMICRO_ID2311STLINK_ID2411THIRDPARTY_ID2011TIFET_ID2111XDS100_ID2611$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseARM0C-SPY22810ARMSIM_ID2110CADI_ID2010CMSISDAP_ID2410GDBSERVER_ID2010IJET_ID2810JLINK_ID21610LMIFTDI_ID2210PEMICRO_ID2310STLINK_ID2410THIRDPARTY_ID2010TIFET_ID2110XDS100_ID2610$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/arm7-9/dpp_at91sam7s-ek/qk/iar/dpp-qk.ewp
================================================
3DebugARM1General33111ICCARM23511AARM21011OBJCOPY0111CUSTOM30BICOMP0BUILDACTION1ILINK02311IARCHIVE0011BILINK0Coder0ReleaseARM0General33110ICCARM23510AARM21010OBJCOPY0110CUSTOM30BICOMP0BUILDACTION1ILINK02310IARCHIVE0010BILINK0Coder0Application$PROJ_DIR$\bsp.cDebugICCARM3501ReleaseICCARM3500$PROJ_DIR$\..\..\dpp.h$PROJ_DIR$\..\..\main.c$PROJ_DIR$\..\..\philo.c$PROJ_DIR$\..\..\table.cAT91SAM7S-EK$PROJ_DIR$\..\..\..\..\..\3rd_party\at91sam7s-ek\iar\low_level_init.c$PROJ_DIR$\..\..\..\..\..\3rd_party\at91sam7s-ek\iar\startup_at91mc.sDebugICCARM3501ReleaseICCARM3500QP_ARM$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qkn\qkn.cDebugICCARM3501ReleaseICCARM3500QP_port$PROJ_DIR$\..\..\..\..\..\ports\arm7-9\qk\iar\qfn_port.h$PROJ_DIR$\..\..\..\..\..\ports\arm7-9\qk\iar\qkn_port.sQP_THUMB$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c
================================================
FILE: examples/arm7-9/dpp_at91sam7s-ek/qk/iar/dpp-qk.eww
================================================
$WS_DIR$\dpp-qk.ewp
================================================
FILE: examples/arm7-9/dpp_at91sam7s-ek/qpn_conf.h
================================================
/*****************************************************************************
* Product: QP-nano configuration for the Blinky example
* Last Updated for Version: 5.6.2
* Date of the Last Update: 2016-04-05
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef QPN_CONF_H
#define QPN_CONF_H
#define Q_PARAM_SIZE 4U
#define QF_MAX_TICK_RATE 1U
#define QF_TIMEEVT_CTR_SIZE 2U
#define QF_TIMEEVT_PERIODIC
#endif /* QPN_CONF_H */
================================================
FILE: examples/arm7-9/dpp_at91sam7s-ek/qv/iar/at91SAM7S64.icf
================================================
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\a_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00100000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00100000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0010FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x00200000;
define symbol __ICFEDIT_region_RAM_end__ = 0x00203FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x400;
define symbol __ICFEDIT_size_svcstack__ = 0;
define symbol __ICFEDIT_size_irqstack__ = 0;
define symbol __ICFEDIT_size_fiqstack__ = 0;
define symbol __ICFEDIT_size_undstack__ = 0;
define symbol __ICFEDIT_size_abtstack__ = 0;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region VEC_region = mem:[from __ICFEDIT_region_RAM_start__ size 0x40];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ + 0x40 to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block SVC_STACK with alignment = 8, size = __ICFEDIT_size_svcstack__ { };
define block IRQ_STACK with alignment = 8, size = __ICFEDIT_size_irqstack__ { };
define block FIQ_STACK with alignment = 8, size = __ICFEDIT_size_fiqstack__ { };
define block UND_STACK with alignment = 8, size = __ICFEDIT_size_undstack__ { };
define block ABT_STACK with alignment = 8, size = __ICFEDIT_size_abtstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place in VEC_region { section .vectors };
place in RAM_region { readwrite,
block CSTACK, block SVC_STACK, block IRQ_STACK, block FIQ_STACK,
block UND_STACK, block ABT_STACK, block HEAP };
================================================
FILE: examples/arm7-9/dpp_at91sam7s-ek/qv/iar/bsp.c
================================================
/*****************************************************************************
* Product: DPP on AT91SAM7S-EK board, cooperative QV kernel
* Last Updated for Version: 5.5.1
* Date of the Last Update: 2015-10-05
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "dpp.h"
#include "bsp.h"
#include "AT91SAM7S64.h" /* Atmel AT91SAM7S64 MCU */
//Q_DEFINE_THIS_FILE
#pragma diag_suppress=Ta021 /* call __iar_disable_interrupt from __ramfunc */
#pragma diag_suppress=Ta022 /* possible ROM access from __ramfunc */
#pragma diag_suppress=Ta023 /* call to non __ramfunc from __ramfunc */
/* Local objects -----------------------------------------------------------*/
typedef void (*IntVector)(void); /* IntVector pointer-to-function */
uint32_t get_MCK_FREQ(void); /* CPU clock set up in __low_level_init() */
uint32_t const l_led[] = {
(1U << 0), /* LED D1 on AT91SAM7S-EK */
(1U << 1), /* LED D2 on AT91SAM7S-EK */
(1U << 2), /* LED D3 on AT91SAM7S-EK */
(1U << 3) /* LED D4 on AT91SAM7S-EK */
};
#define LED_ON(num_) (AT91C_BASE_PIOA->PIO_CODR = l_led[num_])
#define LED_OFF(num_) (AT91C_BASE_PIOA->PIO_SODR = l_led[num_])
uint32_t const l_btn[] = {
(1U << 19), /* BTN P1 on AT91SAM7S-EK */
(1U << 20), /* BTN P2 on AT91SAM7S-EK */
(1U << 14), /* BTN P3 on AT91SAM7S-EK */
(1U << 15) /* BTN P4 on AT91SAM7S-EK */
};
/* random seed */
static uint32_t l_rnd;
/* ISRs and ISR "wrappers" ================================================*/
__ramfunc
void BSP_irq(void) {
IntVector vect = (IntVector)AT91C_BASE_AIC->AIC_IVR; /* read the IVR */
AT91C_BASE_AIC->AIC_IVR = (AT91_REG)vect; /* write AIC_IVR if protected */
QF_INT_ENABLE(); /* allow nesting interrupts */
(*vect)(); /* call the IRQ ISR via the pointer to function */
QF_INT_DISABLE(); /* disable interrups for the exit sequence */
AT91C_BASE_AIC->AIC_EOICR = 0; /* write AIC_EOICR to clear interrupt */
}
/* ISRs --------------------------------------------------------------------*/
__ramfunc
static void ISR_tick(void) {
/* state of the button debouncing, see below */
static struct ButtonsDebouncing {
uint32_t depressed;
uint32_t previous;
} buttons = { ~0U, ~0U };
uint32_t current;
uint32_t volatile tmp;
/* clear the interrupt source */
tmp = AT91C_BASE_PITC->PITC_PIVR;
QF_tickXISR(0U); /* process time events for rate 0 */
/* Perform the debouncing of buttons. The algorithm for debouncing
* adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
* and Michael Barr, page 71.
*/
current = ~AT91C_BASE_PIOA->PIO_PDSR;/* read PIOA with state of Buttons */
tmp = buttons.depressed; /* save the debounced depressed buttons */
buttons.depressed |= (buttons.previous & current); /* set depressed */
buttons.depressed &= (buttons.previous | current); /* clear released */
buttons.previous = current; /* update the history */
tmp ^= buttons.depressed; /* changed debounced depressed */
if ((tmp & l_btn[0]) != 0U) { /* debounced BTN_P1 state changed? */
if ((buttons.depressed & l_btn[0]) != 0U) { /* is BTN_P1 depressed? */
QACTIVE_POST_ISR(&AO_Table, PAUSE_SIG, 0U);
}
else { /* the button is released */
QACTIVE_POST_ISR(&AO_Table, SERVE_SIG, 0U);
}
}
}
/*..........................................................................*/
__ramfunc
static void ISR_spur(void) {
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
uint32_t i;
/* When using the JTAG debugger the AIC might not be initialised
* to the correct default state. This line ensures that AIC does not
* mask all interrupts at the start.
*/
AT91C_BASE_AIC->AIC_EOICR = 0U;
/* enable peripheral clock for PIOA */
AT91C_BASE_PMC->PMC_PCER = (1U << AT91C_ID_PIOA);
/* initialize the LEDs... */
for (i = 0; i < Q_DIM(l_led); ++i) {
AT91C_BASE_PIOA->PIO_PER = l_led[i]; /* enable pin */
AT91C_BASE_PIOA->PIO_OER = l_led[i]; /* configure as output pin */
LED_OFF(i); /* extinguish the LED */
}
/* initialize the Buttons... */
for (i = 0; i < Q_DIM(l_btn); ++i) {
AT91C_BASE_PIOA->PIO_ODR = l_btn[i]; /* disable output (input pin) */
AT91C_BASE_PIOA->PIO_PER = l_btn[i]; /* enable pin */
}
/* configure Advanced Interrupt Controller (AIC) of AT91... */
AT91C_BASE_AIC->AIC_IDCR = ~0; /* disable all interrupts */
AT91C_BASE_AIC->AIC_ICCR = ~0; /* clear all interrupts */
for (i = 0; i < 8; ++i) {
AT91C_BASE_AIC->AIC_EOICR = 0; /* write AIC_EOICR 8 times */
}
/* set the desired ticking rate for the PIT... */
i = (get_MCK_FREQ() / 16U / BSP_TICKS_PER_SEC) - 1U;
AT91C_BASE_PITC->PITC_PIMR = (AT91C_PITC_PITEN | AT91C_PITC_PITIEN | i);
BSP_randomSeed(1234U); /* seed the random number generator */
}
/*..........................................................................*/
void BSP_displayPhilStat(uint8_t n, char const *stat) {
if (stat[0] == 'h') {
LED_ON(0); /* turn LED on */
}
else {
LED_OFF(0); /* turn LED off */
}
if (stat[0] == 'e') {
LED_ON(1); /* turn LED on */
}
else {
LED_OFF(1); /* turn LED off */
}
}
/*..........................................................................*/
void BSP_displayPaused(uint8_t paused) {
if (paused != (uint8_t)0) {
LED_ON(2); /* turn LED on */
}
else {
LED_OFF(2); /* turn LED off */
}
}
/*..........................................................................*/
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
l_rnd = l_rnd * (3U*7U*11U*13U*23U);
return l_rnd >> 8;
}
/*..........................................................................*/
void BSP_randomSeed(uint32_t seed) {
l_rnd = seed;
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
(void)result;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* hook the exception handlers from the QF port... */
*(uint32_t volatile *)0x24 = (uint32_t)&QF_undef;
*(uint32_t volatile *)0x28 = (uint32_t)&QF_swi;
*(uint32_t volatile *)0x2C = (uint32_t)&QF_pAbort;
*(uint32_t volatile *)0x30 = (uint32_t)&QF_dAbort;
*(uint32_t volatile *)0x34 = (uint32_t)&QF_reserved;
*(uint32_t volatile *)0x38 = (uint32_t)&QV_irq;
*(uint32_t volatile *)0x3C = (uint32_t)0; /* QV_fiq unimplemented! */
AT91C_BASE_AIC->AIC_SVR[AT91C_ID_SYS] = (uint32_t)&ISR_tick;
AT91C_BASE_AIC->AIC_SPU = (uint32_t)&ISR_spur; /* spurious IRQ */
AT91C_BASE_AIC->AIC_SMR[AT91C_ID_SYS] =
(AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL | AT91C_AIC_PRIOR_LOWEST);
AT91C_BASE_AIC->AIC_ICCR = (1 << AT91C_ID_SYS);
AT91C_BASE_AIC->AIC_IECR = (1 << AT91C_ID_SYS);
}
/*..........................................................................*/
__ramfunc
void QV_onIdle(void) { /* NOTE: called with interrupts DISABLED */
/* toggle first LED on and off, see NOTE01 */
LED_ON(3); /* turn LED on */
LED_OFF(3); /* turn LED off */
#ifdef NDEBUG /* only if not debugging (idle mode hinders debugging) */
AT91C_BASE_PMC->PMC_SCDR = 1;/* Power-Management: disable the CPU clock */
/* NOTE: an interrupt starts the CPU clock again */
QF_INT_ENABLE(); /* enable interrupts as soon as CPU clock starts */
#else
QF_INT_ENABLE();
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int loc) {
QF_INT_DISABLE(); /* disable all interrupts */
/*
* NOTE: add here your application-specific error handling
*/
(void)module;
(void)loc;
/* trip the Watchdog to reset the system */
AT91C_BASE_WDTC->WDTC_WDCR = (0xA5U << 24) | AT91C_WDTC_WDRSTT;
/* hang in here until the reset occurrs */
for (;;) {
}
}
/*****************************************************************************
* NOTE01:
* One of the LEDs is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/arm7-9/dpp_at91sam7s-ek/qv/iar/dpp-qv.ewd
================================================
3DebugARM1C-SPY22811ARMSIM_ID2111CADI_ID2011CMSISDAP_ID2411GDBSERVER_ID2011IJET_ID2811JLINK_ID21611LMIFTDI_ID2211PEMICRO_ID2311STLINK_ID2411THIRDPARTY_ID2011TIFET_ID2111XDS100_ID2611$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseARM0C-SPY22810ARMSIM_ID2110CADI_ID2010CMSISDAP_ID2410GDBSERVER_ID2010IJET_ID2810JLINK_ID21610LMIFTDI_ID2210PEMICRO_ID2310STLINK_ID2410THIRDPARTY_ID2010TIFET_ID2110XDS100_ID2610$TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/arm7-9/dpp_at91sam7s-ek/qv/iar/dpp-qv.ewp
================================================
3DebugARM1General32811ICCARM23411AARM21011OBJCOPY0111CUSTOM30BICOMP0BUILDACTION1ILINK02011IARCHIVE0011BILINK0Coder0ReleaseARM0General32810ICCARM23410AARM21010OBJCOPY0110CUSTOM30BICOMP0BUILDACTION1ILINK02010IARCHIVE0010BILINK0Coder0Application$PROJ_DIR$\bsp.cDebugICCARM3401ReleaseICCARM3400$PROJ_DIR$\..\..\dpp.h$PROJ_DIR$\..\..\main.c$PROJ_DIR$\..\..\philo.c$PROJ_DIR$\..\..\table.cAT91SAM7S-EK$PROJ_DIR$\..\..\..\..\..\3rd_party\at91sam7s-ek\iar\low_level_init.c$PROJ_DIR$\..\..\..\..\..\3rd_party\at91sam7s-ek\iar\startup_at91mc.sDebugICCARM3401ReleaseICCARM3400QP_ARM$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qvn\qvn.cDebugICCARM3401ReleaseICCARM3400QP_port$PROJ_DIR$\..\..\..\..\..\ports\arm7-9\qv\iar\qfn_port.h$PROJ_DIR$\..\..\..\..\..\ports\arm7-9\qv\iar\qvn_port.sQP_THUMB$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c
================================================
FILE: examples/arm7-9/dpp_at91sam7s-ek/qv/iar/dpp-qv.eww
================================================
$WS_DIR$\dpp-qv.ewp
================================================
FILE: examples/arm7-9/dpp_at91sam7s-ek/table.c
================================================
/*.$file${.::table.c} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: dpp.qm
* File: ${.::table.c}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::table.c} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("table")
/* Active object class -----------------------------------------------------*/
/*.$declare${AOs::Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table} ...........................................................*/
typedef struct Table {
/* protected: */
QActive super;
/* private: */
uint8_t fork[N_PHILO];
uint8_t isHungry[N_PHILO];
} Table;
/* protected: */
static QState Table_initial(Table * const me);
static QState Table_active(Table * const me);
static QState Table_serving(Table * const me);
static QState Table_paused(Table * const me);
/*.$enddecl${AOs::Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Global objects ----------------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*. Check for the minimum required QP version */
#if (QP_VERSION < 650U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpn version 6.5.0 or higher required
#endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Table} ........................................................*/
struct Table AO_Table;
/*.$enddef${AOs::AO_Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#define RIGHT(n_) ((uint8_t)(((n_) + (N_PHILO - 1U)) % N_PHILO))
#define LEFT(n_) ((uint8_t)(((n_) + 1U) % N_PHILO))
#define FREE ((uint8_t)0)
#define USED ((uint8_t)1)
/*..........................................................................*/
/*.$define${AOs::Table_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table_ctor} ......................................................*/
void Table_ctor(void) {
uint8_t n;
Table *me = &AO_Table;
QActive_ctor(&me->super, Q_STATE_CAST(&Table_initial));
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
}
}
/*.$enddef${AOs::Table_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table} ...........................................................*/
/*.${AOs::Table::SM} .......................................................*/
static QState Table_initial(Table * const me) {
/*.${AOs::Table::SM::initial} */
uint8_t n;
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "thinking");
}
return Q_TRAN(&Table_serving);
}
/*.${AOs::Table::SM::active} ...............................................*/
static QState Table_active(Table * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Table::SM::active::TERMINATE} */
case TERMINATE_SIG: {
BSP_terminate(0);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::EAT} */
case EAT_SIG: {
Q_ERROR();
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Table::SM::active::serving} ......................................*/
static QState Table_serving(Table * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Table::SM::active::serving} */
case Q_ENTRY_SIG: {
uint8_t n;
for (n = 0U; n < N_PHILO; ++n) { /* give permissions to eat... */
if ((me->isHungry[n] != 0U)
&& (me->fork[LEFT(n)] == FREE)
&& (me->fork[n] == FREE))
{
QActive *philo;
me->fork[LEFT(n)] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "eating ");
}
}
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::serving::HUNGRY} */
case HUNGRY_SIG: {
uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "hungry ");
m = LEFT(n);
/*.${AOs::Table::SM::active::serving::HUNGRY::[bothfree]} */
if ((me->fork[m] == FREE) && (me->fork[n] == FREE)) {
me->fork[m] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
BSP_displayPhilStat(n, "eating ");
status_ = Q_HANDLED();
}
/*.${AOs::Table::SM::active::serving::HUNGRY::[else]} */
else {
me->isHungry[n] = 1U;
status_ = Q_HANDLED();
}
break;
}
/*.${AOs::Table::SM::active::serving::DONE} */
case DONE_SIG: {
uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;
m = RIGHT(n); /* check the right neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[m] == FREE)) {
me->fork[n] = USED;
me->fork[m] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}
m = LEFT(n); /* check the left neighbor */
n = LEFT(m); /* left fork of the left neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[n] == FREE)) {
me->fork[m] = USED;
me->fork[n] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::serving::EAT} */
case EAT_SIG: {
Q_ERROR();
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::serving::PAUSE} */
case PAUSE_SIG: {
status_ = Q_TRAN(&Table_paused);
break;
}
default: {
status_ = Q_SUPER(&Table_active);
break;
}
}
return status_;
}
/*.${AOs::Table::SM::active::paused} .......................................*/
static QState Table_paused(Table * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Table::SM::active::paused} */
case Q_ENTRY_SIG: {
BSP_displayPaused(1U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::paused} */
case Q_EXIT_SIG: {
BSP_displayPaused(0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::paused::SERVE} */
case SERVE_SIG: {
status_ = Q_TRAN(&Table_serving);
break;
}
/*.${AOs::Table::SM::active::paused::HUNGRY} */
case HUNGRY_SIG: {
uint8_t n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* philo ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
me->isHungry[n] = 1U;
BSP_displayPhilStat(n, "hungry ");
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::paused::DONE} */
case DONE_SIG: {
uint8_t n, m;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&Table_active);
break;
}
}
return status_;
}
/*.$enddef${AOs::Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
================================================
FILE: examples/avr/README.url
================================================
[InternetShortcut]
URL=http://www.state-machine.com/qpn/exa_avr.html
IconFile=http://www.state-machine.com/qp.ico
================================================
FILE: examples/avr/blinky_arduino-uno/README.url
================================================
[InternetShortcut]
URL=http://www.state-machine.com/qpn/avr_blinky_arduino-uno.html
IconFile=http://www.state-machine.com/qp.ico
================================================
FILE: examples/avr/blinky_arduino-uno/blinky.c
================================================
/*****************************************************************************
* Product: Simple Blinky example
* Last updated for version 5.4.0
* Last updated on 2015-05-18
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, www.state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "blinky.h"
#include "bsp.h"
//Q_DEFINE_THIS_FILE
/*..........................................................................*/
typedef struct BlinkyTag { /* the Blinky active object */
QActive super; /* inherit QActive */
} Blinky;
/* hierarchical state machine ... */
static QState Blinky_initial(Blinky * const me);
static QState Blinky_off (Blinky * const me);
static QState Blinky_on (Blinky * const me);
/* Global objects ----------------------------------------------------------*/
Blinky AO_Blinky; /* the single instance of the Blinky AO */
/*..........................................................................*/
void Blinky_ctor(void) {
Blinky * const me = &AO_Blinky;
QActive_ctor(&me->super, Q_STATE_CAST(&Blinky_initial));
}
/* HSM definition ----------------------------------------------------------*/
QState Blinky_initial(Blinky * const me) {
QActive_armX((QActive *)me, 0U,
BSP_TICKS_PER_SEC/2U, BSP_TICKS_PER_SEC/2U);
return Q_TRAN(&Blinky_off);
}
/*..........................................................................*/
QState Blinky_off(Blinky * const me) {
QState status;
switch (Q_SIG(me)) {
case Q_ENTRY_SIG: {
BSP_ledOff();
status = Q_HANDLED();
break;
}
case Q_TIMEOUT_SIG: {
status = Q_TRAN(&Blinky_on);
break;
}
default: {
status = Q_SUPER(&QHsm_top);
break;
}
}
return status;
}
/*..........................................................................*/
QState Blinky_on(Blinky * const me) {
QState status;
switch (Q_SIG(me)) {
case Q_ENTRY_SIG: {
BSP_ledOn();
status = Q_HANDLED();
break;
}
case Q_TIMEOUT_SIG: {
status = Q_TRAN(&Blinky_off);
break;
}
default: {
status = Q_SUPER(&QHsm_top);
break;
}
}
return status;
}
================================================
FILE: examples/avr/blinky_arduino-uno/blinky.h
================================================
/*****************************************************************************
* Product: simple "Blinky" example
* Last updated for version 5.4.0
* Last updated on 2015-05-18
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, www.state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef BLINKY_H
#define BLINKY_H
enum BlinkySignals {
DUMMY_SIG = Q_USER_SIG,
MAX_PUB_SIG, /* the last published signal */
TIMEOUT_SIG,
MAX_SIG /* the last signal */
};
void Blinky_ctor(void);
extern struct BlinkyTag AO_Blinky;
#endif /* BLINKY_H */
================================================
FILE: examples/avr/blinky_arduino-uno/bsp.h
================================================
/*****************************************************************************
* Product: Simple Blinky example
* Last updated for version 5.4.0
* Last updated on 2015-05-18
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, www.state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef BSP_H
#define BSP_H
#define BSP_TICKS_PER_SEC 100U
void BSP_init(void);
void BSP_ledOff(void);
void BSP_ledOn(void);
#endif /* BSP_H */
================================================
FILE: examples/avr/blinky_arduino-uno/main.c
================================================
/*****************************************************************************
* Product: "Blinky" example
* Last Updated for Version: 5.8.0
* Date of the Last Update: 2016-11-06
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h" /* QP-nano API */
#include "bsp.h" /* Board Support Package */
#include "blinky.h" /* Application interface */
/* Local-scope objects -----------------------------------------------------*/
static QEvt l_blinkyQSto[10]; /* Event queue storage for Blinky */
/* QF_active[] array defines all active object control blocks --------------*/
QActiveCB const Q_ROM QF_active[] = {
{ (QActive *)0, (QEvt *)0, 0U },
{ (QActive *)&AO_Blinky, l_blinkyQSto, Q_DIM(l_blinkyQSto) }
};
/*..........................................................................*/
int main(void) {
Blinky_ctor(); /* instantiate all Blinky AO */
QF_init(Q_DIM(QF_active)); /* initialize the QF-nano framework */
BSP_init(); /* initialize the Board Support Package */
return QF_run(); /* transfer control to QF-nano */
}
================================================
FILE: examples/avr/blinky_arduino-uno/qk/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano, Arduino-UNO, preemptive QK kernel, GNU-AVR
# Last Updated for Version: 5.4.0
# Date of the Last Update: 2015-05-28
#
# Q u a n t u m L e a P s
# ---------------------------
# innovating embedded systems
#
# Copyright (C) Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# Web: http://www.state-machine.com
# Email: info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := blinky-qk
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/avr/qk/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qkn \
$(QP_PORT_DIR)
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR)
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
blinky.c \
bsp.c \
main.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qepn.c \
qfn.c \
qkn.c
QP_ASMS :=
LIB_DIRS :=
LIBS :=
# defines
DEFINES :=
# AVR MCU type
AVR_MCU=atmega328p
#-----------------------------------------------------------------------------
# GNU-AVR toolset (NOTE: You need to adjust to your machine)
# see http://sourceforge.net/projects/winavr
#
ifeq ($(GNU_AVR),)
GNU_AVR = C:\tools\WinAVR
endif
# make sure that the GNU-AVR toolset exists...
ifeq ("$(wildcard $(GNU_AVR))","")
$(error GNU_AVR toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_AVR)/bin/avr-gcc
CPP := $(GNU_AVR)/bin/avr-g++
AS := $(GNU_AVR)/bin/avr-as
LINK := $(GNU_AVR)/bin/avr-gcc
BIN := $(GNU_AVR)/bin/avr-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M4F
#
# combine all the soruces...
C_SRCS += $(QP_SRCS) $(QP_PORT)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS =
CFLAGS = -mmcu=$(AVR_MCU) -std=gnu99 -fshort-enums -Wall \
-ffunction-sections -fdata-sections \
-Os $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -mmcu=$(AVR_MCU) -fshort-enums -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-Os $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration .........................................
BIN_DIR := dbg
ASFLAGS =
CFLAGS = -mmcu=$(AVR_MCU) -std=gnu99 -fshort-enums -Wall \
-ffunction-sections -fdata-sections \
-O $(INCLUDES) $(DEFINES)
CPPFLAGS = -mmcu=$(AVR_MCU) -fshort-enums -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES)
endif # .....................................................................
LINKFLAGS = -mmcu=$(AVR_MCU) \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_HEX := $(BIN_DIR)/$(OUTPUT).hex
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_HEX)
#all: $(TARGET_ELF)
$(TARGET_HEX): $(TARGET_ELF)
$(BIN) -O ihex $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(LINK) $(LINKFLAGS) -o $@ $^ $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) -c $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.hex \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/avr/blinky_arduino-uno/qk/gnu/README.txt
================================================
About this Example
==================
This example can be built from the command prompt with the provided
Makefile. The example can also be invoked directly (via the make
utility) from the QM modeling tool.
The Makefile
============
The provided Makefile should be easy to adapt for your own projects.
It contains three build configurations: Debug (default), Release, and
Spy.
The various build configurations are built as follows:
make
make CONF=rel
make clean
make CONF=rel clean
Warning: '__progmem__' attribute ignored
========================================
AVR is a Harvard architecture that uses different program and data spaces as
well as different CPU instructions to access these two address spaces (data
memory is 8-bit wide while program memory is 16-bit wide). Consequently, one
of the biggest concerns in AVR programs is to correctly allocate and access
constant data in the program space (ROM) rather than the precious RAM. Since
the ROM resides in a different address space, you need to tell the compiler
to place variables there. You also need a way to access the data (i.e., the
compiler has to use the lpm instruction.)
The GNU-AVR compiler supports data in the program memory only partially
through the attribute((progmem)) extension (typically used through the
PROGMEM macro). By tagging a variable with attribute((progmem)), you can
force it to reside in the ROM. However, the compiler support ends at this
point. It is the responsibility of the developer to correctly access the
PROGMEM variables. The GCC-AVR provides merely a bunch of macros (all
defined in the avr\pgmspace.h header file).
The bottom line is that the GNU-AVR compiler support for ROM-allocated
objects through the PROGMEM attribute is both incomplete and inconsistent
with the correct implementation in other compilers (such as IAR-AVR).
For example, pointers pointing to PROGMEM objects are not treated correctly,
meaning that the compiler will not generate the right code to access such
ROM objects (the GNU-AVR compiler needs a kludge in form of macros such as
pgm_read_byte_near and others). To recognize that fact, the GNU-AVR
generates the warnings "'progmem' attribute ignored ".
However, the QP source code is written for a standard correct implementation
(how else would you achieve portability?). For example, the IAR-AVR compiler
uses the attribute '__flash' to designate objects and pointers to ROM
objects. The compiler then generates the right code for all such flash
objects and pointers, without any kludges necessary for the GNU compiler.
In summary, the warnings "'progmem' attribute ignored" should be ignored
in the QP library build. To avoid these warnings, the QP source code would
have to be modified in such a way that it would be incorrect for other
compilers that handle these declarations correctly.
================================================
FILE: examples/avr/blinky_arduino-uno/qk/gnu/bsp.c
================================================
/*****************************************************************************
* Product: Blinky example, Arduino-UNO board, preemptive QK-nano kernel
* Last Updated for Version: 5.4.0
* Date of the Last Update: 2015-04-08
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "blinky.h"
#include "bsp.h"
/* the AVR device specific header is already included */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/* Local-scope objects -----------------------------------------------------*/
/* Arduino-UNO runs off the 16MHz oscillator */
#define F_CPU 16000000UL
/* the on-board LED labeled "L" on Arduino-UNO */
#define LED_L (1U << 5)
/* ISRs used in this project ===============================================*/
ISR(TIMER2_COMPA_vect) {
QK_ISR_ENTRY(); /* inform QK about entering an ISR */
QF_tickXISR(0U); /* process time events for rate 0 */
QK_ISR_EXIT(); /* inform QK about exiting an ISR */
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
DDRB = 0xFFU; // All PORTB pins are outputs (user LED)
PORTB = 0x00U; // drive all pins low
}
/*..........................................................................*/
void BSP_ledOff(void) {
PORTB &= ~LED_L;
}
/*..........................................................................*/
void BSP_ledOn(void) {
PORTB |= LED_L;
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
(void)result;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set Timer2 in CTC mode, 1/1024 prescaler, start the timer ticking... */
TCCR2A = (1U << WGM21) | (0U << WGM20);
TCCR2B = (1U << CS22 ) | (1U << CS21) | (1U << CS20); /* 1/2^10 */
ASSR &= ~(1U << AS2);
TIMSK2 = (1U << OCIE2A); /* Enable TIMER2 compare Interrupt */
TCNT2 = 0U;
OCR2A = (F_CPU / BSP_TICKS_PER_SEC / 1024U) - 1U;
}
/*..........................................................................*/
void QF_onCleanup(void) {
}
/*..........................................................................*/
void QK_onIdle(void) {
/* toggle the User LED, see NOTE1 , not enough LEDs to implement! */
//QF_INT_DISABLE();
//PORTB |= LED_L;
//PORTB &= ~LED_L;
//QF_INT_ENABLE();
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular AVR MCU.
*/
SMCR = (0 << SM0) | (1 << SE); /* idle mode, adjust to your project */
QK_CPU_SLEEP(); /* put CPU to sleep */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const file, int line) {
/* implement the error-handling policy for your application!!! */
QF_INT_DISABLE(); /* disable all interrupts */
QF_RESET(); /* reset the CPU */
for (;;) {
}
}
/*****************************************************************************
* NOTE1:
* The User LED is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/avr/blinky_arduino-uno/qk/gnu/flash.bat
================================================
@echo off
::============================================================================
:: Batch file to program the flash of Arduino-UNO
::
:: NOTE: requires the AVRDUDE uitlity which is included in the QTools
:: collection
::
setlocal
@echo off
@echo Load a given hex file to the flash of Arduino-UNO
@echo usage: flash hex-file [COM-port]
@echo example: flash dbg\blinky-qk.hex
@echo example: flash dbg\blinky-qk.hex COM5
::----------------------------------------------------------------------------
:: NOTE: Adjust the following symbol to the location of the
:: AVRDUDE utility on your machine
::
set AVRDUDE=avrdude.exe
set COM_PORT=COM5
if [%2] NEQ [] set COM_PORT=%2
if ["%~1"]==[""] (
@echo The hex file missing
@goto end
)
if not exist %~s1 (
@echo The hex file '%1' does not exist
@goto end
)
@echo on
%AVRDUDE% -p atmega328p -c arduino -P %COM_PORT% -b 115200 -D -v -U flash:w:%1:i
@echo off
:end
endlocal
================================================
FILE: examples/avr/blinky_arduino-uno/qk/iar/blinky-qk.ewd
================================================
2DebugAVR1C-SPY61611ATMELICEAVR5111AVRONE4411CCRAVR2111ICE200AVR2111JTAGICEAVR3211JTAGICE3AVR5611JTAGICEMKIIAVR5711DRAGONAVR3311SIMAVR2111THIRDPARTYAVR2111$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\Stk600\Stk600Plugin.ewplugin1$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin1$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseAVR0C-SPY61610ATMELICEAVR5110AVRONE4410CCRAVR2110ICE200AVR2110JTAGICEAVR3210JTAGICE3AVR5610JTAGICEMKIIAVR5710DRAGONAVR3310SIMAVR2110THIRDPARTYAVR2110$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\Stk600\Stk600Plugin.ewplugin1$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin1$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/avr/blinky_arduino-uno/qk/iar/blinky-qk.ewp
================================================
2DebugAVR1General11911ICCAVR61711AAVR51111CUSTOM30BICOMP0BUILDACTION1XLINK31611XAR2011BILINK0ReleaseAVR0General11910ICCAVR61710AAVR51110CUSTOM30BICOMP0BUILDACTION1XLINK31610XAR2010BILINK0Application$PROJ_DIR$\..\..\blinky.c$PROJ_DIR$\..\..\blinky.h$PROJ_DIR$\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\main.cQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qkn\qkn.c
================================================
FILE: examples/avr/blinky_arduino-uno/qk/iar/blinky-qk.eww
================================================
$WS_DIR$\blinky-qk.ewp
================================================
FILE: examples/avr/blinky_arduino-uno/qk/iar/bsp.c
================================================
/*****************************************************************************
* Product: Blinky example, Arduino-UNO, preemptive QK-nano kernel, IAR-AVR
* Last Updated for Version: 5.4.0
* Date of the Last Update: 2015-05-28
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "blinky.h"
#include "bsp.h"
#include /* the AVR MCU variant used */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/* Local-scope objects -----------------------------------------------------*/
/* Arduino-UNO runs off the 16MHz oscillator */
#define F_CPU 16000000UL
/* the on-board LED labeled "L" on Arduino-UNO */
#define LED_L (1U << 5)
/* ISRs used in this project ===============================================*/
#pragma vector = TIMER2_COMPA_vect
__interrupt void timer2_ISR(void) {
QK_ISR_ENTRY(); /* inform QK about entering an ISR */
QF_tickXISR(0U); /* process time events for rate 0 */
QK_ISR_EXIT(); /* inform QK about exiting an ISR */
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
DDRB = 0xFFU; // All PORTB pins are outputs (user LED)
PORTB = 0x00U; // drive all pins low
}
/*..........................................................................*/
void BSP_ledOff(void) {
PORTB &= ~LED_L;
}
/*..........................................................................*/
void BSP_ledOn(void) {
PORTB |= LED_L;
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
(void)result;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set Timer2 in CTC mode, 1/1024 prescaler, start the timer ticking... */
TCCR2A = (1U << WGM21) | (0U << WGM20);
TCCR2B = (1U << CS22 ) | (1U << CS21) | (1U << CS20); /* 1/2^10 */
ASSR &= ~(1U << AS2);
TIMSK2 = (1U << OCIE2A); /* Enable TIMER2 compare Interrupt */
TCNT2 = 0U;
OCR2A = (F_CPU / BSP_TICKS_PER_SEC / 1024U) - 1U;
}
/*..........................................................................*/
void QF_onCleanup(void) {
}
/*..........................................................................*/
void QK_onIdle(void) {
/* toggle the User LED, see NOTE1 , not enough LEDs to implement! */
//QF_INT_DISABLE();
//PORTB |= LED_L;
//PORTB &= ~LED_L;
//QF_INT_ENABLE();
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular AVR MCU.
*/
SMCR = (0 << SM0) | (1 << SE); /* idle mode, adjust to your project */
QK_CPU_SLEEP(); /* put CPU to sleep */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const file, int line) {
/* implement the error-handling policy for your application!!! */
QF_INT_DISABLE(); /* disable all interrupts */
QF_RESET(); /* reset the CPU */
}
/*****************************************************************************
* NOTE1:
* The User LED is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/avr/blinky_arduino-uno/qk/iar/flash.bat
================================================
@echo off
::============================================================================
:: Batch file to program the flash of Arduino-UNO
::
:: NOTE: requires the AVRDUDE uitlity which is included in the QTools
:: collection
::
setlocal
@echo off
@echo Load a given hex file to the flash of Arduino-UNO
@echo usage: flash hex-file [COM-port]
@echo example: flash dbg\blinky-qk.hex
@echo example: flash dbg\blinky-qk.hex COM5
::----------------------------------------------------------------------------
:: NOTE: Adjust the following symbol to the location of the
:: AVRDUDE utility on your machine
::
set AVRDUDE=avrdude.exe
set COM_PORT=COM5
if [%2] NEQ [] set COM_PORT=%2
if ["%~1"]==[""] (
@echo The hex file missing
@goto end
)
if not exist %~s1 (
@echo The hex file '%1' does not exist
@goto end
)
@echo on
%AVRDUDE% -p atmega328p -c arduino -P %COM_PORT% -b 115200 -D -v -U flash:w:%1:i
@echo off
:end
endlocal
================================================
FILE: examples/avr/blinky_arduino-uno/qpn_conf.h
================================================
/*****************************************************************************
* Product: QP-nano configuration for the Blinky example
* Last Updated for Version: 5.6.2
* Date of the Last Update: 2016-04-05
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef QPN_CONF_H
#define QPN_CONF_H
#define Q_PARAM_SIZE 4U
#define QF_MAX_TICK_RATE 1U
#define QF_TIMEEVT_CTR_SIZE 2U
#define QF_TIMEEVT_PERIODIC
#endif /* QPN_CONF_H */
================================================
FILE: examples/avr/blinky_arduino-uno/qv/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano, Arduino-UNO, cooperative QV kernel, GNU-AVR
# Last Updated for Version: 5.4.0
# Date of the Last Update: 2015-05-28
#
# Q u a n t u m L e a P s
# ---------------------------
# innovating embedded systems
#
# Copyright (C) Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# Web: http://www.state-machine.com
# Email: info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := blinky-qv
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/avr/qv/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qvn \
$(QP_PORT_DIR)
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR)
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
blinky.c \
bsp.c \
main.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT := $(PROJECT).ld
QP_SRCS := \
qepn.c \
qfn.c \
qvn.c
QP_ASMS :=
LIB_DIRS :=
LIBS :=
# defines
DEFINES :=
# AVR MCU type
AVR_MCU=atmega328p
#-----------------------------------------------------------------------------
# GNU-AVR toolset (NOTE: You need to adjust to your machine)
# see http://sourceforge.net/projects/winavr
#
ifeq ($(GNU_AVR),)
GNU_AVR = C:\tools\WinAVR
endif
# make sure that the GNU-AVR toolset exists...
ifeq ("$(wildcard $(GNU_AVR))","")
$(error GNU_AVR toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_AVR)/bin/avr-gcc
CPP := $(GNU_AVR)/bin/avr-g++
AS := $(GNU_AVR)/bin/avr-as
LINK := $(GNU_AVR)/bin/avr-gcc
BIN := $(GNU_AVR)/bin/avr-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M4F
#
# combine all the soruces...
C_SRCS += $(QP_SRCS) $(QP_PORT)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS =
CFLAGS = -mmcu=$(AVR_MCU) -std=gnu99 -fshort-enums -Wall \
-ffunction-sections -fdata-sections \
-Os $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -mmcu=$(AVR_MCU) -fshort-enums -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-Os $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration .........................................
BIN_DIR := dbg
ASFLAGS =
CFLAGS = -mmcu=$(AVR_MCU) -std=gnu99 -fshort-enums -Wall \
-ffunction-sections -fdata-sections \
-O $(INCLUDES) $(DEFINES)
CPPFLAGS = -mmcu=$(AVR_MCU) -fshort-enums -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES)
endif # .....................................................................
LINKFLAGS = -mmcu=$(AVR_MCU) \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_HEX := $(BIN_DIR)/$(OUTPUT).hex
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_HEX)
#all: $(TARGET_ELF)
$(TARGET_HEX): $(TARGET_ELF)
$(BIN) -O ihex $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(LINK) $(LINKFLAGS) -o $@ $^ $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) -c $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.hex \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/avr/blinky_arduino-uno/qv/gnu/README.txt
================================================
About this Example
==================
This example can be built from the command prompt with the provided
Makefile. The example can also be invoked directly (via the make
utility) from the QM modeling tool.
The Makefile
============
The provided Makefile should be easy to adapt for your own projects.
It contains three build configurations: Debug (default), Release, and
Spy.
The various build configurations are built as follows:
make
make CONF=rel
make CONF=spy
make clean
make CONF=rel clean
make CONF=spy clean
Warning: '__progmem__' attribute ignored
========================================
AVR is a Harvard architecture that uses different program and data spaces as
well as different CPU instructions to access these two address spaces (data
memory is 8-bit wide while program memory is 16-bit wide). Consequently, one
of the biggest concerns in AVR programs is to correctly allocate and access
constant data in the program space (ROM) rather than the precious RAM. Since
the ROM resides in a different address space, you need to tell the compiler
to place variables there. You also need a way to access the data (i.e., the
compiler has to use the lpm instruction.)
The GNU-AVR compiler supports data in the program memory only partially
through the attribute((progmem)) extension (typically used through the
PROGMEM macro). By tagging a variable with attribute((progmem)), you can
force it to reside in the ROM. However, the compiler support ends at this
point. It is the responsibility of the developer to correctly access the
PROGMEM variables. The GCC-AVR provides merely a bunch of macros (all
defined in the avr\pgmspace.h header file).
The bottom line is that the GNU-AVR compiler support for ROM-allocated
objects through the PROGMEM attribute is both incomplete and inconsistent
with the correct implementation in other compilers (such as IAR-AVR).
For example, pointers pointing to PROGMEM objects are not treated correctly,
meaning that the compiler will not generate the right code to access such
ROM objects (the GNU-AVR compiler needs a kludge in form of macros such as
pgm_read_byte_near and others). To recognize that fact, the GNU-AVR
generates the warnings "'progmem' attribute ignored ".
However, the QP source code is written for a standard correct implementation
(how else would you achieve portability?). For example, the IAR-AVR compiler
uses the attribute '__flash' to designate objects and pointers to ROM
objects. The compiler then generates the right code for all such flash
objects and pointers, without any kludges necessary for the GNU compiler.
In summary, the warnings "'progmem' attribute ignored" should be ignored
in the QP library build. To avoid these warnings, the QP source code would
have to be modified in such a way that it would be incorrect for other
compilers that handle these declarations correctly.
================================================
FILE: examples/avr/blinky_arduino-uno/qv/gnu/bsp.c
================================================
/*****************************************************************************
* Product: Blinky example, Arduino-UNO board, cooperative QV kernel, GNU-AVR
* Last Updated for Version: 5.4.0
* Date of the Last Update: 2015-04-08
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "blinky.h"
#include "bsp.h"
/* the AVR device specific header is already included */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/* Local-scope objects -----------------------------------------------------*/
/* Arduino-UNO runs off the 16MHz oscillator */
#define F_CPU 16000000UL
/* the on-board LED labeled "L" on Arduino-UNO (PORTB) */
#define LED_L (1U << 5)
/* ISRs used in this project ===============================================*/
ISR(TIMER2_COMPA_vect) {
QF_tickXISR(0U); /* process time events for rate 0 */
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
DDRB = 0xFFU; // All PORTB pins are outputs (user LED)
PORTB = 0x00U; // drive all pins low
}
/*..........................................................................*/
void BSP_ledOff(void) {
PORTB &= ~LED_L;
}
/*..........................................................................*/
void BSP_ledOn(void) {
PORTB |= LED_L;
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
(void)result;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set Timer2 in CTC mode, 1/1024 prescaler, start the timer ticking... */
TCCR2A = (1U << WGM21) | (0U << WGM20);
TCCR2B = (1U << CS22 ) | (1U << CS21) | (1U << CS20); /* 1/2^10 */
ASSR &= ~(1U << AS2);
TIMSK2 = (1U << OCIE2A); /* Enable TIMER2 compare Interrupt */
TCNT2 = 0U;
OCR2A = (F_CPU / BSP_TICKS_PER_SEC / 1024U) - 1U;
}
/*..........................................................................*/
void QF_onCleanup(void) {
}
/*..........................................................................*/
void QV_onIdle(void) { /* called with interrupts DISABLED, see NOTE1 */
/* toggle the User LED, see NOTE2 , not enough LEDs to implement! */
//PORTB |= LED_L;
//PORTB &= ~LED_L;
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular AVR MCU.
*/
SMCR = (0 << SM0) | (1 << SE); /* idle mode, adjust to your project */
QV_CPU_SLEEP(); /* atomically go to sleep and enable interrupts */
#else
QF_INT_ENABLE(); /* just enable interrupts */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const file, int line) {
/* implement the error-handling policy for your application!!! */
QF_INT_DISABLE(); /* disable all interrupts */
QF_RESET(); /* reset the CPU */
for (;;) {
}
}
/*****************************************************************************
* NOTE01:
* The QV_onIdle() callback is called with interrupts disabled, because the
* determination of the idle condition might change by any interrupt posting
* an event. QV_onIdle() must internally enable interrupts, ideally
* atomically with putting the CPU to the power-saving mode.
*
* NOTE2:
* The User LED is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/avr/blinky_arduino-uno/qv/gnu/flash.bat
================================================
@echo off
::============================================================================
:: Batch file to program the flash of Arduino-UNO
::
:: NOTE: requires the AVRDUDE uitlity which is included in the QTools
:: collection
::
setlocal
@echo off
@echo Load a given hex file to the flash of Arduino-UNO
@echo usage: flash hex-file [COM-port]
@echo example: flash dbg\blinky-qk.hex
@echo example: flash dbg\blinky-qk.hex COM5
::----------------------------------------------------------------------------
:: NOTE: Adjust the following symbol to the location of the
:: AVRDUDE utility on your machine
::
set AVRDUDE=avrdude.exe
set COM_PORT=COM5
if [%2] NEQ [] set COM_PORT=%2
if ["%~1"]==[""] (
@echo The hex file missing
@goto end
)
if not exist %~s1 (
@echo The hex file '%1' does not exist
@goto end
)
@echo on
%AVRDUDE% -p atmega328p -c arduino -P %COM_PORT% -b 115200 -D -v -U flash:w:%1:i
@echo off
:end
endlocal
================================================
FILE: examples/avr/blinky_arduino-uno/qv/iar/blinky-qv.ewd
================================================
2DebugAVR1C-SPY61611ATMELICEAVR5111AVRONE4411CCRAVR2111ICE200AVR2111JTAGICEAVR3211JTAGICE3AVR5611JTAGICEMKIIAVR5711DRAGONAVR3311SIMAVR2111THIRDPARTYAVR2111$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\Stk600\Stk600Plugin.ewplugin1$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin1$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseAVR0C-SPY61610ATMELICEAVR5110AVRONE4410CCRAVR2110ICE200AVR2110JTAGICEAVR3210JTAGICE3AVR5610JTAGICEMKIIAVR5710DRAGONAVR3310SIMAVR2110THIRDPARTYAVR2110$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\Stk600\Stk600Plugin.ewplugin1$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin1$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/avr/blinky_arduino-uno/qv/iar/blinky-qv.ewp
================================================
2DebugAVR1General11911ICCAVR61711AAVR51111CUSTOM30BICOMP0BUILDACTION1XLINK31611XAR2011BILINK0ReleaseAVR0General11910ICCAVR61710AAVR51110CUSTOM30BICOMP0BUILDACTION1XLINK31610XAR2010BILINK0Application$PROJ_DIR$\..\..\blinky.c$PROJ_DIR$\..\..\blinky.h$PROJ_DIR$\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\main.cQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qvn\qvn.c
================================================
FILE: examples/avr/blinky_arduino-uno/qv/iar/blinky-qv.eww
================================================
$WS_DIR$\blinky-qv.ewp
================================================
FILE: examples/avr/blinky_arduino-uno/qv/iar/bsp.c
================================================
/*****************************************************************************
* Product: Blinky example for Arduino-UNO, cooperative QV kernel, IAR-AVR
* Last Updated for Version: 5.4.0
* Date of the Last Update: 2015-05-28
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "blinky.h"
#include "bsp.h"
#include /* the AVR MCU variant used */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/* Local-scope objects -----------------------------------------------------*/
/* Arduino-UNO runs off the 16MHz oscillator */
#define F_CPU 16000000UL
/* the on-board LED labeled "L" on Arduino-UNO */
#define LED_L (1U << 5)
/* ISRs used in this project ===============================================*/
#pragma vector = TIMER2_COMPA_vect
__interrupt void timer2_ISR(void) {
QF_tickXISR(0U); /* process time events for rate 0 */
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
DDRB = 0xFFU; // All PORTB pins are outputs (user LED)
PORTB = 0x00U; // drive all pins low
}
/*..........................................................................*/
void BSP_ledOff(void) {
PORTB &= ~LED_L;
}
/*..........................................................................*/
void BSP_ledOn(void) {
PORTB |= LED_L;
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
(void)result;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set Timer2 in CTC mode, 1/1024 prescaler, start the timer ticking... */
TCCR2A = (1U << WGM21) | (0U << WGM20);
TCCR2B = (1U << CS22 ) | (1U << CS21) | (1U << CS20); /* 1/2^10 */
ASSR &= ~(1U << AS2);
TIMSK2 = (1U << OCIE2A); /* Enable TIMER2 compare Interrupt */
TCNT2 = 0U;
OCR2A = (F_CPU / BSP_TICKS_PER_SEC / 1024U) - 1U;
}
/*..........................................................................*/
void QF_onCleanup(void) {
}
/*..........................................................................*/
void QV_onIdle(void) { /* called with interrupts DISABLED, see NOTE1 */
/* toggle the User LED, see NOTE2 , not enough LEDs to implement! */
//PORTB |= LED_L;
//PORTB &= ~LED_L;
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular AVR MCU.
*/
SMCR = (0 << SM0) | (1 << SE); /* idle mode, adjust to your project */
QV_CPU_SLEEP(); /* atomically go to sleep and enable interrupts */
#else
QF_INT_ENABLE(); /* just enable interrupts */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const file, int line) {
/* implement the error-handling policy for your application!!! */
QF_INT_DISABLE(); /* disable all interrupts */
QF_RESET(); /* reset the CPU */
}
/*****************************************************************************
* NOTE01:
* The QV_onIdle() callback is called with interrupts disabled, because the
* determination of the idle condition might change by any interrupt posting
* an event. QV_onIdle() must internally enable interrupts, ideally
* atomically with putting the CPU to the power-saving mode.
*
* NOTE2:
* The User LED is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/avr/blinky_arduino-uno/qv/iar/flash.bat
================================================
@echo off
::============================================================================
:: Batch file to program the flash of Arduino-UNO
::
:: NOTE: requires the AVRDUDE uitlity which is included in the QTools
:: collection
::
setlocal
@echo off
@echo Load a given hex file to the flash of Arduino-UNO
@echo usage: flash hex-file [COM-port]
@echo example: flash dbg\blinky-qk.hex
@echo example: flash dbg\blinky-qk.hex COM5
::----------------------------------------------------------------------------
:: NOTE: Adjust the following symbol to the location of the
:: AVRDUDE utility on your machine
::
set AVRDUDE=avrdude.exe
set COM_PORT=COM5
if [%2] NEQ [] set COM_PORT=%2
if ["%~1"]==[""] (
@echo The hex file missing
@goto end
)
if not exist %~s1 (
@echo The hex file '%1' does not exist
@goto end
)
@echo on
%AVRDUDE% -p atmega328p -c arduino -P %COM_PORT% -b 115200 -D -v -U flash:w:%1:i
@echo off
:end
endlocal
================================================
FILE: examples/avr/dpp_arduino-uno/README.url
================================================
[InternetShortcut]
URL=http://www.state-machine.com/qpn/avr_dpp_arduino-uno.html
IconFile=http://www.state-machine.com/qp.ico
================================================
FILE: examples/avr/dpp_arduino-uno/bsp.h
================================================
/*****************************************************************************
* Product: DPP example
* Last Updated for Version: 5.4.0
* Date of the Last Update: 2015-03-07
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
* Web : www.state-machine.com
*
*****************************************************************************/
#ifndef BSP_H
#define BSP_H
#define BSP_TICKS_PER_SEC 100U
void BSP_init(void);
void BSP_displayPaused(uint8_t paused);
void BSP_displayPhilStat(uint8_t n, char_t const *stat);
void BSP_terminate(int16_t result);
void BSP_randomSeed(uint32_t seed); /* random seed */
uint32_t BSP_random(void); /* pseudo-random generator */
#endif /* BSP_H */
================================================
FILE: examples/avr/dpp_arduino-uno/dpp.h
================================================
/*.$file${.::dpp.h} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: dpp.qm
* File: ${.::dpp.h}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::dpp.h} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#ifndef DPP_H
#define DPP_H
enum DPPSignals {
EAT_SIG = Q_USER_SIG, /* published by Table to let a philosopher eat */
DONE_SIG, /* published by Philosopher when done eating */
PAUSE_SIG, /* published by BSP to pause the application */
SERVE_SIG, /* published by BSP to pause the application */
TERMINATE_SIG, /* published by BSP to terminate the application */
HUNGRY_SIG, /* posted direclty to Table from hungry Philo */
MAX_SIG /* the last signal */
};
/* number of philosophers */
#define N_PHILO ((uint8_t)5)
#define PHILO_0_PRIO 1
/*.$declare${AOs::AO_Philo0} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo0;
/*.$enddecl${AOs::AO_Philo0} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo1} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo1;
/*.$enddecl${AOs::AO_Philo1} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo2} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo2;
/*.$enddecl${AOs::AO_Philo2} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo3} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo3;
/*.$enddecl${AOs::AO_Philo3} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Philo4} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Philo AO_Philo4;
/*.$enddecl${AOs::AO_Philo4} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::AO_Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
extern struct Table AO_Table;
/*.$enddecl${AOs::AO_Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::Philo_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo_ctor} ......................................................*/
void Philo_ctor(void);
/*.$enddecl${AOs::Philo_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$declare${AOs::Table_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table_ctor} ......................................................*/
void Table_ctor(void);
/*.$enddecl${AOs::Table_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#endif /* DPP_H */
================================================
FILE: examples/avr/dpp_arduino-uno/dpp.qm
================================================
Dining Philosopher Problem example with QActiveQActive_armX(&me->super, 0U, THINK_TIME, 0U);QActive_disarmX(&me->super, 0U);Q_ERROR(); /* these events should never arrive in this state */QACTIVE_POST(&AO_Table, HUNGRY_SIG, me->super.prio);Q_ERROR(); /* this event should never arrive in this state */QActive_armX(&me->super, 0U, EAT_TIME, 0U);QActive_disarmX(&me->super, 0U);
QACTIVE_POST(&AO_Table, DONE_SIG, me->super.prio);Q_ERROR(); /* these events should never arrive in this state */uint8_t n;
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "thinking");
}BSP_terminate(0);Q_ERROR();uint8_t n;
for (n = 0U; n < N_PHILO; ++n) { /* give permissions to eat... */
if ((me->isHungry[n] != 0U)
&& (me->fork[LEFT(n)] == FREE)
&& (me->fork[n] == FREE))
{
QActive *philo;
me->fork[LEFT(n)] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "eating ");
}
}uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "hungry ");
m = LEFT(n);(me->fork[m] == FREE) && (me->fork[n] == FREE)me->fork[m] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
BSP_displayPhilStat(n, "eating ");elseme->isHungry[n] = 1U;uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;
m = RIGHT(n); /* check the right neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[m] == FREE)) {
me->fork[n] = USED;
me->fork[m] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}
m = LEFT(n); /* check the left neighbor */
n = LEFT(m); /* left fork of the left neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[n] == FREE)) {
me->fork[m] = USED;
me->fork[n] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}Q_ERROR();BSP_displayPaused(1U);BSP_displayPaused(0U);uint8_t n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* philo ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
me->isHungry[n] = 1U;
BSP_displayPhilStat(n, "hungry ");uint8_t n, m;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;QActive_ctor(&AO_Philo0.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo1.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo2.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo3.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo4.super, Q_STATE_CAST(&Philo_initial));
BSP_randomSeed(123U);uint8_t n;
Table *me = &AO_Table;
QActive_ctor(&me->super, Q_STATE_CAST(&Table_initial));
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
}#ifndef DPP_H
#define DPP_H
enum DPPSignals {
EAT_SIG = Q_USER_SIG, /* published by Table to let a philosopher eat */
DONE_SIG, /* published by Philosopher when done eating */
PAUSE_SIG, /* published by BSP to pause the application */
SERVE_SIG, /* published by BSP to pause the application */
TERMINATE_SIG, /* published by BSP to terminate the application */
HUNGRY_SIG, /* posted direclty to Table from hungry Philo */
MAX_SIG /* the last signal */
};
/* number of philosophers */
#define N_PHILO ((uint8_t)5)
#define PHILO_0_PRIO 1
$declare${AOs::AO_Philo0}
$declare${AOs::AO_Philo1}
$declare${AOs::AO_Philo2}
$declare${AOs::AO_Philo3}
$declare${AOs::AO_Philo4}
$declare${AOs::AO_Table}
$declare${AOs::Philo_ctor}
$declare${AOs::Table_ctor}
#endif /* DPP_H */
#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("philo")
/* Active object class -----------------------------------------------------*/
$declare${AOs::Philo}
/* Global objects ----------------------------------------------------------*/
$define${AOs::AO_Philo0}
$define${AOs::AO_Philo1}
$define${AOs::AO_Philo2}
$define${AOs::AO_Philo3}
$define${AOs::AO_Philo4}
/* Local objects -----------------------------------------------------------*/
#define THINK_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + (BSP_TICKS_PER_SEC/2U))
#define EAT_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + BSP_TICKS_PER_SEC)
/* Philo definition --------------------------------------------------------*/
$define${AOs::Philo_ctor}
$define${AOs::Philo}#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("table")
/* Active object class -----------------------------------------------------*/
$declare${AOs::Table}
/* Global objects ----------------------------------------------------------*/
$define${AOs::AO_Table}
#define RIGHT(n_) ((uint8_t)(((n_) + (N_PHILO - 1U)) % N_PHILO))
#define LEFT(n_) ((uint8_t)(((n_) + 1U) % N_PHILO))
#define FREE ((uint8_t)0)
#define USED ((uint8_t)1)
/*..........................................................................*/
$define${AOs::Table_ctor}
$define${AOs::Table}
================================================
FILE: examples/avr/dpp_arduino-uno/main.c
================================================
/*****************************************************************************
* Product: DPP example
* Last Updated for Version: 5.8.0
* Date of the Last Update: 2016-11-06
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h" /* QP-nano */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
/*..........................................................................*/
static QEvt l_philoQueue[N_PHILO][N_PHILO];
static QEvt l_tableQueue[2];
/* QF_active[] array defines all active object control blocks --------------*/
QActiveCB const Q_ROM QF_active[] = {
{ (QActive *)0, (QEvt *)0, 0U },
{ (QActive *)&AO_Philo0, l_philoQueue[0], Q_DIM(l_philoQueue[0]) },
{ (QActive *)&AO_Philo1, l_philoQueue[1], Q_DIM(l_philoQueue[1]) },
{ (QActive *)&AO_Philo2, l_philoQueue[2], Q_DIM(l_philoQueue[2]) },
{ (QActive *)&AO_Philo3, l_philoQueue[3], Q_DIM(l_philoQueue[3]) },
{ (QActive *)&AO_Philo4, l_philoQueue[4], Q_DIM(l_philoQueue[4]) },
{ (QActive *)&AO_Table, l_tableQueue, Q_DIM(l_tableQueue) }
};
/*..........................................................................*/
int_t main() {
Philo_ctor(); /* instantiate all Philo AOs */
Table_ctor(); /* instantiate the Table AO */
QF_init(Q_DIM(QF_active)); /* initialize the QF-nano framework */
BSP_init(); /* initialize the Board Support Package */
return QF_run(); /* transfer control to QF-nano */
}
================================================
FILE: examples/avr/dpp_arduino-uno/philo.c
================================================
/*.$file${.::philo.c} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: dpp.qm
* File: ${.::philo.c}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::philo.c} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("philo")
/* Active object class -----------------------------------------------------*/
/*.$declare${AOs::Philo} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo} ...........................................................*/
typedef struct Philo {
/* protected: */
QActive super;
} Philo;
/* protected: */
static QState Philo_initial(Philo * const me);
static QState Philo_thinking(Philo * const me);
static QState Philo_hungry(Philo * const me);
static QState Philo_eating(Philo * const me);
/*.$enddecl${AOs::Philo} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Global objects ----------------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*. Check for the minimum required QP version */
#if (QP_VERSION < 650U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpn version 6.5.0 or higher required
#endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo0} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo0} .......................................................*/
struct Philo AO_Philo0;
/*.$enddef${AOs::AO_Philo0} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo1} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo1} .......................................................*/
struct Philo AO_Philo1;
/*.$enddef${AOs::AO_Philo1} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo2} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo2} .......................................................*/
struct Philo AO_Philo2;
/*.$enddef${AOs::AO_Philo2} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo3} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo3} .......................................................*/
struct Philo AO_Philo3;
/*.$enddef${AOs::AO_Philo3} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Philo4} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Philo4} .......................................................*/
struct Philo AO_Philo4;
/*.$enddef${AOs::AO_Philo4} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Local objects -----------------------------------------------------------*/
#define THINK_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + (BSP_TICKS_PER_SEC/2U))
#define EAT_TIME \
(QTimeEvtCtr)((BSP_random() % BSP_TICKS_PER_SEC) + BSP_TICKS_PER_SEC)
/* Philo definition --------------------------------------------------------*/
/*.$define${AOs::Philo_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo_ctor} ......................................................*/
void Philo_ctor(void) {
QActive_ctor(&AO_Philo0.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo1.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo2.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo3.super, Q_STATE_CAST(&Philo_initial));
QActive_ctor(&AO_Philo4.super, Q_STATE_CAST(&Philo_initial));
BSP_randomSeed(123U);
}
/*.$enddef${AOs::Philo_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Philo} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Philo} ...........................................................*/
/*.${AOs::Philo::SM} .......................................................*/
static QState Philo_initial(Philo * const me) {
/*.${AOs::Philo::SM::initial} */
return Q_TRAN(&Philo_thinking);
}
/*.${AOs::Philo::SM::thinking} .............................................*/
static QState Philo_thinking(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Philo::SM::thinking} */
case Q_ENTRY_SIG: {
QActive_armX(&me->super, 0U, THINK_TIME, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::thinking} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::thinking::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Philo_hungry);
break;
}
/*.${AOs::Philo::SM::thinking::EAT, DONE} */
case EAT_SIG: /* intentionally fall through */
case DONE_SIG: {
Q_ERROR(); /* these events should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Philo::SM::hungry} ...............................................*/
static QState Philo_hungry(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Philo::SM::hungry} */
case Q_ENTRY_SIG: {
QACTIVE_POST(&AO_Table, HUNGRY_SIG, me->super.prio);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::hungry::EAT} */
case EAT_SIG: {
status_ = Q_TRAN(&Philo_eating);
break;
}
/*.${AOs::Philo::SM::hungry::DONE} */
case DONE_SIG: {
Q_ERROR(); /* this event should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Philo::SM::eating} ...............................................*/
static QState Philo_eating(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Philo::SM::eating} */
case Q_ENTRY_SIG: {
QActive_armX(&me->super, 0U, EAT_TIME, 0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::eating} */
case Q_EXIT_SIG: {
QActive_disarmX(&me->super, 0U);
QACTIVE_POST(&AO_Table, DONE_SIG, me->super.prio);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Philo::SM::eating::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Philo_thinking);
break;
}
/*.${AOs::Philo::SM::eating::EAT, DONE} */
case EAT_SIG: /* intentionally fall through */
case DONE_SIG: {
Q_ERROR(); /* these events should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.$enddef${AOs::Philo} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
================================================
FILE: examples/avr/dpp_arduino-uno/qk/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano, Arduino-UNO, preemptive QK kernel, GNU-AVR
# Last Updated for Version: 5.4.0
# Date of the Last Update: 2015-05-28
#
# Q u a n t u m L e a P s
# ---------------------------
# innovating embedded systems
#
# Copyright (C) Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# Web: http://www.state-machine.com
# Email: info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := dpp-qk
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/avr/qk/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qkn \
$(QP_PORT_DIR)
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR)
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
bsp.c \
main.c \
philo.c \
table.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT :=
QP_SRCS := \
qepn.c \
qfn.c \
qkn.c
QP_ASMS :=
LIB_DIRS :=
LIBS :=
# defines
DEFINES :=
# AVR MCU type
AVR_MCU=atmega328p
#-----------------------------------------------------------------------------
# GNU-AVR toolset (NOTE: You need to adjust to your machine)
# see http://sourceforge.net/projects/winavr
#
ifeq ($(GNU_AVR),)
GNU_AVR = C:\tools\WinAVR
endif
# make sure that the GNU-AVR toolset exists...
ifeq ("$(wildcard $(GNU_AVR))","")
$(error GNU_AVR toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_AVR)/bin/avr-gcc
CPP := $(GNU_AVR)/bin/avr-g++
AS := $(GNU_AVR)/bin/avr-as
LINK := $(GNU_AVR)/bin/avr-gcc
BIN := $(GNU_AVR)/bin/avr-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M4F
#
# combine all the soruces...
C_SRCS += $(QP_SRCS) $(QP_PORT)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS =
CFLAGS = -mmcu=$(AVR_MCU) -std=gnu99 -fshort-enums -Wall \
-ffunction-sections -fdata-sections \
-Os $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -mmcu=$(AVR_MCU) -fshort-enums -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-Os $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration .........................................
BIN_DIR := dbg
ASFLAGS =
CFLAGS = -mmcu=$(AVR_MCU) -std=gnu99 -fshort-enums -Wall \
-ffunction-sections -fdata-sections \
-O $(INCLUDES) $(DEFINES)
CPPFLAGS = -mmcu=$(AVR_MCU) -fshort-enums -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES)
endif # .....................................................................
LINKFLAGS = -mmcu=$(AVR_MCU) \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_HEX := $(BIN_DIR)/$(OUTPUT).hex
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_HEX)
#all: $(TARGET_ELF)
$(TARGET_HEX): $(TARGET_ELF)
$(BIN) -O ihex $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(LINK) $(LINKFLAGS) -o $@ $^ $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) -c $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.hex \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/avr/dpp_arduino-uno/qk/gnu/README.txt
================================================
About this Example
==================
This example can be built from the command prompt with the provided
Makefile. The example can also be invoked directly (via the make
utility) from the QM modeling tool.
The Makefile
============
The provided Makefile should be easy to adapt for your own projects.
It contains three build configurations: Debug (default) and Release.
The various build configurations are built as follows:
make
make CONF=rel
make clean
make CONF=rel clean
Warning: '__progmem__' attribute ignored
========================================
AVR is a Harvard architecture that uses different program and data spaces as
well as different CPU instructions to access these two address spaces (data
memory is 8-bit wide while program memory is 16-bit wide). Consequently, one
of the biggest concerns in AVR programs is to correctly allocate and access
constant data in the program space (ROM) rather than the precious RAM. Since
the ROM resides in a different address space, you need to tell the compiler
to place variables there. You also need a way to access the data (i.e., the
compiler has to use the lpm instruction.)
The GNU-AVR compiler supports data in the program memory only partially
through the attribute((progmem)) extension (typically used through the
PROGMEM macro). By tagging a variable with attribute((progmem)), you can
force it to reside in the ROM. However, the compiler support ends at this
point. It is the responsibility of the developer to correctly access the
PROGMEM variables. The GCC-AVR provides merely a bunch of macros (all
defined in the avr\pgmspace.h header file).
The bottom line is that the GNU-AVR compiler support for ROM-allocated
objects through the PROGMEM attribute is both incomplete and inconsistent
with the correct implementation in other compilers (such as IAR-AVR).
For example, pointers pointing to PROGMEM objects are not treated correctly,
meaning that the compiler will not generate the right code to access such
ROM objects (the GNU-AVR compiler needs a kludge in form of macros such as
pgm_read_byte_near and others). To recognize that fact, the GNU-AVR
generates the warnings "'progmem' attribute ignored ".
However, the QP source code is written for a standard correct implementation
(how else would you achieve portability?). For example, the IAR-AVR compiler
uses the attribute '__flash' to designate objects and pointers to ROM
objects. The compiler then generates the right code for all such flash
objects and pointers, without any kludges necessary for the GNU compiler.
In summary, the warnings "'progmem' attribute ignored" should be ignored
in the QP library build. To avoid these warnings, the QP source code would
have to be modified in such a way that it would be incorrect for other
compilers that handle these declarations correctly.
================================================
FILE: examples/avr/dpp_arduino-uno/qk/gnu/bsp.c
================================================
/*****************************************************************************
* Product: DPP example, Arduino-UNO board, preemptive QK kernel, GNU-AVR
* Last updated for version 6.8.0
* Last updated on 2020-03-22
*
* Q u a n t u m L e a P s
* ------------------------
* Modern Embedded Software
*
* Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "dpp.h"
#include "bsp.h"
/* the AVR device specific header is already included */
/* add other drivers if necessary... */
Q_DEFINE_THIS_FILE
/* Local-scope objects -----------------------------------------------------*/
/* Arduino-UNO runs off the 16MHz oscillator */
#define F_CPU 16000000UL
/* the on-board LED labeled "L" on Arduino-UNO (PORTB) */
#define LED_L (1U << 5)
/* external button BTN_EXT (PORTD), arduino.cc/en/tutorial/button */
#define BTN_EXT (1U << 2)
static unsigned l_rnd; /* random seed */
/* ISRs used in this project ===============================================*/
ISR(TIMER2_COMPA_vect) {
/* state of the button debouncing, see below */
static struct ButtonsDebouncing {
uint8_t depressed;
uint8_t previous;
} buttons = { 0xFFU, 0xFFU };
uint8_t current;
uint8_t tmp;
QK_ISR_ENTRY(); /* inform QK about entering an ISR */
QF_tickXISR(0U); /* process time events for rate 0 */
/* Perform the debouncing of buttons. The algorithm for debouncing
* adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
* and Michael Barr, page 71.
*/
current = PIND; /* read PORTD with the state of BTN_EXT */
tmp = buttons.depressed; /* save the debounced depressed buttons */
buttons.depressed |= (buttons.previous & current); /* set depressed */
buttons.depressed &= (buttons.previous | current); /* clear released */
buttons.previous = current; /* update the history */
tmp ^= buttons.depressed; /* changed debounced depressed */
if ((tmp & BTN_EXT) != 0U) { /* debounced BTN_EXT state changed? */
if ((buttons.depressed & BTN_EXT) != 0U) { /* is BTN_EXT depressed? */
QACTIVE_POST_ISR(&AO_Table, PAUSE_SIG, 0U);
}
else { /* the button is released */
QACTIVE_POST_ISR(&AO_Table, SERVE_SIG, 0U);
}
}
QK_ISR_EXIT(); /* inform QK about exiting an ISR */
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* setup the port for the LED (PORTB.5) */
DDRB = 0xFFU; /* set all pins on PORTB as output */
PORTB &= ~LED_L; /* drive LED_L pin low */
/* setup the port for the Button (PORTD.2) */
DDRD &= ~BTN_EXT; /* set PORTD pin BTN_EXT as input */
}
/*..........................................................................*/
void BSP_displayPhilStat(uint8_t n, char const *stat) {
if (stat[0] == 'h') {
PORTB |= LED_L;
}
else {
PORTB &= ~LED_L;
}
}
/*..........................................................................*/
void BSP_displayPaused(uint8_t paused) {
/* not enouhg LEDs to implement this feature */
if (paused != 0U) {
//PORTB |= LED_L;
}
else {
//PORTB &= ~LED_L;
}
}
/*..........................................................................*/
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
l_rnd = l_rnd * (3U*7U*11U*13U*23U);
return l_rnd >> 8;
}
/*..........................................................................*/
void BSP_randomSeed(uint32_t seed) {
l_rnd = seed;
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
(void)result;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set Timer2 in CTC mode, 1/1024 prescaler, start the timer ticking... */
TCCR2A = (1U << WGM21) | (0U << WGM20);
TCCR2B = (1U << CS22 ) | (1U << CS21) | (1U << CS20); /* 1/2^10 */
ASSR &= ~(1U << AS2);
TIMSK2 = (1U << OCIE2A); /* Enable TIMER2 compare Interrupt */
TCNT2 = 0U;
OCR2A = (F_CPU / BSP_TICKS_PER_SEC / 1024U) - 1U;
}
/*..........................................................................*/
void QF_onCleanup(void) {
}
/*..........................................................................*/
void QK_onIdle(void) {
/* toggle the User LED, see NOTE1 , not enough LEDs to implement! */
//QF_INT_DISABLE();
//PORTB |= LED_L;
//PORTB &= ~LED_L;
//QF_INT_ENABLE();
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular AVR MCU.
*/
SMCR = (0 << SM0) | (1 << SE); /* idle mode, adjust to your project */
QK_CPU_SLEEP(); /* put CPU to sleep */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int location) {
/* implement the error-handling policy for your application!!! */
QF_INT_DISABLE(); /* disable all interrupts */
QF_RESET(); /* reset the CPU */
for (;;) {
}
}
/*****************************************************************************
* NOTE1:
* The User LED is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/avr/dpp_arduino-uno/qk/gnu/flash.bat
================================================
@echo off
::============================================================================
:: Batch file to program the flash of Arduino-UNO
::
:: NOTE: requires the AVRDUDE uitlity which is included in the QTools
:: collection
::
setlocal
@echo off
@echo Load a given hex file to the flash of Arduino-UNO
@echo usage: flash hex-file [COM-port]
@echo example: flash dbg\blinky-qk.hex
@echo example: flash dbg\blinky-qk.hex COM5
::----------------------------------------------------------------------------
:: NOTE: Adjust the following symbol to the location of the
:: AVRDUDE utility on your machine
::
set AVRDUDE=avrdude.exe
set COM_PORT=COM5
if [%2] NEQ [] set COM_PORT=%2
if ["%~1"]==[""] (
@echo The hex file missing
@goto end
)
if not exist %~s1 (
@echo The hex file '%1' does not exist
@goto end
)
@echo on
%AVRDUDE% -p atmega328p -c arduino -P %COM_PORT% -b 115200 -D -v -U flash:w:%1:i
@echo off
:end
endlocal
================================================
FILE: examples/avr/dpp_arduino-uno/qk/iar/README.txt
================================================
About The DPP-AVR Example
=========================
This directory contains the DPP example for the 8-bit AVRmega processor family
with the IAR-AVR compiler.
***
NOTE: The Debug build configuration needs to use the high optimization level
(for size) in order to fit under the code size limit of the free KickStart
version of the IAR-AVR toolset.
***
================================================
FILE: examples/avr/dpp_arduino-uno/qk/iar/bsp.c
================================================
/*****************************************************************************
* Product: DPP example, Arduino-UNO board, preemptive QK kernel, IAR-AVR
* Last updated for version 6.8.0
* Last updated on 2020-03-22
*
* Q u a n t u m L e a P s
* ------------------------
* Modern Embedded Software
*
* Copyright (C) 2005-2020 Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "dpp.h"
#include "bsp.h"
#include /* the AVR MCU variant used */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/* Local-scope objects -----------------------------------------------------*/
/* Arduino-UNO runs off the 16MHz oscillator */
#define F_CPU 16000000UL
/* the on-board LED labeled "L" on Arduino-UNO (PORTB) */
#define LED_L (1U << 5)
/* external button BTN_EXT (PORTD), arduino.cc/en/tutorial/button */
#define BTN_EXT (1U << 2)
static unsigned l_rnd; /* random seed */
/* ISRs used in this project ===============================================*/
#pragma vector = TIMER2_COMPA_vect
__interrupt void timer2_ISR(void) {
/* state of the button debouncing, see below */
static struct ButtonsDebouncing {
uint8_t depressed;
uint8_t previous;
} buttons = { 0xFFU, 0xFFU };
uint8_t current;
uint8_t tmp;
QK_ISR_ENTRY(); /* inform QK about entering an ISR */
QF_tickXISR(0U); /* process time events for rate 0 */
/* Perform the debouncing of buttons. The algorithm for debouncing
* adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
* and Michael Barr, page 71.
*/
current = PIND; /* read PORTD with the state of BTN_EXT */
tmp = buttons.depressed; /* save the debounced depressed buttons */
buttons.depressed |= (buttons.previous & current); /* set depressed */
buttons.depressed &= (buttons.previous | current); /* clear released */
buttons.previous = current; /* update the history */
tmp ^= buttons.depressed; /* changed debounced depressed */
if ((tmp & BTN_EXT) != 0U) { /* debounced BTN_EXT state changed? */
if ((buttons.depressed & BTN_EXT) != 0U) { /* is BTN_EXT depressed? */
QACTIVE_POST_ISR(&AO_Table, PAUSE_SIG, 0U);
}
else { /* the button is released */
QACTIVE_POST_ISR(&AO_Table, SERVE_SIG, 0U);
}
}
QK_ISR_EXIT(); /* inform QK about exiting an ISR */
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* setup the port for the LED (PORTB.5) */
DDRB = 0xFFU; /* set all pins on PORTB as output */
PORTB &= ~LED_L; /* drive LED_L pin low */
/* setup the port for the Button (PORTD.2) */
DDRD &= ~BTN_EXT; /* set PORTD pin BTN_EXT as input */
}
/*..........................................................................*/
void BSP_displayPhilStat(uint8_t n, char const *stat) {
if (stat[0] == 'h') {
PORTB |= LED_L;
}
else {
PORTB &= ~LED_L;
}
}
/*..........................................................................*/
void BSP_displayPaused(uint8_t paused) {
/* not enouhg LEDs to implement this feature */
if (paused != 0U) {
//PORTB |= LED_L;
}
else {
//PORTB &= ~LED_L;
}
}
/*..........................................................................*/
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
l_rnd = l_rnd * (3U*7U*11U*13U*23U);
return l_rnd >> 8;
}
/*..........................................................................*/
void BSP_randomSeed(uint32_t seed) {
l_rnd = seed;
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
(void)result;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set Timer2 in CTC mode, 1/1024 prescaler, start the timer ticking... */
TCCR2A = (1U << WGM21) | (0U << WGM20);
TCCR2B = (1U << CS22 ) | (1U << CS21) | (1U << CS20); /* 1/2^10 */
ASSR &= ~(1U << AS2);
TIMSK2 = (1U << OCIE2A); /* Enable TIMER2 compare Interrupt */
TCNT2 = 0U;
OCR2A = (F_CPU / BSP_TICKS_PER_SEC / 1024U) - 1U;
}
/*..........................................................................*/
void QF_onCleanup(void) {
}
/*..........................................................................*/
void QK_onIdle(void) {
/* toggle the User LED, see NOTE1 , not enough LEDs to implement! */
//QF_INT_DISABLE();
//PORTB |= LED_L;
//PORTB &= ~LED_L;
//QF_INT_ENABLE();
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular AVR MCU.
*/
SMCR = (0 << SM0) | (1 << SE); /* idle mode, adjust to your project */
QK_CPU_SLEEP(); /* put CPU to sleep */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int location) {
/* implement the error-handling policy for your application!!! */
QF_INT_DISABLE(); /* disable all interrupts */
QF_RESET(); /* reset the CPU */
for (;;) {
}
}
/*****************************************************************************
* NOTE1:
* The User LED is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/avr/dpp_arduino-uno/qk/iar/dpp-qk.ewd
================================================
2DebugAVR1C-SPY61611ATMELICEAVR5111AVRONE4411CCRAVR2111ICE200AVR2111JTAGICEAVR3211JTAGICE3AVR5611JTAGICEMKIIAVR5711DRAGONAVR3311SIMAVR2111THIRDPARTYAVR2111$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\Stk600\Stk600Plugin.ewplugin1$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin1$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseAVR0C-SPY61610ATMELICEAVR5110AVRONE4410CCRAVR2110ICE200AVR2110JTAGICEAVR3210JTAGICE3AVR5610JTAGICEMKIIAVR5710DRAGONAVR3310SIMAVR2110THIRDPARTYAVR2110$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\Stk600\Stk600Plugin.ewplugin1$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin1$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/avr/dpp_arduino-uno/qk/iar/dpp-qk.ewp
================================================
2DebugAVR1General11911ICCAVR61711AAVR51111CUSTOM30BICOMP0BUILDACTION1XLINK31611XAR2011BILINK0ReleaseAVR0General11910ICCAVR61710AAVR51110CUSTOM30BICOMP0BUILDACTION1XLINK31610XAR2010BILINK0Application$PROJ_DIR$\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\dpp.h$PROJ_DIR$\..\..\main.c$PROJ_DIR$\..\..\philo.c$PROJ_DIR$\..\..\table.cQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qkn\qkn.c
================================================
FILE: examples/avr/dpp_arduino-uno/qk/iar/dpp-qk.eww
================================================
$WS_DIR$\dpp-qk.ewp
================================================
FILE: examples/avr/dpp_arduino-uno/qk/iar/flash.bat
================================================
@echo off
::============================================================================
:: Batch file to program the flash of Arduino-UNO
::
:: NOTE: requires the AVRDUDE uitlity which is included in the QTools
:: collection
::
setlocal
@echo off
@echo Load a given hex file to the flash of Arduino-UNO
@echo usage: flash hex-file [COM-port]
@echo example: flash dbg\blinky-qk.hex
@echo example: flash dbg\blinky-qk.hex COM5
::----------------------------------------------------------------------------
:: NOTE: Adjust the following symbol to the location of the
:: AVRDUDE utility on your machine
::
set AVRDUDE=avrdude.exe
set COM_PORT=COM5
if [%2] NEQ [] set COM_PORT=%2
if ["%~1"]==[""] (
@echo The hex file missing
@goto end
)
if not exist %~s1 (
@echo The hex file '%1' does not exist
@goto end
)
@echo on
%AVRDUDE% -p atmega328p -c arduino -P %COM_PORT% -b 115200 -D -v -U flash:w:%1:i
@echo off
:end
endlocal
================================================
FILE: examples/avr/dpp_arduino-uno/qk/iar/spy.bat
================================================
set COM_PORT=COM5
if [%1] NEQ [] set COM_PORT=%1
qspy -c%COM_PORT% -b115200 -O2 -F2 -E1 -P1 -B1
================================================
FILE: examples/avr/dpp_arduino-uno/qpn_conf.h
================================================
/*****************************************************************************
* Product: QP-nano configuration for the Blinky example
* Last Updated for Version: 5.6.2
* Date of the Last Update: 2016-04-05
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef QPN_CONF_H
#define QPN_CONF_H
#define Q_PARAM_SIZE 4U
#define QF_MAX_TICK_RATE 1U
#define QF_TIMEEVT_CTR_SIZE 2U
#define QF_TIMEEVT_PERIODIC
#endif /* QPN_CONF_H */
================================================
FILE: examples/avr/dpp_arduino-uno/qv/gnu/Makefile
================================================
##############################################################################
# Product: Makefile for QP-nano, Arduino-UNO, cooperative QV kernel, GNU-AVR
# Last Updated for Version: 5.4.0
# Date of the Last Update: 2015-05-28
#
# Q u a n t u m L e a P s
# ---------------------------
# innovating embedded systems
#
# Copyright (C) Quantum Leaps, LLC. All rights reserved.
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Contact information:
# Web: http://www.state-machine.com
# Email: info@state-machine.com
##############################################################################
# examples of invoking this Makefile:
# building configurations: Debug (default), Release, and Spy
# make
# make CONF=rel
#
# cleaning configurations: Debug (default), Release, and Spy
# make clean
# make CONF=rel clean
#
# NOTE:
# To use this Makefile on Windows, you will need the GNU make utility, which
# is included in the Qtools collection for Windows, see:
# http://sourceforge.net/projects/qpc/files/Qtools/
#
#-----------------------------------------------------------------------------
# project name
#
PROJECT := dpp-qv
#-----------------------------------------------------------------------------
# project directories
#
# location of the QP-nano framework (if not provided in an environemnt var.)
ifeq ($(QPN),)
QPN := ../../../../..
endif
# QP port used in this project
QP_PORT_DIR := $(QPN)/ports/avr/qv/gnu
# list of all source directories used by this project
VPATH = \
.. \
../.. \
$(QPN)/src/qfn \
$(QPN)/src/qvn \
$(QP_PORT_DIR)
# list of all include directories needed by this project
INCLUDES = \
-I../.. \
-I$(QPN)/include \
-I$(QP_PORT_DIR)
#-----------------------------------------------------------------------------
# files
#
# assembler source files
ASM_SRCS :=
# C source files
C_SRCS := \
bsp.c \
main.c \
philo.c \
table.c
# C++ source files
CPP_SRCS :=
OUTPUT := $(PROJECT)
LD_SCRIPT :=
QP_SRCS := \
qepn.c \
qfn.c \
qvn.c
QP_ASMS :=
LIB_DIRS :=
LIBS :=
# defines
DEFINES :=
# AVR MCU type
AVR_MCU=atmega328p
#-----------------------------------------------------------------------------
# GNU-AVR toolset (NOTE: You need to adjust to your machine)
# see http://sourceforge.net/projects/winavr
#
ifeq ($(GNU_AVR),)
GNU_AVR = C:\tools\WinAVR
endif
# make sure that the GNU-AVR toolset exists...
ifeq ("$(wildcard $(GNU_AVR))","")
$(error GNU_AVR toolset not found. Please adjust the Makefile)
endif
CC := $(GNU_AVR)/bin/avr-gcc
CPP := $(GNU_AVR)/bin/avr-g++
AS := $(GNU_AVR)/bin/avr-as
LINK := $(GNU_AVR)/bin/avr-gcc
BIN := $(GNU_AVR)/bin/avr-objcopy
##############################################################################
# Typically, you should not need to change anything below this line
# basic utilities (included in Qtools for Windows), see:
# http://sourceforge.net/projects/qpc/files/Qtools
MKDIR := mkdir
RM := rm
#-----------------------------------------------------------------------------
# build options for various configurations for ARM Cortex-M4F
#
# combine all the soruces...
C_SRCS += $(QP_SRCS) $(QP_PORT)
ifeq (rel, $(CONF)) # Release configuration ..................................
BIN_DIR := rel
ASFLAGS =
CFLAGS = -mmcu=$(AVR_MCU) -std=gnu99 -fshort-enums -Wall \
-ffunction-sections -fdata-sections \
-Os $(INCLUDES) $(DEFINES) -DNDEBUG
CPPFLAGS = -mmcu=$(AVR_MCU) -fshort-enums -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-Os $(INCLUDES) $(DEFINES) -DNDEBUG
else # default Debug configuration .........................................
BIN_DIR := dbg
ASFLAGS =
CFLAGS = -mmcu=$(AVR_MCU) -std=gnu99 -fshort-enums -Wall \
-ffunction-sections -fdata-sections \
-O $(INCLUDES) $(DEFINES)
CPPFLAGS = -mmcu=$(AVR_MCU) -fshort-enums -Wall \
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
-O $(INCLUDES) $(DEFINES)
endif # .....................................................................
LINKFLAGS = -mmcu=$(AVR_MCU) \
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
TARGET_HEX := $(BIN_DIR)/$(OUTPUT).hex
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
# create $(BIN_DIR) if it does not exist
ifeq ("$(wildcard $(BIN_DIR))","")
$(shell $(MKDIR) $(BIN_DIR))
endif
#-----------------------------------------------------------------------------
# rules
#
all: $(TARGET_HEX)
#all: $(TARGET_ELF)
$(TARGET_HEX): $(TARGET_ELF)
$(BIN) -O ihex $< $@
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
$(LINK) $(LINKFLAGS) -o $@ $^ $(LIBS)
$(BIN_DIR)/%.d : %.c
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
$(BIN_DIR)/%.d : %.cpp
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
$(BIN_DIR)/%.o : %.s
$(AS) $(ASFLAGS) $< -o $@
$(BIN_DIR)/%.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
$(BIN_DIR)/%.o : %.cpp
$(CPP) $(CPPFLAGS) -c $< -o $@
# include dependency files only if our goal depends on their existence
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),show)
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
endif
endif
.PHONY : clean
clean:
-$(RM) $(BIN_DIR)/*.o \
$(BIN_DIR)/*.d \
$(BIN_DIR)/*.hex \
$(BIN_DIR)/*.elf \
$(BIN_DIR)/*.map
show:
@echo PROJECT = $(PROJECT)
@echo CONF = $(CONF)
@echo DEFINES = $(DEFINES)
@echo ASM_FPU = $(ASM_FPU)
@echo ASM_SRCS = $(ASM_SRCS)
@echo C_SRCS = $(C_SRCS)
@echo CPP_SRCS = $(CPP_SRCS)
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
@echo C_OBJS_EXT = $(C_OBJS_EXT)
@echo C_DEPS_EXT = $(C_DEPS_EXT)
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
@echo TARGET_ELF = $(TARGET_ELF)
================================================
FILE: examples/avr/dpp_arduino-uno/qv/gnu/README.txt
================================================
About this Example
==================
This example can be built from the command prompt with the provided
Makefile. The example can also be invoked directly (via the make
utility) from the QM modeling tool.
The Makefile
============
The provided Makefile should be easy to adapt for your own projects.
It contains three build configurations: Debug (default) and Release.
The various build configurations are built as follows:
make
make CONF=rel
make clean
make CONF=rel clean
Warning: '__progmem__' attribute ignored
========================================
AVR is a Harvard architecture that uses different program and data spaces as
well as different CPU instructions to access these two address spaces (data
memory is 8-bit wide while program memory is 16-bit wide). Consequently, one
of the biggest concerns in AVR programs is to correctly allocate and access
constant data in the program space (ROM) rather than the precious RAM. Since
the ROM resides in a different address space, you need to tell the compiler
to place variables there. You also need a way to access the data (i.e., the
compiler has to use the lpm instruction.)
The GNU-AVR compiler supports data in the program memory only partially
through the attribute((progmem)) extension (typically used through the
PROGMEM macro). By tagging a variable with attribute((progmem)), you can
force it to reside in the ROM. However, the compiler support ends at this
point. It is the responsibility of the developer to correctly access the
PROGMEM variables. The GCC-AVR provides merely a bunch of macros (all
defined in the avr\pgmspace.h header file).
The bottom line is that the GNU-AVR compiler support for ROM-allocated
objects through the PROGMEM attribute is both incomplete and inconsistent
with the correct implementation in other compilers (such as IAR-AVR).
For example, pointers pointing to PROGMEM objects are not treated correctly,
meaning that the compiler will not generate the right code to access such
ROM objects (the GNU-AVR compiler needs a kludge in form of macros such as
pgm_read_byte_near and others). To recognize that fact, the GNU-AVR
generates the warnings "'progmem' attribute ignored ".
However, the QP source code is written for a standard correct implementation
(how else would you achieve portability?). For example, the IAR-AVR compiler
uses the attribute '__flash' to designate objects and pointers to ROM
objects. The compiler then generates the right code for all such flash
objects and pointers, without any kludges necessary for the GNU compiler.
In summary, the warnings "'progmem' attribute ignored" should be ignored
in the QP library build. To avoid these warnings, the QP source code would
have to be modified in such a way that it would be incorrect for other
compilers that handle these declarations correctly.
================================================
FILE: examples/avr/dpp_arduino-uno/qv/gnu/bsp.c
================================================
/*****************************************************************************
* Product: DPP example, Arduino-UNO board, cooperative QV kernel, GNU-AVR
* Last updated for version 6.8.0
* Last updated on 2020-03-22
*
* Q u a n t u m L e a P s
* ------------------------
* Modern Embedded Software
*
* Copyright (C) 2005-2020 Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "dpp.h"
#include "bsp.h"
/* the AVR device specific header is already included */
/* add other drivers if necessary... */
Q_DEFINE_THIS_FILE
/* Local-scope objects -----------------------------------------------------*/
/* Arduino-UNO runs off the 16MHz oscillator */
#define F_CPU 16000000UL
/* the on-board LED labeled "L" on Arduino-UNO (PORTB) */
#define LED_L (1U << 5)
/* external button BTN_EXT (PORTD), arduino.cc/en/tutorial/button */
#define BTN_EXT (1U << 2)
static unsigned l_rnd; /* random seed */
/* ISRs used in this project ===============================================*/
ISR(TIMER2_COMPA_vect) {
/* state of the button debouncing, see below */
static struct ButtonsDebouncing {
uint8_t depressed;
uint8_t previous;
} buttons = { 0xFFU, 0xFFU };
uint8_t current;
uint8_t tmp;
QF_tickXISR(0U); /* process time events for rate 0 */
/* Perform the debouncing of buttons. The algorithm for debouncing
* adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
* and Michael Barr, page 71.
*/
current = PIND; /* read PORTD with the state of BTN_EXT */
tmp = buttons.depressed; /* save the debounced depressed buttons */
buttons.depressed |= (buttons.previous & current); /* set depressed */
buttons.depressed &= (buttons.previous | current); /* clear released */
buttons.previous = current; /* update the history */
tmp ^= buttons.depressed; /* changed debounced depressed */
if ((tmp & BTN_EXT) != 0U) { /* debounced BTN_EXT state changed? */
if ((buttons.depressed & BTN_EXT) != 0U) { /* is BTN_EXT depressed? */
QACTIVE_POST_ISR(&AO_Table, PAUSE_SIG, 0U);
}
else { /* the button is released */
QACTIVE_POST_ISR(&AO_Table, SERVE_SIG, 0U);
}
}
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* setup the port for the LED (PORTB.5) */
DDRB = 0xFFU; /* set all pins on PORTB as output */
PORTB &= ~LED_L; /* drive LED_L pin low */
/* setup the port for the Button (PORTD.2) */
DDRD &= ~BTN_EXT; /* set PORTD pin BTN_EXT as input */
}
/*..........................................................................*/
void BSP_displayPhilStat(uint8_t n, char const *stat) {
if (stat[0] == 'h') {
PORTB |= LED_L;
}
else {
PORTB &= ~LED_L;
}
}
/*..........................................................................*/
void BSP_displayPaused(uint8_t paused) {
/* not enouhg LEDs to implement this feature */
if (paused != 0U) {
//PORTB |= LED_L;
}
else {
//PORTB &= ~LED_L;
}
}
/*..........................................................................*/
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
l_rnd = l_rnd * (3U*7U*11U*13U*23U);
return l_rnd >> 8;
}
/*..........................................................................*/
void BSP_randomSeed(uint32_t seed) {
l_rnd = seed;
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
(void)result;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set Timer2 in CTC mode, 1/1024 prescaler, start the timer ticking... */
TCCR2A = (1U << WGM21) | (0U << WGM20);
TCCR2B = (1U << CS22 ) | (1U << CS21) | (1U << CS20); /* 1/2^10 */
ASSR &= ~(1U << AS2);
TIMSK2 = (1U << OCIE2A); /* Enable TIMER2 compare Interrupt */
TCNT2 = 0U;
OCR2A = (F_CPU / BSP_TICKS_PER_SEC / 1024U) - 1U;
}
/*..........................................................................*/
void QF_onCleanup(void) {
}
/*..........................................................................*/
void QV_onIdle(void) { /* called with interrupts DISABLED, see NOTE1 */
/* toggle the User LED, see NOTE1 , not enough LEDs to implement! */
//PORTB |= LED_L;
//PORTB &= ~LED_L;
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular AVR MCU.
*/
SMCR = (0 << SM0) | (1 << SE); /* idle mode, adjust to your project */
QV_CPU_SLEEP(); /* atomically go to sleep and enable interrupts */
#else
QF_INT_ENABLE(); /* just enable interrupts */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int location) {
/* implement the error-handling policy for your application!!! */
QF_INT_DISABLE(); /* disable all interrupts */
QF_RESET(); /* reset the CPU */
for (;;) {
}
}
/*****************************************************************************
* NOTE1:
* The QV_onIdle() callback is called with interrupts disabled, because the
* determination of the idle condition might change by any interrupt posting
* an event. QV_onIdle() must internally enable interrupts, ideally
* atomically with putting the CPU to the power-saving mode.
*
* NOTE2:
* The User LED is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/avr/dpp_arduino-uno/qv/gnu/flash.bat
================================================
@echo off
::============================================================================
:: Batch file to program the flash of Arduino-UNO
::
:: NOTE: requires the AVRDUDE uitlity which is included in the QTools
:: collection
::
setlocal
@echo off
@echo Load a given hex file to the flash of Arduino-UNO
@echo usage: flash hex-file [COM-port]
@echo example: flash dbg\blinky-qk.hex
@echo example: flash dbg\blinky-qk.hex COM5
::----------------------------------------------------------------------------
:: NOTE: Adjust the following symbol to the location of the
:: AVRDUDE utility on your machine
::
set AVRDUDE=avrdude.exe
set COM_PORT=COM5
if [%2] NEQ [] set COM_PORT=%2
if ["%~1"]==[""] (
@echo The hex file missing
@goto end
)
if not exist %~s1 (
@echo The hex file '%1' does not exist
@goto end
)
@echo on
%AVRDUDE% -p atmega328p -c arduino -P %COM_PORT% -b 115200 -D -v -U flash:w:%1:i
@echo off
:end
endlocal
================================================
FILE: examples/avr/dpp_arduino-uno/qv/gnu/spy.bat
================================================
set COM_PORT=COM5
if [%1] NEQ [] set COM_PORT=%1
qspy -c%COM_PORT% -b115200 -O2 -F2 -E1 -P1 -B1
================================================
FILE: examples/avr/dpp_arduino-uno/qv/iar/README.txt
================================================
About The DPP-AVR Example
=========================
This directory contains the DPP example for the 8-bit AVRmega processor family
with the IAR-AVR compiler.
***
NOTE: The Debug build configuration needs to use the high optimization level
(for size) in order to fit under the code size limit of the free KickStart
version of the IAR-AVR toolset.
***
================================================
FILE: examples/avr/dpp_arduino-uno/qv/iar/bsp.c
================================================
/*****************************************************************************
* Product: DPP example, Arduino-UNO board, cooperative QV kernel, IAR-AVR
* Last updated for version 6.8.0
* Last updated on 2020-03-22
*
* Q u a n t u m L e a P s
* ------------------------
* Modern Embedded Software
*
* Copyright (C) 2005-2020 Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "dpp.h"
#include "bsp.h"
#include /* the AVR MCU variant used */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/* Local-scope objects -----------------------------------------------------*/
/* Arduino-UNO runs off the 16MHz oscillator */
#define F_CPU 16000000UL
/* the on-board LED labeled "L" on Arduino-UNO (PORTB) */
#define LED_L (1U << 5)
/* external button BTN_EXT (PORTD), arduino.cc/en/tutorial/button */
#define BTN_EXT (1U << 2)
static unsigned l_rnd; /* random seed */
/* ISRs used in this project ===============================================*/
#pragma vector = TIMER2_COMPA_vect
__interrupt void timer2_ISR(void) {
/* state of the button debouncing, see below */
static struct ButtonsDebouncing {
uint8_t depressed;
uint8_t previous;
} buttons = { 0xFFU, 0xFFU };
uint8_t current;
uint8_t tmp;
QF_tickXISR(0U); /* process time events for rate 0 */
/* Perform the debouncing of buttons. The algorithm for debouncing
* adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
* and Michael Barr, page 71.
*/
current = PIND; /* read PORTD with the state of BTN_EXT */
tmp = buttons.depressed; /* save the debounced depressed buttons */
buttons.depressed |= (buttons.previous & current); /* set depressed */
buttons.depressed &= (buttons.previous | current); /* clear released */
buttons.previous = current; /* update the history */
tmp ^= buttons.depressed; /* changed debounced depressed */
if ((tmp & BTN_EXT) != 0U) { /* debounced BTN_EXT state changed? */
if ((buttons.depressed & BTN_EXT) != 0U) { /* is BTN_EXT depressed? */
QACTIVE_POST_ISR(&AO_Table, PAUSE_SIG, 0U);
}
else { /* the button is released */
QACTIVE_POST_ISR(&AO_Table, SERVE_SIG, 0U);
}
}
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* setup the port for the LED (PORTB.5) */
DDRB = 0xFFU; /* set all pins on PORTB as output */
PORTB &= ~LED_L; /* drive LED_L pin low */
/* setup the port for the Button (PORTD.2) */
DDRD &= ~BTN_EXT; /* set PORTD pin BTN_EXT as input */
}
/*..........................................................................*/
void BSP_displayPhilStat(uint8_t n, char const *stat) {
if (stat[0] == 'h') {
PORTB |= LED_L;
}
else {
PORTB &= ~LED_L;
}
}
/*..........................................................................*/
void BSP_displayPaused(uint8_t paused) {
/* not enouhg LEDs to implement this feature */
if (paused != 0U) {
//PORTB |= LED_L;
}
else {
//PORTB &= ~LED_L;
}
}
/*..........................................................................*/
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
l_rnd = l_rnd * (3U*7U*11U*13U*23U);
return l_rnd >> 8;
}
/*..........................................................................*/
void BSP_randomSeed(uint32_t seed) {
l_rnd = seed;
}
/*..........................................................................*/
void BSP_terminate(int16_t result) {
(void)result;
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
/* set Timer2 in CTC mode, 1/1024 prescaler, start the timer ticking... */
TCCR2A = (1U << WGM21) | (0U << WGM20);
TCCR2B = (1U << CS22 ) | (1U << CS21) | (1U << CS20); /* 1/2^10 */
ASSR &= ~(1U << AS2);
TIMSK2 = (1U << OCIE2A); /* Enable TIMER2 compare Interrupt */
TCNT2 = 0U;
OCR2A = (F_CPU / BSP_TICKS_PER_SEC / 1024U) - 1U;
}
/*..........................................................................*/
void QF_onCleanup(void) {
}
/*..........................................................................*/
void QV_onIdle(void) { /* called with interrupts DISABLED, see NOTE1 */
/* toggle the User LED, see NOTE1 , not enough LEDs to implement! */
//PORTB |= LED_L;
//PORTB &= ~LED_L;
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular AVR MCU.
*/
SMCR = (0 << SM0) | (1 << SE); /* idle mode, adjust to your project */
QV_CPU_SLEEP(); /* atomically go to sleep and enable interrupts */
#else
QF_INT_ENABLE(); /* just enable interrupts */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const module, int location) {
/* implement the error-handling policy for your application!!! */
QF_INT_DISABLE(); /* disable all interrupts */
QF_RESET(); /* reset the CPU */
for (;;) {
}
}
/*****************************************************************************
* NOTE1:
* The QV_onIdle() callback is called with interrupts disabled, because the
* determination of the idle condition might change by any interrupt posting
* an event. QV_onIdle() must internally enable interrupts, ideally
* atomically with putting the CPU to the power-saving mode.
*
* NOTE2:
* The User LED is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/avr/dpp_arduino-uno/qv/iar/dpp-qv.ewd
================================================
2DebugAVR1C-SPY61611ATMELICEAVR5111AVRONE4411CCRAVR2111ICE200AVR2111JTAGICEAVR3211JTAGICE3AVR5611JTAGICEMKIIAVR5711DRAGONAVR3311SIMAVR2111THIRDPARTYAVR2111$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\Stk600\Stk600Plugin.ewplugin1$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin1$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0ReleaseAVR0C-SPY61610ATMELICEAVR5110AVRONE4410CCRAVR2110ICE200AVR2110JTAGICEAVR3210JTAGICE3AVR5610JTAGICEMKIIAVR5710DRAGONAVR3310SIMAVR2110THIRDPARTYAVR2110$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin0$TOOLKIT_DIR$\plugins\Stk600\Stk600Plugin.ewplugin1$EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin1$EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0$EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin1$EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin0
================================================
FILE: examples/avr/dpp_arduino-uno/qv/iar/dpp-qv.ewp
================================================
2DebugAVR1General11911ICCAVR61711AAVR51111CUSTOM30BICOMP0BUILDACTION1XLINK31611XAR2011BILINK0ReleaseAVR0General11910ICCAVR61710AAVR51110CUSTOM30BICOMP0BUILDACTION1XLINK31610XAR2010BILINK0Application$PROJ_DIR$\bsp.c$PROJ_DIR$\..\..\bsp.h$PROJ_DIR$\..\..\dpp.h$PROJ_DIR$\..\..\main.c$PROJ_DIR$\..\..\philo.c$PROJ_DIR$\..\..\table.cQP$PROJ_DIR$\..\..\..\..\..\src\qfn\qepn.c$PROJ_DIR$\..\..\..\..\..\src\qfn\qfn.c$PROJ_DIR$\..\..\..\..\..\src\qvn\qvn.c
================================================
FILE: examples/avr/dpp_arduino-uno/qv/iar/dpp-qv.eww
================================================
$WS_DIR$\dpp-qv.ewp
================================================
FILE: examples/avr/dpp_arduino-uno/qv/iar/flash.bat
================================================
@echo off
::============================================================================
:: Batch file to program the flash of Arduino-UNO
::
:: NOTE: requires the AVRDUDE uitlity which is included in the QTools
:: collection
::
setlocal
@echo off
@echo Load a given hex file to the flash of Arduino-UNO
@echo usage: flash hex-file [COM-port]
@echo example: flash dbg\blinky-qk.hex
@echo example: flash dbg\blinky-qk.hex COM5
::----------------------------------------------------------------------------
:: NOTE: Adjust the following symbol to the location of the
:: AVRDUDE utility on your machine
::
set AVRDUDE=avrdude.exe
set COM_PORT=COM5
if [%2] NEQ [] set COM_PORT=%2
if ["%~1"]==[""] (
@echo The hex file missing
@goto end
)
if not exist %~s1 (
@echo The hex file '%1' does not exist
@goto end
)
@echo on
%AVRDUDE% -p atmega328p -c arduino -P %COM_PORT% -b 115200 -D -v -U flash:w:%1:i
@echo off
:end
endlocal
================================================
FILE: examples/avr/dpp_arduino-uno/qv/iar/spy.bat
================================================
set COM_PORT=COM5
if [%1] NEQ [] set COM_PORT=%1
qspy -c%COM_PORT% -b115200 -O2 -F2 -E1 -P1 -B1
================================================
FILE: examples/avr/dpp_arduino-uno/table.c
================================================
/*.$file${.::table.c} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*
* Model: dpp.qm
* File: ${.::table.c}
*
* This code has been generated by QM 4.6.0 .
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/*.$endhead${.::table.c} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#include "qpn.h" /* QP-nano port */
#include "bsp.h" /* Board Support Package */
#include "dpp.h" /* Application interface */
Q_DEFINE_THIS_MODULE("table")
/* Active object class -----------------------------------------------------*/
/*.$declare${AOs::Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table} ...........................................................*/
typedef struct Table {
/* protected: */
QActive super;
/* private: */
uint8_t fork[N_PHILO];
uint8_t isHungry[N_PHILO];
} Table;
/* protected: */
static QState Table_initial(Table * const me);
static QState Table_active(Table * const me);
static QState Table_serving(Table * const me);
static QState Table_paused(Table * const me);
/*.$enddecl${AOs::Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/* Global objects ----------------------------------------------------------*/
/*.$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*. Check for the minimum required QP version */
#if (QP_VERSION < 650U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpn version 6.5.0 or higher required
#endif
/*.$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::AO_Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::AO_Table} ........................................................*/
struct Table AO_Table;
/*.$enddef${AOs::AO_Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#define RIGHT(n_) ((uint8_t)(((n_) + (N_PHILO - 1U)) % N_PHILO))
#define LEFT(n_) ((uint8_t)(((n_) + 1U) % N_PHILO))
#define FREE ((uint8_t)0)
#define USED ((uint8_t)1)
/*..........................................................................*/
/*.$define${AOs::Table_ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table_ctor} ......................................................*/
void Table_ctor(void) {
uint8_t n;
Table *me = &AO_Table;
QActive_ctor(&me->super, Q_STATE_CAST(&Table_initial));
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
}
}
/*.$enddef${AOs::Table_ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*.$define${AOs::Table} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
/*.${AOs::Table} ...........................................................*/
/*.${AOs::Table::SM} .......................................................*/
static QState Table_initial(Table * const me) {
/*.${AOs::Table::SM::initial} */
uint8_t n;
for (n = 0U; n < N_PHILO; ++n) {
me->fork[n] = FREE;
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "thinking");
}
return Q_TRAN(&Table_serving);
}
/*.${AOs::Table::SM::active} ...............................................*/
static QState Table_active(Table * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Table::SM::active::TERMINATE} */
case TERMINATE_SIG: {
BSP_terminate(0);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::EAT} */
case EAT_SIG: {
Q_ERROR();
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
/*.${AOs::Table::SM::active::serving} ......................................*/
static QState Table_serving(Table * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Table::SM::active::serving} */
case Q_ENTRY_SIG: {
uint8_t n;
for (n = 0U; n < N_PHILO; ++n) { /* give permissions to eat... */
if ((me->isHungry[n] != 0U)
&& (me->fork[LEFT(n)] == FREE)
&& (me->fork[n] == FREE))
{
QActive *philo;
me->fork[LEFT(n)] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
me->isHungry[n] = 0U;
BSP_displayPhilStat(n, "eating ");
}
}
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::serving::HUNGRY} */
case HUNGRY_SIG: {
uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "hungry ");
m = LEFT(n);
/*.${AOs::Table::SM::active::serving::HUNGRY::[bothfree]} */
if ((me->fork[m] == FREE) && (me->fork[n] == FREE)) {
me->fork[m] = USED;
me->fork[n] = USED;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + n].act));
QACTIVE_POST(philo, EAT_SIG, n);
BSP_displayPhilStat(n, "eating ");
status_ = Q_HANDLED();
}
/*.${AOs::Table::SM::active::serving::HUNGRY::[else]} */
else {
me->isHungry[n] = 1U;
status_ = Q_HANDLED();
}
break;
}
/*.${AOs::Table::SM::active::serving::DONE} */
case DONE_SIG: {
uint8_t n, m;
QActive *philo;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;
m = RIGHT(n); /* check the right neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[m] == FREE)) {
me->fork[n] = USED;
me->fork[m] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}
m = LEFT(n); /* check the left neighbor */
n = LEFT(m); /* left fork of the left neighbor */
if ((me->isHungry[m] != 0U) && (me->fork[n] == FREE)) {
me->fork[m] = USED;
me->fork[n] = USED;
me->isHungry[m] = 0U;
philo = QF_ACTIVE_CAST(Q_ROM_PTR(QF_active[PHILO_0_PRIO + m].act));
QACTIVE_POST(philo, EAT_SIG, m);
BSP_displayPhilStat(m, "eating ");
}
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::serving::EAT} */
case EAT_SIG: {
Q_ERROR();
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::serving::PAUSE} */
case PAUSE_SIG: {
status_ = Q_TRAN(&Table_paused);
break;
}
default: {
status_ = Q_SUPER(&Table_active);
break;
}
}
return status_;
}
/*.${AOs::Table::SM::active::paused} .......................................*/
static QState Table_paused(Table * const me) {
QState status_;
switch (Q_SIG(me)) {
/*.${AOs::Table::SM::active::paused} */
case Q_ENTRY_SIG: {
BSP_displayPaused(1U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::paused} */
case Q_EXIT_SIG: {
BSP_displayPaused(0U);
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::paused::SERVE} */
case SERVE_SIG: {
status_ = Q_TRAN(&Table_serving);
break;
}
/*.${AOs::Table::SM::active::paused::HUNGRY} */
case HUNGRY_SIG: {
uint8_t n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* philo ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
me->isHungry[n] = 1U;
BSP_displayPhilStat(n, "hungry ");
status_ = Q_HANDLED();
break;
}
/*.${AOs::Table::SM::active::paused::DONE} */
case DONE_SIG: {
uint8_t n, m;
n = (uint8_t)(Q_PAR(me) - PHILO_0_PRIO);
/* phil ID must be in range and he must be not hungry */
Q_ASSERT((n < N_PHILO) && (me->isHungry[n] == 0U));
BSP_displayPhilStat(n, "thinking");
m = LEFT(n);
/* both forks of Phil[n] must be used */
Q_ASSERT((me->fork[n] == USED) && (me->fork[m] == USED));
me->fork[m] = FREE;
me->fork[n] = FREE;
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&Table_active);
break;
}
}
return status_;
}
/*.$enddef${AOs::Table} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
================================================
FILE: examples/msp430/README.url
================================================
[InternetShortcut]
URL=http://www.state-machine.com/qpn/exa_msp430.html
IconFile=http://www.state-machine.com/qp.ico
================================================
FILE: examples/msp430/blinky_msp-exp430f5529lp/README.url
================================================
[InternetShortcut]
URL=http://www.state-machine.com/qpn/msp430_blinky_msp-exp430f5529lp.html
IconFile=http://www.state-machine.com/qp.ico
================================================
FILE: examples/msp430/blinky_msp-exp430f5529lp/blinky.c
================================================
/*****************************************************************************
* Product: Simple Blinky example
* Last updated for version 5.4.0
* Last updated on 2015-05-18
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, www.state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "blinky.h"
#include "bsp.h"
//Q_DEFINE_THIS_FILE
/*..........................................................................*/
typedef struct BlinkyTag { /* the Blinky active object */
QActive super; /* inherit QActive */
} Blinky;
/* hierarchical state machine ... */
static QState Blinky_initial(Blinky * const me);
static QState Blinky_off (Blinky * const me);
static QState Blinky_on (Blinky * const me);
/* Global objects ----------------------------------------------------------*/
Blinky AO_Blinky; /* the single instance of the Blinky AO */
/*..........................................................................*/
void Blinky_ctor(void) {
Blinky * const me = &AO_Blinky;
QActive_ctor(&me->super, Q_STATE_CAST(&Blinky_initial));
}
/* HSM definition ----------------------------------------------------------*/
QState Blinky_initial(Blinky * const me) {
QActive_armX((QActive *)me, 0U,
BSP_TICKS_PER_SEC/2U, BSP_TICKS_PER_SEC/2U);
return Q_TRAN(&Blinky_off);
}
/*..........................................................................*/
QState Blinky_off(Blinky * const me) {
QState status;
switch (Q_SIG(me)) {
case Q_ENTRY_SIG: {
BSP_ledOff();
status = Q_HANDLED();
break;
}
case Q_TIMEOUT_SIG: {
status = Q_TRAN(&Blinky_on);
break;
}
default: {
status = Q_SUPER(&QHsm_top);
break;
}
}
return status;
}
/*..........................................................................*/
QState Blinky_on(Blinky * const me) {
QState status;
switch (Q_SIG(me)) {
case Q_ENTRY_SIG: {
BSP_ledOn();
status = Q_HANDLED();
break;
}
case Q_TIMEOUT_SIG: {
status = Q_TRAN(&Blinky_off);
break;
}
default: {
status = Q_SUPER(&QHsm_top);
break;
}
}
return status;
}
================================================
FILE: examples/msp430/blinky_msp-exp430f5529lp/blinky.h
================================================
/*****************************************************************************
* Product: simple "Blinky" example
* Last updated for version 5.4.0
* Last updated on 2015-05-18
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, www.state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef BLINKY_H
#define BLINKY_H
enum BlinkySignals {
DUMMY_SIG = Q_USER_SIG,
MAX_PUB_SIG, /* the last published signal */
TIMEOUT_SIG,
MAX_SIG /* the last signal */
};
void Blinky_ctor(void);
extern struct BlinkyTag AO_Blinky;
#endif /* BLINKY_H */
================================================
FILE: examples/msp430/blinky_msp-exp430f5529lp/bsp.h
================================================
/*****************************************************************************
* Product: Simple Blinky example
* Last updated for version 5.4.0
* Last updated on 2015-05-18
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, www.state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#ifndef BSP_H
#define BSP_H
#define BSP_TICKS_PER_SEC 100U
void BSP_init(void);
void BSP_ledOff(void);
void BSP_ledOn(void);
#endif /* BSP_H */
================================================
FILE: examples/msp430/blinky_msp-exp430f5529lp/main.c
================================================
/*****************************************************************************
* Product: "Blinky" example
* Last Updated for Version: 5.8.0
* Date of the Last Update: 2016-11-06
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. All rights reserved.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h" /* QP-nano API */
#include "bsp.h" /* Board Support Package */
#include "blinky.h" /* Application interface */
/* Local-scope objects -----------------------------------------------------*/
static QEvt l_blinkyQSto[10]; /* Event queue storage for Blinky */
/* QF_active[] array defines all active object control blocks --------------*/
QActiveCB const Q_ROM QF_active[] = {
{ (QActive *)0, (QEvt *)0, 0U },
{ (QActive *)&AO_Blinky, l_blinkyQSto, Q_DIM(l_blinkyQSto) }
};
/*..........................................................................*/
int main(void) {
Blinky_ctor(); /* instantiate all Blinky AO */
QF_init(Q_DIM(QF_active)); /* initialize the QF-nano framework */
BSP_init(); /* initialize the Board Support Package */
return QF_run(); /* transfer control to QF-nano */
}
================================================
FILE: examples/msp430/blinky_msp-exp430f5529lp/qk/bsp.c
================================================
/*****************************************************************************
* Product: "Blinky" on MSP-EXP430F5529LP, preemptive QK-nano kernel
* Last Updated for Version: 5.4.0
* Date of the Last Update: 2015-04-04
*
* Q u a n t u m L e a P s
* ---------------------------
* innovating embedded systems
*
* Copyright (C) Quantum Leaps, LLC. state-machine.com.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, this program may be distributed and modified under the
* terms of Quantum Leaps commercial licenses, which expressly supersede
* the GNU General Public License and are specifically designed for
* licensees interested in retaining the proprietary status of their code.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Contact information:
*
*
*****************************************************************************/
#include "qpn.h"
#include "blinky.h"
#include "bsp.h"
#include /* MSP430 variant used */
/* add other drivers if necessary... */
//Q_DEFINE_THIS_FILE
/* Local-scope objects -----------------------------------------------------*/
/* 1MHz clock setting, see BSP_init() */
#define BSP_MCK 1000000U
#define BSP_SMCLK 1000000U
#define LED1 (1U << 0)
#define LED2 (1U << 7)
#define BTN_S1 (1U << 1)
/* ISRs used in this project ===============================================*/
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
__interrupt void TIMER0_A0_ISR (void); /* prototype */
#pragma vector=TIMER0_A0_VECTOR
__interrupt void TIMER0_A0_ISR(void)
#elif defined(__GNUC__)
__attribute__ ((interrupt(TIMER0_A0_VECTOR)))
void TIMER0_A0_ISR (void)
#else
#error Compiler not supported!
#endif
{
QK_ISR_ENTRY(); /* inform QK about entering the ISR */
QF_tickXISR(0U); /* process time events for rate 0 */
QK_ISR_EXIT(); /* inform QK about exiting the ISR */
}
/* BSP functions ===========================================================*/
void BSP_init(void) {
WDTCTL = WDTPW | WDTHOLD; /* stop watchdog timer */
/* leave the MCK and SMCLK at default DCO setting */
P1DIR |= LED1; /* set LED1 pin to output */
P4DIR |= LED2; /* set LED2 pin to output */
}
/*..........................................................................*/
void BSP_ledOff(void) {
P1OUT &= ~LED1; /* turn LED1 off */
}
/*..........................................................................*/
void BSP_ledOn(void) {
P1OUT |= LED1; /* turn LED1 on */
}
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
TA0CCTL0 = CCIE; /* CCR0 interrupt enabled */
TA0CCR0 = BSP_MCK / BSP_TICKS_PER_SEC;
TA0CTL = TASSEL_2 + MC_1 + TACLR; /* SMCLK, upmode, clear TAR */
}
/*..........................................................................*/
void QK_onIdle(void) {
/* toggle LED2 on and then off, see NOTE1 */
QF_INT_DISABLE();
P4OUT |= LED2; /* turn LED2 on */
P4OUT &= ~LED2; /* turn LED2 off */
QF_INT_ENABLE();
#ifdef NDEBUG
/* Put the CPU and peripherals to the low-power mode.
* you might need to customize the clock management for your application,
* see the datasheet for your particular MSP430 MCU.
*/
__low_power_mode_1(); /* Enter LPM1; also ENABLES interrupts */
#endif
}
/*..........................................................................*/
Q_NORETURN Q_onAssert(char const Q_ROM * const file, int line) {
/* implement the error-handling policy for your application!!! */
QF_INT_DISABLE(); /* disable all interrupts */
/* cause the reset of the CPU... */
WDTCTL = WDTPW | WDTHOLD;
__asm(" push &0xFFFE");
/* return from function does the reset */
}
/*****************************************************************************
* NOTE1:
* One of the LEDs is used to visualize the idle loop activity. The brightness
* of the LED is proportional to the frequency of invcations of the idle loop.
* Please note that the LED is toggled with interrupts locked, so no interrupt
* execution time contributes to the brightness of the User LED.
*/
================================================
FILE: examples/msp430/blinky_msp-exp430f5529lp/qk/ccs/.ccsproject
================================================
================================================
FILE: examples/msp430/blinky_msp-exp430f5529lp/qk/ccs/.cproject
================================================
================================================
FILE: examples/msp430/blinky_msp-exp430f5529lp/qk/ccs/.project
================================================
blinky-qk_msp-exp430f5529lporg.eclipse.cdt.managedbuilder.core.genmakebuilderorg.eclipse.cdt.managedbuilder.core.ScannerConfigBuilderfull,incremental,com.ti.ccstudio.core.ccsNatureorg.eclipse.cdt.core.cnatureorg.eclipse.cdt.managedbuilder.core.managedBuildNatureorg.eclipse.cdt.core.ccnatureorg.eclipse.cdt.managedbuilder.core.ScannerConfigNatureQKn2PARENT-5-PROJECT_LOC/src/qknQP2PARENT-5-PROJECT_LOC/src/qfnQP_port2PARENT-5-PROJECT_LOC/ports/msp430/qk/ccsblinky.c1PARENT-2-PROJECT_LOC/blinky.cblinky.h1PARENT-2-PROJECT_LOC/blinky.hbsp.c1PARENT-1-PROJECT_LOC/bsp.cbsp.h1PARENT-2-PROJECT_LOC/bsp.hmain.c1PARENT-2-PROJECT_LOC/main.c
================================================
FILE: examples/msp430/blinky_msp-exp430f5529lp/qk/ccs/lnk_msp430f5529.cmd
================================================
/* ============================================================================ */
/* Copyright (c) 2014, Texas Instruments Incorporated */
/* All rights reserved. */
/* */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* */
/* * Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* */
/* * Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution. */
/* */
/* * Neither the name of Texas Instruments Incorporated nor the names of */
/* its contributors may be used to endorse or promote products derived */
/* from this software without specific prior written permission. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" */
/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, */
/* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR */
/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */
/* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, */
/* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; */
/* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, */
/* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR */
/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
/* ============================================================================ */
/******************************************************************************/
/* lnk_msp430f5529.cmd - LINKER COMMAND FILE FOR LINKING MSP430F5529 PROGRAMS */
/* */
/* Usage: lnk430 -o -m