├── .gitattributes
├── .gitignore
├── EFM32HG
├── arm_math.h
├── cmsis_gcc.h
├── core_cm0plus.h
├── core_cmFunc.h
├── core_cmInstr.h
├── efm32hg308f64.h
├── efm32hg_acmp.h
├── efm32hg_af_pins.h
├── efm32hg_af_ports.h
├── efm32hg_calibrate.h
├── efm32hg_devinfo.h
├── efm32hg_dma.h
├── efm32hg_dma_ch.h
├── efm32hg_dma_descriptor.h
├── efm32hg_dmactrl.h
├── efm32hg_dmareq.h
├── efm32hg_emu.h
├── efm32hg_gpio.h
├── efm32hg_gpio_p.h
├── efm32hg_i2c.h
├── efm32hg_leuart.h
├── efm32hg_msc.h
├── efm32hg_mtb.h
├── efm32hg_pcnt.h
├── efm32hg_prs_ch.h
├── efm32hg_rmu.h
├── efm32hg_romtable.h
├── efm32hg_rtc.h
├── efm32hg_timer.h
├── efm32hg_timer_cc.h
├── efm32hg_usart.h
├── efm32hg_usb.h
├── efm32hg_usb_diep.h
├── efm32hg_usb_doep.h
├── efm32hg_vcmp.h
├── efm32hg_wdog.h
├── em_device.h
├── system_efm32hg.c
└── system_efm32hg.h
├── LICENSE
├── Makefile
├── README
├── avr.lkr
├── blupdate-efm.c
├── blupdate-efm.h
├── codegen-run-armv6m.c
├── codegen-run-generic.c
├── codegen.c
├── codegen.h
├── cortex.c
├── cortex.h
├── crt-avr.S
├── crt-efm.c
├── efm.lkr
├── led-efm.c
├── led-efm.h
├── main.c
├── memap.c
├── memap.h
├── plat-avr.c
├── plat-efm.c
├── plat.h
├── swd.c
├── swd.h
├── swdCommsPacket.h
├── tool
├── LICENSE.txt
├── Makefile
├── SCRIPTS
│ ├── ATSAM_EEFC.20000000.m3.S
│ ├── ATSAM_NVMCTRL.20000000.m0.S
│ ├── EFM32HG.20000000.m0.S
│ ├── EFM32PG.10000000.m3.S
│ ├── FM3.1fffc000.m3.S
│ ├── FreescaleMKE04.20000100.m0.S
│ ├── FreescaleMKL.1ffffe00.m0.S
│ ├── LPC13xx.10000000.m3.S
│ ├── LPC81x.10000000.m0.S
│ ├── Makefile
│ ├── PSoC4xxx.20000000.m0.S
│ ├── PSoC6.08000000.m0.S
│ ├── STM32F1xx.20000000.m3.S
│ ├── STM32F4.20000000.m3.S
│ ├── STM32G0xx.20000000.m0.S
│ ├── STM32L1.20000000.m3.S
│ ├── linker.lkr
│ └── nRF5x.20000000.m0.S
├── SPECIAL
│ ├── efm32hg_unlock.lua
│ ├── freescale_unlock.lua
│ ├── mb9_unlock.lua
│ ├── nrf51_unlock.lua
│ ├── nrf52_unlock.lua
│ ├── psoc5_acquire.lua
│ ├── samd20_unlock.lua
│ ├── staging
│ │ ├── probeulizer.lua
│ │ ├── psoc4_protection.lua
│ │ ├── psoc4_read_as_privileged.lua
│ │ ├── psoc4_read_minirom.lua
│ │ └── test.lua
│ ├── stm32f1_write_option_bytes.lua
│ └── stm32f4_write_option_word.lua
├── VisualStudioProject
│ ├── CortexProg.rc
│ ├── CortexProg.vcproj
│ ├── icon1.ico
│ └── resource.h
├── alloca.h
├── cpu.c
├── cpu.h
├── debugger.c
├── debugger.h
├── hidapi
│ ├── .gitattributes
│ ├── .gitignore
│ ├── AUTHORS.txt
│ ├── HACKING.txt
│ ├── LICENSE-bsd.txt
│ ├── LICENSE-gpl3.txt
│ ├── LICENSE-orig.txt
│ ├── LICENSE.txt
│ ├── Makefile.am
│ ├── README.txt
│ ├── android
│ │ └── jni
│ │ │ └── Android.mk
│ ├── bootstrap
│ ├── configure.ac
│ ├── doxygen
│ │ └── Doxyfile
│ ├── hidapi
│ │ └── hidapi.h
│ ├── hidtest
│ │ ├── .gitignore
│ │ ├── Makefile.am
│ │ └── hidtest.cpp
│ ├── libusb
│ │ ├── .gitignore
│ │ ├── Makefile-manual
│ │ ├── Makefile.am
│ │ ├── Makefile.freebsd
│ │ ├── Makefile.linux
│ │ └── hid.c
│ ├── linux
│ │ ├── .gitignore
│ │ ├── Makefile-manual
│ │ ├── Makefile.am
│ │ ├── README.txt
│ │ └── hid.c
│ ├── m4
│ │ ├── .gitignore
│ │ ├── ax_pthread.m4
│ │ └── pkg.m4
│ ├── mac
│ │ ├── .gitignore
│ │ ├── Makefile-manual
│ │ ├── Makefile.am
│ │ └── hid.c
│ ├── pc
│ │ ├── .gitignore
│ │ ├── hidapi-hidraw.pc.in
│ │ ├── hidapi-libusb.pc.in
│ │ └── hidapi.pc.in
│ ├── testgui
│ │ ├── .gitignore
│ │ ├── Makefile-manual
│ │ ├── Makefile.am
│ │ ├── Makefile.freebsd
│ │ ├── Makefile.linux
│ │ ├── Makefile.mac
│ │ ├── Makefile.mingw
│ │ ├── TestGUI.app.in
│ │ │ └── Contents
│ │ │ │ ├── Info.plist
│ │ │ │ ├── PkgInfo
│ │ │ │ └── Resources
│ │ │ │ ├── English.lproj
│ │ │ │ └── InfoPlist.strings
│ │ │ │ └── Signal11.icns
│ │ ├── copy_to_bundle.sh
│ │ ├── mac_support.cpp
│ │ ├── mac_support.h
│ │ ├── mac_support_cocoa.m
│ │ ├── start.sh
│ │ ├── test.cpp
│ │ └── testgui.vcproj
│ ├── udev
│ │ └── 99-hid.rules
│ └── windows
│ │ ├── .gitignore
│ │ ├── Makefile-manual
│ │ ├── Makefile.am
│ │ ├── Makefile.mingw
│ │ ├── ddk_build
│ │ ├── .gitignore
│ │ ├── hidapi.def
│ │ └── sources
│ │ ├── hid.c
│ │ ├── hidapi.vcproj
│ │ └── hidtest.vcproj
├── jedec.h
├── lua-5.3.4
│ ├── Makefile
│ ├── README
│ ├── doc
│ │ ├── contents.html
│ │ ├── index.css
│ │ ├── logo.gif
│ │ ├── lua.1
│ │ ├── lua.css
│ │ ├── luac.1
│ │ ├── manual.css
│ │ ├── manual.html
│ │ ├── osi-certified-72x60.png
│ │ └── readme.html
│ └── src
│ │ ├── Makefile
│ │ ├── lapi.c
│ │ ├── lapi.h
│ │ ├── lauxlib.c
│ │ ├── lauxlib.h
│ │ ├── lbaselib.c
│ │ ├── lbitlib.c
│ │ ├── lcode.c
│ │ ├── lcode.h
│ │ ├── lcorolib.c
│ │ ├── lctype.c
│ │ ├── lctype.h
│ │ ├── ldblib.c
│ │ ├── ldebug.c
│ │ ├── ldebug.h
│ │ ├── ldo.c
│ │ ├── ldo.h
│ │ ├── ldump.c
│ │ ├── lfunc.c
│ │ ├── lfunc.h
│ │ ├── lgc.c
│ │ ├── lgc.h
│ │ ├── linit.c
│ │ ├── liolib.c
│ │ ├── llex.c
│ │ ├── llex.h
│ │ ├── llimits.h
│ │ ├── lmathlib.c
│ │ ├── lmem.c
│ │ ├── lmem.h
│ │ ├── loadlib.c
│ │ ├── lobject.c
│ │ ├── lobject.h
│ │ ├── lopcodes.c
│ │ ├── lopcodes.h
│ │ ├── loslib.c
│ │ ├── lparser.c
│ │ ├── lparser.h
│ │ ├── lprefix.h
│ │ ├── lstate.c
│ │ ├── lstate.h
│ │ ├── lstring.c
│ │ ├── lstring.h
│ │ ├── lstrlib.c
│ │ ├── ltable.c
│ │ ├── ltable.h
│ │ ├── ltablib.c
│ │ ├── ltm.c
│ │ ├── ltm.h
│ │ ├── lua.c
│ │ ├── lua.h
│ │ ├── lua.hpp
│ │ ├── luac.c
│ │ ├── luaconf.h
│ │ ├── lualib.h
│ │ ├── lundump.c
│ │ ├── lundump.h
│ │ ├── lutf8lib.c
│ │ ├── lvm.c
│ │ ├── lvm.h
│ │ ├── lzio.c
│ │ └── lzio.h
├── main.c
├── memio.c
├── memio.h
├── misc_tools
│ └── romtableReader.c
├── oldtool
│ ├── Makefile
│ ├── SCRIPTS
│ │ ├── EFM32HG.20000000.m0.S
│ │ ├── EFM32PG.10000000.m3.S
│ │ ├── FreescaleMKE04.1fffff00.m0.S
│ │ ├── FreescaleMKL.1ffffe00.m0.S
│ │ ├── LPC13xx.10000000.m3.S.disabled
│ │ ├── LPC81x.10000000.m0.S
│ │ ├── Makefile
│ │ ├── PSoC4xxx.20000000.m0.S
│ │ ├── STM32F1xx.20000000.m3.S
│ │ ├── STM32F4x5_4x7_4x9.20000000.m3.S
│ │ ├── STM32F4xx.20000000.m3.S
│ │ ├── doc.txt
│ │ ├── linker.lkr
│ │ ├── nRF5x.20000000.m0.S
│ │ └── notes.txt.txt
│ ├── cpu.c
│ ├── cpu.h
│ ├── gdbServer.c
│ ├── gdbServer.h
│ ├── hidapi
│ │ ├── .gitattributes
│ │ ├── .gitignore
│ │ ├── AUTHORS.txt
│ │ ├── HACKING.txt
│ │ ├── LICENSE-bsd.txt
│ │ ├── LICENSE-gpl3.txt
│ │ ├── LICENSE-orig.txt
│ │ ├── LICENSE.txt
│ │ ├── Makefile.am
│ │ ├── README.txt
│ │ ├── android
│ │ │ └── jni
│ │ │ │ └── Android.mk
│ │ ├── bootstrap
│ │ ├── configure.ac
│ │ ├── doxygen
│ │ │ └── Doxyfile
│ │ ├── hidapi
│ │ │ └── hidapi.h
│ │ ├── hidtest
│ │ │ ├── .gitignore
│ │ │ ├── Makefile.am
│ │ │ └── hidtest.cpp
│ │ ├── libusb
│ │ │ ├── .gitignore
│ │ │ ├── Makefile-manual
│ │ │ ├── Makefile.am
│ │ │ ├── Makefile.freebsd
│ │ │ ├── Makefile.linux
│ │ │ └── hid.c
│ │ ├── linux
│ │ │ ├── .gitignore
│ │ │ ├── Makefile-manual
│ │ │ ├── Makefile.am
│ │ │ ├── README.txt
│ │ │ └── hid.c
│ │ ├── m4
│ │ │ ├── .gitignore
│ │ │ ├── ax_pthread.m4
│ │ │ └── pkg.m4
│ │ ├── mac
│ │ │ ├── .gitignore
│ │ │ ├── Makefile-manual
│ │ │ ├── Makefile.am
│ │ │ └── hid.c
│ │ ├── pc
│ │ │ ├── .gitignore
│ │ │ ├── hidapi-hidraw.pc.in
│ │ │ ├── hidapi-libusb.pc.in
│ │ │ └── hidapi.pc.in
│ │ ├── testgui
│ │ │ ├── .gitignore
│ │ │ ├── Makefile-manual
│ │ │ ├── Makefile.am
│ │ │ ├── Makefile.freebsd
│ │ │ ├── Makefile.linux
│ │ │ ├── Makefile.mac
│ │ │ ├── Makefile.mingw
│ │ │ ├── TestGUI.app.in
│ │ │ │ └── Contents
│ │ │ │ │ ├── Info.plist
│ │ │ │ │ ├── PkgInfo
│ │ │ │ │ └── Resources
│ │ │ │ │ ├── English.lproj
│ │ │ │ │ └── InfoPlist.strings
│ │ │ │ │ └── Signal11.icns
│ │ │ ├── copy_to_bundle.sh
│ │ │ ├── mac_support.cpp
│ │ │ ├── mac_support.h
│ │ │ ├── mac_support_cocoa.m
│ │ │ ├── start.sh
│ │ │ ├── test.cpp
│ │ │ └── testgui.vcproj
│ │ ├── udev
│ │ │ └── 99-hid.rules
│ │ └── windows
│ │ │ ├── .gitignore
│ │ │ ├── Makefile-manual
│ │ │ ├── Makefile.am
│ │ │ ├── Makefile.mingw
│ │ │ ├── ddk_build
│ │ │ ├── .gitignore
│ │ │ ├── hidapi.def
│ │ │ └── sources
│ │ │ ├── hid.c
│ │ │ ├── hidapi.vcproj
│ │ │ └── hidtest.vcproj
│ ├── jedec.h
│ ├── main.c
│ ├── romtableReader.c
│ ├── scriptfiles.c
│ └── scriptfiles.h
├── opCore.c
├── opDebug.c
├── opErase.c
├── opEraseAll.c
├── opFwUpdate.c
├── opHelp.c
├── opInfo.c
├── opPower.c
├── opRead.c
├── opSpecial.c
├── opSpeed.c
├── opTrace.c
├── opUpload.c
├── opWrite.c
├── ops.h
├── script.c
├── script.h
├── scriptfiles.c
├── scriptfiles.h
├── types.h
├── utilOp.c
└── utilOp.h
├── util.h
├── wire-arm.c
├── wire-avr-asm.S
├── wire-avr-c.c
├── wire-avr.h
└── wire.h
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Ignore all differences in line endings
2 | * -crlf
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.hex
2 | SWD
3 | *.bak
4 | *.o
5 | SWD.bin
6 | *.swds
7 | tool/tool
8 | *.enc
9 | *.bin
10 | *.elf
11 | newtool/tool
12 | *.zip
13 | *.ncb
14 | *.sln
15 | *.suo
16 | *.vcproj.*.user
17 | tool/VisualStudioProject/Debug
18 | tool/VisualStudioProject/Release
19 | tool/hidapi/windows/ddk_build/makefile
20 | tool/tool.static
21 |
--------------------------------------------------------------------------------
/EFM32HG/efm32hg_calibrate.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file efm32hg_calibrate.h
3 | * @brief EFM32HG_CALIBRATE register and bit field definitions
4 | * @version 4.4.0
5 | ******************************************************************************
6 | * @section License
7 | * Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com
8 | ******************************************************************************
9 | *
10 | * Permission is granted to anyone to use this software for any purpose,
11 | * including commercial applications, and to alter it and redistribute it
12 | * freely, subject to the following restrictions:
13 | *
14 | * 1. The origin of this software must not be misrepresented; you must not
15 | * claim that you wrote the original software.@n
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.@n
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | *
20 | * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Laboratories, Inc.
21 | * has no obligation to support this Software. Silicon Laboratories, Inc. is
22 | * providing the Software "AS IS", with no express or implied warranties of any
23 | * kind, including, but not limited to, any implied warranties of
24 | * merchantability or fitness for any particular purpose or warranties against
25 | * infringement of any proprietary rights of a third party.
26 | *
27 | * Silicon Laboratories, Inc. will not be liable for any consequential,
28 | * incidental, or special damages, or any other relief, or for any claim by
29 | * any third party, arising from your use of this Software.
30 | *
31 | *****************************************************************************/
32 | /**************************************************************************//**
33 | * @addtogroup Parts
34 | * @{
35 | ******************************************************************************/
36 | /**************************************************************************//**
37 | * @defgroup EFM32HG_CALIBRATE
38 | * @{
39 | *****************************************************************************/
40 | #define CALIBRATE_MAX_REGISTERS 50 /**< Max number of address/value pairs for calibration */
41 |
42 | typedef struct
43 | {
44 | __IM uint32_t ADDRESS; /**< Address of calibration register */
45 | __IM uint32_t VALUE; /**< Default value for calibration register */
46 | } CALIBRATE_TypeDef; /** @} */
47 |
48 | /** @} End of group Parts */
49 |
50 |
51 |
--------------------------------------------------------------------------------
/EFM32HG/efm32hg_dma_ch.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file efm32hg_dma_ch.h
3 | * @brief EFM32HG_DMA_CH register and bit field definitions
4 | * @version 4.4.0
5 | ******************************************************************************
6 | * @section License
7 | * Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com
8 | ******************************************************************************
9 | *
10 | * Permission is granted to anyone to use this software for any purpose,
11 | * including commercial applications, and to alter it and redistribute it
12 | * freely, subject to the following restrictions:
13 | *
14 | * 1. The origin of this software must not be misrepresented; you must not
15 | * claim that you wrote the original software.@n
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.@n
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | *
20 | * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Laboratories, Inc.
21 | * has no obligation to support this Software. Silicon Laboratories, Inc. is
22 | * providing the Software "AS IS", with no express or implied warranties of any
23 | * kind, including, but not limited to, any implied warranties of
24 | * merchantability or fitness for any particular purpose or warranties against
25 | * infringement of any proprietary rights of a third party.
26 | *
27 | * Silicon Laboratories, Inc. will not be liable for any consequential,
28 | * incidental, or special damages, or any other relief, or for any claim by
29 | * any third party, arising from your use of this Software.
30 | *
31 | *****************************************************************************/
32 | /**************************************************************************//**
33 | * @addtogroup Parts
34 | * @{
35 | ******************************************************************************/
36 | /**************************************************************************//**
37 | * @brief DMA_CH EFM32HG DMA CH
38 | *****************************************************************************/
39 | typedef struct
40 | {
41 | __IOM uint32_t CTRL; /**< Channel Control Register */
42 | } DMA_CH_TypeDef;
43 |
44 | /** @} End of group Parts */
45 |
46 |
47 |
--------------------------------------------------------------------------------
/EFM32HG/efm32hg_dma_descriptor.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file efm32hg_dma_descriptor.h
3 | * @brief EFM32HG_DMA_DESCRIPTOR register and bit field definitions
4 | * @version 4.4.0
5 | ******************************************************************************
6 | * @section License
7 | * Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com
8 | ******************************************************************************
9 | *
10 | * Permission is granted to anyone to use this software for any purpose,
11 | * including commercial applications, and to alter it and redistribute it
12 | * freely, subject to the following restrictions:
13 | *
14 | * 1. The origin of this software must not be misrepresented; you must not
15 | * claim that you wrote the original software.@n
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.@n
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | *
20 | * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Laboratories, Inc.
21 | * has no obligation to support this Software. Silicon Laboratories, Inc. is
22 | * providing the Software "AS IS", with no express or implied warranties of any
23 | * kind, including, but not limited to, any implied warranties of
24 | * merchantability or fitness for any particular purpose or warranties against
25 | * infringement of any proprietary rights of a third party.
26 | *
27 | * Silicon Laboratories, Inc. will not be liable for any consequential,
28 | * incidental, or special damages, or any other relief, or for any claim by
29 | * any third party, arising from your use of this Software.
30 | *
31 | *****************************************************************************/
32 | /**************************************************************************//**
33 | * @addtogroup Parts
34 | * @{
35 | ******************************************************************************/
36 | /**************************************************************************//**
37 | * @defgroup EFM32HG_DMA_DESCRIPTOR
38 | * @{
39 | *****************************************************************************/
40 | typedef struct
41 | {
42 | /* Note! Use of double __IOM (volatile) qualifier to ensure that both */
43 | /* pointer and referenced memory are declared volatile. */
44 | __IOM void * __IOM SRCEND; /**< DMA source address end */
45 | __IOM void * __IOM DSTEND; /**< DMA destination address end */
46 | __IOM uint32_t CTRL; /**< DMA control register */
47 | __IOM uint32_t USER; /**< DMA padding register, available for user */
48 | } DMA_DESCRIPTOR_TypeDef; /** @} */
49 |
50 | /** @} End of group Parts */
51 |
52 |
53 |
--------------------------------------------------------------------------------
/EFM32HG/efm32hg_gpio_p.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file efm32hg_gpio_p.h
3 | * @brief EFM32HG_GPIO_P register and bit field definitions
4 | * @version 4.4.0
5 | ******************************************************************************
6 | * @section License
7 | * Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com
8 | ******************************************************************************
9 | *
10 | * Permission is granted to anyone to use this software for any purpose,
11 | * including commercial applications, and to alter it and redistribute it
12 | * freely, subject to the following restrictions:
13 | *
14 | * 1. The origin of this software must not be misrepresented; you must not
15 | * claim that you wrote the original software.@n
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.@n
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | *
20 | * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Laboratories, Inc.
21 | * has no obligation to support this Software. Silicon Laboratories, Inc. is
22 | * providing the Software "AS IS", with no express or implied warranties of any
23 | * kind, including, but not limited to, any implied warranties of
24 | * merchantability or fitness for any particular purpose or warranties against
25 | * infringement of any proprietary rights of a third party.
26 | *
27 | * Silicon Laboratories, Inc. will not be liable for any consequential,
28 | * incidental, or special damages, or any other relief, or for any claim by
29 | * any third party, arising from your use of this Software.
30 | *
31 | *****************************************************************************/
32 | /**************************************************************************//**
33 | * @addtogroup Parts
34 | * @{
35 | ******************************************************************************/
36 | /**************************************************************************//**
37 | * @brief GPIO_P EFM32HG GPIO P
38 | *****************************************************************************/
39 | typedef struct
40 | {
41 | __IOM uint32_t CTRL; /**< Port Control Register */
42 | __IOM uint32_t MODEL; /**< Port Pin Mode Low Register */
43 | __IOM uint32_t MODEH; /**< Port Pin Mode High Register */
44 | __IOM uint32_t DOUT; /**< Port Data Out Register */
45 | __OM uint32_t DOUTSET; /**< Port Data Out Set Register */
46 | __OM uint32_t DOUTCLR; /**< Port Data Out Clear Register */
47 | __OM uint32_t DOUTTGL; /**< Port Data Out Toggle Register */
48 | __IM uint32_t DIN; /**< Port Data In Register */
49 | __IOM uint32_t PINLOCKN; /**< Port Unlocked Pins Register */
50 | } GPIO_P_TypeDef;
51 |
52 | /** @} End of group Parts */
53 |
54 |
55 |
--------------------------------------------------------------------------------
/EFM32HG/efm32hg_prs_ch.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file efm32hg_prs_ch.h
3 | * @brief EFM32HG_PRS_CH register and bit field definitions
4 | * @version 4.4.0
5 | ******************************************************************************
6 | * @section License
7 | * Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com
8 | ******************************************************************************
9 | *
10 | * Permission is granted to anyone to use this software for any purpose,
11 | * including commercial applications, and to alter it and redistribute it
12 | * freely, subject to the following restrictions:
13 | *
14 | * 1. The origin of this software must not be misrepresented; you must not
15 | * claim that you wrote the original software.@n
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.@n
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | *
20 | * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Laboratories, Inc.
21 | * has no obligation to support this Software. Silicon Laboratories, Inc. is
22 | * providing the Software "AS IS", with no express or implied warranties of any
23 | * kind, including, but not limited to, any implied warranties of
24 | * merchantability or fitness for any particular purpose or warranties against
25 | * infringement of any proprietary rights of a third party.
26 | *
27 | * Silicon Laboratories, Inc. will not be liable for any consequential,
28 | * incidental, or special damages, or any other relief, or for any claim by
29 | * any third party, arising from your use of this Software.
30 | *
31 | *****************************************************************************/
32 | /**************************************************************************//**
33 | * @addtogroup Parts
34 | * @{
35 | ******************************************************************************/
36 | /**************************************************************************//**
37 | * @brief PRS_CH EFM32HG PRS CH
38 | *****************************************************************************/
39 | typedef struct
40 | {
41 | __IOM uint32_t CTRL; /**< Channel Control Register */
42 | } PRS_CH_TypeDef;
43 |
44 | /** @} End of group Parts */
45 |
46 |
47 |
--------------------------------------------------------------------------------
/EFM32HG/efm32hg_timer_cc.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file efm32hg_timer_cc.h
3 | * @brief EFM32HG_TIMER_CC register and bit field definitions
4 | * @version 4.4.0
5 | ******************************************************************************
6 | * @section License
7 | * Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com
8 | ******************************************************************************
9 | *
10 | * Permission is granted to anyone to use this software for any purpose,
11 | * including commercial applications, and to alter it and redistribute it
12 | * freely, subject to the following restrictions:
13 | *
14 | * 1. The origin of this software must not be misrepresented; you must not
15 | * claim that you wrote the original software.@n
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.@n
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | *
20 | * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Laboratories, Inc.
21 | * has no obligation to support this Software. Silicon Laboratories, Inc. is
22 | * providing the Software "AS IS", with no express or implied warranties of any
23 | * kind, including, but not limited to, any implied warranties of
24 | * merchantability or fitness for any particular purpose or warranties against
25 | * infringement of any proprietary rights of a third party.
26 | *
27 | * Silicon Laboratories, Inc. will not be liable for any consequential,
28 | * incidental, or special damages, or any other relief, or for any claim by
29 | * any third party, arising from your use of this Software.
30 | *
31 | *****************************************************************************/
32 | /**************************************************************************//**
33 | * @addtogroup Parts
34 | * @{
35 | ******************************************************************************/
36 | /**************************************************************************//**
37 | * @brief TIMER_CC EFM32HG TIMER CC
38 | *****************************************************************************/
39 | typedef struct
40 | {
41 | __IOM uint32_t CTRL; /**< CC Channel Control Register */
42 | __IOM uint32_t CCV; /**< CC Channel Value Register */
43 | __IM uint32_t CCVP; /**< CC Channel Value Peek Register */
44 | __IOM uint32_t CCVB; /**< CC Channel Buffer Register */
45 | } TIMER_CC_TypeDef;
46 |
47 | /** @} End of group Parts */
48 |
49 |
50 |
--------------------------------------------------------------------------------
/EFM32HG/efm32hg_usb_diep.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file efm32hg_usb_diep.h
3 | * @brief EFM32HG_USB_DIEP register and bit field definitions
4 | * @version 4.4.0
5 | ******************************************************************************
6 | * @section License
7 | * Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com
8 | ******************************************************************************
9 | *
10 | * Permission is granted to anyone to use this software for any purpose,
11 | * including commercial applications, and to alter it and redistribute it
12 | * freely, subject to the following restrictions:
13 | *
14 | * 1. The origin of this software must not be misrepresented; you must not
15 | * claim that you wrote the original software.@n
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.@n
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | *
20 | * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Laboratories, Inc.
21 | * has no obligation to support this Software. Silicon Laboratories, Inc. is
22 | * providing the Software "AS IS", with no express or implied warranties of any
23 | * kind, including, but not limited to, any implied warranties of
24 | * merchantability or fitness for any particular purpose or warranties against
25 | * infringement of any proprietary rights of a third party.
26 | *
27 | * Silicon Laboratories, Inc. will not be liable for any consequential,
28 | * incidental, or special damages, or any other relief, or for any claim by
29 | * any third party, arising from your use of this Software.
30 | *
31 | *****************************************************************************/
32 | /**************************************************************************//**
33 | * @addtogroup Parts
34 | * @{
35 | ******************************************************************************/
36 | /**************************************************************************//**
37 | * @brief USB_DIEP EFM32HG USB DIEP
38 | *****************************************************************************/
39 | typedef struct
40 | {
41 | __IOM uint32_t CTL; /**< Device IN Endpoint x+1 Control Register */
42 | uint32_t RESERVED0[1]; /**< Reserved for future use **/
43 | __IOM uint32_t INT; /**< Device IN Endpoint x+1 Interrupt Register */
44 | uint32_t RESERVED1[1]; /**< Reserved for future use **/
45 | __IOM uint32_t TSIZ; /**< Device IN Endpoint x+1 Transfer Size Register */
46 | __IOM uint32_t DMAADDR; /**< Device IN Endpoint x+1 DMA Address Register */
47 | __IM uint32_t TXFSTS; /**< Device IN Endpoint x+1 Transmit FIFO Status Register */
48 | uint32_t RESERVED2[1]; /**< Reserved future */
49 | } USB_DIEP_TypeDef;
50 |
51 | /** @} End of group Parts */
52 |
53 |
54 |
--------------------------------------------------------------------------------
/EFM32HG/efm32hg_usb_doep.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file efm32hg_usb_doep.h
3 | * @brief EFM32HG_USB_DOEP register and bit field definitions
4 | * @version 4.4.0
5 | ******************************************************************************
6 | * @section License
7 | * Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com
8 | ******************************************************************************
9 | *
10 | * Permission is granted to anyone to use this software for any purpose,
11 | * including commercial applications, and to alter it and redistribute it
12 | * freely, subject to the following restrictions:
13 | *
14 | * 1. The origin of this software must not be misrepresented; you must not
15 | * claim that you wrote the original software.@n
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.@n
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | *
20 | * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Laboratories, Inc.
21 | * has no obligation to support this Software. Silicon Laboratories, Inc. is
22 | * providing the Software "AS IS", with no express or implied warranties of any
23 | * kind, including, but not limited to, any implied warranties of
24 | * merchantability or fitness for any particular purpose or warranties against
25 | * infringement of any proprietary rights of a third party.
26 | *
27 | * Silicon Laboratories, Inc. will not be liable for any consequential,
28 | * incidental, or special damages, or any other relief, or for any claim by
29 | * any third party, arising from your use of this Software.
30 | *
31 | *****************************************************************************/
32 | /**************************************************************************//**
33 | * @addtogroup Parts
34 | * @{
35 | ******************************************************************************/
36 | /**************************************************************************//**
37 | * @brief USB_DOEP EFM32HG USB DOEP
38 | *****************************************************************************/
39 | typedef struct
40 | {
41 | __IOM uint32_t CTL; /**< Device OUT Endpoint x+1 Control Register */
42 | uint32_t RESERVED0[1]; /**< Reserved for future use **/
43 | __IOM uint32_t INT; /**< Device OUT Endpoint x+1 Interrupt Register */
44 | uint32_t RESERVED1[1]; /**< Reserved for future use **/
45 | __IOM uint32_t TSIZ; /**< Device OUT Endpoint x+1 Transfer Size Register */
46 | __IOM uint32_t DMAADDR; /**< Device OUT Endpoint x+1 DMA Address Register */
47 | uint32_t RESERVED2[2]; /**< Reserved future */
48 | } USB_DOEP_TypeDef;
49 |
50 | /** @} End of group Parts */
51 |
52 |
53 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | CortexProg source code is under the following license:
2 |
3 | * you may use this code for any non-commercial purpose
4 | * any changes you made while using this code must be published by you
5 | * you may not sell any hardware incorporating this code
6 | * alternative licensing is available. license@cortexprog.com
7 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | APP = SWD
2 |
3 | COM_FLAGS = -Wall -Wextra -g -ggdb3
4 | CC_FLAGS = $(COM_FLAGS) -ffunction-sections -fdata-sections -fomit-frame-pointer -ffreestanding -Wno-unused-but-set-variable -Wno-strict-aliasing -Wno-unused-function -fno-exceptions
5 | LD_FLAGS = $(COM_FLAGS) -Wl,--gc-sections -Wl,--relax -lm -lc -lgcc
6 |
7 | CC_FLAGS-avr = -Os -I/usr/lib/avr/include -mmcu=attiny85 -mcall-prologues -DF_CPU=16500000UL -DAVR -D_CPU_SUPPORTS_UNALIGNED_ACCESS_ -Wno-aggressive-loop-optimizations -fsplit-wide-types -fno-tree-scev-cprop -finline-limit=3 -fno-inline-small-functions -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wno-pragmas
8 | LD_FLAGS-avr = -mmcu=attiny85 -e __reset_vector_ptr
9 |
10 | CC_FLAGS-efm = -O2 -mthumb -march=armv6-m -IEFM32HG -I. -DEFM32HG308F64 -DEFM -DCLOCKFREQ=21000000UL -flto
11 | LD_FLAGS-efm = -O2 -mthumb -march=armv6-m -flto
12 |
13 | CC-avr = avr-gcc
14 | LD-avr = avr-gcc
15 | OBJCOPY-avr = avr-objcopy
16 | CC-efm = arm-none-eabi-gcc
17 | LD-efm = arm-none-eabi-gcc
18 | OBJCOPY-efm = arm-none-eabi-objcopy
19 | OBJS = main.o swd.o memap.o cortex.o
20 | OBJS-avr = wire-avr-asm.o wire-avr-c.o crt-avr.o plat-avr.o
21 | OBJS-efm = wire-arm.o crt-efm.o EFM32HG/system_efm32hg.o led-efm.o plat-efm.o blupdate-efm.o codegen.o
22 |
23 | #OBJS-efm += codegen-run-armv6m.o
24 | OBJS-efm += codegen-run-generic.o
25 |
26 | OBJS-avr-all = $(subst .o,.avr.o,$(OBJS) $(OBJS-avr))
27 | OBJS-efm-all = $(subst .o,.efm.o,$(OBJS) $(OBJS-efm))
28 |
29 | all: $(APP).efm.bin $(APP).avr.bin
30 |
31 | $(APP).%.bin : $(APP).%.elf Makefile
32 | $(OBJCOPY-$*) -j.text -j.data -j.rodata -j.vectors -O binary $< $@
33 |
34 | $(APP).avr.elf: $(OBJS-avr-all) avr.lkr Makefile
35 | $(LD-avr) $(LD_FLAGS) $(LD_FLAGS-avr) -o $@ $(OBJS-avr-all) -Wl,-T avr.lkr
36 |
37 | $(APP).efm.elf: $(OBJS-efm-all) efm.lkr Makefile
38 | $(LD-efm) $(LD_FLAGS) $(LD_FLAGS-efm) -o $@ $(OBJS-efm-all) -Wl,-T efm.lkr
39 |
40 | %.efm.o : %.c Makefile
41 | $(CC-efm) $(CC_FLAGS) $(CC_FLAGS-efm) -c $< -o $@
42 |
43 | %.efm.o : %.S Makefile
44 | $(CC-efm) $(CC_FLAGS) $(CC_FLAGS-efm) -c $< -o $@
45 |
46 | %.avr.o : %.c Makefile
47 | $(CC-avr) $(CC_FLAGS) $(CC_FLAGS-avr) -c $< -o $@
48 |
49 | %.avr.o : %.S Makefile
50 | $(CC-avr) $(CC_FLAGS) $(CC_FLAGS-avr) -c $< -o $@
51 |
52 | fuses: Makefile
53 | avrdude -p $(DEVICE) -c avrisp2 -P usb -U efuse:w:0b11111110:m -U hfuse:w:0b11011111:m -U lfuse:w:0b11100001:m -F -B 250
54 | #no BOD & no HW bootloader
55 | #no JTAG & OCD, SPI_prog on, WDT off, defaults
56 | #no clock div, defaults, crystal clock
57 |
58 | clean: Makefile
59 | rm -f $(OBJS) $(APP).efm.bin $(APP).avr.bin $(APP).efm.elf $(APP).avr.elf $(OBJS-avr-all) $(OBJS-efm-all)
60 |
61 | upload_avr: $(APP).avr.bin Makefile
62 | sudo ../ModulaR/tool/uploader $<
63 | rm $<
64 |
65 | upload_efm: $(APP).efm.bin Makefile
66 | ../ModulaR/tool/encryptor d1c2c8e7a5bb4ee3c730cb7bb0295f26 < $< > $<.enc
67 | sudo ../ModulaR/tool/uploader $<.enc
68 | rm $<
69 |
70 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | This is the CortexProg source code
2 |
3 | learn more at the official site: https://cortexprog.com/
4 |
--------------------------------------------------------------------------------
/avr.lkr:
--------------------------------------------------------------------------------
1 | OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
2 | OUTPUT_ARCH(avr:25)
3 |
4 | MEMORY
5 | {
6 | flash (rx) : ORIGIN = 0xcc0, LENGTH = 0x1340
7 | ram (rw!x) : ORIGIN = 0x8001e0, LENGTH = 0x80
8 |
9 | trash : ORIGIN = 0xffff0000, LENGTH = 0xffff
10 | }
11 |
12 | SECTIONS
13 | {
14 | .text :
15 | {
16 | *(.vecs)
17 | *(.vecs*)
18 | KEEP(*(.vecs*))
19 | KEEP(*(.vecs))
20 |
21 | *(.progmem.gcc*)
22 | *(.progmem*)
23 |
24 | . = ALIGN(2);
25 | *(.jumptables)
26 | *(.jumptables*)
27 | *(.lowtext)
28 | *(.lowtext*)
29 |
30 | *(.text)
31 | *(.text.*)
32 |
33 | PROVIDE (__data_data = .) ;
34 |
35 | } > flash
36 |
37 | .data : AT (ADDR (.text) + SIZEOF (.text))
38 | {
39 | PROVIDE (__data_start = .) ;
40 | *(.data)
41 | *(.data.*)
42 | *(.rodata)
43 | *(.rodata.*)
44 | PROVIDE (__data_end_bss_start = .) ;
45 | } > ram
46 |
47 |
48 | .bss :
49 | {
50 | *(.bss)
51 | *(.bss*)
52 | *(COMMON)
53 | PROVIDE (__bss_end = .) ;
54 | } > ram
55 |
56 | .trash :
57 | {
58 | *(.vectors)
59 | *(.vectors.*)
60 | } > trash
61 | }
62 |
63 |
64 | PROVIDE (usbWork = 15 * 2) ;
65 | PROVIDE (packetCanSend = 16 * 2) ;
66 | PROVIDE (packetSend = 17 * 2) ;
67 | PROVIDE (packetRx = 18 * 2) ;
68 | PROVIDE (packetRxRelease = 19 * 2) ;
69 | PROVIDE (bootloader = 20 * 2) ;
70 | PROVIDE (getUsbCaps = 21 * 2) ;
71 | PROVIDE (usbReenumerate = 22 * 2) ;
72 | PROVIDE (blGetBlVersion = 23 * 2) ;
--------------------------------------------------------------------------------
/blupdate-efm.c:
--------------------------------------------------------------------------------
1 | #include "blupdate-efm.h"
2 | #include "efm32hg308f64.h"
3 |
4 | #define DESIRED_BL_VER 1 //all our BLS are 2+
5 | #define FLASH_PAGE_SIZE 1024
6 |
7 |
8 |
9 |
10 | static uint32_t getUpdateData(const uint8_t **dataP); //returns size and length. must be 4-byte aligned and size must be a multiple of FLASH_PAGE_SIZE
11 |
12 | static void flashReadyWait(void)
13 | {
14 | while (MSC->STATUS & MSC_STATUS_BUSY);
15 | }
16 |
17 | static void flashErase(uint16_t dstAddr) //erase a page
18 | {
19 | if (dstAddr & (FLASH_PAGE_SIZE - 1)) //can only erase on block boundary
20 | return;
21 |
22 | MSC->WRITECTRL |= MSC_WRITECTRL_WREN;
23 | MSC->ADDRB = dstAddr;
24 | flashReadyWait();
25 | MSC->WRITECMD = MSC_WRITECMD_LADDRIM; //latch addr
26 |
27 | MSC->WRITECMD = MSC_WRITECMD_ERASEPAGE; //page erase
28 | flashReadyWait();
29 | MSC->WRITECTRL &=~ MSC_WRITECTRL_WREN;
30 | }
31 | //write a page
32 | static void flashWrite(uint16_t dstAddr, const uint8_t *srcData /* must be 4 byte aligned*/)
33 | {
34 | uint32_t i, *src = (uint32_t*)srcData; //WILL BE ALIGNED
35 |
36 | if (dstAddr & (FLASH_PAGE_SIZE - 1)) //can only write on block boundary
37 | return;
38 |
39 | MSC->WRITECTRL |= MSC_WRITECTRL_WREN;
40 | MSC->ADDRB = dstAddr;
41 | flashReadyWait();
42 | MSC->WRITECMD = MSC_WRITECMD_LADDRIM; //latch addr
43 |
44 | for (i = 0; i < FLASH_PAGE_SIZE; i += sizeof(uint32_t)) {
45 |
46 | while (!(MSC->STATUS & MSC_STATUS_WDATAREADY)); //wait for flash to be ready for data
47 | MSC->WDATA = *src++;
48 | MSC->WRITECMD = MSC_WRITECMD_WRITEONCE;
49 | flashReadyWait();
50 | }
51 |
52 | MSC->WRITECTRL &=~ MSC_WRITECTRL_WREN;
53 | }
54 |
55 | void blUpdateIfNeeded(uint8_t curVer)
56 | {
57 | uint32_t i, updateSz;
58 | const uint8_t *updataData;
59 |
60 | if (curVer >= DESIRED_BL_VER)
61 | return;
62 | if (curVer < 2) //before v2 BLs were locked in the EFM HW and we cannot update those
63 | return;
64 |
65 | //we are commited - disable all interrupts
66 | asm volatile("cpsid i");
67 | asm volatile("cpsid f");
68 |
69 | //get ready...
70 | updateSz = getUpdateData(&updataData);
71 |
72 | //go
73 | for (i = 0; i < updateSz; i += FLASH_PAGE_SIZE) {
74 |
75 | flashErase(i);
76 | flashWrite(i, updataData + i);
77 | }
78 |
79 | //reset
80 | NVIC_SystemReset();
81 | }
82 |
83 | static uint32_t getUpdateData(const uint8_t **dataP)
84 | {
85 | static const uint8_t __attribute__((aligned(4))) update[] = {
86 | //insert exactly 16K of binary data here
87 | };
88 |
89 |
90 | *dataP = update;
91 | return sizeof(update);
92 | }
93 |
--------------------------------------------------------------------------------
/blupdate-efm.h:
--------------------------------------------------------------------------------
1 | #ifndef _BL_UPDATE_EFM_H_
2 | #define _BL_UPDATE_EFM_H_
3 |
4 | #include
5 |
6 |
7 | void blUpdateIfNeeded(uint8_t curVer); //update BL if needed, reset devce after (do not return)
8 |
9 |
10 |
11 | #endif
12 |
--------------------------------------------------------------------------------
/cortex.h:
--------------------------------------------------------------------------------
1 | #ifndef _CORTEX_H_
2 | #define _CORTEX_H_
3 |
4 | #ifndef WIN32
5 | #include
6 | #include
7 | #endif
8 | #include "util.h"
9 |
10 |
11 | #define CPUID_PART_M0 0xC200
12 | #define CPUID_PART_M1 0xC210
13 | #define CPUID_PART_M3 0xC230
14 | #define CPUID_PART_M4 0xC240
15 | #define CPUID_PART_M0p 0xC600
16 | #define CPUID_PART_M7 0xC270
17 | #define CPUID_PART_UNREADABLE 0xBEEF
18 |
19 | #define CORTEX_W_HALT_OR_STEP 0x01 /* C_HALT or C_STEP set */
20 | #define CORTEX_W_BKPT 0x02 /* BKPT executed */
21 | #define CORTEX_W_DWPT 0x04 /* data watchpoint */
22 | #define CORTEX_W_VCATCH 0x08 /* vector caught */
23 | #define CORTEX_W_EXTERNAL 0x10 /* external debug request */
24 | #define CORTEX_W_FAIL 0xFF
25 |
26 |
27 | #define CORTEX_WP_OFF 0
28 | #define CORTEX_WP_PC 4
29 | #define CORTEX_WP_READ 5
30 | #define CORTEX_WP_WRITE 6
31 | #define CORTEX_WP_RW 7
32 | #define CORTEX_WP_MASK 0x0F
33 |
34 | #define CORTEX_INIT_OK 0
35 | #define CORTEX_INIT_CPUID_READ_FAIL 1
36 | #define CORTEX_INIT_CPU_TYPE_UNKNOWN 2
37 | #define CORTEX_INIT_DEMCR_WRITE_FAIL 3
38 | #define CORTEX_INIT_WPT_SETUP_FAIL 4
39 | #define CORTEX_INIT_BPT_SETUP_FAIL 5
40 | #define CORTEX_INIT_FPU_CHECK_FAIL 6
41 |
42 | //stateP is used for fast cpu switching later on
43 | uint8_t cortexInit(unaligned_uint16_t *cortexTypeP, uint8_t *fastCpuSwitchingStateP); //zero on error
44 |
45 | //to be done after memap has been switched already
46 | bool cortexFastCpuSwitch(uint8_t fastCpuSwitchingState);
47 |
48 | bool cortexRegRead(uint8_t regNo, unaligned_uint32_t *valP);
49 | bool cortexRegWrite(uint8_t regNo, uint32_t val);
50 |
51 | bool cortexStep(void);
52 | bool cortexStop(void);
53 | bool cortexGo(void);
54 | bool cortexReset(void);
55 | uint8_t cortexGetStopReason(void); //return & CLEAR(!!!) stop reason (aka: "what happened??") -> CORTEX_W_*
56 |
57 | bool cortexHaveFpu(void);
58 |
59 | #define CORTEX_REG_Rx(x) (x) //R0..R15
60 | #define CORTEX_REG_XPSR 16
61 | #define CORTEX_REG_MSP 17
62 | #define CORTEX_REG_PSP 18
63 | #define CORTEX_REG_CFBP 20 /* control, faultmask, basepri, primask */
64 | #define CORTEX_REG_FPCSR 33
65 | #define CORTEX_REG_Sx(x) (64 + (x)) //S0..S31
66 |
67 |
68 | #endif
69 |
70 |
--------------------------------------------------------------------------------
/crt-avr.S:
--------------------------------------------------------------------------------
1 | .section .vecs
2 |
3 | .globl __reset_vector_ptr
4 | __reset_vector_ptr:
5 | __bad_interrupt:
6 | rjmp __reset_vector
7 |
8 | //vector table for cpu (forward all but INT0)
9 | rjmp __reset_vector //this vector is never used as BL does not give it to us
10 | rjmp __vector_2
11 | rjmp __vector_3
12 | rjmp __vector_4
13 | rjmp __vector_5
14 | rjmp __vector_6
15 | rjmp __vector_7
16 | rjmp __vector_8
17 | rjmp __vector_9
18 | rjmp __vector_10
19 | rjmp __vector_11
20 | rjmp __vector_12
21 | rjmp __vector_13
22 | rjmp __vector_14
23 |
24 |
25 | .section .text
26 |
27 | __reset_vector:
28 |
29 | //load data start and end, copy data
30 | ldi r17, hi8(__data_end_bss_start)
31 | ldi r26, lo8(__data_start)
32 | ldi r27, hi8(__data_start)
33 | ldi r30, lo8(__data_data)
34 | ldi r31, hi8(__data_data)
35 |
36 | //copy data
37 | rjmp __data_copy_loop_check
38 |
39 | __data_copy_loop:
40 | lpm r0, Z+
41 | st X+, r0
42 |
43 | __data_copy_loop_check:
44 | cpi r26, lo8(__data_end_bss_start)
45 | cpc r27, r17
46 | brne __data_copy_loop
47 |
48 | //load bss start and end ptrs
49 | ldi r18, hi8(__bss_end)
50 |
51 | //clear bss
52 | rjmp __bss_clear_loop_check
53 |
54 | __bss_clear_loop:
55 | st X+, r1
56 |
57 | __bss_clear_loop_check:
58 | cpi r26, lo8(__bss_end)
59 | cpc r27, r18
60 | brne __bss_clear_loop
61 |
62 |
63 | rjmp main
64 |
65 |
--------------------------------------------------------------------------------
/efm.lkr:
--------------------------------------------------------------------------------
1 |
2 | MEMORY
3 | {
4 | rom : ORIGIN = 16K, LENGTH = 48K
5 | ram : ORIGIN = 0x20001000, LENGTH = 4K
6 | trash : ORIGIN = 0xffff0000, LENGTH = 65535
7 | }
8 |
9 | SECTIONS
10 | {
11 | . = 0x00000000;
12 | .vectors : { *(.vectors) } > rom
13 |
14 | .text : { *(.text) *(.text.*) ; } > rom
15 | .rodata : { *(.rodata) *(.rodata.*) ; . = ALIGN(4) ; __data_data = ABSOLUTE(.) ;} > rom
16 |
17 | . = 0x20000800;
18 | .data : AT ( ADDR ( .rodata ) + SIZEOF ( .rodata ) ) { . = ALIGN(4) ; __data_start = ADDR ( .data ) + . ; *(.data) ; *(.data.*) ; . = ALIGN(4) ; __data_end = ADDR ( .data ) + . ; } > ram
19 | .bss : { . = ALIGN(4) ; __bss_start = ABSOLUTE(.) ; *(.bss) *(.bss.*) *(COMMON) ; . = ALIGN(4) ; __bss_end = ABSOLUTE(.) ; } > ram
20 |
21 | .trash1 : { *(.ARM.exidx) *(.ARM.exidx.*) ; } > trash
22 | .trash2 : { *(.init) *(.init.*) ; *(.fini) *(.fini.*) ; } > trash
23 | }
24 |
25 | __stack_top = (ORIGIN(ram) + LENGTH(ram)) & 0xfffffff8;
26 | __vectors_start = ORIGIN(rom);
27 |
28 |
29 | ENTRY(__VECTORS)
30 |
31 |
32 |
--------------------------------------------------------------------------------
/led-efm.c:
--------------------------------------------------------------------------------
1 | #include "efm32hg308f64.h"
2 | #include "led-efm.h"
3 |
4 |
5 | //v0,v1,v2,v3,v4:
6 | // b13 is vcc for leds (must be high)
7 | // b8 (pwr), b11 (act) are active low
8 | // b8 is tim1_cc1 which we'll use to reduce its brightness to 1/8 brightness via PWM
9 | //v5:
10 | // b11 is act, power led i snot controllable
11 |
12 | void ledInit(void)
13 | {
14 | if (BL->blGetHwVer() == HW_VER_EFM_V5) { //simpler v5 code
15 |
16 | //clock up gpio
17 | CMU->HFPERCLKEN0 |= CMU_HFPERCLKEN0_GPIO;
18 |
19 | //unlock gpio
20 | GPIO->LOCK = _GPIO_LOCK_LOCKKEY_UNLOCK;
21 |
22 | //enable high-current drive
23 | GPIO->P[1].CTRL = GPIO_P_CTRL_DRIVEMODE_HIGH;
24 |
25 | //enable proper pins as gpios in high current mode
26 | GPIO->P[1].MODEH = (GPIO->P[1].MODEH &~ _GPIO_P_MODEH_MODE11_MASK) | GPIO_P_MODEH_MODE11_PUSHPULLDRIVE;
27 |
28 | //set ACT pin high (led off)
29 | GPIO->P[1].DOUTSET = 1 << 11;
30 | }
31 | else {
32 | //clock up gpio and timer1
33 | CMU->HFPERCLKEN0 |= CMU_HFPERCLKEN0_GPIO | CMU_HFPERCLKEN0_TIMER1;
34 |
35 | //unlock gpio
36 | GPIO->LOCK = _GPIO_LOCK_LOCKKEY_UNLOCK;
37 |
38 | //enable high-current drive
39 | GPIO->P[1].CTRL = GPIO_P_CTRL_DRIVEMODE_HIGH;
40 |
41 | //enable proper pins as gpios in high current mode
42 | GPIO->P[1].MODEH = (GPIO->P[1].MODEH &~ (_GPIO_P_MODEH_MODE8_MASK | _GPIO_P_MODEH_MODE11_MASK | _GPIO_P_MODEH_MODE13_MASK)) | GPIO_P_MODEH_MODE8_PUSHPULLDRIVE | GPIO_P_MODEH_MODE11_PUSHPULLDRIVE | GPIO_P_MODEH_MODE13_PUSHPULLDRIVE;
43 |
44 | //set all pins (macrofab populated LEDS backwards)
45 | GPIO->P[1].DOUTSET = (1 << 8) | (1 << 11) | (1 << 13);
46 |
47 | //config timer 1
48 | TIMER1->CMD = TIMER_CMD_STOP;
49 | TIMER1->CTRL = TIMER_CTRL_PRESC_DIV1 | TIMER_CTRL_CLKSEL_PRESCHFPERCLK | TIMER_CTRL_MODE_UP;
50 | TIMER1->TOP = 0xFF;
51 | TIMER1->TOPB = 0xFF;
52 | TIMER1->CNT = 0;
53 | TIMER1->ROUTE = TIMER_ROUTE_LOCATION_LOC3 | TIMER_ROUTE_CC1PEN;
54 | TIMER1->CC[1].CTRL = TIMER_CC_CTRL_MODE_PWM;
55 | TIMER1->CC[1].CCV = 0x100;
56 | TIMER1->CMD = TIMER_CMD_START;
57 | }
58 | }
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/led-efm.h:
--------------------------------------------------------------------------------
1 | #ifndef _LED_H_
2 | #define _LED_H_
3 |
4 | #include
5 | #include
6 | #include "plat.h"
7 |
8 | #define LED_ACT 0
9 | #define LED_PWR 1
10 |
11 | void ledInit(void);
12 |
13 | static inline void ledSet(uint32_t which, bool on)
14 | {
15 | if (which == LED_ACT) {
16 |
17 | uint32_t mask = 1 << 11;
18 |
19 | if (on)
20 | GPIO->P[1].DOUTCLR = mask;
21 | else
22 | GPIO->P[1].DOUTSET = mask;
23 | }
24 | else if (BL->blGetHwVer() != HW_VER_EFM_V5) //power control only available in pre-v5 boards
25 | TIMER1->CC[1].CCV = on ? 0xE0 : 0x100;
26 | }
27 |
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/memap.h:
--------------------------------------------------------------------------------
1 | #ifndef _MEM_AP_H_
2 | #define _MEM_AP_H_
3 |
4 | #include
5 | #include
6 | #include "util.h"
7 |
8 |
9 | #define MEMAP_OK 0
10 | #define MEMAP_INIT_CFG_READ_FAIL 1
11 | #define MEMAP_INIT_MEM_IS_BE 2
12 | #define MEMAP_INIT_ACCESS_SIZE_SET_ERR 3
13 | #define MEMAP_INIT_ROM_TAB_ADDR_READ_FAIL 4
14 | #define MEMAP_INIT_ROM_TAB_REG_INVAL 5
15 | #define MEMAP_INIT_AP_SEL_FAIL 6
16 |
17 | //init/reinit
18 | uint8_t memapInit(uint8_t apSel, unaligned_uint32_t* romTabP); //selects the ap to do things. return rom table addr or 0 is fail
19 | bool memapReselect(uint8_t apSel); //tobe done when changing APs
20 |
21 | //lowest level funcs
22 | bool memapSetAddr(uint32_t addr);
23 | bool memapReadMultiple(unaligned_uint32_t *dst, uint16_t num);
24 | bool memapWriteMultiple(const unaligned_uint32_t *vals, uint16_t num);
25 |
26 | //middle-layer funcs
27 | bool memapRead(unaligned_uint32_t *valP); //autoincrements. not fast, if need multiple do it another way
28 | bool memapWrite(uint32_t val); //autoincrements. not fast, if need multiple do it another way
29 |
30 | //convenience wrappers
31 | bool memapReadAddr(uint32_t addr, unaligned_uint32_t *valP);
32 | bool memapWriteAddr(uint32_t addr, uint32_t val);
33 |
34 |
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/plat-avr.c:
--------------------------------------------------------------------------------
1 | #include "plat.h"
2 |
3 |
4 |
5 | struct UsbStringDescr {
6 | uint8_t len;
7 | uint8_t type;
8 | uint16_t chars[];
9 | } __attribute__((aligned(4)));
10 |
11 | static const PROGMEM struct UsbStringDescr mDevStr = {24, 3, {'C', 'o', 'r', 't', 'e', 'x', 'P', 'r', 'o', 'g', '1'}};
12 | static struct UsbStringDescr mSnumStr = {.chars = {0, 0, 0, 0, 0, 0, 0, 0}};
13 |
14 |
15 | //sig area is 0x2B bytes, but we read 0x2C, because fuck it
16 | static void calc_snum(uint8_t *val)
17 | {
18 | uint8_t bits = (1 << RSIG) | (1 << SPMEN), t, t2, smallIdx, bigIdx;
19 | uint16_t addr;
20 |
21 | asm volatile(
22 | "0: \n\t"
23 | " ldi %5, 4 \n\t"
24 | "1: \n\t"
25 | " out 0x37, %2 \n\t" //spmcsr = 0x37
26 | " lpm %3, Z+ \n\t"
27 | " ld %4, X \n\t"
28 | " eor %4, %3 \n\t"
29 | " st X+, %4 \n\t"
30 | " dec %5 \n\t"
31 | " brne 1b \n\t"
32 | " sbiw r26, 4 \n\t"
33 | " dec %6 \n\t"
34 | " brne 0b \n\t"
35 | :"=z"(addr), "=x"(val), "=a"(bits), "=a"(t), "=a"(t2), "=a"(smallIdx), "=a"(bigIdx)
36 | :"0"((uint16_t)0), "1"(val), "2"(bits), "6"((uint8_t)(0x2C / 0x04))
37 | :"cc", "memory"
38 | );
39 | }
40 |
41 | static void print_snum(uint16_t *dst, const uint8_t *src)
42 | {
43 | uint8_t smallIdx, bigIdx, t, t2;
44 |
45 | asm volatile(
46 | "0: \n\t"
47 | " ldi %2, 2 \n\t"
48 | " ld %4, X+ \n\t"
49 | "1: \n\t"
50 | " mov %5, %4 \n\t"
51 | " andi %5, 15 \n\t"
52 | " cpi %5, 10 \n\t" //carry set if "%5 < 10"
53 | " brcs 2f \n\t" //taken if "%5 < 10"
54 | " subi %5, -0x27 \n\t" //0x27 = 'a' - '0' - 10
55 | "2: \n\t"
56 | " subi %5, -0x30 \n\t" //0x30 = '0'
57 | " st Z, %5 \n\t"
58 | " adiw r30, 2 \n\t"
59 | " swap %4 \n\t"
60 | " dec %2 \n\t"
61 | " brne 1b \n\t"
62 | " dec %3 \n\t"
63 | " brne 0b \n\t"
64 | :"=z"(dst), "=x"(src), "=a"(smallIdx), "=a"(bigIdx), "=a"(t), "=a"(t2)
65 | :"0"(dst), "1"(src), "3"((uint8_t)4)
66 | :"cc", "memory"
67 | );
68 | }
69 |
70 | static void setupUsb(bool setSnum)
71 | {
72 | uint8_t snum[4] = {0,};
73 |
74 | if (setSnum) {
75 |
76 | //get "snum"
77 | calc_snum(snum);
78 |
79 | //print it
80 | mSnumStr.len = sizeof(struct UsbStringDescr) + sizeof(uint16_t) * 8;
81 | mSnumStr.type = 3;
82 | print_snum(mSnumStr.chars, snum);
83 | }
84 |
85 | //use
86 | usbReenumerate(&mDevStr, setSnum ? &mSnumStr : 0);
87 | }
88 |
89 | void platInit(bool enableCdcAcmUart, uint8_t blVer)
90 | {
91 | (void)blVer; //for now
92 |
93 | //this all not needed as we trust our bootloader to disable WDT and not to touch the default (good) reset value of MCUCR
94 | if (0) {
95 | //wdt
96 | cli();
97 | wdt_reset();
98 | wdt_disable();
99 | sei();
100 |
101 | //ports
102 | MCUCR &=~ 0x40; //pullups on
103 | }
104 |
105 | (void)enableCdcAcmUart;
106 | setupUsb(true);
107 | }
108 |
109 |
--------------------------------------------------------------------------------
/plat.h:
--------------------------------------------------------------------------------
1 | #ifndef _PLAT_H_
2 | #define _PLAT_H_
3 |
4 |
5 | #include "../ModulaR/bl.h"
6 | #include
7 | #include
8 |
9 |
10 | void platInit(bool enableCdcAcmUart, uint8_t blVer);
11 |
12 | #ifdef EFM
13 |
14 | // #define USE_TX_AS_RST //hack for now, overwrites everything (incl real reset pin)
15 |
16 | #include "efm32hg308f64.h"
17 |
18 | #define usbWork BL->usbWork
19 | #define packetCanSend BL->packetCanSend
20 | #define packetSend BL->packetSend
21 | #define packetRx BL->packetRx
22 | #define packetRxRelease BL->packetRxRelease
23 | #define bootloader BL->bootloader
24 | #define getUsbCaps BL->getUsbCaps
25 | #define usbReenumerate BL->usbReenumerate
26 | #define blGetBlVersion BL->blGetBlVersion
27 |
28 | void platDeinit(void);
29 | void platWork(void);
30 |
31 | uint32_t platGetFlags(void); //this should be fast. cache as needed
32 | bool platPowerOnOffSet(bool on);
33 | bool platPowerVaribleSet(uint32_t mV);
34 |
35 | int32_t platGetCurSupplyVoltage(void); //only tells us what we're trying to supply
36 |
37 | #define HW_TYPE SWD_COMMS_HW_TYP_EFM
38 | uint8_t platGetHwVerForComms(); //get platform version in format that comms understands: SWD_COMMS_HW_*_VER_*
39 |
40 | void platGetSupplyAbilities(uint16_t *millivoltsMinP, uint16_t *millivoltsMaxP, uint16_t *milliampsMaxP);
41 | uint32_t platGetSwdMaxClkSpeed(void); //in hz
42 | uint32_t platSetSwdClockSpeed(uint32_t speed);
43 |
44 | uint64_t platGetTicks(void);
45 | uint32_t platGetTicksPerSecond(void);
46 |
47 | #endif
48 |
49 | #ifdef AVR
50 |
51 | #include
52 | #include
53 | #include
54 | #include
55 | #include
56 | #define platDeinit()
57 | #define platWork()
58 | #define platPowerOnOffSet(on) (0 * on /* just to make sure it is used */)
59 | #define platPowerVaribleSet(mv) (0 * mv /* just to make sure it is used */)
60 | #define platGetFlags() (SWD_FLAG_SLOW_DEBUGGER)
61 | #define platGetHwVerForComms() (0)
62 | #define platGetSupplyAbilities(...) LINK_ERROR_THIS_SHOULD_NEVER_BE_CALLED()
63 | #define platGetSwdMaxClkSpeed(...) LINK_ERROR_THIS_SHOULD_NEVER_BE_CALLED()
64 | #define platSetSwdClockSpeed(...) LINK_ERROR_THIS_SHOULD_NEVER_BE_CALLED()
65 | #define platGetCurSupplyVoltage() (-1)
66 |
67 | #define HW_TYPE SWD_COMMS_HW_TYP_AVR_PROTO
68 |
69 | extern int LINK_ERROR_THIS_SHOULD_NEVER_BE_CALLED(void);
70 |
71 | #define platGetTicks() LINK_ERROR_THIS_SHOULD_NEVER_BE_CALLED()
72 | #define platGetTicksPerSecond() LINK_ERROR_THIS_SHOULD_NEVER_BE_CALLED()
73 |
74 | #endif
75 |
76 |
77 |
78 |
79 |
80 |
81 | #endif
--------------------------------------------------------------------------------
/swd.h:
--------------------------------------------------------------------------------
1 | #ifndef _SWD_H_
2 | #define _SWD_H_
3 |
4 |
5 | #include
6 | #include
7 | #include "util.h"
8 | #include "wire.h"
9 |
10 |
11 |
12 | //mega low-level things
13 | bool swdWireBusRead(uint1_t ap, uint8_t a23, unaligned_uint32_t *valP);
14 | bool swdWireBusWrite(uint1_t ap, uint8_t a23, uint32_t val);
15 |
16 |
17 | //super low level things
18 | bool swdReadIdcode(unaligned_uint32_t *valP);
19 | bool swdReadStat(unaligned_uint32_t *valP);
20 | bool swdReadRdbuf(unaligned_uint32_t *valP);
21 | bool swdWriteAbort(uint32_t val);
22 | bool swdWriteSelect(uint32_t val);
23 | bool swdWriteCtrl(uint32_t val);
24 |
25 | //medium level
26 | #define SWD_OK 0
27 | #define SWD_ATTACH_IDCODE_READ_FAIL 1
28 | #define SWD_ATTACH_DAP_V0 2
29 | #define SWD_ATTACH_REG_WRITE_FAIL 3 //some reg write failed
30 | #define SWD_ATTACH_REG_READ_FAIL 4 //some reg read failed
31 | #define SWD_ATTACH_RDBUF_READ_FAIL 5
32 | #define SWD_ATTACH_CTRL_STAT_VAL_ERR 6
33 | #define SWD_ATTACH_AHB_NOT_FOUND 7 //returned at end of enum. not necessarily error (if there were results)
34 |
35 |
36 | uint8_t swdDapInit(void); //returns the error code above
37 |
38 | //returns above error codes, takes state. start it at zero. returns SWD_ATTACH_AHB_NOT_FOUND when no more results
39 | uint8_t swdAttachAndEnumApsWithAhbs(uint8_t *stateP);
40 |
41 | //convert above iterator state into a valid apIdx
42 | static inline uint8_t swdStateToApIdx(uint8_t state)
43 | {
44 | return state - 1;
45 | }
46 |
47 | #endif
48 |
49 |
--------------------------------------------------------------------------------
/tool/LICENSE.txt:
--------------------------------------------------------------------------------
1 | This is the CortexProg Pc-side tool source distribution.
2 | It may be used only under the terms of this license. You
3 | may use these source files to build the CortexProg
4 | PC-side tool anytime you wish. You may not sell this
5 | tool or access to this tool. You must provide this souce
6 | package to anyone who requests it if you also gave them
7 | a binary you built from it. This license must accompany
8 | this source code and all of its derivatives and will
9 | apply to them all.
10 |
--------------------------------------------------------------------------------
/tool/SCRIPTS/Makefile:
--------------------------------------------------------------------------------
1 | TARGETS_M0 = $(patsubst %.m0.S,%.swds,$(wildcard *.m0.S))
2 | TARGETS_M3 = $(patsubst %.m3.S,%.swds,$(wildcard *.m3.S))
3 | TARGETS = $(TARGETS_M0) $(TARGETS_M3)
4 |
5 |
6 | all: $(TARGETS)
7 |
8 | %.swds: %.elf
9 | arm-none-eabi-objcopy -j.text -j.data -O binary $< $@
10 |
11 | %.elf: %.o
12 | arm-none-eabi-gcc -e entrypts $< -o $@ -Ttext `echo $@ | sed 's/.*\.\([0-9a-f]*\)\.elf/\1/g'` -nostdlib -mthumb -Wl,-T linker.lkr
13 |
14 | %.o: %.m0.S
15 | arm-none-eabi-gcc -mcpu=cortex-m0 -c $< -o $@ -mthumb
16 |
17 | %.o: %.m3.S
18 | arm-none-eabi-gcc -mcpu=cortex-m3 -c $< -o $@ -mthumb
19 |
20 | clean:
21 | rm -rf *.o *.swds *.elf
--------------------------------------------------------------------------------
/tool/SCRIPTS/linker.lkr:
--------------------------------------------------------------------------------
1 | MEMORY
2 | {
3 | memory (rx) : ORIGIN = 0x0, LENGTH = 0xfffffffff
4 | }
5 |
6 | SECTIONS
7 | {
8 | .text :
9 | {
10 | *(.text)
11 | *(.text.2)
12 | } > memory
13 | }
14 |
--------------------------------------------------------------------------------
/tool/SPECIAL/efm32hg_unlock.lua:
--------------------------------------------------------------------------------
1 | EFM32HG_AAP_CMD = 0xF0E00000
2 | EFM32HG_AAP_CMDKEY = 0xF0E00004
3 | EFM32HG_AAP_STATUS = 0xF0E00008
4 | EFM32HG_AAP_IDR = 0xF0E000FC
5 |
6 | EFM32HG_AAP_IDR_VAL = 0x16E60001
7 | EFM32HG_AAP_CMDKEY_VAL = 0xCFACC118
8 | EFM32HG_AAP_CMD_VAL_ERASE = 1
9 | EFM32HG_AAP_CMD_VAL_RESET = 2
10 | EFM32HG_AAP_STATUS_ERASING = 1
11 |
12 |
13 | function main(step, haveDbg, haveCpu, haveScpt)
14 |
15 | if step == TOOL_OP_STEP_PRE_SCRIPT then
16 |
17 | print(" attempting to erase an EFM32 Happy Gecko chip")
18 |
19 | if cpuWordRead(EFM32HG_AAP_IDR) ~= EFM32HG_AAP_IDR_VAL then
20 | print(" EFM32HG_AAP_IDR value invalid. Refusing to proceed")
21 | return false
22 | end
23 |
24 | print(" AAP found")
25 | if not cpuWordWrite(EFM32HG_AAP_CMDKEY, EFM32HG_AAP_CMDKEY_VAL) then
26 | print(" Failed to write EFM32HG_AAP_CMDKEY 1")
27 | return false
28 | end
29 |
30 | print(" Erasing...")
31 | if not cpuWordWrite(EFM32HG_AAP_CMD, EFM32HG_AAP_CMD_VAL_ERASE) then
32 | print(" Failed to write EFM32HG_AAP_CMD 1")
33 | return false
34 | end
35 |
36 | if not cpuWordWrite(EFM32HG_AAP_CMDKEY, 0) then
37 | print(" Failed to write EFM32HG_AAP_CMDKEY 2")
38 | return false
39 | end
40 |
41 | repeat
42 | ret = cpuWordRead(EFM32HG_AAP_STATUS)
43 | if not ret then
44 | print(" Failed to read EFM32HG_AAP_STATUS\n")
45 | return false
46 | end
47 | until (ret & EFM32HG_AAP_STATUS_ERASING) == 0
48 |
49 | print(" Erase done, resetting")
50 | if not cpuWordWrite(EFM32HG_AAP_CMDKEY, EFM32HG_AAP_CMDKEY_VAL) then
51 | print(" Failed to write EFM32HG_AAP_CMDKEY 3")
52 | return false
53 | end
54 |
55 | if not cpuWordWrite(EFM32HG_AAP_CMD, EFM32HG_AAP_CMD_VAL_RESET) then
56 | print(" Failed to write EFM32HG_AAP_CMD 2")
57 | return false
58 | end
59 |
60 | print(" Success")
61 |
62 | end
63 |
64 | return true
65 | end
66 |
67 | function init(params)
68 |
69 | return TOOL_OP_NEEDS_DEBUGGER | TOOL_OP_NEEDS_CPU
70 | end
--------------------------------------------------------------------------------
/tool/SPECIAL/mb9_unlock.lua:
--------------------------------------------------------------------------------
1 | --needs to be tested. docs say this cannot be done over swd, only serial. but it should work this way. we'll test
2 | --we may need a "STRH" gadget. maybe in ram?
3 |
4 | function main(step, haveDbg, haveCpu, haveScpt)
5 |
6 | if step == TOOL_OP_STEP_PRE_SCRIPT then
7 |
8 | print("Erasing an MB9 chip")
9 |
10 | --disable WDT
11 | if not cpuWordWrite(0x40011c00, 0x1ACCE551) or not cpuWordWrite(0x40011c00, 0xE5331AAE) or not cpuWordWrite(0x40011000, 0) then
12 | print("Failed to disable WDT")
13 | return false
14 | end
15 |
16 | if not cpuWordWrite(0x100, 0xF0) or not cpuWordWrite(0xAA8, 0xAA) or not cpuWordWrite(0x554, 0x55) or not cpuWordWrite(0xAA8, 0x80) or not cpuWordWrite(0xAA8, 0xAA) or not cpuWordWrite(0x554, 0x55) or not cpuWordWrite(0xAA8, 0x10) then
17 | print("Failed to start erase")
18 | return false
19 | end
20 |
21 |
22 | print("Erase started...")
23 |
24 | --dummy read
25 | cpuWordRead(0x40000008)
26 |
27 | repeat
28 | ret = cpuWordRead(0x40000008)
29 | if not ret then
30 | print("Failed to read Flash status")
31 | return false
32 | end
33 | until (ret & 3) == 1
34 |
35 | print("Success, resetting chip")
36 |
37 | cpuReset()
38 |
39 | end
40 |
41 | return true
42 | end
43 |
44 | function init(params)
45 |
46 | return TOOL_OP_NEEDS_DEBUGGER | TOOL_OP_NEEDS_CPU
47 | end
--------------------------------------------------------------------------------
/tool/SPECIAL/nrf51_unlock.lua:
--------------------------------------------------------------------------------
1 | NRF51_NVMC_BASE = 0x4001E000
2 | NRF51_NVMC_CONFIG = NRF51_NVMC_BASE + 0x504
3 | NRF51_NVMC_ERASEALL = NRF51_NVMC_BASE + 0x50C
4 |
5 |
6 | function main(step, haveDbg, haveCpu, haveScpt)
7 |
8 | if step == TOOL_OP_STEP_PRE_SCRIPT then
9 |
10 | print("Erasing an nRF51 chip")
11 |
12 | ret = cpuWordWrite(NRF51_NVMC_CONFIG, 2)
13 | if (not ret) or (cpuWordRead(NRF51_NVMC_CONFIG) ~= 2) then
14 | print("Failed to write NVMC.CONFIG")
15 | return false
16 | end
17 |
18 | ret = cpuWordWrite(NRF51_NVMC_ERASEALL, 1)
19 | cpuWordRead(NRF51_NVMC_ERASEALL) --force a read
20 | if not ret then
21 | print("Failed to write NVMC.ERASEALL")
22 | return false
23 | end
24 | print("Erase started...")
25 |
26 | repeat
27 | ret = cpuWordRead(NRF51_NVMC_ERASEALL)
28 | if not ret then
29 | print("Failed to read NVMC.ERASEALL")
30 | return false
31 | end
32 | until (ret & 1) == 0
33 |
34 | print("Success, resetting chip")
35 |
36 | cpuReset()
37 |
38 | end
39 |
40 | return true
41 | end
42 |
43 | function init(params)
44 |
45 | return TOOL_OP_NEEDS_DEBUGGER | TOOL_OP_NEEDS_CPU
46 | end
--------------------------------------------------------------------------------
/tool/SPECIAL/staging/probeulizer.lua:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cortexprog/cortexprogfw/dbfc46a8dfdadb990bfa95388fb3729a3b63d752/tool/SPECIAL/staging/probeulizer.lua
--------------------------------------------------------------------------------
/tool/SPECIAL/staging/psoc4_protection.lua:
--------------------------------------------------------------------------------
1 | PSOC_CPUID_REG_ADDR = 0xF0000FE0
2 | PSOC41xx_42xx_ADDR_CPUSS_BASE = 0x40000000
3 | PSOC_OTHERS_ADDR_CPUSS_BASE = 0x40100000
4 |
5 | RAM_CODE_LOCATION = 0x20000080
6 | RAM_CODE = 0x5088
7 | RAM_LOC_STACK_TOP = 0x20000700
8 | SYSCALL_NUM = 0x1234
9 | MAX_STEPS = 0x32
10 | MAX_OFST = 0x7C
11 |
12 | PSOC4xxx_ADDROFST_CPUSS_SYSREQ = 0x00000004
13 | PSOC4xxx_SYSREQ_BIT_SYSCALL_REQ = 0x80000000
14 | PSOC4xxx_SYSREQ_BIT_ROM_ACCESS_EN = 0x20000000
15 |
16 | DHCSR_BITS_KEY = 0xa05f0000
17 | DHCSR_BITS_WRITEABLE = 0x0000ffff
18 | DHCSR_BIT_DEBUGEN = 0x00000001
19 |
20 | ADDR_DHCSR = 0xE000EDF0
21 | ADDR_DEMCR = 0xE000EDFC
22 |
23 | function psoc4Idenfiy()
24 |
25 | local family = cpuWordRead(PSOC_CPUID_REG_ADDR)
26 |
27 | if not v then
28 | error(" Failed to read PSoC romtab CPUID")
29 | end
30 |
31 | if (family >> 8) ~= 0 then
32 | error(string.format(" PSoC romtab CPUID invalid 0x%08X", ret))
33 | end
34 |
35 | cpuss = PSOC_OTHERS_ADDR_CPUSS_BASE
36 | if family == 0x93 then
37 | print(" PSoC4100/4200 detected")
38 | cpuss = PSOC41xx_42xx_ADDR_CPUSS_BASE
39 | elseif family == 0x9E then
40 | print(" CYBL10x6x (PSoC4000-BLE?) detected")
41 | elseif family == 0x9A then
42 | print(" PSoC4000 detected")
43 | elseif family == 0xA1 then
44 | print(" PSoC4100M/4200M detected")
45 | elseif family == 0xA9 then
46 | print(" PSoC4000S detected")
47 | else
48 | print(string.format(" Unknown PSoC 0x%02X detected. Assuming CPUSS 0x%08X\n", family, cpuss))
49 | end
50 |
51 | --[[
52 | other known vals:
53 | AE, A3, AA - PSoC_BLE of some type
54 |
55 | 69 - PSoC5
56 | A0 - 4200L
57 | A7 - 4200D ?
58 | AB - 4100S
59 | AC - analog coprocessor (aka PSoC4400)
60 | --]]
61 |
62 | return cpuss
63 |
64 | end
65 |
66 |
67 | function main(step, haveDbg, haveCpu, haveScpt)
68 |
69 | if step == TOOL_OP_STEP_PRE_SCRIPT then
70 |
71 | local val
72 |
73 | print("resetting")
74 |
75 | cpuWordWrite(0x40030014, 0x80000000)
76 | cpuReset()
77 |
78 | repeat
79 |
80 | until cpuWordWrite(0x40030014, 0x80000000)
81 |
82 | print("written")
83 |
84 | repeat
85 | val = cpuWordRead(0x40100004)
86 | until (val & 0x10000000) == 0
87 |
88 | print("stopped out of rom")
89 |
90 | print(string.format("SYSREQ=0x%08X Pc=0x%08X", val, cpuRegGet(15)))
91 | return true
92 |
93 |
94 | end
95 |
96 | return true
97 | end
98 |
99 | function init(params)
100 |
101 | if params == "open" then
102 | mDesiredMode = 0x01
103 | elseif params == "protected" then
104 | mDesiredMode = 0x02
105 | elseif params == "kill" then
106 | mDesiredMode = 0x04
107 | elseif params == "read" then
108 | mDesiredMode = 0
109 | else
110 | print("This script needs a paramater. Options are:\n\t\"read\" - read current mode (if possible)\n\t\"open\" - set open mode\n\t\"protected\" - set protected mode\n\t\"kill\" - set kill mode")
111 | return nil
112 | end
113 |
114 | return TOOL_OP_NEEDS_DEBUGGER | TOOL_OP_NEEDS_CPU
115 | end
--------------------------------------------------------------------------------
/tool/SPECIAL/staging/test.lua:
--------------------------------------------------------------------------------
1 |
2 | SWD_ADDR_DPIDR_R = 0
3 | SWD_ADDR_ABORT_W = 0
4 | SWD_ADDR_SELECT_W = 2
5 | SWD_ADDR_RDBUFF_R = 3
6 |
7 | AP_ADDR_IDR = 0xFC
8 |
9 | SWD_REG_BANK_MASK = 0xF0
10 | SWD_REG_SEL_MASK = 0x0C
11 | SWD_REG_SEL_SHIFT = 2
12 |
13 | mSelectedAp = 0xffffffff
14 |
15 | function swdSelectApAndRegBank(apNum, regNum)
16 |
17 | desiredVal = (apNum << 24) | (regNum & SWD_REG_BANK_MASK)
18 |
19 | if desiredVal == mSelectedAp then
20 | return true
21 | end
22 |
23 | ret = dbgSwdWrite(0, SWD_ADDR_SELECT_W, desiredVal)
24 | if ret == nil then
25 | return nil
26 | end
27 |
28 | mSelectedAp = desiredVal
29 | return true
30 | end
31 |
32 |
33 | function swdApRegRead(apNum, addr)
34 |
35 | regSel = (addr & SWD_REG_SEL_MASK) >> SWD_REG_SEL_SHIFT;
36 |
37 | --setup the bank
38 | ret = swdSelectApAndRegBank(apNum, addr)
39 | if ret == nil then
40 | return nil
41 | end
42 |
43 | --request read of given reg
44 | ret = dbgSwdRead(1, regSel)
45 | if ret == nil then
46 | return nil
47 | end
48 |
49 | --let it cycle through the AP & get the result
50 | ret = dbgSwdRead(0, SWD_ADDR_RDBUFF_R)
51 | if ret == nil then
52 | return nil
53 | end
54 |
55 | --done
56 | return ret
57 | end
58 |
59 | function swdApRegWrite(apNum, addr, val)
60 |
61 | regSel = (addr & SWD_REG_SEL_MASK) >> SWD_REG_SEL_SHIFT;
62 |
63 | --setup the bank
64 | ret = swdSelectApAndRegBank(apNum, addr)
65 | if ret == nil then
66 | return nil
67 | end
68 |
69 | --request read of given reg
70 | ret = dbgSwdWrite(1, regSel, val)
71 | if ret == nil then
72 | return nil
73 | end
74 |
75 | --let it cycle through the AP & get the result
76 | ret = dbgSwdRead(0, SWD_ADDR_RDBUFF_R)
77 | if ret == nil then
78 | return nil
79 | end
80 |
81 | --done
82 | return true
83 | end
84 |
85 |
86 | function main(step, haveDbg, haveCpu, haveScpt)
87 |
88 | if step == TOOL_OP_STEP_PRE_SCRIPT then
89 |
90 | print("Checking on APs")
91 |
92 | for i=0,255 do
93 |
94 | val = swdApRegRead(i, AP_ADDR_IDR)
95 | if val == nil or val == 0 then break end
96 | print(string.format("AP %d has id 0x%08x", i, val))
97 | end
98 | end
99 |
100 | return true
101 | end
102 |
103 | function init(params)
104 |
105 | return TOOL_OP_NEEDS_DEBUGGER | TOOL_OP_WANTS_CPU
106 | end
--------------------------------------------------------------------------------
/tool/VisualStudioProject/CortexProg.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #include "resource.h"
4 |
5 | #define APSTUDIO_READONLY_SYMBOLS
6 | /////////////////////////////////////////////////////////////////////////////
7 | //
8 | // Generated from the TEXTINCLUDE 2 resource.
9 | //
10 | #include "windows.h"
11 |
12 | /////////////////////////////////////////////////////////////////////////////
13 | #undef APSTUDIO_READONLY_SYMBOLS
14 |
15 | /////////////////////////////////////////////////////////////////////////////
16 | // English (U.S.) resources
17 |
18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
19 | #ifdef _WIN32
20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
21 | #pragma code_page(1252)
22 | #endif //_WIN32
23 |
24 | #ifdef APSTUDIO_INVOKED
25 | /////////////////////////////////////////////////////////////////////////////
26 | //
27 | // TEXTINCLUDE
28 | //
29 |
30 | 1 TEXTINCLUDE
31 | BEGIN
32 | "resource.h\0"
33 | END
34 |
35 | 3 TEXTINCLUDE
36 | BEGIN
37 | "\r\n"
38 | END
39 |
40 | 2 TEXTINCLUDE
41 | BEGIN
42 | "#include ""afxres.h""\r\n"
43 | END
44 |
45 | #endif // APSTUDIO_INVOKED
46 |
47 |
48 | /////////////////////////////////////////////////////////////////////////////
49 | //
50 | // Icon
51 | //
52 |
53 | // Icon with lowest ID value placed first to ensure application icon
54 | // remains consistent on all systems.
55 | IDI_ICON1 ICON "icon1.ico"
56 | #endif // English (U.S.) resources
57 | /////////////////////////////////////////////////////////////////////////////
58 |
59 |
60 |
61 | #ifndef APSTUDIO_INVOKED
62 | /////////////////////////////////////////////////////////////////////////////
63 | //
64 | // Generated from the TEXTINCLUDE 3 resource.
65 | //
66 |
67 |
68 | /////////////////////////////////////////////////////////////////////////////
69 | #endif // not APSTUDIO_INVOKED
70 |
71 |
--------------------------------------------------------------------------------
/tool/VisualStudioProject/icon1.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cortexprog/cortexprogfw/dbfc46a8dfdadb990bfa95388fb3729a3b63d752/tool/VisualStudioProject/icon1.ico
--------------------------------------------------------------------------------
/tool/VisualStudioProject/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by CortexProg.rc
4 | //
5 | #define IDI_ICON1 101
6 |
7 | // Next default values for new objects
8 | //
9 | #ifdef APSTUDIO_INVOKED
10 | #ifndef APSTUDIO_READONLY_SYMBOLS
11 | #define _APS_NEXT_RESOURCE_VALUE 102
12 | #define _APS_NEXT_COMMAND_VALUE 40001
13 | #define _APS_NEXT_CONTROL_VALUE 1001
14 | #define _APS_NEXT_SYMED_VALUE 101
15 | #endif
16 | #endif
17 |
--------------------------------------------------------------------------------
/tool/alloca.h:
--------------------------------------------------------------------------------
1 | #ifndef _MY_ALLOCA_H_
2 | #define _MY_ALLOCA_H_
3 |
4 | #ifdef WIN32
5 | #include
6 | #include
7 | #else
8 | #include
9 | #endif
10 |
11 | #endif
12 |
--------------------------------------------------------------------------------
/tool/cpu.h:
--------------------------------------------------------------------------------
1 | #ifndef _CPU_H_
2 | #define _CPU_H_
3 |
4 |
5 | struct Cpu;
6 |
7 | #include "types.h"
8 | #include
9 | #define D_CPU_SUPPORTS_UNALIGNED_ACCESS_ //for windows
10 | #undef UNALIGNED
11 | #include "../cortex.h"
12 | #include "scriptfiles.h"
13 | #include "debugger.h"
14 |
15 |
16 | #define CPU_NUM_REGS_PER_SET NUM_REGS //how many regs we get per cpuRegs*() call
17 |
18 |
19 | //status codes
20 | #define CPU_STAT_CODE_HALT_OR_STEP CORTEX_W_HALT_OR_STEP
21 | #define CPU_STAT_CODE_BKPT CORTEX_W_BKPT
22 | #define CPU_STAT_CODE_DWPT CORTEX_W_DWPT
23 | #define CPU_STAT_CODE_VCATCH CORTEX_W_VCATCH
24 | #define CPU_STAT_CODE_EXTERNAL CORTEX_W_EXTERNAL
25 | #define CPU_STAT_CODE_FAILED CORTEX_W_FAIL
26 |
27 | //watchpoint types
28 | #define CPU_WPT_TYPE_OFF CORTEX_WP_OFF
29 | #define CPU_WPT_TYPE_PC CORTEX_WP_PC
30 | #define CPU_WPT_TYPE_READ CORTEX_WP_READ
31 | #define CPU_WPT_TYPE_WRITE CORTEX_WP_WRITE
32 | #define CPU_WPT_TYPE_RW CORTEX_WP_RW
33 | #define CPU_WPT_TYPE_MASK CORTEX_WP_MASK
34 |
35 | struct Cpu* cpuAttach(struct Debugger *dbg, bool verbose); //returns non-NULL on success
36 | const struct PotentialScriptfile *cpuGetScriptfileOptions(const struct Cpu* cpu); //post attach returns the options
37 | void cpuFree(struct Cpu* cpu);
38 |
39 | uint32_t cpuGetOptimalReadNumWords(struct Cpu *cpu);
40 | uint32_t cpuGetOptimalWriteNumWords(struct Cpu *cpu);
41 |
42 | bool cpuMemReadEx(struct Cpu *cpu, uint32_t base, uint32_t numWords, uint32_t *dst, bool silent/* do not write any errors to stdout*/);
43 | bool cpuMemRead(struct Cpu *cpu, uint32_t base, uint32_t numWords, uint32_t *dst);
44 | bool cpuMemWrite(struct Cpu *cpu, uint32_t base, uint32_t numWords, const uint32_t *src, bool withAck);
45 |
46 | bool cpuRegsGet(struct Cpu *cpu, uint8_t regSet, uint32_t *dst);
47 | bool cpuRegsSet(struct Cpu *cpu, uint8_t regSet, const uint32_t *src);
48 |
49 | uint8_t cpuStop(struct Cpu *cpu); // ->CPU_STAT_*
50 | bool cpuReset(struct Cpu *cpu);
51 | bool cpuGo(struct Cpu *cpu);
52 | uint8_t cpuStep(struct Cpu *cpu); // ->CPU_STAT_*
53 | uint8_t cpuIsStoppedAndWhy(struct Cpu *cpu); // ->CPU_STAT_*
54 |
55 | uint8_t cpuResetStop(struct Cpu *cpu); // ->CPU_STAT_*
56 |
57 | //pass-though getter for "is slow debugger?"
58 | bool cpuIsDebuggerHwSlow(const struct Cpu *cpu);
59 |
60 | //special-purpose convenience funcs
61 | bool cpuSetWatchpoint(struct Cpu* cpu, uint32_t idx, uint32_t addr, uint32_t size, uint32_t type); //type is CPU_WPT_TYPE_*
62 | bool cpuSetCpsrTbitAndDisableInterrupts(struct Cpu *cpu); //optionally return control regs we read (can pass NULL if uninterested)
63 |
64 | //higher level
65 | int32_t cpuTraceLogRead(struct Cpu* cpu, uint32_t addr, void **bufP); //caller must free buf that this func allocates and returns in *bufP. length of buf is returned
66 |
67 | //info
68 | bool cpuHasFpu(const struct Cpu* cpu);
69 | bool cpuIsV7(const struct Cpu* cpu);
70 |
71 | //core switching (only ID 0 is supported in case of no debugger multicore support
72 | bool cpuSelectCore(struct Cpu* cpu, uint16_t coreId);
73 |
74 |
75 | #endif
76 |
--------------------------------------------------------------------------------
/tool/debugger.h:
--------------------------------------------------------------------------------
1 | #ifndef _DEBUGGER_H_
2 | #define _DEBUGGER_H_
3 |
4 | #define _LARGE_PACKETS_
5 | #include "types.h"
6 | #include "../swdCommsPacket.h"
7 |
8 | #define PACKET_RX_FAIL 0xFFFFFFFFUL
9 |
10 | struct Debugger;
11 |
12 | #define DEBUGGER_SNUM_GUARANTEED_ILLEGAL ((void*)1) //guaranteed to never succeed being opened as a valid debugger
13 |
14 | struct Debugger *debuggerOpen(const char *snum, bool verbose); //snum can be null
15 | void debuggerClose(struct Debugger *dbg);
16 |
17 | bool debuggerInit(struct Debugger *dbg, bool verbose); //basically reads debugger version and verifies we can talk to it
18 |
19 | //very raw access to the debugger - only of use for fwupdate; return num bytes of payload or PACKET_RX_FAIL
20 | uint32_t debuggerDoOneDevCmd(struct Debugger *dbg, const struct CommsPacket *pktTx, uint32_t txPayloadLen, struct CommsPacket *pktRx);
21 |
22 | uint32_t debuggerGetMaxXferSz(struct Debugger *dbg); //gets max payload sz for THIS debugger
23 |
24 | bool debuggerCanSupportOnOffPowerCtl(const struct Debugger *dbg); //see if old-style power contorl is supported. only useful after debuggerOpen() ha sbeen called
25 | bool debuggerCanSupportVariablePowerCtl(const struct Debugger *dbg); //see if new-style power contorl is supported. only useful after debuggerOpen() ha sbeen called
26 | bool debuggerCanSupportVariableClockSpeed(const struct Debugger *dbg); //see if clock speed contorl is possible in this debugger
27 | bool debuggerIsSlowHw(const struct Debugger *dbg); //see if this hardware is slow enough to warrant longer timeouts
28 | bool debuggerHasResetPin(const struct Debugger *dbg); //see if debugger has a dedicated reset pin
29 | bool debuggerCanSupportUploadableCode(const struct Debugger *dbg); //see if debugger can support uploadable code
30 |
31 | bool debuggerPowerCtlSimple(struct Debugger *dbg, bool on);
32 | bool debuggerPowerCtlVariable(struct Debugger *dbg, uint32_t mv);
33 | bool debuggerClockCtlSet(struct Debugger *dbg, uint32_t requestedClock, uint32_t *suppliedclockP);
34 |
35 | bool debuggerResetPinCtl(struct Debugger *dbg, bool high);
36 | bool debuggerUploadableCodeInit(struct Debugger *dbg);
37 | bool debuggerUploadableCodeRun(struct Debugger *dbg, uint32_t *regsInOutP);
38 | bool debuggerUploadableCodeSendOpcode(struct Debugger *dbg, uint8_t opcode, uint32_t param1, uint32_t param2, uint32_t param3, uint32_t *returnValP); //ctlCode is SWD_UPLOAD_CTL_CODE_*, others are params as seen in swdCommsPacket.h in order they are seen always
39 |
40 | //both of these will retry a few times before giving up
41 | bool debuggerRawSwdBusRead(struct Debugger *dbg, uint8_t ap, uint8_t a23, uint32_t *valP);
42 | bool debuggerRawSwdBusWrite(struct Debugger *dbg, uint8_t ap, uint8_t a23, uint32_t val);
43 |
44 | #endif
--------------------------------------------------------------------------------
/tool/hidapi/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 |
3 | *.sln text eol=crlf
4 | *.vcproj text eol=crlf
5 |
6 | bootstrap text eol=lf
7 | configure.ac text eol=lf
8 |
--------------------------------------------------------------------------------
/tool/hidapi/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Autotools-added generated files
3 | Makefile.in
4 | aclocal.m4
5 | autom4te.cache/
6 | config.*
7 | configure
8 | depcomp
9 | install-sh
10 | libusb/Makefile.in
11 | linux/Makefile.in
12 | ltmain.sh
13 | mac/Makefile.in
14 | missing
15 | testgui/Makefile.in
16 | windows/Makefile.in
17 |
18 | Makefile
19 | stamp-h1
20 | libtool
21 |
--------------------------------------------------------------------------------
/tool/hidapi/AUTHORS.txt:
--------------------------------------------------------------------------------
1 |
2 | HIDAPI Authors:
3 |
4 | Alan Ott :
5 | Original Author and Maintainer
6 | Linux, Windows, and Mac implementations
7 |
8 | Ludovic Rousseau :
9 | Formatting for Doxygen documentation
10 | Bug fixes
11 | Correctness fixes
12 |
13 |
14 | For a comprehensive list of contributions, see the commit list at github:
15 | http://github.com/signal11/hidapi/commits/master
16 |
17 |
--------------------------------------------------------------------------------
/tool/hidapi/HACKING.txt:
--------------------------------------------------------------------------------
1 | This file is mostly for the maintainer.
2 |
3 | 1. Build hidapi.dll
4 | 2. Build hidtest.exe in DEBUG and RELEASE
5 | 3. Commit all
6 |
7 | 4. Run the Following
8 | export VERSION=0.1.0
9 | export TAG_NAME=hidapi-$VERSION
10 | git tag $TAG_NAME
11 | git archive --format zip --prefix $TAG_NAME/ $TAG_NAME >../$TAG_NAME.zip
12 | 5. Test the zip file.
13 | 6. Run the following:
14 | git push origin $TAG_NAME
15 |
16 |
--------------------------------------------------------------------------------
/tool/hidapi/LICENSE-bsd.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2010, Alan Ott, Signal 11 Software
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright notice,
8 | this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in the
11 | documentation and/or other materials provided with the distribution.
12 | * Neither the name of Signal 11 Software nor the names of its
13 | contributors may be used to endorse or promote products derived from
14 | this software without specific prior written permission.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 | POSSIBILITY OF SUCH DAMAGE.
27 |
--------------------------------------------------------------------------------
/tool/hidapi/LICENSE-orig.txt:
--------------------------------------------------------------------------------
1 | HIDAPI - Multi-Platform library for
2 | communication with HID devices.
3 |
4 | Copyright 2009, Alan Ott, Signal 11 Software.
5 | All Rights Reserved.
6 |
7 | This software may be used by anyone for any reason so
8 | long as the copyright notice in the source files
9 | remains intact.
10 |
--------------------------------------------------------------------------------
/tool/hidapi/LICENSE.txt:
--------------------------------------------------------------------------------
1 | HIDAPI can be used under one of three licenses.
2 |
3 | 1. The GNU General Public License, version 3.0, in LICENSE-gpl3.txt
4 | 2. A BSD-Style License, in LICENSE-bsd.txt.
5 | 3. The more liberal original HIDAPI license. LICENSE-orig.txt
6 |
7 | The license chosen is at the discretion of the user of HIDAPI. For example:
8 | 1. An author of GPL software would likely use HIDAPI under the terms of the
9 | GPL.
10 |
11 | 2. An author of commercial closed-source software would likely use HIDAPI
12 | under the terms of the BSD-style license or the original HIDAPI license.
13 |
14 |
--------------------------------------------------------------------------------
/tool/hidapi/Makefile.am:
--------------------------------------------------------------------------------
1 |
2 | ACLOCAL_AMFLAGS = -I m4
3 |
4 | if OS_FREEBSD
5 | pkgconfigdir=$(prefix)/libdata/pkgconfig
6 | else
7 | pkgconfigdir=$(libdir)/pkgconfig
8 | endif
9 |
10 | if OS_LINUX
11 | pkgconfig_DATA=pc/hidapi-hidraw.pc pc/hidapi-libusb.pc
12 | else
13 | pkgconfig_DATA=pc/hidapi.pc
14 | endif
15 |
16 | SUBDIRS=
17 |
18 | if OS_LINUX
19 | SUBDIRS += linux libusb
20 | endif
21 |
22 | if OS_DARWIN
23 | SUBDIRS += mac
24 | endif
25 |
26 | if OS_FREEBSD
27 | SUBDIRS += libusb
28 | endif
29 |
30 | if OS_KFREEBSD
31 | SUBDIRS += libusb
32 | endif
33 |
34 | if OS_WINDOWS
35 | SUBDIRS += windows
36 | endif
37 |
38 | SUBDIRS += hidtest
39 |
40 | if BUILD_TESTGUI
41 | SUBDIRS += testgui
42 | endif
43 |
44 | EXTRA_DIST = udev doxygen
45 |
46 | dist_doc_DATA = \
47 | README.txt \
48 | AUTHORS.txt \
49 | LICENSE-bsd.txt \
50 | LICENSE-gpl3.txt \
51 | LICENSE-orig.txt \
52 | LICENSE.txt
53 |
54 | SCMCLEAN_TARGETS= \
55 | aclocal.m4 \
56 | config.guess \
57 | config.sub \
58 | configure \
59 | config.h.in \
60 | depcomp \
61 | install-sh \
62 | ltmain.sh \
63 | missing \
64 | mac/Makefile.in \
65 | testgui/Makefile.in \
66 | libusb/Makefile.in \
67 | Makefile.in \
68 | linux/Makefile.in \
69 | windows/Makefile.in \
70 | m4/libtool.m4 \
71 | m4/lt~obsolete.m4 \
72 | m4/ltoptions.m4 \
73 | m4/ltsugar.m4 \
74 | m4/ltversion.m4
75 |
76 | SCMCLEAN_DIR_TARGETS = \
77 | autom4te.cache
78 |
79 | scm-clean: distclean
80 | rm -f $(SCMCLEAN_TARGETS)
81 | rm -Rf $(SCMCLEAN_DIR_TARGETS)
82 |
--------------------------------------------------------------------------------
/tool/hidapi/android/jni/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH:= $(call my-dir)
2 |
3 | HIDAPI_ROOT_REL:= ../..
4 | HIDAPI_ROOT_ABS:= $(LOCAL_PATH)/../..
5 |
6 | include $(CLEAR_VARS)
7 |
8 | LOCAL_SRC_FILES := \
9 | $(HIDAPI_ROOT_REL)/libusb/hid.c
10 |
11 | LOCAL_C_INCLUDES += \
12 | $(HIDAPI_ROOT_ABS)/hidapi \
13 | $(HIDAPI_ROOT_ABS)/android
14 |
15 | LOCAL_SHARED_LIBRARIES := libusb1.0
16 |
17 | LOCAL_MODULE := libhidapi
18 |
19 | include $(BUILD_SHARED_LIBRARY)
20 |
--------------------------------------------------------------------------------
/tool/hidapi/bootstrap:
--------------------------------------------------------------------------------
1 | #!/bin/sh -x
2 | autoreconf --install --verbose --force
3 |
--------------------------------------------------------------------------------
/tool/hidapi/hidtest/.gitignore:
--------------------------------------------------------------------------------
1 | Debug
2 | Release
3 | *.exp
4 | *.ilk
5 | *.lib
6 | *.suo
7 | *.vcproj.*
8 | *.ncb
9 | *.suo
10 | *.dll
11 | *.pdb
12 | *.o
13 | .deps/
14 | .libs/
15 | hidtest-hidraw
16 | hidtest-libusb
17 | hidtest
18 |
--------------------------------------------------------------------------------
/tool/hidapi/hidtest/Makefile.am:
--------------------------------------------------------------------------------
1 | AM_CPPFLAGS = -I$(top_srcdir)/hidapi/
2 |
3 | ## Linux
4 | if OS_LINUX
5 | noinst_PROGRAMS = hidtest-libusb hidtest-hidraw
6 |
7 | hidtest_hidraw_SOURCES = hidtest.cpp
8 | hidtest_hidraw_LDADD = $(top_builddir)/linux/libhidapi-hidraw.la
9 |
10 | hidtest_libusb_SOURCES = hidtest.cpp
11 | hidtest_libusb_LDADD = $(top_builddir)/libusb/libhidapi-libusb.la
12 | else
13 |
14 | # Other OS's
15 | noinst_PROGRAMS = hidtest
16 |
17 | hidtest_SOURCES = hidtest.cpp
18 | hidtest_LDADD = $(top_builddir)/$(backend)/libhidapi.la
19 |
20 | endif
21 |
--------------------------------------------------------------------------------
/tool/hidapi/libusb/.gitignore:
--------------------------------------------------------------------------------
1 | *.o
2 | *.so
3 | *.la
4 | *.lo
5 | *.a
6 | .libs
7 | .deps
8 | hidtest-libusb
9 |
--------------------------------------------------------------------------------
/tool/hidapi/libusb/Makefile-manual:
--------------------------------------------------------------------------------
1 |
2 |
3 | OS=$(shell uname)
4 |
5 | ifeq ($(OS), Linux)
6 | FILE=Makefile.linux
7 | endif
8 |
9 | ifeq ($(OS), FreeBSD)
10 | FILE=Makefile.freebsd
11 | endif
12 |
13 | ifeq ($(FILE), )
14 | all:
15 | $(error Your platform ${OS} is not supported by hidapi/libusb at this time.)
16 | endif
17 |
18 | include $(FILE)
19 |
--------------------------------------------------------------------------------
/tool/hidapi/libusb/Makefile.am:
--------------------------------------------------------------------------------
1 | AM_CPPFLAGS = -I$(top_srcdir)/hidapi $(CFLAGS_LIBUSB)
2 |
3 | if OS_LINUX
4 | lib_LTLIBRARIES = libhidapi-libusb.la
5 | libhidapi_libusb_la_SOURCES = hid.c
6 | libhidapi_libusb_la_LDFLAGS = $(LTLDFLAGS) $(PTHREAD_CFLAGS)
7 | libhidapi_libusb_la_LIBADD = $(LIBS_LIBUSB)
8 | endif
9 |
10 | if OS_FREEBSD
11 | lib_LTLIBRARIES = libhidapi.la
12 | libhidapi_la_SOURCES = hid.c
13 | libhidapi_la_LDFLAGS = $(LTLDFLAGS)
14 | libhidapi_la_LIBADD = $(LIBS_LIBUSB)
15 | endif
16 |
17 | if OS_KFREEBSD
18 | lib_LTLIBRARIES = libhidapi.la
19 | libhidapi_la_SOURCES = hid.c
20 | libhidapi_la_LDFLAGS = $(LTLDFLAGS)
21 | libhidapi_la_LIBADD = $(LIBS_LIBUSB)
22 | endif
23 |
24 | hdrdir = $(includedir)/hidapi
25 | hdr_HEADERS = $(top_srcdir)/hidapi/hidapi.h
26 |
27 | EXTRA_DIST = Makefile-manual
28 |
--------------------------------------------------------------------------------
/tool/hidapi/libusb/Makefile.freebsd:
--------------------------------------------------------------------------------
1 | ###########################################
2 | # Simple Makefile for HIDAPI test program
3 | #
4 | # Alan Ott
5 | # Signal 11 Software
6 | # 2010-06-01
7 | ###########################################
8 |
9 | all: hidtest libs
10 |
11 | libs: libhidapi.so
12 |
13 | CC ?= cc
14 | CFLAGS ?= -Wall -g -fPIC
15 |
16 | CXX ?= c++
17 | CXXFLAGS ?= -Wall -g
18 |
19 | COBJS = hid.o
20 | CPPOBJS = ../hidtest/hidtest.o
21 | OBJS = $(COBJS) $(CPPOBJS)
22 | INCLUDES = -I../hidapi -I/usr/local/include
23 | LDFLAGS = -L/usr/local/lib
24 | LIBS = -lusb -liconv -pthread
25 |
26 |
27 | # Console Test Program
28 | hidtest: $(OBJS)
29 | $(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -o $@ $(LIBS)
30 |
31 | # Shared Libs
32 | libhidapi.so: $(COBJS)
33 | $(CC) $(LDFLAGS) -shared -Wl,-soname,$@.0 $^ -o $@ $(LIBS)
34 |
35 | # Objects
36 | $(COBJS): %.o: %.c
37 | $(CC) $(CFLAGS) -c $(INCLUDES) $< -o $@
38 |
39 | $(CPPOBJS): %.o: %.cpp
40 | $(CXX) $(CXXFLAGS) -c $(INCLUDES) $< -o $@
41 |
42 |
43 | clean:
44 | rm -f $(OBJS) hidtest libhidapi.so ../hidtest/hidtest.o
45 |
46 | .PHONY: clean libs
47 |
--------------------------------------------------------------------------------
/tool/hidapi/libusb/Makefile.linux:
--------------------------------------------------------------------------------
1 | ###########################################
2 | # Simple Makefile for HIDAPI test program
3 | #
4 | # Alan Ott
5 | # Signal 11 Software
6 | # 2010-06-01
7 | ###########################################
8 |
9 | all: hidtest-libusb libs
10 |
11 | libs: libhidapi-libusb.so
12 |
13 | CC ?= gcc
14 | CFLAGS ?= -Wall -g -fpic
15 |
16 | CXX ?= g++
17 | CXXFLAGS ?= -Wall -g -fpic
18 |
19 | LDFLAGS ?= -Wall -g
20 |
21 | COBJS_LIBUSB = hid.o
22 | COBJS = $(COBJS_LIBUSB)
23 | CPPOBJS = ../hidtest/hidtest.o
24 | OBJS = $(COBJS) $(CPPOBJS)
25 | LIBS_USB = `pkg-config libusb-1.0 --libs` -lrt -lpthread
26 | LIBS = $(LIBS_USB)
27 | INCLUDES ?= -I../hidapi `pkg-config libusb-1.0 --cflags`
28 |
29 |
30 | # Console Test Program
31 | hidtest-libusb: $(COBJS_LIBUSB) $(CPPOBJS)
32 | $(CXX) $(LDFLAGS) $^ $(LIBS_USB) -o $@
33 |
34 | # Shared Libs
35 | libhidapi-libusb.so: $(COBJS_LIBUSB)
36 | $(CC) $(LDFLAGS) $(LIBS_USB) -shared -fpic -Wl,-soname,$@.0 $^ -o $@
37 |
38 | # Objects
39 | $(COBJS): %.o: %.c
40 | $(CC) $(CFLAGS) -c $(INCLUDES) $< -o $@
41 |
42 | $(CPPOBJS): %.o: %.cpp
43 | $(CXX) $(CXXFLAGS) -c $(INCLUDES) $< -o $@
44 |
45 |
46 | clean:
47 | rm -f $(OBJS) hidtest-libusb libhidapi-libusb.so ../hidtest/hidtest.o
48 |
49 | .PHONY: clean libs
50 |
--------------------------------------------------------------------------------
/tool/hidapi/linux/.gitignore:
--------------------------------------------------------------------------------
1 | Debug
2 | Release
3 | *.exp
4 | *.ilk
5 | *.lib
6 | *.suo
7 | *.vcproj.*
8 | *.ncb
9 | *.suo
10 | *.dll
11 | *.pdb
12 | *.o
13 | *.so
14 | hidtest-hidraw
15 | .deps
16 | .libs
17 | *.lo
18 | *.la
19 |
--------------------------------------------------------------------------------
/tool/hidapi/linux/Makefile-manual:
--------------------------------------------------------------------------------
1 | ###########################################
2 | # Simple Makefile for HIDAPI test program
3 | #
4 | # Alan Ott
5 | # Signal 11 Software
6 | # 2010-06-01
7 | ###########################################
8 |
9 | all: hidtest-hidraw libs
10 |
11 | libs: libhidapi-hidraw.so
12 |
13 | CC ?= gcc
14 | CFLAGS ?= -Wall -g -fpic
15 |
16 | CXX ?= g++
17 | CXXFLAGS ?= -Wall -g -fpic
18 |
19 | LDFLAGS ?= -Wall -g
20 |
21 |
22 | COBJS = hid.o
23 | CPPOBJS = ../hidtest/hidtest.o
24 | OBJS = $(COBJS) $(CPPOBJS)
25 | LIBS_UDEV = `pkg-config libudev --libs` -lrt
26 | LIBS = $(LIBS_UDEV)
27 | INCLUDES ?= -I../hidapi `pkg-config libusb-1.0 --cflags`
28 |
29 |
30 | # Console Test Program
31 | hidtest-hidraw: $(COBJS) $(CPPOBJS)
32 | $(CXX) $(LDFLAGS) $^ $(LIBS_UDEV) -o $@
33 |
34 | # Shared Libs
35 | libhidapi-hidraw.so: $(COBJS)
36 | $(CC) $(LDFLAGS) $(LIBS_UDEV) -shared -fpic -Wl,-soname,$@.0 $^ -o $@
37 |
38 | # Objects
39 | $(COBJS): %.o: %.c
40 | $(CC) $(CFLAGS) -c $(INCLUDES) $< -o $@
41 |
42 | $(CPPOBJS): %.o: %.cpp
43 | $(CXX) $(CXXFLAGS) -c $(INCLUDES) $< -o $@
44 |
45 |
46 | clean:
47 | rm -f $(OBJS) hidtest-hidraw libhidapi-hidraw.so ../hidtest/hidtest.o
48 |
49 | .PHONY: clean libs
50 |
--------------------------------------------------------------------------------
/tool/hidapi/linux/Makefile.am:
--------------------------------------------------------------------------------
1 | lib_LTLIBRARIES = libhidapi-hidraw.la
2 | libhidapi_hidraw_la_SOURCES = hid.c
3 | libhidapi_hidraw_la_LDFLAGS = $(LTLDFLAGS)
4 | AM_CPPFLAGS = -I$(top_srcdir)/hidapi/ $(CFLAGS_HIDRAW)
5 | libhidapi_hidraw_la_LIBADD = $(LIBS_HIDRAW)
6 |
7 | hdrdir = $(includedir)/hidapi
8 | hdr_HEADERS = $(top_srcdir)/hidapi/hidapi.h
9 |
10 | EXTRA_DIST = Makefile-manual
11 |
--------------------------------------------------------------------------------
/tool/hidapi/linux/README.txt:
--------------------------------------------------------------------------------
1 |
2 | There are two implementations of HIDAPI for Linux. One (hid.c) uses the
3 | Linux hidraw driver, and the other (hid-libusb.c) uses libusb. Which one you
4 | use depends on your application. Complete functionality of the hidraw
5 | version depends on patches to the Linux kernel which are not currently in
6 | the mainline. These patches have to do with sending and receiving feature
7 | reports. The libusb implementation uses libusb to talk directly to the
8 | device, bypassing any Linux HID driver. The disadvantage of the libusb
9 | version is that it will only work with USB devices, while the hidraw
10 | implementation will work with Bluetooth devices as well.
11 |
12 | To use HIDAPI, simply drop either hid.c or hid-libusb.c into your
13 | application and build using the build parameters in the Makefile.
14 |
15 | By default, on Linux, the Makefile in this directory is configured to use
16 | the libusb implementation. To switch to the hidraw implementation, simply
17 | change hid-libusb.c to hid.c in the Makefile.
18 |
19 |
20 | Libusb Implementation notes
21 | ----------------------------
22 | For the libusb implementation, libusb-1.0 must be installed. Libusb 1.0 is
23 | different than the legacy libusb 0.1 which is installed on many systems. To
24 | install libusb-1.0 on Ubuntu and other Debian-based systems, run:
25 | sudo apt-get install libusb-1.0-0-dev
26 |
27 |
28 | Hidraw Implementation notes
29 | ----------------------------
30 | For the hidraw implementation, libudev headers and libraries are required to
31 | build hidapi programs. To install libudev libraries on Ubuntu,
32 | and other Debian-based systems, run:
33 | sudo apt-get install libudev-dev
34 |
35 | On Redhat-based systems, run the following as root:
36 | yum install libudev-devel
37 |
38 | Unfortunately, the hidraw driver, which the linux version of hidapi is based
39 | on, contains bugs in kernel versions < 2.6.36, which the client application
40 | should be aware of.
41 |
42 | Bugs (hidraw implementation only):
43 | -----------------------------------
44 | On Kernel versions < 2.6.34, if your device uses numbered reports, an extra
45 | byte will be returned at the beginning of all reports returned from read()
46 | for hidraw devices. This is worked around in the libary. No action should be
47 | necessary in the client library.
48 |
49 | On Kernel versions < 2.6.35, reports will only be sent using a Set_Report
50 | transfer on the CONTROL endpoint. No data will ever be sent on an Interrupt
51 | Out endpoint if one exists. This is fixed in 2.6.35. In 2.6.35, OUTPUT
52 | reports will be sent to the device on the first INTERRUPT OUT endpoint if it
53 | exists; If it does not exist, OUTPUT reports will be sent on the CONTROL
54 | endpoint.
55 |
56 | On Kernel versions < 2.6.36, add an extra byte containing the report number
57 | to sent reports if numbered reports are used, and the device does not
58 | contain an INTERRPUT OUT endpoint for OUTPUT transfers. For example, if
59 | your device uses numbered reports and wants to send {0x2 0xff 0xff 0xff} to
60 | the device (0x2 is the report number), you must send {0x2 0x2 0xff 0xff
61 | 0xff}. If your device has the optional Interrupt OUT endpoint, this does not
62 | apply (but really on 2.6.35 only, because 2.6.34 won't use the interrupt
63 | out endpoint).
64 |
--------------------------------------------------------------------------------
/tool/hidapi/m4/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore All, except pkg.m4, and of course this file.
2 | *
3 | !.gitignore
4 | !pkg.m4
5 | !ax_pthread.m4
6 |
--------------------------------------------------------------------------------
/tool/hidapi/mac/.gitignore:
--------------------------------------------------------------------------------
1 | Debug
2 | Release
3 | *.exp
4 | *.ilk
5 | *.lib
6 | *.suo
7 | *.vcproj.*
8 | *.ncb
9 | *.suo
10 | *.dll
11 | *.pdb
12 | *.o
13 | hidapi-hidtest
14 | .deps
15 | .libs
16 | *.la
17 | *.lo
18 |
--------------------------------------------------------------------------------
/tool/hidapi/mac/Makefile-manual:
--------------------------------------------------------------------------------
1 | ###########################################
2 | # Simple Makefile for HIDAPI test program
3 | #
4 | # Alan Ott
5 | # Signal 11 Software
6 | # 2010-07-03
7 | ###########################################
8 |
9 | all: hidtest
10 |
11 | CC=gcc
12 | CXX=g++
13 | COBJS=hid.o
14 | CPPOBJS=../hidtest/hidtest.o
15 | OBJS=$(COBJS) $(CPPOBJS)
16 | CFLAGS+=-I../hidapi -Wall -g -c
17 | LIBS=-framework IOKit -framework CoreFoundation
18 |
19 |
20 | hidtest: $(OBJS)
21 | g++ -Wall -g $^ $(LIBS) -o hidtest
22 |
23 | $(COBJS): %.o: %.c
24 | $(CC) $(CFLAGS) $< -o $@
25 |
26 | $(CPPOBJS): %.o: %.cpp
27 | $(CXX) $(CFLAGS) $< -o $@
28 |
29 | clean:
30 | rm -f *.o hidtest $(CPPOBJS)
31 |
32 | .PHONY: clean
33 |
--------------------------------------------------------------------------------
/tool/hidapi/mac/Makefile.am:
--------------------------------------------------------------------------------
1 | lib_LTLIBRARIES = libhidapi.la
2 | libhidapi_la_SOURCES = hid.c
3 | libhidapi_la_LDFLAGS = $(LTLDFLAGS)
4 | AM_CPPFLAGS = -I$(top_srcdir)/hidapi/
5 |
6 | hdrdir = $(includedir)/hidapi
7 | hdr_HEADERS = $(top_srcdir)/hidapi/hidapi.h
8 |
9 | EXTRA_DIST = Makefile-manual
10 |
--------------------------------------------------------------------------------
/tool/hidapi/pc/.gitignore:
--------------------------------------------------------------------------------
1 | *.pc
2 |
--------------------------------------------------------------------------------
/tool/hidapi/pc/hidapi-hidraw.pc.in:
--------------------------------------------------------------------------------
1 | prefix=@prefix@
2 | exec_prefix=@exec_prefix@
3 | libdir=@libdir@
4 | includedir=@includedir@
5 |
6 | Name: hidapi-hidraw
7 | Description: C Library for USB/Bluetooth HID device access from Linux, Mac OS X, FreeBSD, and Windows. This is the hidraw implementation.
8 | Version: @VERSION@
9 | Libs: -L${libdir} -lhidapi-hidraw
10 | Cflags: -I${includedir}/hidapi
11 |
--------------------------------------------------------------------------------
/tool/hidapi/pc/hidapi-libusb.pc.in:
--------------------------------------------------------------------------------
1 | prefix=@prefix@
2 | exec_prefix=@exec_prefix@
3 | libdir=@libdir@
4 | includedir=@includedir@
5 |
6 | Name: hidapi-libusb
7 | Description: C Library for USB HID device access from Linux, Mac OS X, FreeBSD, and Windows. This is the libusb implementation.
8 | Version: @VERSION@
9 | Libs: -L${libdir} -lhidapi-libusb
10 | Cflags: -I${includedir}/hidapi
11 |
--------------------------------------------------------------------------------
/tool/hidapi/pc/hidapi.pc.in:
--------------------------------------------------------------------------------
1 | prefix=@prefix@
2 | exec_prefix=@exec_prefix@
3 | libdir=@libdir@
4 | includedir=@includedir@
5 |
6 | Name: hidapi
7 | Description: C Library for USB/Bluetooth HID device access from Linux, Mac OS X, FreeBSD, and Windows.
8 | Version: @VERSION@
9 | Libs: -L${libdir} -lhidapi
10 | Cflags: -I${includedir}/hidapi
11 |
--------------------------------------------------------------------------------
/tool/hidapi/testgui/.gitignore:
--------------------------------------------------------------------------------
1 | Debug
2 | Release
3 | *.exp
4 | *.ilk
5 | *.lib
6 | *.suo
7 | *.vcproj.*
8 | *.ncb
9 | *.suo
10 | *.dll
11 | *.pdb
12 | *.o
13 | hidapi-testgui
14 | hidapi-hidraw-testgui
15 | hidapi-libusb-testgui
16 | .deps
17 | .libs
18 | *.la
19 | *.lo
20 | TestGUI.app
21 |
--------------------------------------------------------------------------------
/tool/hidapi/testgui/Makefile-manual:
--------------------------------------------------------------------------------
1 |
2 |
3 | OS=$(shell uname)
4 |
5 | ifeq ($(OS), Darwin)
6 | FILE=Makefile.mac
7 | endif
8 |
9 | ifneq (,$(findstring MINGW,$(OS)))
10 | FILE=Makefile.mingw
11 | endif
12 |
13 | ifeq ($(OS), Linux)
14 | FILE=Makefile.linux
15 | endif
16 |
17 | ifeq ($(OS), FreeBSD)
18 | FILE=Makefile.freebsd
19 | endif
20 |
21 | ifeq ($(FILE), )
22 | all:
23 | $(error Your platform ${OS} is not supported at this time.)
24 | endif
25 |
26 | include $(FILE)
27 |
--------------------------------------------------------------------------------
/tool/hidapi/testgui/Makefile.am:
--------------------------------------------------------------------------------
1 |
2 | AM_CPPFLAGS = -I$(top_srcdir)/hidapi/ $(CFLAGS_TESTGUI)
3 |
4 | if OS_LINUX
5 | ## Linux
6 | bin_PROGRAMS = hidapi-hidraw-testgui hidapi-libusb-testgui
7 |
8 | hidapi_hidraw_testgui_SOURCES = test.cpp
9 | hidapi_hidraw_testgui_LDADD = $(top_builddir)/linux/libhidapi-hidraw.la $(LIBS_TESTGUI)
10 |
11 | hidapi_libusb_testgui_SOURCES = test.cpp
12 | hidapi_libusb_testgui_LDADD = $(top_builddir)/libusb/libhidapi-libusb.la $(LIBS_TESTGUI)
13 | else
14 | ## Other OS's
15 | bin_PROGRAMS = hidapi-testgui
16 |
17 | hidapi_testgui_SOURCES = test.cpp
18 | hidapi_testgui_LDADD = $(top_builddir)/$(backend)/libhidapi.la $(LIBS_TESTGUI)
19 | endif
20 |
21 | if OS_DARWIN
22 | hidapi_testgui_SOURCES = test.cpp mac_support_cocoa.m mac_support.h
23 | # Rules for copying the binary and its dependencies into the app bundle.
24 | TestGUI.app/Contents/MacOS/hidapi-testgui$(EXEEXT): hidapi-testgui$(EXEEXT)
25 | $(srcdir)/copy_to_bundle.sh
26 |
27 | all: all-am TestGUI.app/Contents/MacOS/hidapi-testgui$(EXEEXT)
28 |
29 | endif
30 |
31 | EXTRA_DIST = \
32 | copy_to_bundle.sh \
33 | Makefile-manual \
34 | Makefile.freebsd \
35 | Makefile.linux \
36 | Makefile.mac \
37 | Makefile.mingw \
38 | TestGUI.app.in \
39 | testgui.sln \
40 | testgui.vcproj
41 |
42 | distclean-local:
43 | rm -rf TestGUI.app
44 |
--------------------------------------------------------------------------------
/tool/hidapi/testgui/Makefile.freebsd:
--------------------------------------------------------------------------------
1 | ###########################################
2 | # Simple Makefile for HIDAPI test program
3 | #
4 | # Alan Ott
5 | # Signal 11 Software
6 | # 2010-06-01
7 | ###########################################
8 |
9 | all: testgui
10 |
11 | CC=cc
12 | CXX=c++
13 | COBJS=../libusb/hid.o
14 | CPPOBJS=test.o
15 | OBJS=$(COBJS) $(CPPOBJS)
16 | CFLAGS=-I../hidapi -I/usr/local/include `fox-config --cflags` -Wall -g -c
17 | LDFLAGS= -L/usr/local/lib
18 | LIBS= -lusb -liconv `fox-config --libs` -pthread
19 |
20 |
21 | testgui: $(OBJS)
22 | $(CXX) -Wall -g $^ $(LDFLAGS) -o $@ $(LIBS)
23 |
24 | $(COBJS): %.o: %.c
25 | $(CC) $(CFLAGS) $< -o $@
26 |
27 | $(CPPOBJS): %.o: %.cpp
28 | $(CXX) $(CFLAGS) $< -o $@
29 |
30 | clean:
31 | rm *.o testgui
32 |
33 | .PHONY: clean
34 |
--------------------------------------------------------------------------------
/tool/hidapi/testgui/Makefile.linux:
--------------------------------------------------------------------------------
1 | ###########################################
2 | # Simple Makefile for HIDAPI test program
3 | #
4 | # Alan Ott
5 | # Signal 11 Software
6 | # 2010-06-01
7 | ###########################################
8 |
9 | all: testgui
10 |
11 | CC=gcc
12 | CXX=g++
13 | COBJS=../libusb/hid.o
14 | CPPOBJS=test.o
15 | OBJS=$(COBJS) $(CPPOBJS)
16 | CFLAGS=-I../hidapi -Wall -g -c `fox-config --cflags` `pkg-config libusb-1.0 --cflags`
17 | LIBS=-ludev -lrt -lpthread `fox-config --libs` `pkg-config libusb-1.0 --libs`
18 |
19 |
20 | testgui: $(OBJS)
21 | g++ -Wall -g $^ $(LIBS) -o testgui
22 |
23 | $(COBJS): %.o: %.c
24 | $(CC) $(CFLAGS) $< -o $@
25 |
26 | $(CPPOBJS): %.o: %.cpp
27 | $(CXX) $(CFLAGS) $< -o $@
28 |
29 | clean:
30 | rm *.o testgui
31 |
32 | .PHONY: clean
33 |
--------------------------------------------------------------------------------
/tool/hidapi/testgui/Makefile.mac:
--------------------------------------------------------------------------------
1 | ###########################################
2 | # Simple Makefile for HIDAPI test program
3 | #
4 | # Alan Ott
5 | # Signal 11 Software
6 | # 2010-07-03
7 | ###########################################
8 |
9 | all: hidapi-testgui
10 |
11 | CC=gcc
12 | CXX=g++
13 | COBJS=../mac/hid.o
14 | CPPOBJS=test.o
15 | OBJCOBJS=mac_support_cocoa.o
16 | OBJS=$(COBJS) $(CPPOBJS) $(OBJCOBJS)
17 | CFLAGS=-I../hidapi -Wall -g -c `fox-config --cflags`
18 | LDFLAGS=-L/usr/X11R6/lib
19 | LIBS=`fox-config --libs` -framework IOKit -framework CoreFoundation -framework Cocoa
20 |
21 |
22 | hidapi-testgui: $(OBJS) TestGUI.app
23 | g++ -Wall -g $(OBJS) $(LIBS) $(LDFLAGS) -o hidapi-testgui
24 | ./copy_to_bundle.sh
25 | #cp TestGUI.app/Contents/MacOS/hidapi-testgui TestGUI.app/Contents/MacOS/tg
26 | #cp start.sh TestGUI.app/Contents/MacOS/hidapi-testgui
27 |
28 | $(COBJS): %.o: %.c
29 | $(CC) $(CFLAGS) $< -o $@
30 |
31 | $(CPPOBJS): %.o: %.cpp
32 | $(CXX) $(CFLAGS) $< -o $@
33 |
34 | $(OBJCOBJS): %.o: %.m
35 | $(CXX) $(CFLAGS) -x objective-c++ $< -o $@
36 |
37 | TestGUI.app: TestGUI.app.in
38 | rm -Rf TestGUI.app
39 | mkdir -p TestGUI.app
40 | cp -R TestGUI.app.in/ TestGUI.app
41 |
42 | clean:
43 | rm -f $(OBJS) hidapi-testgui
44 | rm -Rf TestGUI.app
45 |
46 | .PHONY: clean
47 |
--------------------------------------------------------------------------------
/tool/hidapi/testgui/Makefile.mingw:
--------------------------------------------------------------------------------
1 | ###########################################
2 | # Simple Makefile for HIDAPI test program
3 | #
4 | # Alan Ott
5 | # Signal 11 Software
6 | # 2010-06-01
7 | ###########################################
8 |
9 | all: hidapi-testgui
10 |
11 | CC=gcc
12 | CXX=g++
13 | COBJS=../windows/hid.o
14 | CPPOBJS=test.o
15 | OBJS=$(COBJS) $(CPPOBJS)
16 | CFLAGS=-I../hidapi -I../../hidapi-externals/fox/include -g -c
17 | LIBS= -mwindows -lsetupapi -L../../hidapi-externals/fox/lib -Wl,-Bstatic -lFOX-1.6 -Wl,-Bdynamic -lgdi32 -Wl,--enable-auto-import -static-libgcc -static-libstdc++ -lkernel32
18 |
19 |
20 | hidapi-testgui: $(OBJS)
21 | g++ -g $^ $(LIBS) -o hidapi-testgui
22 |
23 | $(COBJS): %.o: %.c
24 | $(CC) $(CFLAGS) $< -o $@
25 |
26 | $(CPPOBJS): %.o: %.cpp
27 | $(CXX) $(CFLAGS) $< -o $@
28 |
29 | clean:
30 | rm -f *.o hidapi-testgui.exe
31 |
32 | .PHONY: clean
33 |
--------------------------------------------------------------------------------
/tool/hidapi/testgui/TestGUI.app.in/Contents/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleDisplayName
8 |
9 | CFBundleExecutable
10 | hidapi-testgui
11 | CFBundleIconFile
12 | Signal11.icns
13 | CFBundleIdentifier
14 | us.signal11.hidtestgui
15 | CFBundleInfoDictionaryVersion
16 | 6.0
17 | CFBundleName
18 | testgui
19 | CFBundlePackageType
20 | APPL
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | CSResourcesFileMapped
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/tool/hidapi/testgui/TestGUI.app.in/Contents/PkgInfo:
--------------------------------------------------------------------------------
1 | APPL????
--------------------------------------------------------------------------------
/tool/hidapi/testgui/TestGUI.app.in/Contents/Resources/English.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cortexprog/cortexprogfw/dbfc46a8dfdadb990bfa95388fb3729a3b63d752/tool/hidapi/testgui/TestGUI.app.in/Contents/Resources/English.lproj/InfoPlist.strings
--------------------------------------------------------------------------------
/tool/hidapi/testgui/TestGUI.app.in/Contents/Resources/Signal11.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cortexprog/cortexprogfw/dbfc46a8dfdadb990bfa95388fb3729a3b63d752/tool/hidapi/testgui/TestGUI.app.in/Contents/Resources/Signal11.icns
--------------------------------------------------------------------------------
/tool/hidapi/testgui/copy_to_bundle.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #### Configuration:
4 | # The name of the executable. It is assumed
5 | # that it is in the current working directory.
6 | EXE_NAME=hidapi-testgui
7 | # Path to the executable directory inside the bundle.
8 | # This must be an absolute path, so use $PWD.
9 | EXEPATH=$PWD/TestGUI.app/Contents/MacOS
10 | # Libraries to explicitly bundle, even though they
11 | # may not be in /opt/local. One per line. These
12 | # are used with grep, so only a portion of the name
13 | # is required. eg: libFOX, libz, etc.
14 | LIBS_TO_BUNDLE=libFOX
15 |
16 |
17 | function copydeps {
18 | local file=$1
19 | # echo "Copying deps for $file...."
20 | local BASE_OF_EXE=`basename $file`
21 |
22 | # A will contain the dependencies of this library
23 | local A=`otool -LX $file |cut -f 1 -d " "`
24 | local i
25 | for i in $A; do
26 | local BASE=`basename $i`
27 |
28 | # See if it's a lib we specifically want to bundle
29 | local bundle_this_lib=0
30 | local j
31 | for j in $LIBS_TO_BUNDLE; do
32 | echo $i |grep -q $j
33 | if [ $? -eq 0 ]; then
34 | bundle_this_lib=1
35 | echo "bundling $i because it's in the list."
36 | break;
37 | fi
38 | done
39 |
40 | # See if it's in /opt/local. Bundle all in /opt/local
41 | local isOptLocal=0
42 | echo $i |grep -q /opt/local
43 | if [ $? -eq 0 ]; then
44 | isOptLocal=1
45 | echo "bundling $i because it's in /opt/local."
46 | fi
47 |
48 | # Bundle the library
49 | if [ $isOptLocal -ne 0 ] || [ $bundle_this_lib -ne 0 ]; then
50 |
51 | # Copy the file into the bundle if it exists.
52 | if [ -f $EXEPATH/$BASE ]; then
53 | z=0
54 | else
55 | cp $i $EXEPATH
56 | chmod 755 $EXEPATH/$BASE
57 | fi
58 |
59 |
60 | # echo "$BASE_OF_EXE depends on $BASE"
61 |
62 | # Fix the paths using install_name_tool and then
63 | # call this function recursively for each dependency
64 | # of this library.
65 | if [ $BASE_OF_EXE != $BASE ]; then
66 |
67 | # Fix the paths
68 | install_name_tool -id @executable_path/$BASE $EXEPATH/$BASE
69 | install_name_tool -change $i @executable_path/$BASE $EXEPATH/$BASE_OF_EXE
70 |
71 | # Call this function (recursive) on
72 | # on each dependency of this library.
73 | copydeps $EXEPATH/$BASE
74 | fi
75 | fi
76 | done
77 | }
78 |
79 | rm -f $EXEPATH/*
80 |
81 | # Copy the binary into the bundle. Use ../libtool to do this if it's
82 | # available beacuse if $EXE_NAME was built with autotools, it will be
83 | # necessary. If ../libtool not available, just use cp to do the copy, but
84 | # only if $EXE_NAME is a binary.
85 | if [ -x ../libtool ]; then
86 | ../libtool --mode=install cp $EXE_NAME $EXEPATH
87 | else
88 | file -bI $EXE_NAME |grep binary
89 | if [ $? -ne 0 ]; then
90 | echo "There is no ../libtool and $EXE_NAME is not a binary."
91 | echo "I'm not sure what to do."
92 | exit 1
93 | else
94 | cp $EXE_NAME $EXEPATH
95 | fi
96 | fi
97 | copydeps $EXEPATH/$EXE_NAME
98 |
--------------------------------------------------------------------------------
/tool/hidapi/testgui/mac_support.h:
--------------------------------------------------------------------------------
1 | /*******************************
2 | Mac support for HID Test GUI
3 |
4 | Alan Ott
5 | Signal 11 Software
6 |
7 | *******************************/
8 |
9 | #ifndef MAC_SUPPORT_H__
10 | #define MAC_SUPPORT_H__
11 |
12 | extern "C" {
13 | void init_apple_message_system();
14 | void check_apple_events();
15 | }
16 |
17 | #endif
18 |
--------------------------------------------------------------------------------
/tool/hidapi/testgui/mac_support_cocoa.m:
--------------------------------------------------------------------------------
1 | /*******************************
2 | Mac support for HID Test GUI
3 |
4 | Alan Ott
5 | Signal 11 Software
6 | *******************************/
7 |
8 | #include
9 | #import
10 |
11 | extern FXMainWindow *g_main_window;
12 |
13 |
14 | @interface MyAppDelegate : NSObject
15 | {
16 | }
17 | @end
18 |
19 | @implementation MyAppDelegate
20 | - (void) applicationWillBecomeActive:(NSNotification*)notif
21 | {
22 | printf("WillBecomeActive\n");
23 | g_main_window->show();
24 |
25 | }
26 |
27 | - (void) applicationWillTerminate:(NSNotification*)notif
28 | {
29 | /* Doesn't get called. Not sure why */
30 | printf("WillTerminate\n");
31 | FXApp::instance()->exit();
32 | }
33 |
34 | - (NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication*)sender
35 | {
36 | /* Doesn't get called. Not sure why */
37 | printf("ShouldTerminate\n");
38 | return YES;
39 | }
40 |
41 | - (void) applicationWillHide:(NSNotification*)notif
42 | {
43 | printf("WillHide\n");
44 | g_main_window->hide();
45 | }
46 |
47 | - (void) handleQuitEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAppleEventDescriptor*)replyEvent
48 | {
49 | printf("QuitEvent\n");
50 | FXApp::instance()->exit();
51 | }
52 |
53 | @end
54 |
55 | extern "C" {
56 |
57 | void
58 | init_apple_message_system()
59 | {
60 | static MyAppDelegate *d = [MyAppDelegate new];
61 |
62 | [[NSApplication sharedApplication] setDelegate:d];
63 |
64 | /* Register for Apple Events. */
65 | /* This is from
66 | http://stackoverflow.com/questions/1768497/application-exit-event */
67 | NSAppleEventManager *aem = [NSAppleEventManager sharedAppleEventManager];
68 | [aem setEventHandler:d
69 | andSelector:@selector(handleQuitEvent:withReplyEvent:)
70 | forEventClass:kCoreEventClass andEventID:kAEQuitApplication];
71 | }
72 |
73 | void
74 | check_apple_events()
75 | {
76 | NSApplication *app = [NSApplication sharedApplication];
77 |
78 | NSAutoreleasePool *pool = [NSAutoreleasePool new];
79 | while (1) {
80 | NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
81 | untilDate:nil
82 | inMode:NSDefaultRunLoopMode
83 | dequeue:YES];
84 | if (event == NULL)
85 | break;
86 | else {
87 | //printf("Event happened: Type: %d\n", event->_type);
88 | [app sendEvent: event];
89 | }
90 | }
91 | [pool release];
92 | }
93 |
94 | } /* extern "C" */
95 |
--------------------------------------------------------------------------------
/tool/hidapi/testgui/start.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | xterm -e /Users/alan/work/hidapi/testgui/TestGUI.app/Contents/MacOS/tg
3 |
--------------------------------------------------------------------------------
/tool/hidapi/udev/99-hid.rules:
--------------------------------------------------------------------------------
1 | # This is a sample udev file for HIDAPI devices which changes the permissions
2 | # to 0666 (world readable/writable) for a specified device on Linux systems.
3 |
4 |
5 | # If you are using the libusb implementation of hidapi (hid-libusb.c), then
6 | # use something like the following line, substituting the VID and PID with
7 | # those of your device. Note that for kernels before 2.6.24, you will need
8 | # to substitute "usb" with "usb_device". It shouldn't hurt to use two lines
9 | # (one each way) for compatibility with older systems.
10 |
11 | # HIDAPI/libusb
12 | SUBSYSTEM=="usb", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="003f", MODE="0666"
13 |
14 |
15 | # If you are using the hidraw implementation, then do something like the
16 | # following, substituting the VID and PID with your device. Busnum 1 is USB.
17 |
18 | # HIDAPI/hidraw
19 | KERNEL=="hidraw*", ATTRS{busnum}=="1", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="003f", MODE="0666"
20 |
21 | # Once done, optionally rename this file for your device, and drop it into
22 | # /etc/udev/rules.d and unplug and re-plug your device. This is all that is
23 | # necessary to see the new permissions. Udev does not have to be restarted.
24 |
25 | # Note that the hexadecimal values for VID and PID are case sensitive and
26 | # must be lower case.
27 |
28 | # If you think permissions of 0666 are too loose, then see:
29 | # http://reactivated.net/writing_udev_rules.html for more information on finer
30 | # grained permission setting. For example, it might be sufficient to just
31 | # set the group or user owner for specific devices (for example the plugdev
32 | # group on some systems).
33 |
--------------------------------------------------------------------------------
/tool/hidapi/windows/.gitignore:
--------------------------------------------------------------------------------
1 | Debug
2 | Release
3 | *.exp
4 | *.ilk
5 | *.lib
6 | *.suo
7 | *.vcproj.*
8 | *.ncb
9 | *.suo
10 | *.dll
11 | *.pdb
12 | .deps
13 | .libs
14 | *.lo
15 | *.la
16 |
--------------------------------------------------------------------------------
/tool/hidapi/windows/Makefile-manual:
--------------------------------------------------------------------------------
1 |
2 |
3 | OS=$(shell uname)
4 |
5 | ifneq (,$(findstring MINGW,$(OS)))
6 | FILE=Makefile.mingw
7 | endif
8 |
9 | ifeq ($(FILE), )
10 | all:
11 | $(error Your platform ${OS} is not supported at this time.)
12 | endif
13 |
14 | include $(FILE)
15 |
--------------------------------------------------------------------------------
/tool/hidapi/windows/Makefile.am:
--------------------------------------------------------------------------------
1 | lib_LTLIBRARIES = libhidapi.la
2 | libhidapi_la_SOURCES = hid.c
3 | libhidapi_la_LDFLAGS = $(LTLDFLAGS)
4 | AM_CPPFLAGS = -I$(top_srcdir)/hidapi/
5 | libhidapi_la_LIBADD = $(LIBS)
6 |
7 | hdrdir = $(includedir)/hidapi
8 | hdr_HEADERS = $(top_srcdir)/hidapi/hidapi.h
9 |
10 | EXTRA_DIST = \
11 | ddk_build \
12 | hidapi.vcproj \
13 | hidtest.vcproj \
14 | Makefile-manual \
15 | Makefile.mingw \
16 | hidapi.sln
17 |
--------------------------------------------------------------------------------
/tool/hidapi/windows/Makefile.mingw:
--------------------------------------------------------------------------------
1 | ###########################################
2 | # Simple Makefile for HIDAPI test program
3 | #
4 | # Alan Ott
5 | # Signal 11 Software
6 | # 2010-06-01
7 | ###########################################
8 |
9 | all: hidtest libhidapi.dll
10 |
11 | CC=gcc
12 | CXX=g++
13 | COBJS=hid.o
14 | CPPOBJS=../hidtest/hidtest.o
15 | OBJS=$(COBJS) $(CPPOBJS)
16 | CFLAGS=-I../hidapi -g -c
17 | LIBS= -lsetupapi
18 | DLL_LDFLAGS = -mwindows -lsetupapi
19 |
20 | hidtest: $(OBJS)
21 | g++ -g $^ $(LIBS) -o hidtest
22 |
23 | libhidapi.dll: $(OBJS)
24 | $(CC) -g $^ $(DLL_LDFLAGS) -o libhidapi.dll
25 |
26 | $(COBJS): %.o: %.c
27 | $(CC) $(CFLAGS) $< -o $@
28 |
29 | $(CPPOBJS): %.o: %.cpp
30 | $(CXX) $(CFLAGS) $< -o $@
31 |
32 | clean:
33 | rm *.o ../hidtest/*.o hidtest.exe
34 |
35 | .PHONY: clean
36 |
--------------------------------------------------------------------------------
/tool/hidapi/windows/ddk_build/.gitignore:
--------------------------------------------------------------------------------
1 | *.log
2 | obj*_*_*
--------------------------------------------------------------------------------
/tool/hidapi/windows/ddk_build/hidapi.def:
--------------------------------------------------------------------------------
1 | LIBRARY hidapi
2 | EXPORTS
3 | hid_open @1
4 | hid_write @2
5 | hid_read @3
6 | hid_close @4
7 | hid_get_product_string @5
8 | hid_get_manufacturer_string @6
9 | hid_get_serial_number_string @7
10 | hid_get_indexed_string @8
11 | hid_error @9
12 | hid_set_nonblocking @10
13 | hid_enumerate @11
14 | hid_open_path @12
15 | hid_send_feature_report @13
16 | hid_get_feature_report @14
17 |
--------------------------------------------------------------------------------
/tool/hidapi/windows/ddk_build/sources:
--------------------------------------------------------------------------------
1 | TARGETNAME=hidapi
2 | TARGETTYPE=DYNLINK
3 | UMTYPE=console
4 | UMENTRY=main
5 |
6 | MSC_WARNING_LEVEL=/W3 /WX
7 |
8 | TARGETLIBS=$(SDK_LIB_PATH)\hid.lib \
9 | $(SDK_LIB_PATH)\setupapi.lib \
10 | $(SDK_LIB_PATH)\kernel32.lib \
11 | $(SDK_LIB_PATH)\comdlg32.lib
12 |
13 | USE_MSVCRT=1
14 |
15 | INCLUDES= ..\..\hidapi
16 | SOURCES= ..\hid.c \
17 |
18 |
19 | TARGET_DESTINATION=retail
20 |
21 | MUI=0
22 | MUI_COMMENT="HID Interface DLL"
23 |
24 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/README:
--------------------------------------------------------------------------------
1 |
2 | This is Lua 5.3.4, released on 12 Jan 2017.
3 |
4 | For installation instructions, license details, and
5 | further information about Lua, see doc/readme.html.
6 |
7 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/doc/index.css:
--------------------------------------------------------------------------------
1 | ul {
2 | list-style-type: none ;
3 | }
4 |
5 | ul.contents {
6 | padding: 0 ;
7 | }
8 |
9 | table {
10 | border: none ;
11 | border-spacing: 0 ;
12 | border-collapse: collapse ;
13 | }
14 |
15 | td {
16 | vertical-align: top ;
17 | padding: 0 ;
18 | text-align: left ;
19 | line-height: 1.25 ;
20 | width: 15% ;
21 | }
22 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/doc/logo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cortexprog/cortexprogfw/dbfc46a8dfdadb990bfa95388fb3729a3b63d752/tool/lua-5.3.4/doc/logo.gif
--------------------------------------------------------------------------------
/tool/lua-5.3.4/doc/lua.1:
--------------------------------------------------------------------------------
1 | .\" $Id: lua.man,v 1.14 2016/10/17 15:43:50 lhf Exp $
2 | .TH LUA 1 "$Date: 2016/10/17 15:43:50 $"
3 | .SH NAME
4 | lua \- Lua interpreter
5 | .SH SYNOPSIS
6 | .B lua
7 | [
8 | .I options
9 | ]
10 | [
11 | .I script
12 | [
13 | .I args
14 | ]
15 | ]
16 | .SH DESCRIPTION
17 | .B lua
18 | is the standalone Lua interpreter.
19 | It loads and executes Lua programs,
20 | either in textual source form or
21 | in precompiled binary form.
22 | (Precompiled binaries are output by
23 | .BR luac ,
24 | the Lua compiler.)
25 | .B lua
26 | can be used as a batch interpreter and also interactively.
27 | .LP
28 | The given
29 | .I options
30 | are handled in order and then
31 | the Lua program in file
32 | .I script
33 | is loaded and executed.
34 | The given
35 | .I args
36 | are available to
37 | .I script
38 | as strings in a global table named
39 | .BR arg .
40 | If no options or arguments are given,
41 | then
42 | .B "\-v \-i"
43 | is assumed when the standard input is a terminal;
44 | otherwise,
45 | .B "\-"
46 | is assumed.
47 | .LP
48 | In interactive mode,
49 | .B lua
50 | prompts the user,
51 | reads lines from the standard input,
52 | and executes them as they are read.
53 | If the line contains an expression or list of expressions,
54 | then the line is evaluated and the results are printed.
55 | If a line does not contain a complete statement,
56 | then a secondary prompt is displayed and
57 | lines are read until a complete statement is formed or
58 | a syntax error is found.
59 | .LP
60 | At the very start,
61 | before even handling the command line,
62 | .B lua
63 | checks the contents of the environment variables
64 | .B LUA_INIT_5_3
65 | or
66 | .BR LUA_INIT ,
67 | in that order.
68 | If the contents is of the form
69 | .RI '@ filename ',
70 | then
71 | .I filename
72 | is executed.
73 | Otherwise, the string is assumed to be a Lua statement and is executed.
74 | .SH OPTIONS
75 | .TP
76 | .BI \-e " stat"
77 | execute statement
78 | .IR stat .
79 | .TP
80 | .B \-i
81 | enter interactive mode after executing
82 | .IR script .
83 | .TP
84 | .BI \-l " name"
85 | execute the equivalent of
86 | .IB name =require(' name ')
87 | before executing
88 | .IR script .
89 | .TP
90 | .B \-v
91 | show version information.
92 | .TP
93 | .B \-E
94 | ignore environment variables.
95 | .TP
96 | .B \-\-
97 | stop handling options.
98 | .TP
99 | .B \-
100 | stop handling options and execute the standard input as a file.
101 | .SH "SEE ALSO"
102 | .BR luac (1)
103 | .br
104 | The documentation at lua.org,
105 | especially section 7 of the reference manual.
106 | .SH DIAGNOSTICS
107 | Error messages should be self explanatory.
108 | .SH AUTHORS
109 | R. Ierusalimschy,
110 | L. H. de Figueiredo,
111 | W. Celes
112 | .\" EOF
113 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/doc/lua.css:
--------------------------------------------------------------------------------
1 | html {
2 | background-color: #F8F8F8 ;
3 | }
4 |
5 | body {
6 | background-color: #FFFFFF ;
7 | color: #000000 ;
8 | font-family: Helvetica, Arial, sans-serif ;
9 | text-align: justify ;
10 | line-height: 1.25 ;
11 | margin: 16px auto ;
12 | padding: 32px ;
13 | border: solid #a0a0a0 1px ;
14 | border-radius: 20px ;
15 | max-width: 70em ;
16 | width: 90% ;
17 | }
18 |
19 | h1, h2, h3, h4 {
20 | color: #000080 ;
21 | font-family: Verdana, Geneva, sans-serif ;
22 | font-weight: normal ;
23 | font-style: normal ;
24 | text-align: left ;
25 | }
26 |
27 | h1 {
28 | font-size: 28pt ;
29 | }
30 |
31 | h1 img {
32 | vertical-align: text-bottom ;
33 | }
34 |
35 | h2:before {
36 | content: "\2756" ;
37 | padding-right: 0.5em ;
38 | }
39 |
40 | a {
41 | text-decoration: none ;
42 | }
43 |
44 | a:link {
45 | color: #000080 ;
46 | }
47 |
48 | a:link:hover, a:visited:hover {
49 | background-color: #D0D0FF ;
50 | color: #000080 ;
51 | border-radius: 4px ;
52 | }
53 |
54 | a:link:active, a:visited:active {
55 | color: #FF0000 ;
56 | }
57 |
58 | div.menubar {
59 | padding-bottom: 0.5em ;
60 | }
61 |
62 | p.menubar {
63 | margin-left: 2.5em ;
64 | }
65 |
66 | .menubar a:hover {
67 | margin: -3px -3px -3px -3px ;
68 | padding: 3px 3px 3px 3px ;
69 | border-radius: 4px ;
70 | }
71 |
72 | :target {
73 | background-color: #F0F0F0 ;
74 | margin: -8px ;
75 | padding: 8px ;
76 | border-radius: 8px ;
77 | outline: none ;
78 | }
79 |
80 | hr {
81 | display: none ;
82 | }
83 |
84 | table hr {
85 | background-color: #a0a0a0 ;
86 | color: #a0a0a0 ;
87 | border: 0 ;
88 | height: 1px ;
89 | display: block ;
90 | }
91 |
92 | .footer {
93 | color: gray ;
94 | font-size: x-small ;
95 | text-transform: lowercase ;
96 | }
97 |
98 | input[type=text] {
99 | border: solid #a0a0a0 2px ;
100 | border-radius: 2em ;
101 | background-image: url('images/search.png') ;
102 | background-repeat: no-repeat ;
103 | background-position: 4px center ;
104 | padding-left: 20px ;
105 | height: 2em ;
106 | }
107 |
108 | pre.session {
109 | background-color: #F8F8F8 ;
110 | padding: 1em ;
111 | border-radius: 8px ;
112 | }
113 |
114 | td.gutter {
115 | width: 4% ;
116 | }
117 |
118 | table.columns {
119 | border: none ;
120 | border-spacing: 0 ;
121 | border-collapse: collapse ;
122 | }
123 |
124 | table.columns td {
125 | vertical-align: top ;
126 | padding: 0 ;
127 | padding-bottom: 1em ;
128 | text-align: justify ;
129 | line-height: 1.25 ;
130 | }
131 |
132 | p.logos a:link:hover, p.logos a:visited:hover {
133 | background-color: inherit ;
134 | }
135 |
136 | table.book {
137 | border: none ;
138 | border-spacing: 0 ;
139 | border-collapse: collapse ;
140 | }
141 |
142 | table.book td {
143 | padding: 0 ;
144 | vertical-align: top ;
145 | }
146 |
147 | table.book td.cover {
148 | padding-right: 1em ;
149 | }
150 |
151 | table.book img {
152 | border: solid #000080 1px ;
153 | }
154 |
155 | table.book span {
156 | font-size: small ;
157 | text-align: left ;
158 | display: block ;
159 | margin-top: 0.25em ;
160 | }
161 |
162 | img {
163 | background-color: white ;
164 | }
165 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/doc/manual.css:
--------------------------------------------------------------------------------
1 | h3 code {
2 | font-family: inherit ;
3 | font-size: inherit ;
4 | }
5 |
6 | pre, code {
7 | font-size: 12pt ;
8 | }
9 |
10 | span.apii {
11 | color: gray ;
12 | float: right ;
13 | font-family: inherit ;
14 | font-style: normal ;
15 | font-size: small ;
16 | }
17 |
18 | h2:before {
19 | content: "" ;
20 | padding-right: 0em ;
21 | }
22 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/doc/osi-certified-72x60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cortexprog/cortexprogfw/dbfc46a8dfdadb990bfa95388fb3729a3b63d752/tool/lua-5.3.4/doc/osi-certified-72x60.png
--------------------------------------------------------------------------------
/tool/lua-5.3.4/src/lapi.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lapi.h,v 2.9 2015/03/06 19:49:50 roberto Exp $
3 | ** Auxiliary functions from Lua API
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lapi_h
8 | #define lapi_h
9 |
10 |
11 | #include "llimits.h"
12 | #include "lstate.h"
13 |
14 | #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \
15 | "stack overflow");}
16 |
17 | #define adjustresults(L,nres) \
18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; }
19 |
20 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \
21 | "not enough elements in the stack")
22 |
23 |
24 | #endif
25 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/src/lctype.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lctype.c,v 1.12 2014/11/02 19:19:04 roberto Exp $
3 | ** 'ctype' functions for Lua
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #define lctype_c
8 | #define LUA_CORE
9 |
10 | #include "lprefix.h"
11 |
12 |
13 | #include "lctype.h"
14 |
15 | #if !LUA_USE_CTYPE /* { */
16 |
17 | #include
18 |
19 | LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = {
20 | 0x00, /* EOZ */
21 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */
22 | 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */
24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25 | 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */
26 | 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
27 | 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */
28 | 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
29 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */
30 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
31 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */
32 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05,
33 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */
34 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
35 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */
36 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00,
37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */
38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9. */
40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a. */
42 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b. */
44 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c. */
46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d. */
48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e. */
50 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */
52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53 | };
54 |
55 | #endif /* } */
56 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/src/lctype.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lctype.h,v 1.12 2011/07/15 12:50:29 roberto Exp $
3 | ** 'ctype' functions for Lua
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lctype_h
8 | #define lctype_h
9 |
10 | #include "lua.h"
11 |
12 |
13 | /*
14 | ** WARNING: the functions defined here do not necessarily correspond
15 | ** to the similar functions in the standard C ctype.h. They are
16 | ** optimized for the specific needs of Lua
17 | */
18 |
19 | #if !defined(LUA_USE_CTYPE)
20 |
21 | #if 'A' == 65 && '0' == 48
22 | /* ASCII case: can use its own tables; faster and fixed */
23 | #define LUA_USE_CTYPE 0
24 | #else
25 | /* must use standard C ctype */
26 | #define LUA_USE_CTYPE 1
27 | #endif
28 |
29 | #endif
30 |
31 |
32 | #if !LUA_USE_CTYPE /* { */
33 |
34 | #include
35 |
36 | #include "llimits.h"
37 |
38 |
39 | #define ALPHABIT 0
40 | #define DIGITBIT 1
41 | #define PRINTBIT 2
42 | #define SPACEBIT 3
43 | #define XDIGITBIT 4
44 |
45 |
46 | #define MASK(B) (1 << (B))
47 |
48 |
49 | /*
50 | ** add 1 to char to allow index -1 (EOZ)
51 | */
52 | #define testprop(c,p) (luai_ctype_[(c)+1] & (p))
53 |
54 | /*
55 | ** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_'
56 | */
57 | #define lislalpha(c) testprop(c, MASK(ALPHABIT))
58 | #define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT)))
59 | #define lisdigit(c) testprop(c, MASK(DIGITBIT))
60 | #define lisspace(c) testprop(c, MASK(SPACEBIT))
61 | #define lisprint(c) testprop(c, MASK(PRINTBIT))
62 | #define lisxdigit(c) testprop(c, MASK(XDIGITBIT))
63 |
64 | /*
65 | ** this 'ltolower' only works for alphabetic characters
66 | */
67 | #define ltolower(c) ((c) | ('A' ^ 'a'))
68 |
69 |
70 | /* two more entries for 0 and -1 (EOZ) */
71 | LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2];
72 |
73 |
74 | #else /* }{ */
75 |
76 | /*
77 | ** use standard C ctypes
78 | */
79 |
80 | #include
81 |
82 |
83 | #define lislalpha(c) (isalpha(c) || (c) == '_')
84 | #define lislalnum(c) (isalnum(c) || (c) == '_')
85 | #define lisdigit(c) (isdigit(c))
86 | #define lisspace(c) (isspace(c))
87 | #define lisprint(c) (isprint(c))
88 | #define lisxdigit(c) (isxdigit(c))
89 |
90 | #define ltolower(c) (tolower(c))
91 |
92 | #endif /* } */
93 |
94 | #endif
95 |
96 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/src/ldebug.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ldebug.h,v 2.14 2015/05/22 17:45:56 roberto Exp $
3 | ** Auxiliary functions from Debug Interface module
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef ldebug_h
8 | #define ldebug_h
9 |
10 |
11 | #include "lstate.h"
12 |
13 |
14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1)
15 |
16 | #define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1)
17 |
18 | #define resethookcount(L) (L->hookcount = L->basehookcount)
19 |
20 |
21 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o,
22 | const char *opname);
23 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1,
24 | const TValue *p2);
25 | LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1,
26 | const TValue *p2,
27 | const char *msg);
28 | LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1,
29 | const TValue *p2);
30 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1,
31 | const TValue *p2);
32 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...);
33 | LUAI_FUNC const char *luaG_addinfo (lua_State *L, const char *msg,
34 | TString *src, int line);
35 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L);
36 | LUAI_FUNC void luaG_traceexec (lua_State *L);
37 |
38 |
39 | #endif
40 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/src/ldo.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ldo.h,v 2.29 2015/12/21 13:02:14 roberto Exp $
3 | ** Stack and Call structure of Lua
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef ldo_h
8 | #define ldo_h
9 |
10 |
11 | #include "lobject.h"
12 | #include "lstate.h"
13 | #include "lzio.h"
14 |
15 |
16 | /*
17 | ** Macro to check stack size and grow stack if needed. Parameters
18 | ** 'pre'/'pos' allow the macro to preserve a pointer into the
19 | ** stack across reallocations, doing the work only when needed.
20 | ** 'condmovestack' is used in heavy tests to force a stack reallocation
21 | ** at every check.
22 | */
23 | #define luaD_checkstackaux(L,n,pre,pos) \
24 | if (L->stack_last - L->top <= (n)) \
25 | { pre; luaD_growstack(L, n); pos; } else { condmovestack(L,pre,pos); }
26 |
27 | /* In general, 'pre'/'pos' are empty (nothing to save) */
28 | #define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0)
29 |
30 |
31 |
32 | #define savestack(L,p) ((char *)(p) - (char *)L->stack)
33 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n)))
34 |
35 |
36 | /* type of protected functions, to be ran by 'runprotected' */
37 | typedef void (*Pfunc) (lua_State *L, void *ud);
38 |
39 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name,
40 | const char *mode);
41 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line);
42 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults);
43 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
44 | LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults);
45 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
46 | ptrdiff_t oldtop, ptrdiff_t ef);
47 | LUAI_FUNC int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult,
48 | int nres);
49 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
50 | LUAI_FUNC void luaD_growstack (lua_State *L, int n);
51 | LUAI_FUNC void luaD_shrinkstack (lua_State *L);
52 | LUAI_FUNC void luaD_inctop (lua_State *L);
53 |
54 | LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode);
55 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
56 |
57 | #endif
58 |
59 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/src/lfunc.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lfunc.h,v 2.15 2015/01/13 15:49:11 roberto Exp $
3 | ** Auxiliary functions to manipulate prototypes and closures
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lfunc_h
8 | #define lfunc_h
9 |
10 |
11 | #include "lobject.h"
12 |
13 |
14 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \
15 | cast(int, sizeof(TValue)*((n)-1)))
16 |
17 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \
18 | cast(int, sizeof(TValue *)*((n)-1)))
19 |
20 |
21 | /* test whether thread is in 'twups' list */
22 | #define isintwups(L) (L->twups != L)
23 |
24 |
25 | /*
26 | ** maximum number of upvalues in a closure (both C and Lua). (Value
27 | ** must fit in a VM register.)
28 | */
29 | #define MAXUPVAL 255
30 |
31 |
32 | /*
33 | ** Upvalues for Lua closures
34 | */
35 | struct UpVal {
36 | TValue *v; /* points to stack or to its own value */
37 | lu_mem refcount; /* reference counter */
38 | union {
39 | struct { /* (when open) */
40 | UpVal *next; /* linked list */
41 | int touched; /* mark to avoid cycles with dead threads */
42 | } open;
43 | TValue value; /* the value (when closed) */
44 | } u;
45 | };
46 |
47 | #define upisopen(up) ((up)->v != &(up)->u.value)
48 |
49 |
50 | LUAI_FUNC Proto *luaF_newproto (lua_State *L);
51 | LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems);
52 | LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems);
53 | LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl);
54 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
55 | LUAI_FUNC void luaF_close (lua_State *L, StkId level);
56 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
57 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,
58 | int pc);
59 |
60 |
61 | #endif
62 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/src/linit.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: linit.c,v 1.39 2016/12/04 20:17:24 roberto Exp $
3 | ** Initialization of libraries for lua.c and other clients
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 |
8 | #define linit_c
9 | #define LUA_LIB
10 |
11 | /*
12 | ** If you embed Lua in your program and need to open the standard
13 | ** libraries, call luaL_openlibs in your program. If you need a
14 | ** different set of libraries, copy this file to your project and edit
15 | ** it to suit your needs.
16 | **
17 | ** You can also *preload* libraries, so that a later 'require' can
18 | ** open the library, which is already linked to the application.
19 | ** For that, do the following code:
20 | **
21 | ** luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE);
22 | ** lua_pushcfunction(L, luaopen_modname);
23 | ** lua_setfield(L, -2, modname);
24 | ** lua_pop(L, 1); // remove PRELOAD table
25 | */
26 |
27 | #include "lprefix.h"
28 |
29 |
30 | #include
31 |
32 | #include "lua.h"
33 |
34 | #include "lualib.h"
35 | #include "lauxlib.h"
36 |
37 |
38 | /*
39 | ** these libs are loaded by lua.c and are readily available to any Lua
40 | ** program
41 | */
42 | static const luaL_Reg loadedlibs[] = {
43 | {"_G", luaopen_base},
44 | {LUA_LOADLIBNAME, luaopen_package},
45 | {LUA_COLIBNAME, luaopen_coroutine},
46 | {LUA_TABLIBNAME, luaopen_table},
47 | {LUA_IOLIBNAME, luaopen_io},
48 | {LUA_OSLIBNAME, luaopen_os},
49 | {LUA_STRLIBNAME, luaopen_string},
50 | {LUA_MATHLIBNAME, luaopen_math},
51 | {LUA_UTF8LIBNAME, luaopen_utf8},
52 | {LUA_DBLIBNAME, luaopen_debug},
53 | #if defined(LUA_COMPAT_BITLIB)
54 | {LUA_BITLIBNAME, luaopen_bit32},
55 | #endif
56 | {NULL, NULL}
57 | };
58 |
59 |
60 | LUALIB_API void luaL_openlibs (lua_State *L) {
61 | const luaL_Reg *lib;
62 | /* "require" functions from 'loadedlibs' and set results to global table */
63 | for (lib = loadedlibs; lib->func; lib++) {
64 | luaL_requiref(L, lib->name, lib->func, 1);
65 | lua_pop(L, 1); /* remove lib */
66 | }
67 | }
68 |
69 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/src/llex.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: llex.h,v 1.79 2016/05/02 14:02:12 roberto Exp $
3 | ** Lexical Analyzer
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef llex_h
8 | #define llex_h
9 |
10 | #include "lobject.h"
11 | #include "lzio.h"
12 |
13 |
14 | #define FIRST_RESERVED 257
15 |
16 |
17 | #if !defined(LUA_ENV)
18 | #define LUA_ENV "_ENV"
19 | #endif
20 |
21 |
22 | /*
23 | * WARNING: if you change the order of this enumeration,
24 | * grep "ORDER RESERVED"
25 | */
26 | enum RESERVED {
27 | /* terminal symbols denoted by reserved words */
28 | TK_AND = FIRST_RESERVED, TK_BREAK,
29 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION,
30 | TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT,
31 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
32 | /* other terminal symbols */
33 | TK_IDIV, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE,
34 | TK_SHL, TK_SHR,
35 | TK_DBCOLON, TK_EOS,
36 | TK_FLT, TK_INT, TK_NAME, TK_STRING
37 | };
38 |
39 | /* number of reserved words */
40 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))
41 |
42 |
43 | typedef union {
44 | lua_Number r;
45 | lua_Integer i;
46 | TString *ts;
47 | } SemInfo; /* semantics information */
48 |
49 |
50 | typedef struct Token {
51 | int token;
52 | SemInfo seminfo;
53 | } Token;
54 |
55 |
56 | /* state of the lexer plus state of the parser when shared by all
57 | functions */
58 | typedef struct LexState {
59 | int current; /* current character (charint) */
60 | int linenumber; /* input line counter */
61 | int lastline; /* line of last token 'consumed' */
62 | Token t; /* current token */
63 | Token lookahead; /* look ahead token */
64 | struct FuncState *fs; /* current function (parser) */
65 | struct lua_State *L;
66 | ZIO *z; /* input stream */
67 | Mbuffer *buff; /* buffer for tokens */
68 | Table *h; /* to avoid collection/reuse strings */
69 | struct Dyndata *dyd; /* dynamic structures used by the parser */
70 | TString *source; /* current source name */
71 | TString *envn; /* environment variable name */
72 | } LexState;
73 |
74 |
75 | LUAI_FUNC void luaX_init (lua_State *L);
76 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z,
77 | TString *source, int firstchar);
78 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);
79 | LUAI_FUNC void luaX_next (LexState *ls);
80 | LUAI_FUNC int luaX_lookahead (LexState *ls);
81 | LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s);
82 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token);
83 |
84 |
85 | #endif
86 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/src/lmem.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lmem.c,v 1.91 2015/03/06 19:45:54 roberto Exp $
3 | ** Interface to Memory Manager
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #define lmem_c
8 | #define LUA_CORE
9 |
10 | #include "lprefix.h"
11 |
12 |
13 | #include
14 |
15 | #include "lua.h"
16 |
17 | #include "ldebug.h"
18 | #include "ldo.h"
19 | #include "lgc.h"
20 | #include "lmem.h"
21 | #include "lobject.h"
22 | #include "lstate.h"
23 |
24 |
25 |
26 | /*
27 | ** About the realloc function:
28 | ** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize);
29 | ** ('osize' is the old size, 'nsize' is the new size)
30 | **
31 | ** * frealloc(ud, NULL, x, s) creates a new block of size 's' (no
32 | ** matter 'x').
33 | **
34 | ** * frealloc(ud, p, x, 0) frees the block 'p'
35 | ** (in this specific case, frealloc must return NULL);
36 | ** particularly, frealloc(ud, NULL, 0, 0) does nothing
37 | ** (which is equivalent to free(NULL) in ISO C)
38 | **
39 | ** frealloc returns NULL if it cannot create or reallocate the area
40 | ** (any reallocation to an equal or smaller size cannot fail!)
41 | */
42 |
43 |
44 |
45 | #define MINSIZEARRAY 4
46 |
47 |
48 | void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems,
49 | int limit, const char *what) {
50 | void *newblock;
51 | int newsize;
52 | if (*size >= limit/2) { /* cannot double it? */
53 | if (*size >= limit) /* cannot grow even a little? */
54 | luaG_runerror(L, "too many %s (limit is %d)", what, limit);
55 | newsize = limit; /* still have at least one free place */
56 | }
57 | else {
58 | newsize = (*size)*2;
59 | if (newsize < MINSIZEARRAY)
60 | newsize = MINSIZEARRAY; /* minimum size */
61 | }
62 | newblock = luaM_reallocv(L, block, *size, newsize, size_elems);
63 | *size = newsize; /* update only when everything else is OK */
64 | return newblock;
65 | }
66 |
67 |
68 | l_noret luaM_toobig (lua_State *L) {
69 | luaG_runerror(L, "memory allocation error: block too big");
70 | }
71 |
72 |
73 |
74 | /*
75 | ** generic allocation routine.
76 | */
77 | void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) {
78 | void *newblock;
79 | global_State *g = G(L);
80 | size_t realosize = (block) ? osize : 0;
81 | lua_assert((realosize == 0) == (block == NULL));
82 | #if defined(HARDMEMTESTS)
83 | if (nsize > realosize && g->gcrunning)
84 | luaC_fullgc(L, 1); /* force a GC whenever possible */
85 | #endif
86 | newblock = (*g->frealloc)(g->ud, block, osize, nsize);
87 | if (newblock == NULL && nsize > 0) {
88 | lua_assert(nsize > realosize); /* cannot fail when shrinking a block */
89 | if (g->version) { /* is state fully built? */
90 | luaC_fullgc(L, 1); /* try to free some memory... */
91 | newblock = (*g->frealloc)(g->ud, block, osize, nsize); /* try again */
92 | }
93 | if (newblock == NULL)
94 | luaD_throw(L, LUA_ERRMEM);
95 | }
96 | lua_assert((nsize == 0) == (newblock == NULL));
97 | g->GCdebt = (g->GCdebt + nsize) - realosize;
98 | return newblock;
99 | }
100 |
101 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/src/lmem.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lmem.h,v 1.43 2014/12/19 17:26:14 roberto Exp $
3 | ** Interface to Memory Manager
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lmem_h
8 | #define lmem_h
9 |
10 |
11 | #include
12 |
13 | #include "llimits.h"
14 | #include "lua.h"
15 |
16 |
17 | /*
18 | ** This macro reallocs a vector 'b' from 'on' to 'n' elements, where
19 | ** each element has size 'e'. In case of arithmetic overflow of the
20 | ** product 'n'*'e', it raises an error (calling 'luaM_toobig'). Because
21 | ** 'e' is always constant, it avoids the runtime division MAX_SIZET/(e).
22 | **
23 | ** (The macro is somewhat complex to avoid warnings: The 'sizeof'
24 | ** comparison avoids a runtime comparison when overflow cannot occur.
25 | ** The compiler should be able to optimize the real test by itself, but
26 | ** when it does it, it may give a warning about "comparison is always
27 | ** false due to limited range of data type"; the +1 tricks the compiler,
28 | ** avoiding this warning but also this optimization.)
29 | */
30 | #define luaM_reallocv(L,b,on,n,e) \
31 | (((sizeof(n) >= sizeof(size_t) && cast(size_t, (n)) + 1 > MAX_SIZET/(e)) \
32 | ? luaM_toobig(L) : cast_void(0)) , \
33 | luaM_realloc_(L, (b), (on)*(e), (n)*(e)))
34 |
35 | /*
36 | ** Arrays of chars do not need any test
37 | */
38 | #define luaM_reallocvchar(L,b,on,n) \
39 | cast(char *, luaM_realloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char)))
40 |
41 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0)
42 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0)
43 | #define luaM_freearray(L, b, n) luaM_realloc_(L, (b), (n)*sizeof(*(b)), 0)
44 |
45 | #define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s))
46 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t)))
47 | #define luaM_newvector(L,n,t) \
48 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t)))
49 |
50 | #define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s))
51 |
52 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \
53 | if ((nelems)+1 > (size)) \
54 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e)))
55 |
56 | #define luaM_reallocvector(L, v,oldn,n,t) \
57 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
58 |
59 | LUAI_FUNC l_noret luaM_toobig (lua_State *L);
60 |
61 | /* not to be called directly */
62 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
63 | size_t size);
64 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size,
65 | size_t size_elem, int limit,
66 | const char *what);
67 |
68 | #endif
69 |
70 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/src/lprefix.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lprefix.h,v 1.2 2014/12/29 16:54:13 roberto Exp $
3 | ** Definitions for Lua code that must come before any other header file
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lprefix_h
8 | #define lprefix_h
9 |
10 |
11 | /*
12 | ** Allows POSIX/XSI stuff
13 | */
14 | #if !defined(LUA_USE_C89) /* { */
15 |
16 | #if !defined(_XOPEN_SOURCE)
17 | #define _XOPEN_SOURCE 600
18 | #elif _XOPEN_SOURCE == 0
19 | #undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */
20 | #endif
21 |
22 | /*
23 | ** Allows manipulation of large files in gcc and some other compilers
24 | */
25 | #if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS)
26 | #define _LARGEFILE_SOURCE 1
27 | #define _FILE_OFFSET_BITS 64
28 | #endif
29 |
30 | #endif /* } */
31 |
32 |
33 | /*
34 | ** Windows stuff
35 | */
36 | #if defined(_WIN32) /* { */
37 |
38 | #if !defined(_CRT_SECURE_NO_WARNINGS)
39 | #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */
40 | #endif
41 |
42 | #endif /* } */
43 |
44 | #endif
45 |
46 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/src/lstring.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lstring.h,v 1.61 2015/11/03 15:36:01 roberto Exp $
3 | ** String table (keep all strings handled by Lua)
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lstring_h
8 | #define lstring_h
9 |
10 | #include "lgc.h"
11 | #include "lobject.h"
12 | #include "lstate.h"
13 |
14 |
15 | #define sizelstring(l) (sizeof(union UTString) + ((l) + 1) * sizeof(char))
16 |
17 | #define sizeludata(l) (sizeof(union UUdata) + (l))
18 | #define sizeudata(u) sizeludata((u)->len)
19 |
20 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \
21 | (sizeof(s)/sizeof(char))-1))
22 |
23 |
24 | /*
25 | ** test whether a string is a reserved word
26 | */
27 | #define isreserved(s) ((s)->tt == LUA_TSHRSTR && (s)->extra > 0)
28 |
29 |
30 | /*
31 | ** equality for short strings, which are always internalized
32 | */
33 | #define eqshrstr(a,b) check_exp((a)->tt == LUA_TSHRSTR, (a) == (b))
34 |
35 |
36 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed);
37 | LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts);
38 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b);
39 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
40 | LUAI_FUNC void luaS_clearcache (global_State *g);
41 | LUAI_FUNC void luaS_init (lua_State *L);
42 | LUAI_FUNC void luaS_remove (lua_State *L, TString *ts);
43 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s);
44 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
45 | LUAI_FUNC TString *luaS_new (lua_State *L, const char *str);
46 | LUAI_FUNC TString *luaS_createlngstrobj (lua_State *L, size_t l);
47 |
48 |
49 | #endif
50 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/src/ltable.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ltable.h,v 2.23 2016/12/22 13:08:50 roberto Exp $
3 | ** Lua tables (hash)
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef ltable_h
8 | #define ltable_h
9 |
10 | #include "lobject.h"
11 |
12 |
13 | #define gnode(t,i) (&(t)->node[i])
14 | #define gval(n) (&(n)->i_val)
15 | #define gnext(n) ((n)->i_key.nk.next)
16 |
17 |
18 | /* 'const' to avoid wrong writings that can mess up field 'next' */
19 | #define gkey(n) cast(const TValue*, (&(n)->i_key.tvk))
20 |
21 | /*
22 | ** writable version of 'gkey'; allows updates to individual fields,
23 | ** but not to the whole (which has incompatible type)
24 | */
25 | #define wgkey(n) (&(n)->i_key.nk)
26 |
27 | #define invalidateTMcache(t) ((t)->flags = 0)
28 |
29 |
30 | /* true when 't' is using 'dummynode' as its hash part */
31 | #define isdummy(t) ((t)->lastfree == NULL)
32 |
33 |
34 | /* allocated size for hash nodes */
35 | #define allocsizenode(t) (isdummy(t) ? 0 : sizenode(t))
36 |
37 |
38 | /* returns the key, given the value of a table entry */
39 | #define keyfromval(v) \
40 | (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val))))
41 |
42 |
43 | LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key);
44 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key,
45 | TValue *value);
46 | LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key);
47 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
48 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
49 | LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key);
50 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key);
51 | LUAI_FUNC Table *luaH_new (lua_State *L);
52 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize,
53 | unsigned int nhsize);
54 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize);
55 | LUAI_FUNC void luaH_free (lua_State *L, Table *t);
56 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key);
57 | LUAI_FUNC int luaH_getn (Table *t);
58 |
59 |
60 | #if defined(LUA_DEBUG)
61 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
62 | LUAI_FUNC int luaH_isdummy (const Table *t);
63 | #endif
64 |
65 |
66 | #endif
67 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/src/ltm.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ltm.h,v 2.22 2016/02/26 19:20:15 roberto Exp $
3 | ** Tag methods
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef ltm_h
8 | #define ltm_h
9 |
10 |
11 | #include "lobject.h"
12 |
13 |
14 | /*
15 | * WARNING: if you change the order of this enumeration,
16 | * grep "ORDER TM" and "ORDER OP"
17 | */
18 | typedef enum {
19 | TM_INDEX,
20 | TM_NEWINDEX,
21 | TM_GC,
22 | TM_MODE,
23 | TM_LEN,
24 | TM_EQ, /* last tag method with fast access */
25 | TM_ADD,
26 | TM_SUB,
27 | TM_MUL,
28 | TM_MOD,
29 | TM_POW,
30 | TM_DIV,
31 | TM_IDIV,
32 | TM_BAND,
33 | TM_BOR,
34 | TM_BXOR,
35 | TM_SHL,
36 | TM_SHR,
37 | TM_UNM,
38 | TM_BNOT,
39 | TM_LT,
40 | TM_LE,
41 | TM_CONCAT,
42 | TM_CALL,
43 | TM_N /* number of elements in the enum */
44 | } TMS;
45 |
46 |
47 |
48 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \
49 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
50 |
51 | #define fasttm(l,et,e) gfasttm(G(l), et, e)
52 |
53 | #define ttypename(x) luaT_typenames_[(x) + 1]
54 |
55 | LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS];
56 |
57 |
58 | LUAI_FUNC const char *luaT_objtypename (lua_State *L, const TValue *o);
59 |
60 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
61 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o,
62 | TMS event);
63 | LUAI_FUNC void luaT_init (lua_State *L);
64 |
65 | LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1,
66 | const TValue *p2, TValue *p3, int hasres);
67 | LUAI_FUNC int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2,
68 | StkId res, TMS event);
69 | LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2,
70 | StkId res, TMS event);
71 | LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1,
72 | const TValue *p2, TMS event);
73 |
74 |
75 |
76 | #endif
77 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/src/lua.hpp:
--------------------------------------------------------------------------------
1 | // lua.hpp
2 | // Lua header files for C++
3 | // <> not supplied automatically because Lua also compiles as C++
4 |
5 | extern "C" {
6 | #include "lua.h"
7 | #include "lualib.h"
8 | #include "lauxlib.h"
9 | }
10 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/src/lualib.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lualib.h,v 1.45 2017/01/12 17:14:26 roberto Exp $
3 | ** Lua standard libraries
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 |
8 | #ifndef lualib_h
9 | #define lualib_h
10 |
11 | #include "lua.h"
12 |
13 |
14 | /* version suffix for environment variable names */
15 | #define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR
16 |
17 |
18 | LUAMOD_API int (luaopen_base) (lua_State *L);
19 |
20 | #define LUA_COLIBNAME "coroutine"
21 | LUAMOD_API int (luaopen_coroutine) (lua_State *L);
22 |
23 | #define LUA_TABLIBNAME "table"
24 | LUAMOD_API int (luaopen_table) (lua_State *L);
25 |
26 | #define LUA_IOLIBNAME "io"
27 | LUAMOD_API int (luaopen_io) (lua_State *L);
28 |
29 | #define LUA_OSLIBNAME "os"
30 | LUAMOD_API int (luaopen_os) (lua_State *L);
31 |
32 | #define LUA_STRLIBNAME "string"
33 | LUAMOD_API int (luaopen_string) (lua_State *L);
34 |
35 | #define LUA_UTF8LIBNAME "utf8"
36 | LUAMOD_API int (luaopen_utf8) (lua_State *L);
37 |
38 | #define LUA_BITLIBNAME "bit32"
39 | LUAMOD_API int (luaopen_bit32) (lua_State *L);
40 |
41 | #define LUA_MATHLIBNAME "math"
42 | LUAMOD_API int (luaopen_math) (lua_State *L);
43 |
44 | #define LUA_DBLIBNAME "debug"
45 | LUAMOD_API int (luaopen_debug) (lua_State *L);
46 |
47 | #define LUA_LOADLIBNAME "package"
48 | LUAMOD_API int (luaopen_package) (lua_State *L);
49 |
50 |
51 | /* open all previous libraries */
52 | LUALIB_API void (luaL_openlibs) (lua_State *L);
53 |
54 |
55 |
56 | #if !defined(lua_assert)
57 | #define lua_assert(x) ((void)0)
58 | #endif
59 |
60 |
61 | #endif
62 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/src/lundump.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lundump.h,v 1.45 2015/09/08 15:41:05 roberto Exp $
3 | ** load precompiled Lua chunks
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lundump_h
8 | #define lundump_h
9 |
10 | #include "llimits.h"
11 | #include "lobject.h"
12 | #include "lzio.h"
13 |
14 |
15 | /* data to catch conversion errors */
16 | #define LUAC_DATA "\x19\x93\r\n\x1a\n"
17 |
18 | #define LUAC_INT 0x5678
19 | #define LUAC_NUM cast_num(370.5)
20 |
21 | #define MYINT(s) (s[0]-'0')
22 | #define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR))
23 | #define LUAC_FORMAT 0 /* this is the official format */
24 |
25 | /* load one chunk; from lundump.c */
26 | LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name);
27 |
28 | /* dump one chunk; from ldump.c */
29 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w,
30 | void* data, int strip);
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/src/lzio.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lzio.c,v 1.37 2015/09/08 15:41:05 roberto Exp $
3 | ** Buffered streams
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #define lzio_c
8 | #define LUA_CORE
9 |
10 | #include "lprefix.h"
11 |
12 |
13 | #include
14 |
15 | #include "lua.h"
16 |
17 | #include "llimits.h"
18 | #include "lmem.h"
19 | #include "lstate.h"
20 | #include "lzio.h"
21 |
22 |
23 | int luaZ_fill (ZIO *z) {
24 | size_t size;
25 | lua_State *L = z->L;
26 | const char *buff;
27 | lua_unlock(L);
28 | buff = z->reader(L, z->data, &size);
29 | lua_lock(L);
30 | if (buff == NULL || size == 0)
31 | return EOZ;
32 | z->n = size - 1; /* discount char being returned */
33 | z->p = buff;
34 | return cast_uchar(*(z->p++));
35 | }
36 |
37 |
38 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
39 | z->L = L;
40 | z->reader = reader;
41 | z->data = data;
42 | z->n = 0;
43 | z->p = NULL;
44 | }
45 |
46 |
47 | /* --------------------------------------------------------------- read --- */
48 | size_t luaZ_read (ZIO *z, void *b, size_t n) {
49 | while (n) {
50 | size_t m;
51 | if (z->n == 0) { /* no bytes in buffer? */
52 | if (luaZ_fill(z) == EOZ) /* try to read more */
53 | return n; /* no more input; return number of missing bytes */
54 | else {
55 | z->n++; /* luaZ_fill consumed first byte; put it back */
56 | z->p--;
57 | }
58 | }
59 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */
60 | memcpy(b, z->p, m);
61 | z->n -= m;
62 | z->p += m;
63 | b = (char *)b + m;
64 | n -= m;
65 | }
66 | return 0;
67 | }
68 |
69 |
--------------------------------------------------------------------------------
/tool/lua-5.3.4/src/lzio.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lzio.h,v 1.31 2015/09/08 15:41:05 roberto Exp $
3 | ** Buffered streams
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 |
8 | #ifndef lzio_h
9 | #define lzio_h
10 |
11 | #include "lua.h"
12 |
13 | #include "lmem.h"
14 |
15 |
16 | #define EOZ (-1) /* end of stream */
17 |
18 | typedef struct Zio ZIO;
19 |
20 | #define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z))
21 |
22 |
23 | typedef struct Mbuffer {
24 | char *buffer;
25 | size_t n;
26 | size_t buffsize;
27 | } Mbuffer;
28 |
29 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
30 |
31 | #define luaZ_buffer(buff) ((buff)->buffer)
32 | #define luaZ_sizebuffer(buff) ((buff)->buffsize)
33 | #define luaZ_bufflen(buff) ((buff)->n)
34 |
35 | #define luaZ_buffremove(buff,i) ((buff)->n -= (i))
36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0)
37 |
38 |
39 | #define luaZ_resizebuffer(L, buff, size) \
40 | ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, \
41 | (buff)->buffsize, size), \
42 | (buff)->buffsize = size)
43 |
44 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
45 |
46 |
47 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
48 | void *data);
49 | LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); /* read next n bytes */
50 |
51 |
52 |
53 | /* --------- Private Part ------------------ */
54 |
55 | struct Zio {
56 | size_t n; /* bytes still unread */
57 | const char *p; /* current position in buffer */
58 | lua_Reader reader; /* reader function */
59 | void *data; /* additional data */
60 | lua_State *L; /* Lua state (for reader) */
61 | };
62 |
63 |
64 | LUAI_FUNC int luaZ_fill (ZIO *z);
65 |
66 | #endif
67 |
--------------------------------------------------------------------------------
/tool/memio.h:
--------------------------------------------------------------------------------
1 | #ifndef _MEMIO_H_
2 | #define _MEMIO_H_
3 |
4 | #include
5 | #include "types.h"
6 | #include "cpu.h"
7 |
8 |
9 | //FILE* api (large, progress indicators)
10 | bool memioWriteFromFile(struct Cpu* cpu, uint32_t dstAddr, uint32_t dstLen, FILE *f, bool withAck, bool showProgress, bool showSpeedInProgress); //will round file read up to nearest 4 bytes. Write is padded by zeroes to asked sz
11 | bool memioReadToFile(struct Cpu *cpu, uint32_t srcAddr, uint32_t srcLen, FILE *f, bool showProgress, bool showSpeedInProgress);
12 |
13 | //void* api (RAM, no progress indicator), return num bytes done
14 | uint32_t memioReadToBuffer(struct Cpu *cpu, uint32_t srcAddr, uint32_t srcLen, void* dst);
15 |
16 |
17 | #endif
18 |
--------------------------------------------------------------------------------
/tool/oldtool/Makefile:
--------------------------------------------------------------------------------
1 | APP = tool
2 | SRCS = main.c cpu.c hidapi/linux/hid.c gdbServer.c scriptfiles.c
3 | INCS = hidapi/hidapi/hidapi.h cpu.h
4 | CCFLAGS = -iquote hidapi/hidapi -O2
5 | LDFLAGS = -ludev
6 |
7 | $(APP): $(SRCS) $(INCS)
8 | gcc -o $(APP) $(SRCS) $(CCFLAGS) $(LDFLAGS) -g -ggdb3
9 |
10 | install: $(APP) scripts
11 | sudo cp $(APP) /usr/bin/CortexProg
12 | sudo mkdir -p /usr/share/cortexprog/scripts
13 | sudo cp -Rvf SCRIPTS/*.swds /usr/share/cortexprog/scripts
14 | sudo chown root:root /usr/bin/CortexProg
15 | sudo chmod 755 /usr/bin/CortexProg
16 |
17 | scripts:
18 | make -C SCRIPTS
19 |
20 | clean:
21 | rm -f $(APP)
22 |
23 | .PHONY: scripts clean
24 |
--------------------------------------------------------------------------------
/tool/oldtool/SCRIPTS/Makefile:
--------------------------------------------------------------------------------
1 | TARGETS_M0 = $(patsubst %.m0.S,%.swds,$(wildcard *.m0.S))
2 | TARGETS_M3 = $(patsubst %.m3.S,%.swds,$(wildcard *.m3.S))
3 | TARGETS = $(TARGETS_M0) $(TARGETS_M3)
4 |
5 |
6 | all: $(TARGETS)
7 |
8 | %.swds: %.elf
9 | arm-none-eabi-objcopy -j.text -j.data -O binary $< $@
10 |
11 | %.elf: %.o
12 | arm-none-eabi-gcc -e entrypts $< -o $@ -Ttext `echo $@ | sed 's/.*\.\([0-9a-f]*\)\.elf/\1/g'` -nostdlib -mthumb -Wl,-T linker.lkr
13 |
14 | %.o: %.m0.S
15 | arm-none-eabi-gcc -mcpu=cortex-m0 -c $< -o $@ -mthumb
16 |
17 | %.o: %.m3.S
18 | arm-none-eabi-gcc -mcpu=cortex-m3 -c $< -o $@ -mthumb
19 |
20 | clean:
21 | rm -rf *.o *.swds *.elf
--------------------------------------------------------------------------------
/tool/oldtool/SCRIPTS/linker.lkr:
--------------------------------------------------------------------------------
1 | MEMORY
2 | {
3 | memory (rx) : ORIGIN = 0x0, LENGTH = 0xfffffffff
4 | }
5 |
6 | SECTIONS
7 | {
8 | .text :
9 | {
10 | *(.text)
11 | *(.text.2)
12 | } > memory
13 | }
14 |
--------------------------------------------------------------------------------
/tool/oldtool/SCRIPTS/notes.txt.txt:
--------------------------------------------------------------------------------
1 | {0, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000009a, 0x00000040, 0x0000001b, 0x00000020}, "PSoC40xx", "PSoC4xxx"}, //4000
2 | {0, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000093, 0x00000040, 0x0000001b, 0x00000010}, "PSoC41xx", "PSoC4xxx"}, //4100
3 |
4 | //M3
5 | {0, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000054, 0x0000004a, 0x00000008, 0x00000000}, "MB9BF524KPMC", "MB9BF524KPMC"},
--------------------------------------------------------------------------------
/tool/oldtool/cpu.h:
--------------------------------------------------------------------------------
1 | #ifndef _CPU_H_
2 | #define _CPU_H_
3 |
4 | #ifdef WIN32
5 | #include
6 | #endif
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | #include "hidapi.h"
14 | #include "../swdCommsPacket.h"
15 | #include "../cortex.h"
16 |
17 | #define CPU_OPTIMAL_MEM_XFER_WORDS SWD_COMMS_MAX_XFER_WORDS
18 | #define CPU_NUM_REGS_PER_SET NUM_REGS
19 |
20 |
21 | #ifdef _LARGE_PACKETS_
22 | #define PACKET_RX_FAIL 0xffffffff
23 | #else
24 | #define PACKET_RX_FAIL 0xff
25 | #endif
26 |
27 | //pktRx == NULL if we do not want a reply, return PACKET_RX_FAIL for fail
28 | typedef uint32_t (*DoOneSwdDevCmdF)(hid_device *handle, const struct CommsPacket *pktTx, uint32_t txPayloadLen, struct CommsPacket *pktRx);
29 |
30 | bool cpuInit(hid_device *dev, DoOneSwdDevCmdF cmdF, uint32_t maxXferBytes);
31 | bool cpuIdentify(uint32_t *loadSzP, uint32_t *loadAddrP, uint32_t *stageAddrP, char **nameP, char** scptFileName, FILE **scptFileHandle); //nameP must be freed by caller
32 |
33 | bool cpuMemReadEx(uint32_t base, uint32_t numWords, uint32_t *dst, bool silent/* do not write any errors to stdout*/);
34 | bool cpuMemRead(uint32_t base, uint32_t numWords, uint32_t *dst);
35 | bool cpuMemWrite(uint32_t base, uint32_t numWords, const uint32_t *src, bool withAck);
36 |
37 | bool cpuRegsGet(uint8_t regSet, uint32_t *dst);
38 | bool cpuRegsSet(uint8_t regSet, const uint32_t *src);
39 |
40 | uint8_t cpuStop(void);
41 | bool cpuReset(void);
42 | bool cpuGo(void);
43 | uint8_t cpuStep(void);
44 | uint8_t cpuIsStoppedAndWhy(void);
45 |
46 | bool cpuIsV7(void);
47 | bool cpuHasFpu(void);
48 |
49 | uint32_t cpuGetOptimalReadNumWords(void);
50 | uint32_t cpuGetOptimalWriteNumWords(void);
51 |
52 |
53 | //very very very low level
54 | uint8_t swdLlWireBusRead(uint8_t ap, uint8_t a23, uint32_t *valP);
55 | uint8_t swdLlWireBusWrite(uint8_t ap, uint8_t a23, uint32_t val);
56 |
57 |
58 | //higher level
59 | uint32_t cpuTraceLogRead(uint32_t addr, uint8_t *buf); //buf better be >= COMMS_PAYLOAD_MAX_SIZE in len
60 |
61 |
62 | //sort of averarching
63 | bool cpuPwrSet(bool on);
64 |
65 | #endif
66 |
--------------------------------------------------------------------------------
/tool/oldtool/gdbServer.h:
--------------------------------------------------------------------------------
1 | #ifndef _GDB_SERVER_H_
2 | #define _GDB_SERVER_H_
3 |
4 | void gdbServer(int port);
5 |
6 |
7 |
8 | #endif
9 |
10 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 |
3 | *.sln text eol=crlf
4 | *.vcproj text eol=crlf
5 |
6 | bootstrap text eol=lf
7 | configure.ac text eol=lf
8 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Autotools-added generated files
3 | Makefile.in
4 | aclocal.m4
5 | autom4te.cache/
6 | config.*
7 | configure
8 | depcomp
9 | install-sh
10 | libusb/Makefile.in
11 | linux/Makefile.in
12 | ltmain.sh
13 | mac/Makefile.in
14 | missing
15 | testgui/Makefile.in
16 | windows/Makefile.in
17 |
18 | Makefile
19 | stamp-h1
20 | libtool
21 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/AUTHORS.txt:
--------------------------------------------------------------------------------
1 |
2 | HIDAPI Authors:
3 |
4 | Alan Ott :
5 | Original Author and Maintainer
6 | Linux, Windows, and Mac implementations
7 |
8 | Ludovic Rousseau :
9 | Formatting for Doxygen documentation
10 | Bug fixes
11 | Correctness fixes
12 |
13 |
14 | For a comprehensive list of contributions, see the commit list at github:
15 | http://github.com/signal11/hidapi/commits/master
16 |
17 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/HACKING.txt:
--------------------------------------------------------------------------------
1 | This file is mostly for the maintainer.
2 |
3 | 1. Build hidapi.dll
4 | 2. Build hidtest.exe in DEBUG and RELEASE
5 | 3. Commit all
6 |
7 | 4. Run the Following
8 | export VERSION=0.1.0
9 | export TAG_NAME=hidapi-$VERSION
10 | git tag $TAG_NAME
11 | git archive --format zip --prefix $TAG_NAME/ $TAG_NAME >../$TAG_NAME.zip
12 | 5. Test the zip file.
13 | 6. Run the following:
14 | git push origin $TAG_NAME
15 |
16 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/LICENSE-bsd.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2010, Alan Ott, Signal 11 Software
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright notice,
8 | this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in the
11 | documentation and/or other materials provided with the distribution.
12 | * Neither the name of Signal 11 Software nor the names of its
13 | contributors may be used to endorse or promote products derived from
14 | this software without specific prior written permission.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 | POSSIBILITY OF SUCH DAMAGE.
27 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/LICENSE-orig.txt:
--------------------------------------------------------------------------------
1 | HIDAPI - Multi-Platform library for
2 | communication with HID devices.
3 |
4 | Copyright 2009, Alan Ott, Signal 11 Software.
5 | All Rights Reserved.
6 |
7 | This software may be used by anyone for any reason so
8 | long as the copyright notice in the source files
9 | remains intact.
10 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/LICENSE.txt:
--------------------------------------------------------------------------------
1 | HIDAPI can be used under one of three licenses.
2 |
3 | 1. The GNU General Public License, version 3.0, in LICENSE-gpl3.txt
4 | 2. A BSD-Style License, in LICENSE-bsd.txt.
5 | 3. The more liberal original HIDAPI license. LICENSE-orig.txt
6 |
7 | The license chosen is at the discretion of the user of HIDAPI. For example:
8 | 1. An author of GPL software would likely use HIDAPI under the terms of the
9 | GPL.
10 |
11 | 2. An author of commercial closed-source software would likely use HIDAPI
12 | under the terms of the BSD-style license or the original HIDAPI license.
13 |
14 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/Makefile.am:
--------------------------------------------------------------------------------
1 |
2 | ACLOCAL_AMFLAGS = -I m4
3 |
4 | if OS_FREEBSD
5 | pkgconfigdir=$(prefix)/libdata/pkgconfig
6 | else
7 | pkgconfigdir=$(libdir)/pkgconfig
8 | endif
9 |
10 | if OS_LINUX
11 | pkgconfig_DATA=pc/hidapi-hidraw.pc pc/hidapi-libusb.pc
12 | else
13 | pkgconfig_DATA=pc/hidapi.pc
14 | endif
15 |
16 | SUBDIRS=
17 |
18 | if OS_LINUX
19 | SUBDIRS += linux libusb
20 | endif
21 |
22 | if OS_DARWIN
23 | SUBDIRS += mac
24 | endif
25 |
26 | if OS_FREEBSD
27 | SUBDIRS += libusb
28 | endif
29 |
30 | if OS_KFREEBSD
31 | SUBDIRS += libusb
32 | endif
33 |
34 | if OS_WINDOWS
35 | SUBDIRS += windows
36 | endif
37 |
38 | SUBDIRS += hidtest
39 |
40 | if BUILD_TESTGUI
41 | SUBDIRS += testgui
42 | endif
43 |
44 | EXTRA_DIST = udev doxygen
45 |
46 | dist_doc_DATA = \
47 | README.txt \
48 | AUTHORS.txt \
49 | LICENSE-bsd.txt \
50 | LICENSE-gpl3.txt \
51 | LICENSE-orig.txt \
52 | LICENSE.txt
53 |
54 | SCMCLEAN_TARGETS= \
55 | aclocal.m4 \
56 | config.guess \
57 | config.sub \
58 | configure \
59 | config.h.in \
60 | depcomp \
61 | install-sh \
62 | ltmain.sh \
63 | missing \
64 | mac/Makefile.in \
65 | testgui/Makefile.in \
66 | libusb/Makefile.in \
67 | Makefile.in \
68 | linux/Makefile.in \
69 | windows/Makefile.in \
70 | m4/libtool.m4 \
71 | m4/lt~obsolete.m4 \
72 | m4/ltoptions.m4 \
73 | m4/ltsugar.m4 \
74 | m4/ltversion.m4
75 |
76 | SCMCLEAN_DIR_TARGETS = \
77 | autom4te.cache
78 |
79 | scm-clean: distclean
80 | rm -f $(SCMCLEAN_TARGETS)
81 | rm -Rf $(SCMCLEAN_DIR_TARGETS)
82 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/android/jni/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH:= $(call my-dir)
2 |
3 | HIDAPI_ROOT_REL:= ../..
4 | HIDAPI_ROOT_ABS:= $(LOCAL_PATH)/../..
5 |
6 | include $(CLEAR_VARS)
7 |
8 | LOCAL_SRC_FILES := \
9 | $(HIDAPI_ROOT_REL)/libusb/hid.c
10 |
11 | LOCAL_C_INCLUDES += \
12 | $(HIDAPI_ROOT_ABS)/hidapi \
13 | $(HIDAPI_ROOT_ABS)/android
14 |
15 | LOCAL_SHARED_LIBRARIES := libusb1.0
16 |
17 | LOCAL_MODULE := libhidapi
18 |
19 | include $(BUILD_SHARED_LIBRARY)
20 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/bootstrap:
--------------------------------------------------------------------------------
1 | #!/bin/sh -x
2 | autoreconf --install --verbose --force
3 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/hidtest/.gitignore:
--------------------------------------------------------------------------------
1 | Debug
2 | Release
3 | *.exp
4 | *.ilk
5 | *.lib
6 | *.suo
7 | *.vcproj.*
8 | *.ncb
9 | *.suo
10 | *.dll
11 | *.pdb
12 | *.o
13 | .deps/
14 | .libs/
15 | hidtest-hidraw
16 | hidtest-libusb
17 | hidtest
18 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/hidtest/Makefile.am:
--------------------------------------------------------------------------------
1 | AM_CPPFLAGS = -I$(top_srcdir)/hidapi/
2 |
3 | ## Linux
4 | if OS_LINUX
5 | noinst_PROGRAMS = hidtest-libusb hidtest-hidraw
6 |
7 | hidtest_hidraw_SOURCES = hidtest.cpp
8 | hidtest_hidraw_LDADD = $(top_builddir)/linux/libhidapi-hidraw.la
9 |
10 | hidtest_libusb_SOURCES = hidtest.cpp
11 | hidtest_libusb_LDADD = $(top_builddir)/libusb/libhidapi-libusb.la
12 | else
13 |
14 | # Other OS's
15 | noinst_PROGRAMS = hidtest
16 |
17 | hidtest_SOURCES = hidtest.cpp
18 | hidtest_LDADD = $(top_builddir)/$(backend)/libhidapi.la
19 |
20 | endif
21 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/libusb/.gitignore:
--------------------------------------------------------------------------------
1 | *.o
2 | *.so
3 | *.la
4 | *.lo
5 | *.a
6 | .libs
7 | .deps
8 | hidtest-libusb
9 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/libusb/Makefile-manual:
--------------------------------------------------------------------------------
1 |
2 |
3 | OS=$(shell uname)
4 |
5 | ifeq ($(OS), Linux)
6 | FILE=Makefile.linux
7 | endif
8 |
9 | ifeq ($(OS), FreeBSD)
10 | FILE=Makefile.freebsd
11 | endif
12 |
13 | ifeq ($(FILE), )
14 | all:
15 | $(error Your platform ${OS} is not supported by hidapi/libusb at this time.)
16 | endif
17 |
18 | include $(FILE)
19 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/libusb/Makefile.am:
--------------------------------------------------------------------------------
1 | AM_CPPFLAGS = -I$(top_srcdir)/hidapi $(CFLAGS_LIBUSB)
2 |
3 | if OS_LINUX
4 | lib_LTLIBRARIES = libhidapi-libusb.la
5 | libhidapi_libusb_la_SOURCES = hid.c
6 | libhidapi_libusb_la_LDFLAGS = $(LTLDFLAGS) $(PTHREAD_CFLAGS)
7 | libhidapi_libusb_la_LIBADD = $(LIBS_LIBUSB)
8 | endif
9 |
10 | if OS_FREEBSD
11 | lib_LTLIBRARIES = libhidapi.la
12 | libhidapi_la_SOURCES = hid.c
13 | libhidapi_la_LDFLAGS = $(LTLDFLAGS)
14 | libhidapi_la_LIBADD = $(LIBS_LIBUSB)
15 | endif
16 |
17 | if OS_KFREEBSD
18 | lib_LTLIBRARIES = libhidapi.la
19 | libhidapi_la_SOURCES = hid.c
20 | libhidapi_la_LDFLAGS = $(LTLDFLAGS)
21 | libhidapi_la_LIBADD = $(LIBS_LIBUSB)
22 | endif
23 |
24 | hdrdir = $(includedir)/hidapi
25 | hdr_HEADERS = $(top_srcdir)/hidapi/hidapi.h
26 |
27 | EXTRA_DIST = Makefile-manual
28 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/libusb/Makefile.freebsd:
--------------------------------------------------------------------------------
1 | ###########################################
2 | # Simple Makefile for HIDAPI test program
3 | #
4 | # Alan Ott
5 | # Signal 11 Software
6 | # 2010-06-01
7 | ###########################################
8 |
9 | all: hidtest libs
10 |
11 | libs: libhidapi.so
12 |
13 | CC ?= cc
14 | CFLAGS ?= -Wall -g -fPIC
15 |
16 | CXX ?= c++
17 | CXXFLAGS ?= -Wall -g
18 |
19 | COBJS = hid.o
20 | CPPOBJS = ../hidtest/hidtest.o
21 | OBJS = $(COBJS) $(CPPOBJS)
22 | INCLUDES = -I../hidapi -I/usr/local/include
23 | LDFLAGS = -L/usr/local/lib
24 | LIBS = -lusb -liconv -pthread
25 |
26 |
27 | # Console Test Program
28 | hidtest: $(OBJS)
29 | $(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -o $@ $(LIBS)
30 |
31 | # Shared Libs
32 | libhidapi.so: $(COBJS)
33 | $(CC) $(LDFLAGS) -shared -Wl,-soname,$@.0 $^ -o $@ $(LIBS)
34 |
35 | # Objects
36 | $(COBJS): %.o: %.c
37 | $(CC) $(CFLAGS) -c $(INCLUDES) $< -o $@
38 |
39 | $(CPPOBJS): %.o: %.cpp
40 | $(CXX) $(CXXFLAGS) -c $(INCLUDES) $< -o $@
41 |
42 |
43 | clean:
44 | rm -f $(OBJS) hidtest libhidapi.so ../hidtest/hidtest.o
45 |
46 | .PHONY: clean libs
47 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/libusb/Makefile.linux:
--------------------------------------------------------------------------------
1 | ###########################################
2 | # Simple Makefile for HIDAPI test program
3 | #
4 | # Alan Ott
5 | # Signal 11 Software
6 | # 2010-06-01
7 | ###########################################
8 |
9 | all: hidtest-libusb libs
10 |
11 | libs: libhidapi-libusb.so
12 |
13 | CC ?= gcc
14 | CFLAGS ?= -Wall -g -fpic
15 |
16 | CXX ?= g++
17 | CXXFLAGS ?= -Wall -g -fpic
18 |
19 | LDFLAGS ?= -Wall -g
20 |
21 | COBJS_LIBUSB = hid.o
22 | COBJS = $(COBJS_LIBUSB)
23 | CPPOBJS = ../hidtest/hidtest.o
24 | OBJS = $(COBJS) $(CPPOBJS)
25 | LIBS_USB = `pkg-config libusb-1.0 --libs` -lrt -lpthread
26 | LIBS = $(LIBS_USB)
27 | INCLUDES ?= -I../hidapi `pkg-config libusb-1.0 --cflags`
28 |
29 |
30 | # Console Test Program
31 | hidtest-libusb: $(COBJS_LIBUSB) $(CPPOBJS)
32 | $(CXX) $(LDFLAGS) $^ $(LIBS_USB) -o $@
33 |
34 | # Shared Libs
35 | libhidapi-libusb.so: $(COBJS_LIBUSB)
36 | $(CC) $(LDFLAGS) $(LIBS_USB) -shared -fpic -Wl,-soname,$@.0 $^ -o $@
37 |
38 | # Objects
39 | $(COBJS): %.o: %.c
40 | $(CC) $(CFLAGS) -c $(INCLUDES) $< -o $@
41 |
42 | $(CPPOBJS): %.o: %.cpp
43 | $(CXX) $(CXXFLAGS) -c $(INCLUDES) $< -o $@
44 |
45 |
46 | clean:
47 | rm -f $(OBJS) hidtest-libusb libhidapi-libusb.so ../hidtest/hidtest.o
48 |
49 | .PHONY: clean libs
50 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/linux/.gitignore:
--------------------------------------------------------------------------------
1 | Debug
2 | Release
3 | *.exp
4 | *.ilk
5 | *.lib
6 | *.suo
7 | *.vcproj.*
8 | *.ncb
9 | *.suo
10 | *.dll
11 | *.pdb
12 | *.o
13 | *.so
14 | hidtest-hidraw
15 | .deps
16 | .libs
17 | *.lo
18 | *.la
19 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/linux/Makefile-manual:
--------------------------------------------------------------------------------
1 | ###########################################
2 | # Simple Makefile for HIDAPI test program
3 | #
4 | # Alan Ott
5 | # Signal 11 Software
6 | # 2010-06-01
7 | ###########################################
8 |
9 | all: hidtest-hidraw libs
10 |
11 | libs: libhidapi-hidraw.so
12 |
13 | CC ?= gcc
14 | CFLAGS ?= -Wall -g -fpic
15 |
16 | CXX ?= g++
17 | CXXFLAGS ?= -Wall -g -fpic
18 |
19 | LDFLAGS ?= -Wall -g
20 |
21 |
22 | COBJS = hid.o
23 | CPPOBJS = ../hidtest/hidtest.o
24 | OBJS = $(COBJS) $(CPPOBJS)
25 | LIBS_UDEV = `pkg-config libudev --libs` -lrt
26 | LIBS = $(LIBS_UDEV)
27 | INCLUDES ?= -I../hidapi `pkg-config libusb-1.0 --cflags`
28 |
29 |
30 | # Console Test Program
31 | hidtest-hidraw: $(COBJS) $(CPPOBJS)
32 | $(CXX) $(LDFLAGS) $^ $(LIBS_UDEV) -o $@
33 |
34 | # Shared Libs
35 | libhidapi-hidraw.so: $(COBJS)
36 | $(CC) $(LDFLAGS) $(LIBS_UDEV) -shared -fpic -Wl,-soname,$@.0 $^ -o $@
37 |
38 | # Objects
39 | $(COBJS): %.o: %.c
40 | $(CC) $(CFLAGS) -c $(INCLUDES) $< -o $@
41 |
42 | $(CPPOBJS): %.o: %.cpp
43 | $(CXX) $(CXXFLAGS) -c $(INCLUDES) $< -o $@
44 |
45 |
46 | clean:
47 | rm -f $(OBJS) hidtest-hidraw libhidapi-hidraw.so ../hidtest/hidtest.o
48 |
49 | .PHONY: clean libs
50 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/linux/Makefile.am:
--------------------------------------------------------------------------------
1 | lib_LTLIBRARIES = libhidapi-hidraw.la
2 | libhidapi_hidraw_la_SOURCES = hid.c
3 | libhidapi_hidraw_la_LDFLAGS = $(LTLDFLAGS)
4 | AM_CPPFLAGS = -I$(top_srcdir)/hidapi/ $(CFLAGS_HIDRAW)
5 | libhidapi_hidraw_la_LIBADD = $(LIBS_HIDRAW)
6 |
7 | hdrdir = $(includedir)/hidapi
8 | hdr_HEADERS = $(top_srcdir)/hidapi/hidapi.h
9 |
10 | EXTRA_DIST = Makefile-manual
11 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/linux/README.txt:
--------------------------------------------------------------------------------
1 |
2 | There are two implementations of HIDAPI for Linux. One (hid.c) uses the
3 | Linux hidraw driver, and the other (hid-libusb.c) uses libusb. Which one you
4 | use depends on your application. Complete functionality of the hidraw
5 | version depends on patches to the Linux kernel which are not currently in
6 | the mainline. These patches have to do with sending and receiving feature
7 | reports. The libusb implementation uses libusb to talk directly to the
8 | device, bypassing any Linux HID driver. The disadvantage of the libusb
9 | version is that it will only work with USB devices, while the hidraw
10 | implementation will work with Bluetooth devices as well.
11 |
12 | To use HIDAPI, simply drop either hid.c or hid-libusb.c into your
13 | application and build using the build parameters in the Makefile.
14 |
15 | By default, on Linux, the Makefile in this directory is configured to use
16 | the libusb implementation. To switch to the hidraw implementation, simply
17 | change hid-libusb.c to hid.c in the Makefile.
18 |
19 |
20 | Libusb Implementation notes
21 | ----------------------------
22 | For the libusb implementation, libusb-1.0 must be installed. Libusb 1.0 is
23 | different than the legacy libusb 0.1 which is installed on many systems. To
24 | install libusb-1.0 on Ubuntu and other Debian-based systems, run:
25 | sudo apt-get install libusb-1.0-0-dev
26 |
27 |
28 | Hidraw Implementation notes
29 | ----------------------------
30 | For the hidraw implementation, libudev headers and libraries are required to
31 | build hidapi programs. To install libudev libraries on Ubuntu,
32 | and other Debian-based systems, run:
33 | sudo apt-get install libudev-dev
34 |
35 | On Redhat-based systems, run the following as root:
36 | yum install libudev-devel
37 |
38 | Unfortunately, the hidraw driver, which the linux version of hidapi is based
39 | on, contains bugs in kernel versions < 2.6.36, which the client application
40 | should be aware of.
41 |
42 | Bugs (hidraw implementation only):
43 | -----------------------------------
44 | On Kernel versions < 2.6.34, if your device uses numbered reports, an extra
45 | byte will be returned at the beginning of all reports returned from read()
46 | for hidraw devices. This is worked around in the libary. No action should be
47 | necessary in the client library.
48 |
49 | On Kernel versions < 2.6.35, reports will only be sent using a Set_Report
50 | transfer on the CONTROL endpoint. No data will ever be sent on an Interrupt
51 | Out endpoint if one exists. This is fixed in 2.6.35. In 2.6.35, OUTPUT
52 | reports will be sent to the device on the first INTERRUPT OUT endpoint if it
53 | exists; If it does not exist, OUTPUT reports will be sent on the CONTROL
54 | endpoint.
55 |
56 | On Kernel versions < 2.6.36, add an extra byte containing the report number
57 | to sent reports if numbered reports are used, and the device does not
58 | contain an INTERRPUT OUT endpoint for OUTPUT transfers. For example, if
59 | your device uses numbered reports and wants to send {0x2 0xff 0xff 0xff} to
60 | the device (0x2 is the report number), you must send {0x2 0x2 0xff 0xff
61 | 0xff}. If your device has the optional Interrupt OUT endpoint, this does not
62 | apply (but really on 2.6.35 only, because 2.6.34 won't use the interrupt
63 | out endpoint).
64 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/m4/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore All, except pkg.m4, and of course this file.
2 | *
3 | !.gitignore
4 | !pkg.m4
5 | !ax_pthread.m4
6 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/mac/.gitignore:
--------------------------------------------------------------------------------
1 | Debug
2 | Release
3 | *.exp
4 | *.ilk
5 | *.lib
6 | *.suo
7 | *.vcproj.*
8 | *.ncb
9 | *.suo
10 | *.dll
11 | *.pdb
12 | *.o
13 | hidapi-hidtest
14 | .deps
15 | .libs
16 | *.la
17 | *.lo
18 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/mac/Makefile-manual:
--------------------------------------------------------------------------------
1 | ###########################################
2 | # Simple Makefile for HIDAPI test program
3 | #
4 | # Alan Ott
5 | # Signal 11 Software
6 | # 2010-07-03
7 | ###########################################
8 |
9 | all: hidtest
10 |
11 | CC=gcc
12 | CXX=g++
13 | COBJS=hid.o
14 | CPPOBJS=../hidtest/hidtest.o
15 | OBJS=$(COBJS) $(CPPOBJS)
16 | CFLAGS+=-I../hidapi -Wall -g -c
17 | LIBS=-framework IOKit -framework CoreFoundation
18 |
19 |
20 | hidtest: $(OBJS)
21 | g++ -Wall -g $^ $(LIBS) -o hidtest
22 |
23 | $(COBJS): %.o: %.c
24 | $(CC) $(CFLAGS) $< -o $@
25 |
26 | $(CPPOBJS): %.o: %.cpp
27 | $(CXX) $(CFLAGS) $< -o $@
28 |
29 | clean:
30 | rm -f *.o hidtest $(CPPOBJS)
31 |
32 | .PHONY: clean
33 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/mac/Makefile.am:
--------------------------------------------------------------------------------
1 | lib_LTLIBRARIES = libhidapi.la
2 | libhidapi_la_SOURCES = hid.c
3 | libhidapi_la_LDFLAGS = $(LTLDFLAGS)
4 | AM_CPPFLAGS = -I$(top_srcdir)/hidapi/
5 |
6 | hdrdir = $(includedir)/hidapi
7 | hdr_HEADERS = $(top_srcdir)/hidapi/hidapi.h
8 |
9 | EXTRA_DIST = Makefile-manual
10 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/pc/.gitignore:
--------------------------------------------------------------------------------
1 | *.pc
2 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/pc/hidapi-hidraw.pc.in:
--------------------------------------------------------------------------------
1 | prefix=@prefix@
2 | exec_prefix=@exec_prefix@
3 | libdir=@libdir@
4 | includedir=@includedir@
5 |
6 | Name: hidapi-hidraw
7 | Description: C Library for USB/Bluetooth HID device access from Linux, Mac OS X, FreeBSD, and Windows. This is the hidraw implementation.
8 | Version: @VERSION@
9 | Libs: -L${libdir} -lhidapi-hidraw
10 | Cflags: -I${includedir}/hidapi
11 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/pc/hidapi-libusb.pc.in:
--------------------------------------------------------------------------------
1 | prefix=@prefix@
2 | exec_prefix=@exec_prefix@
3 | libdir=@libdir@
4 | includedir=@includedir@
5 |
6 | Name: hidapi-libusb
7 | Description: C Library for USB HID device access from Linux, Mac OS X, FreeBSD, and Windows. This is the libusb implementation.
8 | Version: @VERSION@
9 | Libs: -L${libdir} -lhidapi-libusb
10 | Cflags: -I${includedir}/hidapi
11 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/pc/hidapi.pc.in:
--------------------------------------------------------------------------------
1 | prefix=@prefix@
2 | exec_prefix=@exec_prefix@
3 | libdir=@libdir@
4 | includedir=@includedir@
5 |
6 | Name: hidapi
7 | Description: C Library for USB/Bluetooth HID device access from Linux, Mac OS X, FreeBSD, and Windows.
8 | Version: @VERSION@
9 | Libs: -L${libdir} -lhidapi
10 | Cflags: -I${includedir}/hidapi
11 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/testgui/.gitignore:
--------------------------------------------------------------------------------
1 | Debug
2 | Release
3 | *.exp
4 | *.ilk
5 | *.lib
6 | *.suo
7 | *.vcproj.*
8 | *.ncb
9 | *.suo
10 | *.dll
11 | *.pdb
12 | *.o
13 | hidapi-testgui
14 | hidapi-hidraw-testgui
15 | hidapi-libusb-testgui
16 | .deps
17 | .libs
18 | *.la
19 | *.lo
20 | TestGUI.app
21 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/testgui/Makefile-manual:
--------------------------------------------------------------------------------
1 |
2 |
3 | OS=$(shell uname)
4 |
5 | ifeq ($(OS), Darwin)
6 | FILE=Makefile.mac
7 | endif
8 |
9 | ifneq (,$(findstring MINGW,$(OS)))
10 | FILE=Makefile.mingw
11 | endif
12 |
13 | ifeq ($(OS), Linux)
14 | FILE=Makefile.linux
15 | endif
16 |
17 | ifeq ($(OS), FreeBSD)
18 | FILE=Makefile.freebsd
19 | endif
20 |
21 | ifeq ($(FILE), )
22 | all:
23 | $(error Your platform ${OS} is not supported at this time.)
24 | endif
25 |
26 | include $(FILE)
27 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/testgui/Makefile.am:
--------------------------------------------------------------------------------
1 |
2 | AM_CPPFLAGS = -I$(top_srcdir)/hidapi/ $(CFLAGS_TESTGUI)
3 |
4 | if OS_LINUX
5 | ## Linux
6 | bin_PROGRAMS = hidapi-hidraw-testgui hidapi-libusb-testgui
7 |
8 | hidapi_hidraw_testgui_SOURCES = test.cpp
9 | hidapi_hidraw_testgui_LDADD = $(top_builddir)/linux/libhidapi-hidraw.la $(LIBS_TESTGUI)
10 |
11 | hidapi_libusb_testgui_SOURCES = test.cpp
12 | hidapi_libusb_testgui_LDADD = $(top_builddir)/libusb/libhidapi-libusb.la $(LIBS_TESTGUI)
13 | else
14 | ## Other OS's
15 | bin_PROGRAMS = hidapi-testgui
16 |
17 | hidapi_testgui_SOURCES = test.cpp
18 | hidapi_testgui_LDADD = $(top_builddir)/$(backend)/libhidapi.la $(LIBS_TESTGUI)
19 | endif
20 |
21 | if OS_DARWIN
22 | hidapi_testgui_SOURCES = test.cpp mac_support_cocoa.m mac_support.h
23 | # Rules for copying the binary and its dependencies into the app bundle.
24 | TestGUI.app/Contents/MacOS/hidapi-testgui$(EXEEXT): hidapi-testgui$(EXEEXT)
25 | $(srcdir)/copy_to_bundle.sh
26 |
27 | all: all-am TestGUI.app/Contents/MacOS/hidapi-testgui$(EXEEXT)
28 |
29 | endif
30 |
31 | EXTRA_DIST = \
32 | copy_to_bundle.sh \
33 | Makefile-manual \
34 | Makefile.freebsd \
35 | Makefile.linux \
36 | Makefile.mac \
37 | Makefile.mingw \
38 | TestGUI.app.in \
39 | testgui.sln \
40 | testgui.vcproj
41 |
42 | distclean-local:
43 | rm -rf TestGUI.app
44 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/testgui/Makefile.freebsd:
--------------------------------------------------------------------------------
1 | ###########################################
2 | # Simple Makefile for HIDAPI test program
3 | #
4 | # Alan Ott
5 | # Signal 11 Software
6 | # 2010-06-01
7 | ###########################################
8 |
9 | all: testgui
10 |
11 | CC=cc
12 | CXX=c++
13 | COBJS=../libusb/hid.o
14 | CPPOBJS=test.o
15 | OBJS=$(COBJS) $(CPPOBJS)
16 | CFLAGS=-I../hidapi -I/usr/local/include `fox-config --cflags` -Wall -g -c
17 | LDFLAGS= -L/usr/local/lib
18 | LIBS= -lusb -liconv `fox-config --libs` -pthread
19 |
20 |
21 | testgui: $(OBJS)
22 | $(CXX) -Wall -g $^ $(LDFLAGS) -o $@ $(LIBS)
23 |
24 | $(COBJS): %.o: %.c
25 | $(CC) $(CFLAGS) $< -o $@
26 |
27 | $(CPPOBJS): %.o: %.cpp
28 | $(CXX) $(CFLAGS) $< -o $@
29 |
30 | clean:
31 | rm *.o testgui
32 |
33 | .PHONY: clean
34 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/testgui/Makefile.linux:
--------------------------------------------------------------------------------
1 | ###########################################
2 | # Simple Makefile for HIDAPI test program
3 | #
4 | # Alan Ott
5 | # Signal 11 Software
6 | # 2010-06-01
7 | ###########################################
8 |
9 | all: testgui
10 |
11 | CC=gcc
12 | CXX=g++
13 | COBJS=../libusb/hid.o
14 | CPPOBJS=test.o
15 | OBJS=$(COBJS) $(CPPOBJS)
16 | CFLAGS=-I../hidapi -Wall -g -c `fox-config --cflags` `pkg-config libusb-1.0 --cflags`
17 | LIBS=-ludev -lrt -lpthread `fox-config --libs` `pkg-config libusb-1.0 --libs`
18 |
19 |
20 | testgui: $(OBJS)
21 | g++ -Wall -g $^ $(LIBS) -o testgui
22 |
23 | $(COBJS): %.o: %.c
24 | $(CC) $(CFLAGS) $< -o $@
25 |
26 | $(CPPOBJS): %.o: %.cpp
27 | $(CXX) $(CFLAGS) $< -o $@
28 |
29 | clean:
30 | rm *.o testgui
31 |
32 | .PHONY: clean
33 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/testgui/Makefile.mac:
--------------------------------------------------------------------------------
1 | ###########################################
2 | # Simple Makefile for HIDAPI test program
3 | #
4 | # Alan Ott
5 | # Signal 11 Software
6 | # 2010-07-03
7 | ###########################################
8 |
9 | all: hidapi-testgui
10 |
11 | CC=gcc
12 | CXX=g++
13 | COBJS=../mac/hid.o
14 | CPPOBJS=test.o
15 | OBJCOBJS=mac_support_cocoa.o
16 | OBJS=$(COBJS) $(CPPOBJS) $(OBJCOBJS)
17 | CFLAGS=-I../hidapi -Wall -g -c `fox-config --cflags`
18 | LDFLAGS=-L/usr/X11R6/lib
19 | LIBS=`fox-config --libs` -framework IOKit -framework CoreFoundation -framework Cocoa
20 |
21 |
22 | hidapi-testgui: $(OBJS) TestGUI.app
23 | g++ -Wall -g $(OBJS) $(LIBS) $(LDFLAGS) -o hidapi-testgui
24 | ./copy_to_bundle.sh
25 | #cp TestGUI.app/Contents/MacOS/hidapi-testgui TestGUI.app/Contents/MacOS/tg
26 | #cp start.sh TestGUI.app/Contents/MacOS/hidapi-testgui
27 |
28 | $(COBJS): %.o: %.c
29 | $(CC) $(CFLAGS) $< -o $@
30 |
31 | $(CPPOBJS): %.o: %.cpp
32 | $(CXX) $(CFLAGS) $< -o $@
33 |
34 | $(OBJCOBJS): %.o: %.m
35 | $(CXX) $(CFLAGS) -x objective-c++ $< -o $@
36 |
37 | TestGUI.app: TestGUI.app.in
38 | rm -Rf TestGUI.app
39 | mkdir -p TestGUI.app
40 | cp -R TestGUI.app.in/ TestGUI.app
41 |
42 | clean:
43 | rm -f $(OBJS) hidapi-testgui
44 | rm -Rf TestGUI.app
45 |
46 | .PHONY: clean
47 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/testgui/Makefile.mingw:
--------------------------------------------------------------------------------
1 | ###########################################
2 | # Simple Makefile for HIDAPI test program
3 | #
4 | # Alan Ott
5 | # Signal 11 Software
6 | # 2010-06-01
7 | ###########################################
8 |
9 | all: hidapi-testgui
10 |
11 | CC=gcc
12 | CXX=g++
13 | COBJS=../windows/hid.o
14 | CPPOBJS=test.o
15 | OBJS=$(COBJS) $(CPPOBJS)
16 | CFLAGS=-I../hidapi -I../../hidapi-externals/fox/include -g -c
17 | LIBS= -mwindows -lsetupapi -L../../hidapi-externals/fox/lib -Wl,-Bstatic -lFOX-1.6 -Wl,-Bdynamic -lgdi32 -Wl,--enable-auto-import -static-libgcc -static-libstdc++ -lkernel32
18 |
19 |
20 | hidapi-testgui: $(OBJS)
21 | g++ -g $^ $(LIBS) -o hidapi-testgui
22 |
23 | $(COBJS): %.o: %.c
24 | $(CC) $(CFLAGS) $< -o $@
25 |
26 | $(CPPOBJS): %.o: %.cpp
27 | $(CXX) $(CFLAGS) $< -o $@
28 |
29 | clean:
30 | rm -f *.o hidapi-testgui.exe
31 |
32 | .PHONY: clean
33 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/testgui/TestGUI.app.in/Contents/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleDisplayName
8 |
9 | CFBundleExecutable
10 | hidapi-testgui
11 | CFBundleIconFile
12 | Signal11.icns
13 | CFBundleIdentifier
14 | us.signal11.hidtestgui
15 | CFBundleInfoDictionaryVersion
16 | 6.0
17 | CFBundleName
18 | testgui
19 | CFBundlePackageType
20 | APPL
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | CSResourcesFileMapped
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/testgui/TestGUI.app.in/Contents/PkgInfo:
--------------------------------------------------------------------------------
1 | APPL????
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/testgui/TestGUI.app.in/Contents/Resources/English.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cortexprog/cortexprogfw/dbfc46a8dfdadb990bfa95388fb3729a3b63d752/tool/oldtool/hidapi/testgui/TestGUI.app.in/Contents/Resources/English.lproj/InfoPlist.strings
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/testgui/TestGUI.app.in/Contents/Resources/Signal11.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cortexprog/cortexprogfw/dbfc46a8dfdadb990bfa95388fb3729a3b63d752/tool/oldtool/hidapi/testgui/TestGUI.app.in/Contents/Resources/Signal11.icns
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/testgui/copy_to_bundle.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #### Configuration:
4 | # The name of the executable. It is assumed
5 | # that it is in the current working directory.
6 | EXE_NAME=hidapi-testgui
7 | # Path to the executable directory inside the bundle.
8 | # This must be an absolute path, so use $PWD.
9 | EXEPATH=$PWD/TestGUI.app/Contents/MacOS
10 | # Libraries to explicitly bundle, even though they
11 | # may not be in /opt/local. One per line. These
12 | # are used with grep, so only a portion of the name
13 | # is required. eg: libFOX, libz, etc.
14 | LIBS_TO_BUNDLE=libFOX
15 |
16 |
17 | function copydeps {
18 | local file=$1
19 | # echo "Copying deps for $file...."
20 | local BASE_OF_EXE=`basename $file`
21 |
22 | # A will contain the dependencies of this library
23 | local A=`otool -LX $file |cut -f 1 -d " "`
24 | local i
25 | for i in $A; do
26 | local BASE=`basename $i`
27 |
28 | # See if it's a lib we specifically want to bundle
29 | local bundle_this_lib=0
30 | local j
31 | for j in $LIBS_TO_BUNDLE; do
32 | echo $i |grep -q $j
33 | if [ $? -eq 0 ]; then
34 | bundle_this_lib=1
35 | echo "bundling $i because it's in the list."
36 | break;
37 | fi
38 | done
39 |
40 | # See if it's in /opt/local. Bundle all in /opt/local
41 | local isOptLocal=0
42 | echo $i |grep -q /opt/local
43 | if [ $? -eq 0 ]; then
44 | isOptLocal=1
45 | echo "bundling $i because it's in /opt/local."
46 | fi
47 |
48 | # Bundle the library
49 | if [ $isOptLocal -ne 0 ] || [ $bundle_this_lib -ne 0 ]; then
50 |
51 | # Copy the file into the bundle if it exists.
52 | if [ -f $EXEPATH/$BASE ]; then
53 | z=0
54 | else
55 | cp $i $EXEPATH
56 | chmod 755 $EXEPATH/$BASE
57 | fi
58 |
59 |
60 | # echo "$BASE_OF_EXE depends on $BASE"
61 |
62 | # Fix the paths using install_name_tool and then
63 | # call this function recursively for each dependency
64 | # of this library.
65 | if [ $BASE_OF_EXE != $BASE ]; then
66 |
67 | # Fix the paths
68 | install_name_tool -id @executable_path/$BASE $EXEPATH/$BASE
69 | install_name_tool -change $i @executable_path/$BASE $EXEPATH/$BASE_OF_EXE
70 |
71 | # Call this function (recursive) on
72 | # on each dependency of this library.
73 | copydeps $EXEPATH/$BASE
74 | fi
75 | fi
76 | done
77 | }
78 |
79 | rm -f $EXEPATH/*
80 |
81 | # Copy the binary into the bundle. Use ../libtool to do this if it's
82 | # available beacuse if $EXE_NAME was built with autotools, it will be
83 | # necessary. If ../libtool not available, just use cp to do the copy, but
84 | # only if $EXE_NAME is a binary.
85 | if [ -x ../libtool ]; then
86 | ../libtool --mode=install cp $EXE_NAME $EXEPATH
87 | else
88 | file -bI $EXE_NAME |grep binary
89 | if [ $? -ne 0 ]; then
90 | echo "There is no ../libtool and $EXE_NAME is not a binary."
91 | echo "I'm not sure what to do."
92 | exit 1
93 | else
94 | cp $EXE_NAME $EXEPATH
95 | fi
96 | fi
97 | copydeps $EXEPATH/$EXE_NAME
98 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/testgui/mac_support.h:
--------------------------------------------------------------------------------
1 | /*******************************
2 | Mac support for HID Test GUI
3 |
4 | Alan Ott
5 | Signal 11 Software
6 |
7 | *******************************/
8 |
9 | #ifndef MAC_SUPPORT_H__
10 | #define MAC_SUPPORT_H__
11 |
12 | extern "C" {
13 | void init_apple_message_system();
14 | void check_apple_events();
15 | }
16 |
17 | #endif
18 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/testgui/mac_support_cocoa.m:
--------------------------------------------------------------------------------
1 | /*******************************
2 | Mac support for HID Test GUI
3 |
4 | Alan Ott
5 | Signal 11 Software
6 | *******************************/
7 |
8 | #include
9 | #import
10 |
11 | extern FXMainWindow *g_main_window;
12 |
13 |
14 | @interface MyAppDelegate : NSObject
15 | {
16 | }
17 | @end
18 |
19 | @implementation MyAppDelegate
20 | - (void) applicationWillBecomeActive:(NSNotification*)notif
21 | {
22 | printf("WillBecomeActive\n");
23 | g_main_window->show();
24 |
25 | }
26 |
27 | - (void) applicationWillTerminate:(NSNotification*)notif
28 | {
29 | /* Doesn't get called. Not sure why */
30 | printf("WillTerminate\n");
31 | FXApp::instance()->exit();
32 | }
33 |
34 | - (NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication*)sender
35 | {
36 | /* Doesn't get called. Not sure why */
37 | printf("ShouldTerminate\n");
38 | return YES;
39 | }
40 |
41 | - (void) applicationWillHide:(NSNotification*)notif
42 | {
43 | printf("WillHide\n");
44 | g_main_window->hide();
45 | }
46 |
47 | - (void) handleQuitEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAppleEventDescriptor*)replyEvent
48 | {
49 | printf("QuitEvent\n");
50 | FXApp::instance()->exit();
51 | }
52 |
53 | @end
54 |
55 | extern "C" {
56 |
57 | void
58 | init_apple_message_system()
59 | {
60 | static MyAppDelegate *d = [MyAppDelegate new];
61 |
62 | [[NSApplication sharedApplication] setDelegate:d];
63 |
64 | /* Register for Apple Events. */
65 | /* This is from
66 | http://stackoverflow.com/questions/1768497/application-exit-event */
67 | NSAppleEventManager *aem = [NSAppleEventManager sharedAppleEventManager];
68 | [aem setEventHandler:d
69 | andSelector:@selector(handleQuitEvent:withReplyEvent:)
70 | forEventClass:kCoreEventClass andEventID:kAEQuitApplication];
71 | }
72 |
73 | void
74 | check_apple_events()
75 | {
76 | NSApplication *app = [NSApplication sharedApplication];
77 |
78 | NSAutoreleasePool *pool = [NSAutoreleasePool new];
79 | while (1) {
80 | NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
81 | untilDate:nil
82 | inMode:NSDefaultRunLoopMode
83 | dequeue:YES];
84 | if (event == NULL)
85 | break;
86 | else {
87 | //printf("Event happened: Type: %d\n", event->_type);
88 | [app sendEvent: event];
89 | }
90 | }
91 | [pool release];
92 | }
93 |
94 | } /* extern "C" */
95 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/testgui/start.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | xterm -e /Users/alan/work/hidapi/testgui/TestGUI.app/Contents/MacOS/tg
3 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/udev/99-hid.rules:
--------------------------------------------------------------------------------
1 | # This is a sample udev file for HIDAPI devices which changes the permissions
2 | # to 0666 (world readable/writable) for a specified device on Linux systems.
3 |
4 |
5 | # If you are using the libusb implementation of hidapi (hid-libusb.c), then
6 | # use something like the following line, substituting the VID and PID with
7 | # those of your device. Note that for kernels before 2.6.24, you will need
8 | # to substitute "usb" with "usb_device". It shouldn't hurt to use two lines
9 | # (one each way) for compatibility with older systems.
10 |
11 | # HIDAPI/libusb
12 | SUBSYSTEM=="usb", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="003f", MODE="0666"
13 |
14 |
15 | # If you are using the hidraw implementation, then do something like the
16 | # following, substituting the VID and PID with your device. Busnum 1 is USB.
17 |
18 | # HIDAPI/hidraw
19 | KERNEL=="hidraw*", ATTRS{busnum}=="1", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="003f", MODE="0666"
20 |
21 | # Once done, optionally rename this file for your device, and drop it into
22 | # /etc/udev/rules.d and unplug and re-plug your device. This is all that is
23 | # necessary to see the new permissions. Udev does not have to be restarted.
24 |
25 | # Note that the hexadecimal values for VID and PID are case sensitive and
26 | # must be lower case.
27 |
28 | # If you think permissions of 0666 are too loose, then see:
29 | # http://reactivated.net/writing_udev_rules.html for more information on finer
30 | # grained permission setting. For example, it might be sufficient to just
31 | # set the group or user owner for specific devices (for example the plugdev
32 | # group on some systems).
33 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/windows/.gitignore:
--------------------------------------------------------------------------------
1 | Debug
2 | Release
3 | *.exp
4 | *.ilk
5 | *.lib
6 | *.suo
7 | *.vcproj.*
8 | *.ncb
9 | *.suo
10 | *.dll
11 | *.pdb
12 | .deps
13 | .libs
14 | *.lo
15 | *.la
16 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/windows/Makefile-manual:
--------------------------------------------------------------------------------
1 |
2 |
3 | OS=$(shell uname)
4 |
5 | ifneq (,$(findstring MINGW,$(OS)))
6 | FILE=Makefile.mingw
7 | endif
8 |
9 | ifeq ($(FILE), )
10 | all:
11 | $(error Your platform ${OS} is not supported at this time.)
12 | endif
13 |
14 | include $(FILE)
15 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/windows/Makefile.am:
--------------------------------------------------------------------------------
1 | lib_LTLIBRARIES = libhidapi.la
2 | libhidapi_la_SOURCES = hid.c
3 | libhidapi_la_LDFLAGS = $(LTLDFLAGS)
4 | AM_CPPFLAGS = -I$(top_srcdir)/hidapi/
5 | libhidapi_la_LIBADD = $(LIBS)
6 |
7 | hdrdir = $(includedir)/hidapi
8 | hdr_HEADERS = $(top_srcdir)/hidapi/hidapi.h
9 |
10 | EXTRA_DIST = \
11 | ddk_build \
12 | hidapi.vcproj \
13 | hidtest.vcproj \
14 | Makefile-manual \
15 | Makefile.mingw \
16 | hidapi.sln
17 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/windows/Makefile.mingw:
--------------------------------------------------------------------------------
1 | ###########################################
2 | # Simple Makefile for HIDAPI test program
3 | #
4 | # Alan Ott
5 | # Signal 11 Software
6 | # 2010-06-01
7 | ###########################################
8 |
9 | all: hidtest libhidapi.dll
10 |
11 | CC=gcc
12 | CXX=g++
13 | COBJS=hid.o
14 | CPPOBJS=../hidtest/hidtest.o
15 | OBJS=$(COBJS) $(CPPOBJS)
16 | CFLAGS=-I../hidapi -g -c
17 | LIBS= -lsetupapi
18 | DLL_LDFLAGS = -mwindows -lsetupapi
19 |
20 | hidtest: $(OBJS)
21 | g++ -g $^ $(LIBS) -o hidtest
22 |
23 | libhidapi.dll: $(OBJS)
24 | $(CC) -g $^ $(DLL_LDFLAGS) -o libhidapi.dll
25 |
26 | $(COBJS): %.o: %.c
27 | $(CC) $(CFLAGS) $< -o $@
28 |
29 | $(CPPOBJS): %.o: %.cpp
30 | $(CXX) $(CFLAGS) $< -o $@
31 |
32 | clean:
33 | rm *.o ../hidtest/*.o hidtest.exe
34 |
35 | .PHONY: clean
36 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/windows/ddk_build/.gitignore:
--------------------------------------------------------------------------------
1 | *.log
2 | obj*_*_*
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/windows/ddk_build/hidapi.def:
--------------------------------------------------------------------------------
1 | LIBRARY hidapi
2 | EXPORTS
3 | hid_open @1
4 | hid_write @2
5 | hid_read @3
6 | hid_close @4
7 | hid_get_product_string @5
8 | hid_get_manufacturer_string @6
9 | hid_get_serial_number_string @7
10 | hid_get_indexed_string @8
11 | hid_error @9
12 | hid_set_nonblocking @10
13 | hid_enumerate @11
14 | hid_open_path @12
15 | hid_send_feature_report @13
16 | hid_get_feature_report @14
17 |
--------------------------------------------------------------------------------
/tool/oldtool/hidapi/windows/ddk_build/sources:
--------------------------------------------------------------------------------
1 | TARGETNAME=hidapi
2 | TARGETTYPE=DYNLINK
3 | UMTYPE=console
4 | UMENTRY=main
5 |
6 | MSC_WARNING_LEVEL=/W3 /WX
7 |
8 | TARGETLIBS=$(SDK_LIB_PATH)\hid.lib \
9 | $(SDK_LIB_PATH)\setupapi.lib \
10 | $(SDK_LIB_PATH)\kernel32.lib \
11 | $(SDK_LIB_PATH)\comdlg32.lib
12 |
13 | USE_MSVCRT=1
14 |
15 | INCLUDES= ..\..\hidapi
16 | SOURCES= ..\hid.c \
17 |
18 |
19 | TARGET_DESTINATION=retail
20 |
21 | MUI=0
22 | MUI_COMMENT="HID Interface DLL"
23 |
24 |
--------------------------------------------------------------------------------
/tool/oldtool/jedec.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cortexprog/cortexprogfw/dbfc46a8dfdadb990bfa95388fb3729a3b63d752/tool/oldtool/jedec.h
--------------------------------------------------------------------------------
/tool/oldtool/scriptfiles.h:
--------------------------------------------------------------------------------
1 | #ifndef _SCRIPTFILES_H_
2 | #define _SCRIPTFILES_H_
3 |
4 |
5 | #include
6 | #include
7 | #include
8 |
9 | bool scriptfileFind(uint32_t targetid, const uint32_t *cpuidRegs, uint32_t *loadSzP, uint32_t *loadAddrP, uint32_t *stageAddrP, char **cpuNameP, char** scptFileName, FILE **scptFileHandle);
10 |
11 |
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/tool/opCore.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include "ops.h"
5 |
6 | #define NONZERO_OR_MASK 0x80000000UL //we or this with our core id to make sire we get a nonnull value
7 |
8 | static void* coreOpParse(const char *argv0, int *argcP, char ***argvP, uint32_t *needFlagsP)
9 | {
10 | long long coreid;
11 |
12 | if (*argcP < 1 || 1 != sscanf((*argvP)[0], "%lli", &coreid) || coreid < 0 || coreid > 0xffff) {
13 | fprintf(stderr, " core: no valid CORE ID provided\n");
14 | return NULL;
15 | }
16 |
17 | (*argvP)++;
18 | (*argcP)--;
19 | *needFlagsP |= TOOL_OP_NEEDS_DEBUGGER | TOOL_OP_NEEDS_CPU;
20 |
21 | return (void*)(uintptr_t)(NONZERO_OR_MASK | coreid);
22 | }
23 |
24 | static bool coreOpDo(void *toolOpData, uint32_t step, uint32_t flags, struct Debugger *dbg, struct Cpu *cpu, struct Script *scpt)
25 | {
26 | uint16_t coreId = (uint16_t)(uintptr_t)toolOpData;
27 |
28 | if (step >= TOOL_OP_STEP_PRE_SCRIPT && !cpuSelectCore(cpu, coreId)) {
29 |
30 | fprintf(stderr, " core: unable to set core to 0x%04x for step %u\n", coreId, step);
31 | return false;
32 | }
33 |
34 | return true;
35 | }
36 |
37 | static void coreOpFree(void *toolOpData)
38 | {
39 | //nothing
40 | }
41 |
42 | static void coreOpHelp(const char *argv0) //help for "core"
43 | {
44 | fprintf(stderr,
45 | "USAGE: %s core \n"
46 | "\tUse a given CPU CORE to perform further operations.\n"
47 | "\tOnly useful on a multi-core chip. You can use\n"
48 | "\t'%s info' command to get a list of CORE IDs\n",
49 | argv0, argv0);
50 | }
51 |
52 | DEFINE_OP(core, coreOpParse, coreOpDo, coreOpFree, coreOpHelp);
--------------------------------------------------------------------------------
/tool/opEraseAll.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include "utilOp.h"
5 | #include "memio.h"
6 | #include "ops.h"
7 |
8 |
9 | #define NONNULL_RET_VAL ((void*)1)
10 |
11 | static void* eraseAllOpParse(const char *argv0, int *argcP, char ***argvP, uint32_t *needFlagsP)
12 | {
13 | *needFlagsP |= TOOL_OP_NEEDS_DEBUGGER | TOOL_OP_NEEDS_CPU | TOOL_OP_NEEDS_SCRIPT | TOOL_OP_NEEDS_SCPT_ERASEALL;
14 |
15 | return NONNULL_RET_VAL;
16 | }
17 |
18 | static bool eraseAllOpDo(void *toolOpData, uint32_t step, uint32_t flags, struct Debugger *dbg, struct Cpu *cpu, struct Script *scpt)
19 | {
20 | if (step == TOOL_OP_STEP_MAIN) {
21 |
22 | //do the erase
23 | fprintf(stderr, "Performing \"erase all\"...\n");
24 | if (!scriptEraseAll(scpt)) {
25 | fprintf(stderr, " eraseall: failed\n");
26 | return false;
27 | }
28 |
29 | fprintf(stderr, " done\n");
30 | }
31 |
32 | return true;
33 | }
34 |
35 | static void eraseAllOpFree(void *toolOpData)
36 | {
37 | //nothing to do here
38 | }
39 |
40 | static void eraseAllOpHelp(const char *argv0) //help for "eraseall"
41 | {
42 | fprintf(stderr,
43 | "USAGE: %s eraseall\n"
44 | "\tPerforms an \"erase all\" operation on the chip. What\n"
45 | "\tspecifically is erased depends on the chip. In most cases,\n"
46 | "\tall flash is erased. This operation will not work if your\n"
47 | "\tchip's script does not support the \"erase all\" op. In\n"
48 | "\tthat case try the \"erase\" command instead.", argv0);
49 | }
50 |
51 | DEFINE_OP(eraseall, eraseAllOpParse, eraseAllOpDo, eraseAllOpFree, eraseAllOpHelp);
--------------------------------------------------------------------------------
/tool/opHelp.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include "ops.h"
5 |
6 |
7 | struct ToolOpDataHelp {
8 | const char *argv0; //alive always and not freed/alloced by us
9 | char *cmd;
10 | };
11 |
12 | static void* helpOpParse(const char *argv0, int *argcP, char ***argvP, uint32_t *needFlagsP)
13 | {
14 | struct ToolOpDataHelp *ret = calloc(1, sizeof(struct ToolOpDataHelp));
15 |
16 | if (!ret)
17 | return NULL;
18 |
19 | if (*argcP) {
20 | ret->cmd = strdup(**argvP);
21 | *argcP = 0; //no commands allowed after help as it may not be clear if next command was param to help or an actual command
22 | }
23 | ret->argv0 = argv0;
24 | *needFlagsP = TOOL_OP_FLAG_HELP_ONLY;
25 |
26 | return ret;
27 | }
28 |
29 | static bool helpOpDo(void *toolOpData, uint32_t step, uint32_t flags, struct Debugger *dbg, struct Cpu *cpu, struct Script *scpt)
30 | {
31 | struct ToolOpDataHelp *opData = (struct ToolOpDataHelp*)toolOpData;
32 | const struct ToolOpInfo *nfo;
33 |
34 | if (step == TOOL_OP_STEP_PRE_DEBUGGER) {
35 |
36 | const char *prev = NULL;
37 |
38 | if (opData->cmd) {
39 | for (nfo = opsGetFirst(); nfo; nfo = nfo->next) {
40 | if (strcmp(nfo->name, opData->cmd))
41 | continue;
42 |
43 | nfo->toolOpHelpFn(opData->argv0);
44 | return true;
45 | }
46 | //if no command is found, default to normal help
47 | }
48 |
49 | fprintf(stderr,
50 | "USAGE: %s [command [param1 [param2 [...]]]] [command2 [...]]\n"
51 | "Commands are executed in the order they are given.\n"
52 | "KNOWN COMMANDS:\n", opData->argv0);
53 |
54 | //show them in a sorted order
55 |
56 | for (nfo = opsGetFirst(); nfo; nfo = nfo->next) {
57 |
58 | const struct ToolOpInfo *cur;
59 | const char *best = NULL;
60 |
61 | for (cur = opsGetFirst(); cur && cur->name; cur = cur->next) {
62 |
63 | if (prev && strcmp(prev, cur->name) >= 0) //should be greater than prev
64 | continue;
65 | if (best && strcmp(best, cur->name) <= 0) //should be less than best
66 | continue;
67 | best = cur->name;
68 | }
69 | fprintf(stderr, " %s\n", best);
70 | prev = best;
71 | }
72 | fprintf(stderr, "You may learn more about any command by trying:\n %s help \n", opData->argv0);
73 | }
74 |
75 | return true;
76 | }
77 |
78 | static void helpOpFree(void *toolOpData)
79 | {
80 | struct ToolOpDataHelp *opData = (struct ToolOpDataHelp*)toolOpData;
81 |
82 | free(opData->cmd);
83 | free(opData);
84 | }
85 |
86 | static void helpOpHelp(const char *argv0) //help for "help"
87 | {
88 | fprintf(stderr,
89 | "USAGE: %s help [command]\n"
90 | "\tShows the generic help info, or one for a particular command.\n", argv0);
91 | }
92 |
93 |
94 |
95 | DEFINE_OP(help, helpOpParse, helpOpDo, helpOpFree, helpOpHelp);
--------------------------------------------------------------------------------
/tool/opInfo.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include "ops.h"
5 |
6 | #define NONNULL_RET_VAL ((void*)1)
7 |
8 | static void* infoOpParse(const char *argv0, int *argcP, char ***argvP, uint32_t *needFlagsP)
9 | {
10 | *needFlagsP |= TOOL_OP_WANTS_DEBUGGER | TOOL_OP_WANTS_CPU | TOOL_OP_WANTS_SCRIPT | TOOL_OP_FLAG_SET_INFO_MODE;
11 |
12 | return NONNULL_RET_VAL;
13 | }
14 |
15 | static bool infoOpDo(void *toolOpData, uint32_t step, uint32_t flags, struct Debugger *dbg, struct Cpu *cpu, struct Script *scpt)
16 | {
17 | //nothing to do really - this op is a no-op as info is always shown
18 |
19 | return true;
20 | }
21 |
22 | static void infoOpFree(void *toolOpData)
23 | {
24 | //nothing
25 | }
26 |
27 | static void infoOpHelp(const char *argv0) //help for "info"
28 | {
29 | fprintf(stderr,
30 | "USAGE: %s info\n"
31 | "\tJust shows the information on the attached debugged chip\n", argv0);
32 | }
33 |
34 | DEFINE_OP(info, infoOpParse, infoOpDo, infoOpFree, infoOpHelp);
--------------------------------------------------------------------------------
/tool/opSpeed.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include "ops.h"
5 |
6 | //we use the top bit of the pointer for marker for speed
7 |
8 | static void* speedOpParse(const char *argv0, int *argcP, char ***argvP, uint32_t *needFlagsP)
9 | {
10 | long long clock;
11 |
12 | *needFlagsP |= TOOL_OP_NEEDS_DEBUGGER;
13 |
14 | if (!*argcP) {
15 | fprintf(stderr, " speed: \"speed\" command needs a parameter\n");
16 | return NULL;
17 | }
18 |
19 | if(1 != sscanf((*argvP)[0], "%lli", &clock) || (clock < 0) || (clock > 1000000000UL /* 1GHz is too fast anyways */)) {
20 |
21 | fprintf(stderr, " speed: given speed is invalid\n");
22 | return NULL;
23 | }
24 |
25 | (*argvP)++;
26 | (*argcP)--;
27 |
28 | return (void*)(uintptr_t)(0x80000000UL | clock);
29 | }
30 |
31 | static bool speedOpDo(void *toolOpData, uint32_t step, uint32_t flags, struct Debugger *dbg, struct Cpu *cpu, struct Script *scpt)
32 | {
33 | uint32_t resultantClock, clock = ((uint32_t)(uintptr_t)toolOpData) &~ 0x80000000UL;
34 |
35 | if (step > TOOL_OP_STEP_PRE_DEBUGGER_ID) { //for complex scenarios this makes sense - each step after debugger exists we do this
36 |
37 | if (debuggerCanSupportVariableClockSpeed(dbg)) {
38 |
39 | if (!debuggerClockCtlSet(dbg, clock, &resultantClock)) {
40 | fprintf(stderr, " speed: error setting clock speed\n");
41 | return false;
42 | }
43 | if ((flags & TOOL_OP_FLAG_INFO_MODE) && step == TOOL_OP_STEP_MAIN) //log only in main step
44 | fprintf(stderr, " speed: set clock to %u.%06uMHz (requested was %u.%06uMHz)\n", resultantClock / 1000000, resultantClock % 1000000, clock / 1000000, clock % 1000000);
45 |
46 | return true;
47 | }
48 | else {
49 |
50 | fprintf(stderr, " speed: this debugger has no software clock control.\n");
51 | return false;
52 | }
53 | }
54 |
55 | return true;
56 | }
57 |
58 | static void speedOpFree(void *toolOpData)
59 | {
60 | //nothing
61 | }
62 |
63 | static void speedOpHelp(const char *argv0) //help for "speed"
64 | {
65 | fprintf(stderr,
66 | "USAGE: %s speed CLOCKSPEED_IN_HZ\n"
67 | "\tIf the debugger is capable of clock speed control, this\n"
68 | "\tcommand controls that functionality. The parameter is the\n"
69 | "\tdesired SWD clock speed, in Hz. The earest possible speed\n"
70 | "\twill be chosen.\n", argv0);
71 | }
72 |
73 | DEFINE_OP(speed, speedOpParse, speedOpDo, speedOpFree, speedOpHelp);
--------------------------------------------------------------------------------
/tool/opTrace.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include "utilOp.h"
5 | #include "memio.h"
6 | #include "ops.h"
7 |
8 | struct ToolOpDataTrace {
9 | uint32_t addr;
10 | bool noreset;
11 | };
12 |
13 |
14 | static void* traceOpParse(const char *argv0, int *argcP, char ***argvP, uint32_t *needFlagsP)
15 | {
16 | struct ToolOpDataTrace *ret;
17 | bool noreset = false;
18 | long long vAddr;
19 |
20 | if (*argcP && !strcmp("noreset", *(*argvP))) {
21 |
22 | noreset = true;
23 | (*argvP)++;
24 | (*argcP)--;
25 | }
26 |
27 | if (!*argcP || 1 != sscanf((*argvP)[0], "%lli", &vAddr) || (vAddr & 3) || (vAddr >> 32)) {
28 |
29 | fprintf(stderr, " trace: trace mailbox address invalid or not given\n");
30 | return NULL;
31 | }
32 |
33 | (*argvP)++;
34 | (*argcP)--;
35 |
36 | *needFlagsP |= TOOL_OP_NEEDS_DEBUGGER | TOOL_OP_NEEDS_CPU;
37 |
38 | ret = malloc(sizeof(*ret));
39 | if (!ret)
40 | return NULL;
41 |
42 | ret->noreset = noreset;
43 | ret->addr = vAddr;
44 |
45 | return ret;
46 | }
47 |
48 | static bool traceOpDo(void *toolOpData, uint32_t step, uint32_t flags, struct Debugger *dbg, struct Cpu *cpu, struct Script *scpt)
49 | {
50 | struct ToolOpDataTrace *data = (struct ToolOpDataTrace*)toolOpData;
51 | uint32_t traceAddr = data->addr;
52 |
53 | if (step == TOOL_OP_STEP_MAIN) {
54 |
55 | int32_t i, nBytes;
56 | char *buf;
57 |
58 | fprintf(stderr, "TRACING using mailbox at [0x%08X]. Press [ENTER] to terminate\n", traceAddr);
59 |
60 | if (!data->noreset)
61 | (void)cpuReset(cpu);
62 |
63 | while(!utilGetKey() && (nBytes = cpuTraceLogRead(cpu, traceAddr, (void**)&buf)) >= 0) {
64 |
65 | for (i = 0; i < nBytes; i++)
66 | putchar(buf[i]);
67 |
68 | free(buf);
69 | }
70 | }
71 |
72 | return true;
73 | }
74 |
75 | static void traceOpFree(void *toolOpData)
76 | {
77 | struct ToolOpDataTrace *data = (struct ToolOpDataTrace*)toolOpData;
78 |
79 | free(data);
80 | }
81 |
82 | static void traceOpHelp(const char *argv0) //help for "trace"
83 | {
84 | fprintf(stderr,
85 | "USAGE: %s trace [\"noreset\"] trace_addr\n"
86 | "\tZeroWireTrace the running application. Use the given\n"
87 | "\taddress as the mailbox. Any writeable word in RAM or\n"
88 | "\tMMIO will do. Anytime during tracing, pressing [ENTER]\n"
89 | "\twill stop the tracing. Note that this may block the\n"
90 | "\tdebugged program. The \"noreset\" param tells CortexProg\n"
91 | "\tTo not reest the chip before starting.\n", argv0);
92 | }
93 |
94 | DEFINE_OP(trace, traceOpParse, traceOpDo, traceOpFree, traceOpHelp);
--------------------------------------------------------------------------------
/tool/script.h:
--------------------------------------------------------------------------------
1 | #ifndef _SCRIPT_H_
2 | #define _SCRIPT_H_
3 |
4 | #include
5 | #include "cpu.h"
6 |
7 | struct Script;
8 |
9 | #define SCRIPT_OP_FLAG_HAVE_ERASE_ALL 1
10 | #define SCRIPT_OP_FLAG_HAVE_ERASE_BLOCK 2
11 | #define SCRIPT_OP_FLAG_HAVE_WRITE_BLOCK 4
12 |
13 |
14 | //init and deinit
15 | struct Script* scriptLoad(struct Cpu* cpu, bool verbose);
16 | bool scriptInit(struct Script *scpt, bool verbose);
17 | void scriptFree(struct Script *scpt);
18 |
19 | //info
20 | uint32_t scriptGetFlashWriteStageAreaAddr(const struct Script *scpt); //data is cached internally by scriptInit();
21 | uint32_t scriptGetSupportedOps(const struct Script *scpt); //->{SCRIPT_OP_FLAG_HAVE_}, data is cached internally by scriptInit();
22 | bool scriptIsValidFlashRange(const struct Script *scpt, uint32_t start, uint32_t len, bool forWrites, uint32_t *suggestedLenP); //show error to stdout if len is bad and suggestedLenP == NULL, else store suggested len to suggestedLenP. Will store 0 if no possibility exists (len is too big)
23 | uint32_t scriptGetFlashBlockSize(const struct Script *scpt, uint32_t base, bool forWrites);
24 | bool scriptGetNthContiguousFlashAreaInfo(const struct Script *scpt, uint32_t n, uint32_t *areaStartP, uint32_t *areaLenP, const char **nameP); //just to get contig mem areas
25 | const char *scriptGetAreaName(const struct Script *scpt, uint32_t addr); //may be NULL
26 |
27 | //ops
28 | bool scriptEraseAll(struct Script *scpt);
29 | bool scriptEraseBlock(struct Script *scpt, uint32_t base);
30 | bool scriptWriteBlock(struct Script *scpt, uint32_t base);
31 |
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/tool/scriptfiles.h:
--------------------------------------------------------------------------------
1 | #ifndef _SCRIPTFILES_H_
2 | #define _SCRIPTFILES_H_
3 |
4 | #include
5 | #include "types.h"
6 | #include "cpu.h"
7 |
8 | //this and all its children to be freed by the caller
9 | struct PotentialScriptfile {
10 |
11 | struct PotentialScriptfile *next;
12 | uint32_t loadAddr;
13 | uint32_t loadSz;
14 | uint32_t stageAddr;
15 | char *cpuName; //user-visible cpu name
16 | char *scriptfileBaseName; //file name without path
17 | char *scriptfilePath; //full path
18 | FILE *scriptfile; //actually open FILE handle
19 | };
20 |
21 | struct PotentialScriptfile* scriptfilesFind(struct Cpu *cpu, const uint32_t *cpuidRegs);
22 |
23 |
24 |
25 | #endif
26 |
--------------------------------------------------------------------------------
/tool/types.h:
--------------------------------------------------------------------------------
1 | #ifndef _MY_TYPES_H_
2 | #define _MY_TYPES_H_
3 |
4 |
5 | #ifdef WIN32
6 | #include
7 |
8 | typedef unsigned char bool;
9 | #define false 0
10 | #define true 1
11 |
12 | typedef unsigned long long uint64_t;
13 | typedef signed long long int64_t;
14 | typedef unsigned int uint32_t;
15 | typedef signed int int32_t;
16 | typedef unsigned short uint16_t;
17 | typedef signed short int16_t;
18 | typedef unsigned char uint8_t;
19 | typedef signed char int8_t;
20 | #define inline
21 |
22 | #else
23 | #include
24 | #include
25 | #endif
26 |
27 | #endif
--------------------------------------------------------------------------------
/tool/utilOp.h:
--------------------------------------------------------------------------------
1 | #ifndef _UTIL_OP_H_
2 | #define _UTIL_OP_H_
3 |
4 | #include "script.h"
5 | #include "types.h"
6 |
7 | struct UtilProgressState {
8 | uint64_t startTime;
9 | };
10 |
11 | //find the largest flash area in the chip. Ties are settled towards the lowest-address-starting one
12 | bool utilOpFindLargestFlashArea(const struct Script *scpt, uint32_t *baseP, uint32_t *lenP);
13 |
14 | //show a progressbar
15 | void utilOpShowProgress(struct UtilProgressState *state, const char *op, uint32_t startAddr, uint32_t length, uint32_t curOfst, bool showSpeed);
16 |
17 | //nonblocking: see if stdin has a key and if so, consume it.
18 | bool utilGetKey(void);
19 |
20 | //milliseconds form an unknown starting point
21 | uint64_t getTicks(void);
22 |
23 | //file finding: paths array ends with NULL; requiredFileNameEnding can be an extension, somethign else, or NULL; callback returns false to stop
24 | typedef bool (*UtilFindFilesInPathCallbackF)(void *userData, const char *path, const char *justName);
25 | void utilFindFilesInPath(const char *const *paths, const char *requiredFileNameEnding, UtilFindFilesInPathCallbackF cbk, void *userData);
26 |
27 |
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/util.h:
--------------------------------------------------------------------------------
1 | #ifndef _UTIL_H_
2 | #define _UTIL_H_
3 |
4 | #ifndef WIN32
5 | #include
6 | #endif
7 |
8 | #ifdef D_CPU_SUPPORTS_UNALIGNED_ACCESS_
9 |
10 | typedef uint32_t unaligned_uint32_t;
11 | typedef uint16_t unaligned_uint16_t;
12 |
13 | #define WRAP_UNALIGNED_POINTER_32(_ptr) (_ptr)
14 | #define WRAP_UNALIGNED_POINTER_16(_ptr) (_ptr)
15 |
16 | #define UNALIGNED(_wrapped) (*(_wrapped))
17 |
18 | #else
19 |
20 | #pragma pack(push,1)
21 | struct UtilContainer32 {
22 | uint32_t val;
23 | };
24 | #pragma pack(pop)
25 |
26 | #pragma pack(push,1)
27 | struct UtilContainer16 {
28 | uint16_t val;
29 | };
30 | #pragma pack(pop)
31 |
32 | typedef struct UtilContainer32 unaligned_uint32_t;
33 | typedef struct UtilContainer16 unaligned_uint16_t;
34 |
35 | #define WRAP_UNALIGNED_POINTER_32(_ptr) ((unaligned_uint32_t*)(_ptr))
36 | #define WRAP_UNALIGNED_POINTER_16(_ptr) ((unaligned_uint16_t*)(_ptr))
37 |
38 | #define UNALIGNED(_wrapped) ((_wrapped)->val)
39 |
40 | #endif
41 |
42 | #define UNALIGNED_32(_ptr) UNALIGNED(WRAP_UNALIGNED_POINTER_32(_ptr))
43 | #define UNALIGNED_16(_ptr) UNALIGNED(WRAP_UNALIGNED_POINTER_16(_ptr))
44 |
45 | #endif
46 |
--------------------------------------------------------------------------------
/wire-avr-c.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "wire-avr.h"
4 | #include "wire.h"
5 |
6 | #define SWD_PORT_REG (*(volatile uint8_t*)(PORT_SWD + 0x20))
7 | #define SWD_DDR_REG (*(volatile uint8_t*)(DDR_SWD + 0x20))
8 | #define SWD_PIN_REG (*(volatile uint8_t*)(PIN_SWD + 0x20))
9 | #define SWD_MASK_IO ((uint8_t)(1 << BIT_NO_SWDIO))
10 | #define SWD_MASK_CK ((uint8_t)(1 << BIT_NO_SWDCK))
11 | #define SWD_MASK_RST ((uint8_t)(1 << BIT_NO_SWRST))
12 |
13 |
14 |
15 |
16 |
17 | static void wireSendBit(uint1_t bit)
18 | {
19 | if (bit)
20 | SWD_PORT_REG |= SWD_MASK_IO;
21 | else
22 | SWD_PORT_REG &=~ SWD_MASK_IO;
23 |
24 | SWD_PIN_REG = SWD_MASK_CK;
25 | SWD_PIN_REG = SWD_MASK_CK;
26 | }
27 |
28 |
29 | void wireInit(void)
30 | {
31 | SWD_PORT_REG |= SWD_MASK_IO | SWD_MASK_CK; //data,clock & rst idle high
32 | SWD_DDR_REG |= SWD_MASK_IO | SWD_MASK_CK; //data, rst, and clock are outputs
33 | }
34 |
35 |
36 | void wireSwdSendKey(void)
37 | {
38 | uint16_t key = 0xE79E;
39 | uint8_t i;
40 |
41 |
42 | for(i = 0; i < 64; i++)
43 | wireSendBit(1);
44 |
45 | for(i = 0; i < 16; i++, key >>= 1)
46 | wireSendBit((uint8_t)key & 1);
47 |
48 | for(i = 0; i < 64; i++)
49 | wireSendBit(1);
50 |
51 | for(i = 0; i < 8; i++)
52 | wireSendBit(0);
53 | }
54 |
--------------------------------------------------------------------------------
/wire-avr.h:
--------------------------------------------------------------------------------
1 | #ifndef _WIRE_AVR_H_
2 | #define _WIRE_AVR_H_
3 |
4 |
5 | #define BIT_NO_SWDIO 4
6 | #define BIT_NO_SWDCK 3
7 | #define PORT_SWD 0x18 /* PORTx for the SWD port, in io register numbering */
8 | #define DDR_SWD 0x17 /* DDRx for the SWD port, in io register numbering */
9 | #define PIN_SWD 0x16 /* PINx for the SWD port, in io register numbering */
10 |
11 |
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/wire.h:
--------------------------------------------------------------------------------
1 | #ifndef _WIRE_H_
2 | #define _WIRE_H_
3 |
4 | #ifndef WIN32
5 | #include
6 | #include
7 | #endif
8 | #include "util.h"
9 |
10 |
11 | typedef uint8_t uint1_t;
12 |
13 | #define BUS_SWD_ACK 1
14 | #define BUS_SWD_WAIT 2
15 | #define BUS_SWD_FAULT 4
16 | #define BUS_SWD_EMPTY 7 //if bus has nothing on it (or nothing is talking) we'll see this
17 |
18 | #define BUS_DATA_PAR_ERR 0x80 //orred with return of wireBusRead();
19 |
20 |
21 | void wireInit(void);
22 | void wireSwdSendKey(void);
23 |
24 | void wireSetResetPinVal(bool high); //reset is active low
25 |
26 | //low level funcs, do not use
27 | uint8_t llWireBusRead(uint1_t ap, uint8_t a23, unaligned_uint32_t *valP);
28 | uint8_t llWireBusWrite(uint1_t ap, uint8_t a23, uint32_t val);
29 |
30 | uint32_t wireSetClockSpeed(uint32_t speed);
31 |
32 | //even lower - do not use even more (also, not on avr at all due to avr asm code)
33 | void llWireBusWriteBits(uint32_t val, uint32_t nbits); //8..16 bits only
34 |
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------