├── .gitignore ├── COPYING ├── Firmware ├── Makefile ├── bootloader │ ├── bootloader.c │ ├── bootloader.h │ ├── crtstart.asm │ ├── flash.c │ ├── flash.h │ ├── product.mk │ ├── util.c │ └── util.h ├── dst │ ├── bootloader~hm_trp~433.hex │ ├── bootloader~hm_trp~470.hex │ ├── bootloader~hm_trp~868.hex │ ├── bootloader~hm_trp~915.hex │ ├── bootloader~rf50~433.hex │ ├── bootloader~rf50~470.hex │ ├── bootloader~rf50~868.hex │ ├── bootloader~rf50~915.hex │ ├── bootloader~rfd900a~915.hex │ ├── bootloader~rfd900~915.hex │ ├── radio~hm_trp.ihx │ ├── radio~rf50.ihx │ ├── radio~rfd900.ihx │ └── radio~rfd900a.ihx ├── include │ ├── Si1000_defs.h │ ├── board.h │ ├── board_hm_trp.h │ ├── board_info.h │ ├── board_rf50.h │ ├── board_rfd900.h │ ├── board_rfd900a.h │ ├── cdt.h │ ├── compiler_defs.h │ ├── flash_layout.h │ ├── rules.mk │ ├── rules_hm_trp.mk │ ├── rules_rf50.mk │ ├── rules_rfd900.mk │ └── rules_rfd900a.mk ├── radio │ ├── at.c │ ├── at.h │ ├── crc.c │ ├── crc.h │ ├── flash.c │ ├── flash.h │ ├── freq_hopping.c │ ├── freq_hopping.h │ ├── golay.c │ ├── golay.h │ ├── golay23.h │ ├── main.c │ ├── mavlink.c │ ├── packet.c │ ├── packet.h │ ├── parameters.c │ ├── parameters.h │ ├── printfl.c │ ├── product.mk │ ├── radio.c │ ├── radio.h │ ├── rtc.c │ ├── rtc.h │ ├── serial.c │ ├── serial.h │ ├── tdm.c │ ├── tdm.h │ ├── timer.c │ └── timer.h ├── tools │ ├── atcommander.py │ ├── check_code.py │ ├── console.py │ ├── ec2upload │ ├── hexpatch.py │ ├── mavtester.py │ ├── pattern.py │ ├── reflector.py │ ├── registers.py │ ├── sercat.py │ ├── set_speed.py │ ├── set_sreg.py │ ├── show_regs.py │ ├── show_rssi.py │ ├── update_mode.py │ └── uploader.py └── upd.sh ├── README.md └── SiKUploader ├── SiKUploader.sln ├── SiKUploader.userprefs ├── uploader.userprefs └── uploader ├── AssemblyInfo.cs ├── IHex.cs ├── Main.cs ├── MainWindow.cs ├── Mon.cs ├── SiKUploader.csproj ├── SiKUploader.pidb ├── Uploader.cs └── gtk-gui ├── generated.cs ├── gui.stetic ├── uploader.MainWindow.cs └── uploader.Mon.cs /.gitignore: -------------------------------------------------------------------------------- 1 | .metadata 2 | Firmware/bootloader/obj 3 | Firmware/radio/obj 4 | Firmware/.cproject 5 | Firmware/.project 6 | SiKUploader/uploader/bin 7 | Firmware/obj 8 | SiK_Firmware.sublime-project 9 | SiK_Firmware.sublime-workspace 10 | Firmware/Docs 11 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Michael Smith, All Rights Reserved 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | 7 | o Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | o Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 14 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 15 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 16 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 17 | COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 22 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 24 | OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /Firmware/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2011 Michael Smith, 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 6 | # are met: 7 | # 8 | # o Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # o Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in 12 | # the documentation and/or other materials provided with the distribution. 13 | # 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 17 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 18 | # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 19 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 23 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 25 | # OF THE POSSIBILITY OF SUCH DAMAGE. 26 | # 27 | 28 | # 29 | # Makefile for the SiK radio firmware. 30 | # 31 | 32 | ################################################################################ 33 | # No user-serviceable parts below 34 | ################################################################################ 35 | 36 | # 37 | # Generic actions (targets) that the user may invoke. 38 | # 39 | ACTIONS = build clean install 40 | 41 | # 42 | # Locate the root of the firmware source tree 43 | # 44 | export SRCROOT = $(dir $(lastword $(MAKEFILE_LIST))) 45 | 46 | # 47 | # Work out which board(s) we know how to support 48 | # 49 | KNOWN_BOARDS = $(patsubst rules_%.mk,%,$(notdir $(wildcard $(SRCROOT)/include/rules_*.mk))) 50 | 51 | # 52 | # Allow the user to subset the boards for which we will build. 53 | # 54 | BOARDS ?= $(KNOWN_BOARDS) 55 | ifneq ($(filter_out $(VALID_BOARDS),$(BOARDS)),) 56 | $(error One or more invalid board names in '$(BOARDS)'.) 57 | endif 58 | 59 | # 60 | # Make lists of the buildable things 61 | # 62 | # XXX radio should become firmware? 63 | # 64 | BOOTLOADERS = $(foreach board, $(BOARDS), bootloader~$(board)) 65 | FIRMWARES = $(foreach board, $(BOARDS), radio~$(board)) 66 | PRODUCTS = $(BOOTLOADERS) $(FIRMWARES) 67 | 68 | # 69 | # Build a full list of the things that may be built. 70 | # 71 | TARGETS = $(foreach action,$(ACTIONS), \ 72 | $(foreach product,$(PRODUCTS), \ 73 | $(action)~$(product))) 74 | 75 | all: build 76 | 77 | # 78 | # Composite targets for handling actions. 79 | # 80 | build: $(filter build~%,$(TARGETS)) check_code 81 | install: $(filter install~%,$(TARGETS)) 82 | clean: $(filter clean~%,$(TARGETS)) 83 | 84 | check_code: 85 | @./tools/check_code.py 86 | 87 | # 88 | # Composite target for handling the generic actions for each possible combination 89 | # of action and configuration. 90 | # 91 | $(TARGETS): config = $(subst ~, ,$@) 92 | $(TARGETS): action = $(word 1, $(config)) 93 | $(TARGETS): product = $(word 2, $(config)) 94 | $(TARGETS): board = $(word 3, $(config)) 95 | $(TARGETS): 96 | @echo % $(action) $(product) for $(board) 97 | @make -f $(product)/product.mk $(action) \ 98 | BOARD=$(board) 99 | 100 | .PHONY: $(ACTIONS) $(TARGETS) check_code 101 | 102 | help: 103 | @echo "" 104 | @echo "Build bootloaders and firmware for Si1000 radio boards." 105 | @echo "" 106 | @echo "Common targets are:" 107 | @echo "" 108 | @echo " all - Builds bootloaders and firmware, this is the" 109 | @echo " default target." 110 | @echo " bootloader - Builds the bootloader(s) specified" 111 | @echo " firmware - Builds the firmware(s) specified" 112 | @echo " clean - Cleans all build products" 113 | @echo "" 114 | @echo "A specific product may be built by selecting one or more of the following targets:" 115 | @echo "" 116 | @for i in $(TARGETS); do echo " $$i"; done 117 | @echo "" 118 | @echo "Variables may be set to control what is built:" 119 | @echo "" 120 | @echo " BOARDS - One or more board names from the list:" 121 | @echo " $(BOARDS)" 122 | @echo "" 123 | @echo "The following maintenance targets are mostly of interest to" 124 | @echo "developers:" 125 | @echo "" 126 | @echo " format - Automatically (re)formats source code to conform" 127 | @echo " to the SiK coding style. Should be used before" 128 | @echo " checking in or submitting a patch." 129 | @echo "" 130 | 131 | 132 | .PHONY: format 133 | format: 134 | astyle -r $(FMT) "*.c" "*.h" 135 | # 136 | # Below are options passed to Artistic Style for the format target 137 | # 138 | 139 | # Basic style is what AS calls K&R 140 | FMT += --style=kr 141 | 142 | # Indent using 8-space tabs 143 | FMT += --indent=tab=8 144 | 145 | # Indent multiline preprocessor blocks 146 | FMT += --indent-preprocessor 147 | 148 | # Do smart multiline expression indentation 149 | FMT += --min-conditional-indent=0 150 | 151 | # Pad conditionals and else blocks 152 | # Not sure about this one yet 153 | #FMT += --break-blocks=all 154 | 155 | # Add space padding around operators 156 | FMT += --pad-oper 157 | 158 | # Add space padding after paren headers 159 | FMT += --pad-header 160 | 161 | # Clean up excess paren padding 162 | FMT += --unpad-paren 163 | 164 | # Avoid breaking up 'clever' formatting 165 | FMT += --keep-one-line-blocks 166 | FMT += --keep-one-line-statements 167 | 168 | # * belongs with the name (looks good, but syntactically bad) 169 | FMT += --align-pointer=name 170 | 171 | # force *nix line endings 172 | FMT += --lineend=linux 173 | 174 | # ignore various things that should be ignored 175 | FMT += --ignore-exclude-errors-x 176 | FMT += --exclude=obj 177 | 178 | # ignore various files we want to be able to diff with upstream providers 179 | FMT += --exclude=Si1000_defs.h 180 | FMT += --exclude=compiler_defs.h 181 | FMT += --exclude=rtPhy.c 182 | FMT += --exclude=rtPhy.h 183 | FMT += --exclude=rtPhy_defs.h 184 | FMT += --exclude=printfl.c 185 | -------------------------------------------------------------------------------- /Firmware/bootloader/bootloader.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2011 Michael Smith, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file bootloader.h 31 | /// 32 | /// Bootloader structures and defines. 33 | /// 34 | 35 | #ifndef _BOOTLOADER_H_ 36 | #define _BOOTLOADER_H_ 37 | 38 | #include 39 | #include "cdt.h" 40 | 41 | // SiK bootloader flash update protocol. 42 | // 43 | // Command format: 44 | // 45 | // [] 46 | // 47 | // Reply format: 48 | // 49 | // [] 50 | // 51 | // The and values come from the PROTO_ defines below, 52 | // the <*_data> fields is described only for opcodes that transfer data; 53 | // in all other cases the field is omitted. 54 | // 55 | // Expected workflow is: 56 | // 57 | // GET_SYNC verify that the board is present 58 | // GET_DEVICE determine which board (select firmware to upload) 59 | // CHIP_ERASE clear the program area 60 | // loop: 61 | // LOAD_ADDRESS set address for programming fragment 62 | // loop: 63 | // PROG_MULTI program portion of fragment 64 | // loop: 65 | // LOAD_ADDRESS set address for verifying program fragment 66 | // loop: 67 | // READ_MULTI verify portion of fragment 68 | // PARAM_ERASE optional - clear flash scratch/parameter page 69 | // RESET resets chip and starts application 70 | // 71 | #define PROTO_OK 0x10 // 'ok' response 72 | #define PROTO_FAILED 0x11 // 'fail' response 73 | #define PROTO_INSYNC 0x12 // 'in sync' byte sent before status 74 | 75 | #define PROTO_EOC 0x20 // end of command 76 | #define PROTO_GET_SYNC 0x21 // NOP for re-establishing sync 77 | #define PROTO_GET_DEVICE 0x22 // get device ID bytes, : 78 | #define PROTO_CHIP_ERASE 0x23 // erase program area 79 | #define PROTO_LOAD_ADDRESS 0x24 // set next programming address : 80 | #define PROTO_PROG_FLASH 0x25 // write byte at address + increment address : 81 | #define PROTO_READ_FLASH 0x26 // read byte at address + increment address : 82 | #define PROTO_PROG_MULTI 0x27 // write bytes at address + increment : 83 | #define PROTO_READ_MULTI 0x28 // read bytes at address + increment : , : 84 | #define PROTO_PARAM_ERASE 0x29 // erase the parameter flash 85 | 86 | #define PROTO_REBOOT 0x30 // reboot the board & start the app 87 | 88 | #define PROTO_DEBUG 0x31 // emit debug information - format not defined 89 | 90 | #define PROTO_PROG_MULTI_MAX 64 // maximum PROG_MULTI size 91 | #define PROTO_READ_MULTI_MAX 255 // size of the size field 92 | 93 | #endif // _BOOTLOADER_H_ 94 | -------------------------------------------------------------------------------- /Firmware/bootloader/crtstart.asm: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; Copyright (c) 2011 Michael Smith, All Rights Reserved 3 | ;; 4 | ;; 5 | ;; Redistribution and use in source and binary forms, with or without 6 | ;; modification, are permitted provided that the following conditions 7 | ;; are met: 8 | ;; 9 | ;; o Redistributions of source code must retain the above copyright 10 | ;; notice, this list of conditions and the following disclaimer. 11 | ;; o Redistributions in binary form must reproduce the above copyright 12 | ;; notice, this list of conditions and the following disclaimer in 13 | ;; the documentation and/or other materials provided with the distribution. 14 | ;; 15 | ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | ;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | ;; FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | ;; COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | ;; INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | ;; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | ;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | ;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | ;; STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | ;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | ;; OF THE POSSIBILITY OF SUCH DAMAGE. 27 | ;; 28 | 29 | ;; 30 | ;; Modified crtstart.asm for SDCC and Si1000 bootloader 31 | ;; 32 | ;; Inspired by a post on the SiLabs forum by Tsuneo 33 | ;; 34 | 35 | .module crtstart 36 | 37 | .area HOME (CODE) 38 | .area GSINIT0 (CODE) 39 | .area GSINIT (CODE) 40 | .area GSFINAL (CODE) 41 | .area CSEG (CODE) 42 | 43 | ;; Stack segment in internal RAM 44 | 45 | .area SSEG (DATA) 46 | 47 | L__stack: 48 | .ds 1 49 | 50 | ;; Reset vector and interrupt redirection table 51 | 52 | .area HOME (CODE) 53 | 54 | __offset = 0x400 ; XXX would be nice to get this from somewhere 55 | 56 | ljmp L__start ; reset vector 57 | ljmp . + __offset ; /INT0 58 | .ds 5 59 | ljmp . + __offset ; Timer0 overflow 60 | .ds 5 61 | ljmp . + __offset ; /INT1 62 | .ds 5 63 | ljmp . + __offset ; Timer1 overflow 64 | .ds 5 65 | ljmp . + __offset ; UART0 66 | .ds 5 67 | ljmp . + __offset ; Timer2 overflow 68 | .ds 5 69 | ljmp . + __offset ; SPI0 70 | .ds 5 71 | ljmp . + __offset ; SMB0 72 | .ds 5 73 | ljmp . + __offset ; RTC alarm 74 | .ds 5 75 | ljmp . + __offset ; ADC0 comparator 76 | .ds 5 77 | ljmp . + __offset ; ADC0 conversion 78 | .ds 5 79 | ljmp . + __offset ; PCA 80 | .ds 5 81 | ljmp . + __offset ; Comparator0 82 | .ds 5 83 | ljmp . + __offset ; Comparator1 84 | .ds 5 85 | ljmp . + __offset ; Timer3 overflow 86 | .ds 5 87 | ljmp . + __offset ; VDD_MCU early warning 88 | .ds 5 89 | ljmp . + __offset ; Port Match 90 | .ds 5 91 | ljmp . + __offset ; RTC oscillator fail 92 | .ds 5 93 | ljmp . + __offset ; SPI1 94 | .ds 5 95 | 96 | ;; bootloader entry 97 | .globl _bl_main 98 | 99 | .area GSINIT0 (CODE) 100 | 101 | L__start: 102 | mov sp, #L__stack - 1 103 | lcall _bl_main 104 | sjmp . 105 | -------------------------------------------------------------------------------- /Firmware/bootloader/flash.c: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2011 Michael Smith, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file flash.c 31 | /// 32 | /// Flash memory handling 33 | /// 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | #include 40 | 41 | #include "flash.h" 42 | #include "util.h" 43 | 44 | // Place all code in the high page 45 | // 46 | #pragma codeseg HIGHCSEG 47 | 48 | /// Signature bytes at the very end of the application space. 49 | /// 50 | /// These must be supplied by the application as part of the uploaded image, 51 | /// they should be programmed last. 52 | /// 53 | __at(FLASH_SIGNATURE_BYTES) __code uint8_t flash_signature[2]; 54 | 55 | /// Lock byte 56 | /// 57 | /// We explicitly initialise the lock byte to prevent code in the high 58 | /// page from overwriting it, and clear the LSB to lock the first page 59 | /// of flash. This has the side-effect of locking the high page as well; 60 | /// combined this means that the bootloader code cannot be overwritten. 61 | /// RFD900A locks the bootloader as a separate step after calibration instead. 62 | /// 63 | #ifndef BOARD_rfd900a 64 | __at(FLASH_LOCK_BYTE) __code uint8_t flash_lock_byte = 0xfe; 65 | #endif 66 | 67 | /// Patchbay for the board frequency byte. 68 | /// This is patched in the hex file(s) after building. 69 | /// 70 | __at(FLASH_FREQUENCY_BYTE) __code uint8_t board_frequency = FREQ_NONE; 71 | 72 | char 73 | flash_app_valid(void) 74 | { 75 | return (flash_signature[0] == FLASH_SIG0) && (flash_signature[1] == FLASH_SIG1); 76 | } 77 | 78 | /// Tests whether an address is in the visible (app) range 79 | /// 80 | /// @param address The address to be tested 81 | /// @returns True if the address is visible 82 | /// 83 | static bool 84 | flash_address_visible(uint16_t address) 85 | { 86 | if ((address < FLASH_APP_START) || (address >= FLASH_INFO_PAGE)) 87 | return false; 88 | return true; 89 | } 90 | 91 | /// Load the write-enable keys into the hardware in order to enable 92 | /// one write or erase operation. 93 | /// 94 | static void 95 | flash_load_keys(void) 96 | { 97 | FLKEY = 0xa5; 98 | FLKEY = 0xf1; 99 | } 100 | 101 | void 102 | flash_erase_app(void) 103 | { 104 | uint16_t address; 105 | 106 | // start with the signature so that a partial erase will fail the signature check on startup 107 | for (address = FLASH_INFO_PAGE - FLASH_PAGE_SIZE; address >= FLASH_APP_START; address -= FLASH_PAGE_SIZE) { 108 | flash_load_keys(); 109 | PSCTL = 0x03; // set PSWE and PSEE 110 | *(uint8_t __xdata *)address = 0xff; // do the page erase 111 | PSCTL = 0x00; // disable PSWE/PSEE 112 | } 113 | } 114 | 115 | void 116 | flash_erase_scratch(void) 117 | { 118 | // erase the scratch page 119 | flash_load_keys(); // unlock flash for one operation 120 | PSCTL = 0x07; // enable flash erase of the scratch page 121 | *(uint8_t __xdata *)0 = 0xff; // trigger the erase 122 | PSCTL = 0x00; // disable flash write & scratch access 123 | } 124 | 125 | void 126 | flash_write_byte(uint16_t address, uint8_t c) 127 | { 128 | if (flash_address_visible(address)) { 129 | flash_load_keys(); 130 | PSCTL = 0x01; // set PSWE, clear PSEE 131 | *(uint8_t __xdata *)address = c; // write the byte 132 | PSCTL = 0x00; // disable PSWE/PSEE 133 | } 134 | } 135 | 136 | uint8_t 137 | flash_read_byte(uint16_t address) 138 | { 139 | return *(uint8_t __code *)address; 140 | } 141 | 142 | #ifdef BOARD_rfd900a 143 | __at(FLASH_CALIBRATION_AREA_HIGH) uint8_t __code calibration[FLASH_CALIBRATION_AREA_SIZE]; 144 | __at(FLASH_CALIBRATION_CRC_HIGH) uint8_t __code calibration_crc; 145 | 146 | void 147 | flash_transfer_calibration() 148 | { 149 | uint8_t idx, crc = 0; 150 | bool cal_empty = false; 151 | 152 | // ensure the user area (plus crc byte) is all 0xFF 153 | for (idx = 0; idx < FLASH_CALIBRATION_AREA_SIZE; idx++) 154 | { 155 | if (flash_read_byte(FLASH_CALIBRATION_AREA + idx) != 0xFF) 156 | { 157 | return; 158 | } 159 | } 160 | if (flash_read_byte(FLASH_CALIBRATION_CRC) != 0xFF) 161 | { 162 | return; 163 | } 164 | 165 | // ensure valid data is available 166 | for (idx = 0; idx < FLASH_CALIBRATION_AREA_SIZE; idx++) 167 | { 168 | crc ^= calibration[idx]; 169 | } 170 | if (crc != calibration_crc) 171 | { 172 | return; 173 | } 174 | 175 | // transfer calibration data from bootloader area to user area 176 | for (idx = 0; idx < FLASH_CALIBRATION_AREA_SIZE; idx++) 177 | { 178 | flash_write_byte((FLASH_CALIBRATION_AREA + idx), calibration[idx]); 179 | } 180 | flash_write_byte(FLASH_CALIBRATION_CRC, calibration_crc); 181 | } 182 | #endif //BOARD_rfd900a 183 | -------------------------------------------------------------------------------- /Firmware/bootloader/flash.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2011 Michael Smith, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file flash.h 31 | /// 32 | /// Flash memory related defines and prototypes. 33 | /// 34 | 35 | #ifndef _FLASH_H_ 36 | #define _FLASH_H_ 37 | 38 | #include 39 | #include 40 | 41 | #include 42 | 43 | /// Board frequency code, patched into the bootloader at build time. 44 | /// 45 | extern __at(FLASH_FREQUENCY_BYTE) __code uint8_t board_frequency; 46 | 47 | /// Checks to see whether the flash contains a valid application. 48 | /// 49 | /// @returns Nonzero if there is a valid application loaded. 50 | /// 51 | char flash_app_valid(void); 52 | 53 | /// Erases the application from flash, starting with the page containing 54 | /// the signature. 55 | /// 56 | void flash_erase_app(void); 57 | 58 | /// Erases the scratch page, where applications keep their parameters. 59 | /// 60 | void flash_erase_scratch(void); 61 | 62 | /// Writes a byte to flash. 63 | /// 64 | /// @param address The address at which to write the byte 65 | /// @param c The byte to write 66 | /// @returns True if the byte can be written 67 | /// 68 | void flash_write_byte(uint16_t address, uint8_t c); 69 | 70 | /// Reads a byte from flash 71 | /// 72 | /// @param address The address from which to read the byte. 73 | /// @returns The byte that was read. 74 | /// 75 | uint8_t flash_read_byte(uint16_t address); 76 | 77 | #ifdef BOARD_rfd900a 78 | void flash_transfer_calibration(); 79 | #endif 80 | 81 | #endif // _FLASH_H_ 82 | -------------------------------------------------------------------------------- /Firmware/bootloader/product.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2011 Michael Smith, 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 6 | # are met: 7 | # 8 | # o Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # o Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in 12 | # the documentation and/or other materials provided with the distribution. 13 | # 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 17 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 18 | # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 19 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 23 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 25 | # OF THE POSSIBILITY OF SUCH DAMAGE. 26 | # 27 | # 28 | # Makefile for the Si1000 UART bootloader. 29 | # 30 | 31 | VERSION = 1 32 | PRODUCT = bootloader~$(BOARD) 33 | PRODUCT_DIR := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) 34 | PRODUCT_INSTALL = $(foreach frequency,$(FREQUENCIES), $(OBJROOT)/$(PRODUCT)~$(frequency).hex) 35 | 36 | CFLAGS += -DBL_VERSION=$(VERSION) 37 | CFLAGS += --model-small --no-xinit-opt --opt-code-size --Werror 38 | #CFLAGS += --fverbose-asm 39 | 40 | # Set limits for the low (CSEG) and high (HIGHCSEG) code segments. 41 | # 42 | CSEG_LIMIT = $(shell printf %d 0x0400) # start of application space 43 | HIGHCSEG_LIMIT = $(shell printf %d 0xfbdc) # room for 32 calibration and four patch bytes at the end 44 | 45 | # Note that code is split into two parts; low code at 0, and high code at 0xf800. 46 | # 47 | LDFLAGS = --iram-size 256 --xram-size 4096 --stack-size 64 --nostdlib \ 48 | -Wl -bHIGHCSEG=0xf800 49 | 50 | include $(SRCROOT)/include/rules.mk 51 | 52 | # 53 | # Patch the frequency code into the hex file. 54 | # 55 | # Note that we have secret knowledge here that the frequency code byte is 56 | # located at 0xfbfe, and its specific encoding. 57 | # 58 | $(PRODUCT_INSTALL): frequency = $(basename $(word 3, $(subst ~, ,$(notdir $@)))) 59 | $(PRODUCT_INSTALL): $(PRODUCT_HEX) 60 | @echo PATCH $@ 61 | $(v)mkdir -p $(dir $@) 62 | $(v)$(SRCROOT)/tools/hexpatch.py --patch 0xfbfe:0x`expr $(frequency) / 10` $(PRODUCT_HEX) > $@ 63 | 64 | # 65 | # Check that the bootloader has not overflowed its allocated space 66 | # 67 | $(PRODUCT_INSTALL): sizecheck 68 | 69 | sizecheck: mapfile = $(subst .ihx,.map,$(PRODUCT_HEX)) 70 | sizecheck: cseg_base = $(shell printf %d 0x`grep ^CSEG $(mapfile) | cut -c 41-44`) 71 | sizecheck: cseg_size = $(shell printf %d 0x`grep ^CSEG $(mapfile) | cut -c 53-56`) 72 | sizecheck: cseg_end = $(shell expr $(cseg_base) + $(cseg_size)) 73 | sizecheck: highcseg_base = $(shell printf %d 0x`grep ^HIGHCSEG $(mapfile) | cut -c 41-44`) 74 | sizecheck: highcseg_size = $(shell printf %d 0x`grep ^HIGHCSEG $(mapfile) | cut -c 53-56`) 75 | sizecheck: highcseg_end = $(shell expr $(highcseg_base) + $(highcseg_size)) 76 | sizecheck: $(PRODUCT_HEX) 77 | @echo SIZECHECK $<: CSEG $(cseg_size) HIGHCSEG $(highcseg_size) 78 | $(v)test $(cseg_end) -lt $(CSEG_LIMIT) || (echo error: CSEG too large; exit 1) 79 | $(v)test $(highcseg_end) -lt $(HIGHCSEG_LIMIT) || (echo error: HIGHCSEG too large; exit 1) 80 | -------------------------------------------------------------------------------- /Firmware/bootloader/util.c: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2011 Michael Smith, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file util.c 31 | /// 32 | /// Miscellaneous support utilities 33 | /// 34 | 35 | #include 36 | #include 37 | 38 | #include 39 | #include 40 | 41 | #include "bootloader.h" 42 | #include "util.h" 43 | #include "flash.h" 44 | 45 | void 46 | cout(uint8_t c) 47 | { 48 | while (!TI0) 49 | ; 50 | TI0 = 0; 51 | SBUF0 = c; 52 | } 53 | 54 | uint8_t 55 | cin(void) 56 | { 57 | while (!RI0) 58 | ; 59 | RI0 = 0; 60 | return SBUF0; 61 | } 62 | -------------------------------------------------------------------------------- /Firmware/bootloader/util.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2011 Michael Smith, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file util.h 31 | /// 32 | /// Miscellaneous support utilities 33 | /// 34 | 35 | #ifndef _UTIL_H_ 36 | #define _UTIL_H_ 37 | 38 | #include 39 | #include 40 | 41 | #include "bootloader.h" 42 | 43 | /// Send a character to the UART 44 | /// 45 | void cout(uint8_t c); 46 | 47 | /// Get a character from the UART 48 | /// 49 | uint8_t cin(void); 50 | 51 | #endif // _UTIL_H_ 52 | -------------------------------------------------------------------------------- /Firmware/dst/bootloader~hm_trp~433.hex: -------------------------------------------------------------------------------- 1 | :0600000002009B02040354 2 | :03000B0002040BE1 3 | :03001300020413D1 4 | :03001B0002041BC1 5 | :03002300020423B1 6 | :03002B0002042BA1 7 | :0300330002043391 8 | :03003B0002043B81 9 | :0300430002044371 10 | :03004B0002044B61 11 | :0300530002045351 12 | :03005B0002045B41 13 | :0300630002046331 14 | :03006B0002046B21 15 | :0300730002047311 16 | :03007B0002047B01 17 | :03008300020483F1 18 | :03008B0002048BE1 19 | :03009300020493D1 20 | :08009B007581641200A380FED0 21 | :2000A300120292E5EFF56130E10375610212F800E58224FF92007562007FFF2082020562FB 22 | :2000C3008F06EE14FF70F4C296E56120E61630001374382562400D90FBFEE493F5C475C3B5 23 | :2000E300011204001200EC80FBC29612030DAF82D296BF21028017BF22028012BF23028008 24 | :200103000DBF26028008BF29028003BF310FC00712030DAE82D007BE2002800122BF2100A1 25 | :20012300500122EF24CE500122EF24DFFE240A83F582EE241583F583E4735F627581A4CE3B 26 | :20014300E5457B8181818181817C7F010101010101010201020202020202020202028275E1 27 | :20016300824E12030390FBFEE493F58212030302028212F83602028212F85C0202821203B8 28 | :200183000DAE828E6375640012030DAE828E05E44263ED426412030DAE82BE20030202829B 29 | :2001A3002212030DAF82C00712030DAE82D007BE20028001228563828564830563E4B5631A 30 | :2001C3000205648F0812F86C0202828563828564830563E4B56302056412F89612030302BF 31 | :2001E300028212030DE582FE24BF5001227D00C3ED9E5019ED2421F9C006C005C0011203DB 32 | :200203000DE582D001D005D006F70D80E2C00612030DAD82D006BD20697D00C3ED9E505FD8 33 | :200223008563828564830563E4B563020564ED2421F98708C006C00512F86CD005D0060DA3 34 | :2002430080D912030DAE82C00612030DAD82D006BD202F7D00C3ED9E5025856382856483E1 35 | :200263000563E4B563020564C006C00512F896120303D005D0060D80DC43EF10800122026E 36 | :20028300028622758212120303758210020303C2AFAFD974BF5FF5D975B64075B28F75A9E9 37 | :2002A30000758840758920758E08758D9675981275FF807E5E7F011EBEFF011FEE4F70F72F 38 | :2002C30075EF0675A41075A70F75A41075A70075E10143D40C43A404AFA474F75FF5A4AF4E 39 | :2002E300A474FB5FF5A443D56075A70F43A56075A700740F55E44407F5E4C28875E3402205 40 | :20F8000090F7FEE493FFBF3D0B90F7FFE493FFBFC20280047F0080027F018F8222AE82AF50 41 | :20F820008374FC2F500574082F5002C322D32275B7A575B7F1227E007FF4C007C00612F8E2 42 | :20F840002FD006D007758F038E828F8374FFF0758F00EF24FCFFC3940450DF2212F82F75D4 43 | :20F860008F0790000074FFF0758F0022AE82AF83C007C00612F81DD006D0075018C007C027 44 | :1BF880000612F82FD006D007758F018E828F83E508F0758F0022E493F5822247 45 | :01FBFF00FE07 46 | :01FBFE0043C3 47 | :13030300AF8210990280FB8F992210980280FB859982225F 48 | :00000001FF 49 | 50 | -------------------------------------------------------------------------------- /Firmware/dst/bootloader~hm_trp~470.hex: -------------------------------------------------------------------------------- 1 | :0600000002009B02040354 2 | :03000B0002040BE1 3 | :03001300020413D1 4 | :03001B0002041BC1 5 | :03002300020423B1 6 | :03002B0002042BA1 7 | :0300330002043391 8 | :03003B0002043B81 9 | :0300430002044371 10 | :03004B0002044B61 11 | :0300530002045351 12 | :03005B0002045B41 13 | :0300630002046331 14 | :03006B0002046B21 15 | :0300730002047311 16 | :03007B0002047B01 17 | :03008300020483F1 18 | :03008B0002048BE1 19 | :03009300020493D1 20 | :08009B007581641200A380FED0 21 | :2000A300120292E5EFF56130E10375610212F800E58224FF92007562007FFF2082020562FB 22 | :2000C3008F06EE14FF70F4C296E56120E61630001374382562400D90FBFEE493F5C475C3B5 23 | :2000E300011204001200EC80FBC29612030DAF82D296BF21028017BF22028012BF23028008 24 | :200103000DBF26028008BF29028003BF310FC00712030DAE82D007BE2002800122BF2100A1 25 | :20012300500122EF24CE500122EF24DFFE240A83F582EE241583F583E4735F627581A4CE3B 26 | :20014300E5457B8181818181817C7F010101010101010201020202020202020202028275E1 27 | :20016300824E12030390FBFEE493F58212030302028212F83602028212F85C0202821203B8 28 | :200183000DAE828E6375640012030DAE828E05E44263ED426412030DAE82BE20030202829B 29 | :2001A3002212030DAF82C00712030DAE82D007BE20028001228563828564830563E4B5631A 30 | :2001C3000205648F0812F86C0202828563828564830563E4B56302056412F89612030302BF 31 | :2001E300028212030DE582FE24BF5001227D00C3ED9E5019ED2421F9C006C005C0011203DB 32 | :200203000DE582D001D005D006F70D80E2C00612030DAD82D006BD20697D00C3ED9E505FD8 33 | :200223008563828564830563E4B563020564ED2421F98708C006C00512F86CD005D0060DA3 34 | :2002430080D912030DAE82C00612030DAD82D006BD202F7D00C3ED9E5025856382856483E1 35 | :200263000563E4B563020564C006C00512F896120303D005D0060D80DC43EF10800122026E 36 | :20028300028622758212120303758210020303C2AFAFD974BF5FF5D975B64075B28F75A9E9 37 | :2002A30000758840758920758E08758D9675981275FF807E5E7F011EBEFF011FEE4F70F72F 38 | :2002C30075EF0675A41075A70F75A41075A70075E10143D40C43A404AFA474F75FF5A4AF4E 39 | :2002E300A474FB5FF5A443D56075A70F43A56075A700740F55E44407F5E4C28875E3402205 40 | :20F8000090F7FEE493FFBF3D0B90F7FFE493FFBFC20280047F0080027F018F8222AE82AF50 41 | :20F820008374FC2F500574082F5002C322D32275B7A575B7F1227E007FF4C007C00612F8E2 42 | :20F840002FD006D007758F038E828F8374FFF0758F00EF24FCFFC3940450DF2212F82F75D4 43 | :20F860008F0790000074FFF0758F0022AE82AF83C007C00612F81DD006D0075018C007C027 44 | :1BF880000612F82FD006D007758F018E828F83E508F0758F0022E493F5822247 45 | :01FBFF00FE07 46 | :01FBFE0047BF 47 | :13030300AF8210990280FB8F992210980280FB859982225F 48 | :00000001FF 49 | 50 | -------------------------------------------------------------------------------- /Firmware/dst/bootloader~hm_trp~868.hex: -------------------------------------------------------------------------------- 1 | :0600000002009B02040354 2 | :03000B0002040BE1 3 | :03001300020413D1 4 | :03001B0002041BC1 5 | :03002300020423B1 6 | :03002B0002042BA1 7 | :0300330002043391 8 | :03003B0002043B81 9 | :0300430002044371 10 | :03004B0002044B61 11 | :0300530002045351 12 | :03005B0002045B41 13 | :0300630002046331 14 | :03006B0002046B21 15 | :0300730002047311 16 | :03007B0002047B01 17 | :03008300020483F1 18 | :03008B0002048BE1 19 | :03009300020493D1 20 | :08009B007581641200A380FED0 21 | :2000A300120292E5EFF56130E10375610212F800E58224FF92007562007FFF2082020562FB 22 | :2000C3008F06EE14FF70F4C296E56120E61630001374382562400D90FBFEE493F5C475C3B5 23 | :2000E300011204001200EC80FBC29612030DAF82D296BF21028017BF22028012BF23028008 24 | :200103000DBF26028008BF29028003BF310FC00712030DAE82D007BE2002800122BF2100A1 25 | :20012300500122EF24CE500122EF24DFFE240A83F582EE241583F583E4735F627581A4CE3B 26 | :20014300E5457B8181818181817C7F010101010101010201020202020202020202028275E1 27 | :20016300824E12030390FBFEE493F58212030302028212F83602028212F85C0202821203B8 28 | :200183000DAE828E6375640012030DAE828E05E44263ED426412030DAE82BE20030202829B 29 | :2001A3002212030DAF82C00712030DAE82D007BE20028001228563828564830563E4B5631A 30 | :2001C3000205648F0812F86C0202828563828564830563E4B56302056412F89612030302BF 31 | :2001E300028212030DE582FE24BF5001227D00C3ED9E5019ED2421F9C006C005C0011203DB 32 | :200203000DE582D001D005D006F70D80E2C00612030DAD82D006BD20697D00C3ED9E505FD8 33 | :200223008563828564830563E4B563020564ED2421F98708C006C00512F86CD005D0060DA3 34 | :2002430080D912030DAE82C00612030DAD82D006BD202F7D00C3ED9E5025856382856483E1 35 | :200263000563E4B563020564C006C00512F896120303D005D0060D80DC43EF10800122026E 36 | :20028300028622758212120303758210020303C2AFAFD974BF5FF5D975B64075B28F75A9E9 37 | :2002A30000758840758920758E08758D9675981275FF807E5E7F011EBEFF011FEE4F70F72F 38 | :2002C30075EF0675A41075A70F75A41075A70075E10143D40C43A404AFA474F75FF5A4AF4E 39 | :2002E300A474FB5FF5A443D56075A70F43A56075A700740F55E44407F5E4C28875E3402205 40 | :20F8000090F7FEE493FFBF3D0B90F7FFE493FFBFC20280047F0080027F018F8222AE82AF50 41 | :20F820008374FC2F500574082F5002C322D32275B7A575B7F1227E007FF4C007C00612F8E2 42 | :20F840002FD006D007758F038E828F8374FFF0758F00EF24FCFFC3940450DF2212F82F75D4 43 | :20F860008F0790000074FFF0758F0022AE82AF83C007C00612F81DD006D0075018C007C027 44 | :1BF880000612F82FD006D007758F018E828F83E508F0758F0022E493F5822247 45 | :01FBFF00FE07 46 | :01FBFE008680 47 | :13030300AF8210990280FB8F992210980280FB859982225F 48 | :00000001FF 49 | 50 | -------------------------------------------------------------------------------- /Firmware/dst/bootloader~hm_trp~915.hex: -------------------------------------------------------------------------------- 1 | :0600000002009B02040354 2 | :03000B0002040BE1 3 | :03001300020413D1 4 | :03001B0002041BC1 5 | :03002300020423B1 6 | :03002B0002042BA1 7 | :0300330002043391 8 | :03003B0002043B81 9 | :0300430002044371 10 | :03004B0002044B61 11 | :0300530002045351 12 | :03005B0002045B41 13 | :0300630002046331 14 | :03006B0002046B21 15 | :0300730002047311 16 | :03007B0002047B01 17 | :03008300020483F1 18 | :03008B0002048BE1 19 | :03009300020493D1 20 | :08009B007581641200A380FED0 21 | :2000A300120292E5EFF56130E10375610212F800E58224FF92007562007FFF2082020562FB 22 | :2000C3008F06EE14FF70F4C296E56120E61630001374382562400D90FBFEE493F5C475C3B5 23 | :2000E300011204001200EC80FBC29612030DAF82D296BF21028017BF22028012BF23028008 24 | :200103000DBF26028008BF29028003BF310FC00712030DAE82D007BE2002800122BF2100A1 25 | :20012300500122EF24CE500122EF24DFFE240A83F582EE241583F583E4735F627581A4CE3B 26 | :20014300E5457B8181818181817C7F010101010101010201020202020202020202028275E1 27 | :20016300824E12030390FBFEE493F58212030302028212F83602028212F85C0202821203B8 28 | :200183000DAE828E6375640012030DAE828E05E44263ED426412030DAE82BE20030202829B 29 | :2001A3002212030DAF82C00712030DAE82D007BE20028001228563828564830563E4B5631A 30 | :2001C3000205648F0812F86C0202828563828564830563E4B56302056412F89612030302BF 31 | :2001E300028212030DE582FE24BF5001227D00C3ED9E5019ED2421F9C006C005C0011203DB 32 | :200203000DE582D001D005D006F70D80E2C00612030DAD82D006BD20697D00C3ED9E505FD8 33 | :200223008563828564830563E4B563020564ED2421F98708C006C00512F86CD005D0060DA3 34 | :2002430080D912030DAE82C00612030DAD82D006BD202F7D00C3ED9E5025856382856483E1 35 | :200263000563E4B563020564C006C00512F896120303D005D0060D80DC43EF10800122026E 36 | :20028300028622758212120303758210020303C2AFAFD974BF5FF5D975B64075B28F75A9E9 37 | :2002A30000758840758920758E08758D9675981275FF807E5E7F011EBEFF011FEE4F70F72F 38 | :2002C30075EF0675A41075A70F75A41075A70075E10143D40C43A404AFA474F75FF5A4AF4E 39 | :2002E300A474FB5FF5A443D56075A70F43A56075A700740F55E44407F5E4C28875E3402205 40 | :20F8000090F7FEE493FFBF3D0B90F7FFE493FFBFC20280047F0080027F018F8222AE82AF50 41 | :20F820008374FC2F500574082F5002C322D32275B7A575B7F1227E007FF4C007C00612F8E2 42 | :20F840002FD006D007758F038E828F8374FFF0758F00EF24FCFFC3940450DF2212F82F75D4 43 | :20F860008F0790000074FFF0758F0022AE82AF83C007C00612F81DD006D0075018C007C027 44 | :1BF880000612F82FD006D007758F018E828F83E508F0758F0022E493F5822247 45 | :01FBFF00FE07 46 | :01FBFE009175 47 | :13030300AF8210990280FB8F992210980280FB859982225F 48 | :00000001FF 49 | 50 | -------------------------------------------------------------------------------- /Firmware/dst/bootloader~rf50~433.hex: -------------------------------------------------------------------------------- 1 | :0600000002009B02040354 2 | :03000B0002040BE1 3 | :03001300020413D1 4 | :03001B0002041BC1 5 | :03002300020423B1 6 | :03002B0002042BA1 7 | :0300330002043391 8 | :03003B0002043B81 9 | :0300430002044371 10 | :03004B0002044B61 11 | :0300530002045351 12 | :03005B0002045B41 13 | :0300630002046331 14 | :03006B0002046B21 15 | :0300730002047311 16 | :03007B0002047B01 17 | :03008300020483F1 18 | :03008B0002048BE1 19 | :03009300020493D1 20 | :08009B007581641200A380FED0 21 | :2000A300120292E5EFF56130E10375610212F800E58224FF92007562007FFF2086020562F7 22 | :2000C3008F06EE14FF70F4C2A0E56120E61630001374382562400D90FBFEE493F5C475C3AB 23 | :2000E300011204001200EC80FBC2A01202FFAF82D2A0BF21028017BF22028012BF23028003 24 | :200103000DBF26028008BF29028003BF310FC0071202FFAE82D007BE2002800122BF2100B0 25 | :20012300500122EF24CE500122EF24DFFE240A83F582EE241583F583E4735F627581A4CE3B 26 | :20014300E5457B8181818181817C7F010101010101010201020202020202020202028275E1 27 | :20016300824D1202F590FBFEE493F5821202F502028212F83602028212F85C0202821202D8 28 | :20018300FFAE828E637564001202FFAE828E05E44263ED42641202FFAE82BE2003020282C7 29 | :2001A300221202FFAF82C0071202FFAE82D007BE20028001228563828564830563E4B56338 30 | :2001C3000205648F0812F86C0202828563828564830563E4B56302056412F8961202F502CE 31 | :2001E30002821202FFE582FE24BF5001227D00C3ED9E5019ED2421F9C006C005C0011202EB 32 | :20020300FFE582D001D005D006F70D80E2C0061202FFAD82D006BD20697D00C3ED9E505FF5 33 | :200223008563828564830563E4B563020564ED2421F98708C006C00512F86CD005D0060DA3 34 | :2002430080D91202FFAE82C0061202FFAD82D006BD202F7D00C3ED9E5025856382856483FF 35 | :200263000563E4B563020564C006C00512F8961202F5D005D0060D80DC43EF10800122027D 36 | :200283000286227582121202F57582100202F5C2AFAFD974BF5FF5D975B64075B28F75A907 37 | :2002A30000758840758920758E08758D9675981275FF807E5E7F011EBEFF011FEE4F70F72F 38 | :2002C30075EF0675A41075A70F75A41075A70075E10143D44043D56043D62175A70F43A6A4 39 | :1202E3002175A700740F55E44407F5E4C28875E34022E8 40 | :20F8000090F7FEE493FFBF3D0B90F7FFE493FFBFC20280047F0080027F018F8222AE82AF50 41 | :20F820008374FC2F500574082F5002C322D32275B7A575B7F1227E007FF4C007C00612F8E2 42 | :20F840002FD006D007758F038E828F8374FFF0758F00EF24FCFFC3940450DF2212F82F75D4 43 | :20F860008F0790000074FFF0758F0022AE82AF83C007C00612F81DD006D0075018C007C027 44 | :1BF880000612F82FD006D007758F018E828F83E508F0758F0022E493F5822247 45 | :01FBFF00FE07 46 | :01FBFE0043C3 47 | :1302F500AF8210990280FB8F992210980280FB859982226E 48 | :00000001FF 49 | 50 | -------------------------------------------------------------------------------- /Firmware/dst/bootloader~rf50~470.hex: -------------------------------------------------------------------------------- 1 | :0600000002009B02040354 2 | :03000B0002040BE1 3 | :03001300020413D1 4 | :03001B0002041BC1 5 | :03002300020423B1 6 | :03002B0002042BA1 7 | :0300330002043391 8 | :03003B0002043B81 9 | :0300430002044371 10 | :03004B0002044B61 11 | :0300530002045351 12 | :03005B0002045B41 13 | :0300630002046331 14 | :03006B0002046B21 15 | :0300730002047311 16 | :03007B0002047B01 17 | :03008300020483F1 18 | :03008B0002048BE1 19 | :03009300020493D1 20 | :08009B007581641200A380FED0 21 | :2000A300120292E5EFF56130E10375610212F800E58224FF92007562007FFF2086020562F7 22 | :2000C3008F06EE14FF70F4C2A0E56120E61630001374382562400D90FBFEE493F5C475C3AB 23 | :2000E300011204001200EC80FBC2A01202FFAF82D2A0BF21028017BF22028012BF23028003 24 | :200103000DBF26028008BF29028003BF310FC0071202FFAE82D007BE2002800122BF2100B0 25 | :20012300500122EF24CE500122EF24DFFE240A83F582EE241583F583E4735F627581A4CE3B 26 | :20014300E5457B8181818181817C7F010101010101010201020202020202020202028275E1 27 | :20016300824D1202F590FBFEE493F5821202F502028212F83602028212F85C0202821202D8 28 | :20018300FFAE828E637564001202FFAE828E05E44263ED42641202FFAE82BE2003020282C7 29 | :2001A300221202FFAF82C0071202FFAE82D007BE20028001228563828564830563E4B56338 30 | :2001C3000205648F0812F86C0202828563828564830563E4B56302056412F8961202F502CE 31 | :2001E30002821202FFE582FE24BF5001227D00C3ED9E5019ED2421F9C006C005C0011202EB 32 | :20020300FFE582D001D005D006F70D80E2C0061202FFAD82D006BD20697D00C3ED9E505FF5 33 | :200223008563828564830563E4B563020564ED2421F98708C006C00512F86CD005D0060DA3 34 | :2002430080D91202FFAE82C0061202FFAD82D006BD202F7D00C3ED9E5025856382856483FF 35 | :200263000563E4B563020564C006C00512F8961202F5D005D0060D80DC43EF10800122027D 36 | :200283000286227582121202F57582100202F5C2AFAFD974BF5FF5D975B64075B28F75A907 37 | :2002A30000758840758920758E08758D9675981275FF807E5E7F011EBEFF011FEE4F70F72F 38 | :2002C30075EF0675A41075A70F75A41075A70075E10143D44043D56043D62175A70F43A6A4 39 | :1202E3002175A700740F55E44407F5E4C28875E34022E8 40 | :20F8000090F7FEE493FFBF3D0B90F7FFE493FFBFC20280047F0080027F018F8222AE82AF50 41 | :20F820008374FC2F500574082F5002C322D32275B7A575B7F1227E007FF4C007C00612F8E2 42 | :20F840002FD006D007758F038E828F8374FFF0758F00EF24FCFFC3940450DF2212F82F75D4 43 | :20F860008F0790000074FFF0758F0022AE82AF83C007C00612F81DD006D0075018C007C027 44 | :1BF880000612F82FD006D007758F018E828F83E508F0758F0022E493F5822247 45 | :01FBFF00FE07 46 | :01FBFE0047BF 47 | :1302F500AF8210990280FB8F992210980280FB859982226E 48 | :00000001FF 49 | 50 | -------------------------------------------------------------------------------- /Firmware/dst/bootloader~rf50~868.hex: -------------------------------------------------------------------------------- 1 | :0600000002009B02040354 2 | :03000B0002040BE1 3 | :03001300020413D1 4 | :03001B0002041BC1 5 | :03002300020423B1 6 | :03002B0002042BA1 7 | :0300330002043391 8 | :03003B0002043B81 9 | :0300430002044371 10 | :03004B0002044B61 11 | :0300530002045351 12 | :03005B0002045B41 13 | :0300630002046331 14 | :03006B0002046B21 15 | :0300730002047311 16 | :03007B0002047B01 17 | :03008300020483F1 18 | :03008B0002048BE1 19 | :03009300020493D1 20 | :08009B007581641200A380FED0 21 | :2000A300120292E5EFF56130E10375610212F800E58224FF92007562007FFF2086020562F7 22 | :2000C3008F06EE14FF70F4C2A0E56120E61630001374382562400D90FBFEE493F5C475C3AB 23 | :2000E300011204001200EC80FBC2A01202FFAF82D2A0BF21028017BF22028012BF23028003 24 | :200103000DBF26028008BF29028003BF310FC0071202FFAE82D007BE2002800122BF2100B0 25 | :20012300500122EF24CE500122EF24DFFE240A83F582EE241583F583E4735F627581A4CE3B 26 | :20014300E5457B8181818181817C7F010101010101010201020202020202020202028275E1 27 | :20016300824D1202F590FBFEE493F5821202F502028212F83602028212F85C0202821202D8 28 | :20018300FFAE828E637564001202FFAE828E05E44263ED42641202FFAE82BE2003020282C7 29 | :2001A300221202FFAF82C0071202FFAE82D007BE20028001228563828564830563E4B56338 30 | :2001C3000205648F0812F86C0202828563828564830563E4B56302056412F8961202F502CE 31 | :2001E30002821202FFE582FE24BF5001227D00C3ED9E5019ED2421F9C006C005C0011202EB 32 | :20020300FFE582D001D005D006F70D80E2C0061202FFAD82D006BD20697D00C3ED9E505FF5 33 | :200223008563828564830563E4B563020564ED2421F98708C006C00512F86CD005D0060DA3 34 | :2002430080D91202FFAE82C0061202FFAD82D006BD202F7D00C3ED9E5025856382856483FF 35 | :200263000563E4B563020564C006C00512F8961202F5D005D0060D80DC43EF10800122027D 36 | :200283000286227582121202F57582100202F5C2AFAFD974BF5FF5D975B64075B28F75A907 37 | :2002A30000758840758920758E08758D9675981275FF807E5E7F011EBEFF011FEE4F70F72F 38 | :2002C30075EF0675A41075A70F75A41075A70075E10143D44043D56043D62175A70F43A6A4 39 | :1202E3002175A700740F55E44407F5E4C28875E34022E8 40 | :20F8000090F7FEE493FFBF3D0B90F7FFE493FFBFC20280047F0080027F018F8222AE82AF50 41 | :20F820008374FC2F500574082F5002C322D32275B7A575B7F1227E007FF4C007C00612F8E2 42 | :20F840002FD006D007758F038E828F8374FFF0758F00EF24FCFFC3940450DF2212F82F75D4 43 | :20F860008F0790000074FFF0758F0022AE82AF83C007C00612F81DD006D0075018C007C027 44 | :1BF880000612F82FD006D007758F018E828F83E508F0758F0022E493F5822247 45 | :01FBFF00FE07 46 | :01FBFE008680 47 | :1302F500AF8210990280FB8F992210980280FB859982226E 48 | :00000001FF 49 | 50 | -------------------------------------------------------------------------------- /Firmware/dst/bootloader~rf50~915.hex: -------------------------------------------------------------------------------- 1 | :0600000002009B02040354 2 | :03000B0002040BE1 3 | :03001300020413D1 4 | :03001B0002041BC1 5 | :03002300020423B1 6 | :03002B0002042BA1 7 | :0300330002043391 8 | :03003B0002043B81 9 | :0300430002044371 10 | :03004B0002044B61 11 | :0300530002045351 12 | :03005B0002045B41 13 | :0300630002046331 14 | :03006B0002046B21 15 | :0300730002047311 16 | :03007B0002047B01 17 | :03008300020483F1 18 | :03008B0002048BE1 19 | :03009300020493D1 20 | :08009B007581641200A380FED0 21 | :2000A300120292E5EFF56130E10375610212F800E58224FF92007562007FFF2086020562F7 22 | :2000C3008F06EE14FF70F4C2A0E56120E61630001374382562400D90FBFEE493F5C475C3AB 23 | :2000E300011204001200EC80FBC2A01202FFAF82D2A0BF21028017BF22028012BF23028003 24 | :200103000DBF26028008BF29028003BF310FC0071202FFAE82D007BE2002800122BF2100B0 25 | :20012300500122EF24CE500122EF24DFFE240A83F582EE241583F583E4735F627581A4CE3B 26 | :20014300E5457B8181818181817C7F010101010101010201020202020202020202028275E1 27 | :20016300824D1202F590FBFEE493F5821202F502028212F83602028212F85C0202821202D8 28 | :20018300FFAE828E637564001202FFAE828E05E44263ED42641202FFAE82BE2003020282C7 29 | :2001A300221202FFAF82C0071202FFAE82D007BE20028001228563828564830563E4B56338 30 | :2001C3000205648F0812F86C0202828563828564830563E4B56302056412F8961202F502CE 31 | :2001E30002821202FFE582FE24BF5001227D00C3ED9E5019ED2421F9C006C005C0011202EB 32 | :20020300FFE582D001D005D006F70D80E2C0061202FFAD82D006BD20697D00C3ED9E505FF5 33 | :200223008563828564830563E4B563020564ED2421F98708C006C00512F86CD005D0060DA3 34 | :2002430080D91202FFAE82C0061202FFAD82D006BD202F7D00C3ED9E5025856382856483FF 35 | :200263000563E4B563020564C006C00512F8961202F5D005D0060D80DC43EF10800122027D 36 | :200283000286227582121202F57582100202F5C2AFAFD974BF5FF5D975B64075B28F75A907 37 | :2002A30000758840758920758E08758D9675981275FF807E5E7F011EBEFF011FEE4F70F72F 38 | :2002C30075EF0675A41075A70F75A41075A70075E10143D44043D56043D62175A70F43A6A4 39 | :1202E3002175A700740F55E44407F5E4C28875E34022E8 40 | :20F8000090F7FEE493FFBF3D0B90F7FFE493FFBFC20280047F0080027F018F8222AE82AF50 41 | :20F820008374FC2F500574082F5002C322D32275B7A575B7F1227E007FF4C007C00612F8E2 42 | :20F840002FD006D007758F038E828F8374FFF0758F00EF24FCFFC3940450DF2212F82F75D4 43 | :20F860008F0790000074FFF0758F0022AE82AF83C007C00612F81DD006D0075018C007C027 44 | :1BF880000612F82FD006D007758F018E828F83E508F0758F0022E493F5822247 45 | :01FBFF00FE07 46 | :01FBFE009175 47 | :1302F500AF8210990280FB8F992210980280FB859982226E 48 | :00000001FF 49 | 50 | -------------------------------------------------------------------------------- /Firmware/dst/bootloader~rfd900a~915.hex: -------------------------------------------------------------------------------- 1 | :0600000002009B02040354 2 | :03000B0002040BE1 3 | :03001300020413D1 4 | :03001B0002041BC1 5 | :03002300020423B1 6 | :03002B0002042BA1 7 | :0300330002043391 8 | :03003B0002043B81 9 | :0300430002044371 10 | :03004B0002044B61 11 | :0300530002045351 12 | :03005B0002045B41 13 | :0300630002046331 14 | :03006B0002046B21 15 | :0300730002047311 16 | :03007B0002047B01 17 | :03008300020483F1 18 | :03008B0002048BE1 19 | :03009300020493D1 20 | :08009B007581641200A380FED0 21 | :2000A300120295E5EFF56130E10375610212F800E58224FF92007562007FFF2082020562F8 22 | :2000C3008F06EE14FF70F4D296E56120E61930001674382562401012F89B90FBFEE493F5F3 23 | :2000E300C475C3011204001200EF80FBD29612030DAF82C296BF21028017BF22028012BFAE 24 | :200103002302800DBF26028008BF29028003BF310FC00712030DAE82D007BE2002800122DC 25 | :20012300BF2100500122EF24CE500122EF24DFFE240A83F582EE241583F583E47362657845 26 | :2001430084A7D1E8487E8484848484847F82010101010101010201020202020202020202BD 27 | :20016300028575824312030390FBFEE493F58212030302028512F83602028512F85C020258 28 | :200183008512030DAE828E6375640012030DAE828E05E44263ED426412030DAE82BE200387 29 | :2001A3000202852212030DAF82C00712030DAE82D007BE200280012285638285648305638D 30 | :2001C300E4B5630205648F0812F86C0202858563828564830563E4B56302056412F89612C8 31 | :2001E300030302028512030DE582FE24BF5001227D00C3ED9E5019ED2421F9C006C005C0E6 32 | :200203000112030DE582D001D005D006F70D80E2C00612030DAD82D006BD20697D00C3ED0F 33 | :200223009E505F8563828564830563E4B563020564ED2421F98708C006C00512F86CD00539 34 | :20024300D0060D80D912030DAE82C00612030DAD82D006BD202F7D00C3ED9E50258563826A 35 | :200263008564830563E4B563020564C006C00512F896120303D005D0060D80DC43EF108027 36 | :20028300012202028922758212120303758210020303C2AFAFD974BF5FF5D975B64075B26E 37 | :2002A3008F75A900758840758920758E08758D9675981275FF807E5E7F011EBEFF011FEE38 38 | :2002C3004F70F775EF0675A41075A70F75A41075A70075E10143D4CF43D578E5D675D6FF90 39 | :2002E30075A70F43A5F543A5F543A62043A62075A700740F55E44407F5E4C28875E3402204 40 | :20F8000090F7FEE493FFBF3D0B90F7FFE493FFBFC20280047F0080027F018F8222AE82AF50 41 | :20F820008374FC2F500574082F5002C322D32275B7A575B7F1227E007FF4C007C00612F8E2 42 | :20F840002FD006D007758F038E828F8374FFF0758F00EF24FCFFC3940450DF2212F82F75D4 43 | :20F860008F0790000074FFF0758F0022AE82AF83C007C00612F81DD006D0075018C007C027 44 | :20F880000612F82FD006D007758F018E828F83E508F0758F0022E493F582227F007E008EB7 45 | :20F8A000047D0074DE2CF58274F73DF583C007C00612F896AD82D006D007BDFF0280012248 46 | :20F8C0000EBE1F0040D990F7FDC00712F896AE82D007BEFF4D7E00EE90FBDE93FD62070E4C 47 | :20F8E000BE1F0040F290FBFDE493FEEFB506337F008F057E0074DE2DFD74F73EFEEF90FBF1 48 | :20F90000DE93F5088D828E83C00712F86CD0070FBF1F0040DC90FBFDE493F50890F7FD02BA 49 | :03F92000F86C225E 50 | :01FBFE009175 51 | :13030300AF8210990280FB8F992210980280FB859982225F 52 | :00000001FF 53 | 54 | -------------------------------------------------------------------------------- /Firmware/dst/bootloader~rfd900~915.hex: -------------------------------------------------------------------------------- 1 | :0600000002009B02040354 2 | :03000B0002040BE1 3 | :03001300020413D1 4 | :03001B0002041BC1 5 | :03002300020423B1 6 | :03002B0002042BA1 7 | :0300330002043391 8 | :03003B0002043B81 9 | :0300430002044371 10 | :03004B0002044B61 11 | :0300530002045351 12 | :03005B0002045B41 13 | :0300630002046331 14 | :03006B0002046B21 15 | :0300730002047311 16 | :03007B0002047B01 17 | :03008300020483F1 18 | :03008B0002048BE1 19 | :03009300020493D1 20 | :08009B007581641200A380FED0 21 | :2000A300120292E5EFF56130E10375610212F800E58224FF92007562007FFF2082020562FB 22 | :2000C3008F06EE14FF70F4D296E56120E61630001374382562400D90FBFEE493F5C475C3A5 23 | :2000E300011204001200EC80FBD2961202FFAF82C296BF21028017BF22028012BF23028017 24 | :200103000DBF26028008BF29028003BF310FC0071202FFAE82D007BE2002800122BF2100B0 25 | :20012300500122EF24CE500122EF24DFFE240A83F582EE241583F583E4735F627581A4CE3B 26 | :20014300E5457B8181818181817C7F010101010101010201020202020202020202028275E1 27 | :2001630082421202F590FBFEE493F5821202F502028212F83602028212F85C0202821202E3 28 | :20018300FFAE828E637564001202FFAE828E05E44263ED42641202FFAE82BE2003020282C7 29 | :2001A300221202FFAF82C0071202FFAE82D007BE20028001228563828564830563E4B56338 30 | :2001C3000205648F0812F86C0202828563828564830563E4B56302056412F8961202F502CE 31 | :2001E30002821202FFE582FE24BF5001227D00C3ED9E5019ED2421F9C006C005C0011202EB 32 | :20020300FFE582D001D005D006F70D80E2C0061202FFAD82D006BD20697D00C3ED9E505FF5 33 | :200223008563828564830563E4B563020564ED2421F98708C006C00512F86CD005D0060DA3 34 | :2002430080D91202FFAE82C0061202FFAD82D006BD202F7D00C3ED9E5025856382856483FF 35 | :200263000563E4B563020564C006C00512F8961202F5D005D0060D80DC43EF10800122027D 36 | :200283000286227582121202F57582100202F5C2AFAFD974BF5FF5D975B64075B28F75A907 37 | :2002A30000758840758920758E08758D9675981275FF807E5E7F011EBEFF011FEE4F70F72F 38 | :2002C30075EF0675A41075A70F75A41075A70075E10143D40C43D5E075A70F43A5F543A5B6 39 | :1202E300F575A700740F55E44407F5E4C28875E3402214 40 | :20F8000090F7FEE493FFBF3D0B90F7FFE493FFBFC20280047F0080027F018F8222AE82AF50 41 | :20F820008374FC2F500574082F5002C322D32275B7A575B7F1227E007FF4C007C00612F8E2 42 | :20F840002FD006D007758F038E828F8374FFF0758F00EF24FCFFC3940450DF2212F82F75D4 43 | :20F860008F0790000074FFF0758F0022AE82AF83C007C00612F81DD006D0075018C007C027 44 | :1BF880000612F82FD006D007758F018E828F83E508F0758F0022E493F5822247 45 | :01FBFF00FE07 46 | :01FBFE009175 47 | :1302F500AF8210990280FB8F992210980280FB859982226E 48 | :00000001FF 49 | 50 | -------------------------------------------------------------------------------- /Firmware/include/board.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2011 Michael Smith, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file board.h 31 | /// 32 | /// Includes the board-specific configuration header. 33 | /// 34 | /// The following options may (or if required, should) be defined 35 | /// 36 | /// BOARD_ID [required] 37 | /// A unique byte identifying the board. 38 | /// 39 | /// BOARD_NAME [required] 40 | /// A short text string giving the name of the board. 41 | /// 42 | /// LED_BOOTLOADER [required] 43 | /// A __bit controlling an LED for the bootloader. The bootloader 44 | /// will light this LED while waiting for input. 45 | /// 46 | /// LED_RADIO [required] 47 | /// A __bit controlling an LED for the radio. The radio will light 48 | /// this LED while running. 49 | /// 50 | /// LED_ACTIVITY [required] 51 | /// A __bit controlling an LED that can be blinked to show activity. 52 | /// 53 | /// LED_ON [required] 54 | /// The value to write to an LED to turn the LED on. 55 | /// 56 | /// LED_OFF [required] 57 | /// The value to write to an LED to turn the LED off. 58 | /// 59 | /// BUTTON_BOOTLOAD [required] 60 | /// A __bit corresponding to a button or strap that will cause the 61 | /// bootloader to stop and wait for a download. 62 | /// 63 | /// BUTTON_ACTIVE [required] 64 | /// The value that BUTTON will have when the bootloader should stop. 65 | /// 66 | /// HW_INIT [required] 67 | /// A code fragment called at early bootloader startup that configures 68 | /// the SoC for board-specific operation. 69 | /// - configures LED GPIO(s) 70 | /// - configures button GPIO(s) 71 | /// - configures INT0 for the radio interrupt 72 | /// 73 | /// HW_INIT_APPLICATION [optional] 74 | /// A code fragment called at application startup time to adjust any 75 | /// settings that vary between the bootloader and application. 76 | /// 77 | /// EZRADIOPRO_OSC_CAP_VALUE [required] 78 | /// Radio oscillator load capacitor value. 79 | /// 80 | /// ENABLE_RFM50_SWITCH [optional] 81 | /// Assume the RF switch is configured like the HopeRF RFM50 82 | /// XXX this should be generalised 83 | /// 84 | /// SERIAL_RTS [optional] 85 | /// A __bit for output flow control. If this bit is set, the 86 | /// serial device at the other end is ready for data. 87 | /// 88 | /// SERIAL_CTS [optional] 89 | /// A __bit for input flow control. This bit can be cleared 90 | /// to indicate to the serial device at the other end that 91 | /// the local serial buffer is nearly full. 92 | /// 93 | 94 | #ifndef _BOARD_H_ 95 | #define _BOARD_H_ 96 | 97 | #if defined(BOARD_rf50) 98 | # include "board_rf50.h" 99 | #elif defined(BOARD_hm_trp) 100 | # include "board_hm_trp.h" 101 | #elif defined(BOARD_rfd900) 102 | # include "board_rfd900.h" 103 | #elif defined(BOARD_rfd900a) 104 | # include "board_rfd900a.h" 105 | #else 106 | # error Must define a BOARD_ value before including this file. 107 | #endif 108 | 109 | #endif // _BOARD_H_ 110 | -------------------------------------------------------------------------------- /Firmware/include/board_info.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2011 Michael Smith, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file board_info.h 31 | /// 32 | /// Board information passed from the bootloader to the 33 | /// application. 34 | /// 35 | 36 | #ifndef _BOARD_INFO_H_ 37 | #define _BOARD_INFO_H_ 38 | 39 | /// Possible board RF configurations. 40 | /// 41 | /// These bytes are patched into the last byte of the first 42 | /// page of flash. 43 | /// 44 | enum BoardFrequency { 45 | FREQ_433 = 0x43, 46 | FREQ_470 = 0x47, 47 | FREQ_868 = 0x86, 48 | FREQ_915 = 0x91, 49 | FREQ_NONE = 0xf0, 50 | }; 51 | 52 | // SFRs used to temporarily save board information during handoff 53 | // between the bootloader and the application. 54 | // 55 | #define BOARD_FREQUENCY_REG ADC0GTH // board frequency 56 | #define BOARD_BL_VERSION_REG ADC0GTL // bootloader version 57 | #define BOARD_UNUSED1_REG ADC0LTH // spare 58 | #define BOARD_UNUSED2_REG ADC0LTL // spare 59 | 60 | #endif // _BOARD_INFO_H 61 | -------------------------------------------------------------------------------- /Firmware/include/board_rf50.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2011 Michael Smith, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file board_rf50.h 31 | /// 32 | /// Board-specific definitions for the RF50-DEMO board. 33 | /// 34 | 35 | /// @file board.h 36 | /// Board definitions for the HopeRF RF50 demo board 37 | 38 | #ifndef _BOARD_RF50_H 39 | #define _BOARD_RF50_H 40 | 41 | #include 42 | #include 43 | 44 | #define BOARD_ID 0x4d 45 | #define BOARD_NAME "RF50_DEMO" 46 | 47 | #define BOARD_MINTXPOWER 0 // Minimum transmit power level 48 | #define BOARD_MAXTXPOWER 20 // Maximum transmit power level 49 | 50 | // GPIO definitions (not exported) 51 | SBIT(LED_RED, SFR_P2, 0); 52 | SBIT(LED_GREEN, SFR_P2, 5); 53 | SBIT(BUTTON_ENTER, SFR_P0, 6); 54 | SBIT(BUTTON_UP, SFR_P1, 5); 55 | SBIT(BUTTON_DOWN, SFR_P1, 6); 56 | 57 | // Signal polarity definitions 58 | #define LED_ON 0 59 | #define LED_OFF 1 60 | #define BUTTON_ACTIVE 0 61 | 62 | // UI definitions 63 | #define LED_BOOTLOADER LED_RED 64 | #define LED_RADIO LED_GREEN 65 | #define LED_ACTIVITY LED_RED 66 | #define BUTTON_BOOTLOAD BUTTON_ENTER 67 | 68 | // board-specific hardware config 69 | #define HW_INIT \ 70 | do { \ 71 | /* GPIO config */ \ 72 | P0SKIP |= 0x40; /* button */ \ 73 | P1SKIP |= 0x60; /* buttons */ \ 74 | P2SKIP |= 0x21; /* LEDs */ \ 75 | SFRPAGE = CONFIG_PAGE; \ 76 | P2DRV |= 0x21; /* LEDs */ \ 77 | SFRPAGE = LEGACY_PAGE; \ 78 | /* INT0 is the radio interrupt, on P0.7 */ \ 79 | IT01CF = (IT01CF & 0xf) | 0x7; \ 80 | IT0 = 0; /* INT0 leve triggered */ \ 81 | } while(0) 82 | 83 | // EzRadio / rtPhy definitions 84 | // Note that the RFM50 deviates from the appnote/sample code in both the oscillator cap value and the wiring 85 | // of the RF switch 86 | // 87 | #define EZRADIOPRO_OSC_CAP_VALUE 0xb4 // Per HRF demo code 88 | #define ENABLE_RFM50_SWITCH 1 // Per HRF demo code, verified presence of RF switch on the RFM50 module 89 | SBIT(IRQ, SFR_P0, 7); // Per HRF demo code & schematic 90 | SBIT(NSS1, SFR_P1, 4); // SI100x Internal Connection 91 | SBIT(SDN, SFR_P2, 6); // XXX not actually the case on the RFM50... HRF set it this way though 92 | 93 | #endif // _BOARD_RF50_H 94 | -------------------------------------------------------------------------------- /Firmware/include/board_rfd900.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2011 Michael Smith, All Rights Reserved 4 | // Copyright (c) 2012 Seppo Saario, All Rights Reserved 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // o Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // o Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in 14 | // the documentation and/or other materials provided with the distribution. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 19 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 20 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 27 | // OF THE POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | // 30 | /// 31 | /// @file board_rfd900.h 32 | /// 33 | /// Board-specific definitions and documentation for the RFD900 board. 34 | /// 35 | /// The RFD900 board provides pads for programming 36 | /// the Si1000 via the debug port. 37 | /// The pads are on the single horizontal header on the bottom of the board. 38 | /// Pin 1 = GND, Pin 2 = +5V, Pin 3 = C2D, Pin 4 = C2CK 39 | /// 40 | /// The SiLabs programmer has a 10-pin ribbon cable, for which you will 41 | /// need to make an adapter. The User Guide, linked from the page here: 42 | /// 43 | /// http://www.silabs.com/products/mcu/Pages/USBDebug.aspx 44 | /// describes the pinout of the cable. 45 | /// 46 | /// Connect the SiLabs debug adapter to the RFD900 as follows: 47 | /// 48 | /// Debug Adapter Pin: RFD900 pin 49 | /// 50 | /// 2 <--------------------------> GND (Pin 1) 51 | /// 4 <--------------------------> C2D (Pin 3) 52 | /// 7 <--------------------------> C2CK (Pin 4) 53 | /// 10 <--------------------------> +5V (Pin 2) 54 | /// 55 | /// 56 | /// 57 | /// If you are making your own adapter board for the RFD900, note that 58 | /// whilst the stock firmware requires the ENABLE pin be tied low, 59 | /// it is a flow control input to the SiK radio firmware. 60 | /// 61 | /// Also, the CONFIG pin is a flow control output, and a series resistor 62 | /// of at least 33 ohms must be placed in series with it to avoid damage 63 | /// to the Si1000 when it is jumpered low to force bootloader entry. 64 | /// 65 | 66 | #ifndef _BOARD_RFD900 67 | #define _BOARD_RFD900 68 | 69 | #include 70 | #include 71 | 72 | #define BOARD_ID 0x42 73 | #define BOARD_NAME "RFD900" 74 | 75 | #define BOARD_MINTXPOWER 17 // Minimum transmit power level 76 | #define BOARD_MAXTXPOWER 30 // Maximum transmit power level 77 | 78 | // GPIO definitions (not exported) 79 | SBIT(LED_RED, SFR_P1, 6); 80 | SBIT(LED_GREEN, SFR_P1, 5); 81 | SBIT(PIN_CONFIG, SFR_P0, 2); 82 | SBIT(PIN_ENABLE, SFR_P0, 3); 83 | 84 | // Signal polarity definitions 85 | #define LED_ON 1 // LED Sense inverted when compared to HM_TRP 86 | #define LED_OFF 0 87 | #define BUTTON_ACTIVE 0 88 | 89 | // UI definitions 90 | #define LED_BOOTLOADER LED_RED 91 | #define LED_RADIO LED_GREEN 92 | #define LED_ACTIVITY LED_RED 93 | #define BUTTON_BOOTLOAD PIN_CONFIG 94 | 95 | // Serial flow control 96 | #define SERIAL_RTS PIN_ENABLE // always an input 97 | #define SERIAL_CTS PIN_CONFIG // input in bootloader, output in app 98 | 99 | // board-specific hardware config 100 | #define HW_INIT \ 101 | do { \ 102 | /* GPIO config */ \ 103 | P0SKIP |= 0x0C; /* pins */ \ 104 | P1SKIP |= 0xE0; /* LEDs 60*/ \ 105 | SFRPAGE = CONFIG_PAGE; \ 106 | P1MDOUT |= 0xF5; /* SCK1, MOSI1, MISO1 push-pull was 60 */ \ 107 | P1DRV |= 0xF5; /* SPI signals use high-current mode, LEDs and PAEN High current drive was 60 */ \ 108 | SFRPAGE = LEGACY_PAGE; \ 109 | /* INT0 is the radio interrupt, on P0.7 */ \ 110 | IT01CF = (IT01CF & 0xf) | 0x7; \ 111 | IT0 = 0; /* INT0 level triggered */ \ 112 | } while(0) 113 | 114 | // application/board-specific hardware config 115 | #define HW_INIT_APPLICATION \ 116 | do { \ 117 | SFRPAGE = CONFIG_PAGE; \ 118 | P0DRV |= 0x04; /* CTS */ \ 119 | SFRPAGE = LEGACY_PAGE; \ 120 | } while(0) 121 | 122 | // Radio Definitions 123 | 124 | #define EZRADIOPRO_OSC_CAP_VALUE 0xB6 // Measured on RFD900 V1.1 125 | #define ENABLE_RFD900_SWITCH 1 // Define RF switches on the module 126 | #define RFD900_DIVERSITY 1 // Enable/Disable diversity on RFD900 127 | SBIT(IRQ, SFR_P0, 7); // Connection within RFD900 module, P0.7 is connected to nIRQ 128 | SBIT(NSS1, SFR_P1, 4); // SI100x Internal Connection 129 | 130 | #endif // _BOARD_RFD900 131 | -------------------------------------------------------------------------------- /Firmware/include/board_rfd900a.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2011 Michael Smith, All Rights Reserved 4 | // Copyright (c) 2012 Seppo Saario, All Rights Reserved 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // o Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // o Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in 14 | // the documentation and/or other materials provided with the distribution. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 19 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 20 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 27 | // OF THE POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | // 30 | /// 31 | /// @file board_rfd900a.h 32 | /// 33 | /// Board-specific definitions and documentation for the RFD900A, 34 | /// Version 1.2 onwards. 35 | /// 36 | /// The RFD900 board provides pads for programming 37 | /// the Si1000 via the debug port. 38 | /// The pads are on the single horizontal header on the bottom of the board. 39 | /// Pin 1 = GND, Pin 2 = +5V, Pin 3 = C2D, Pin 4 = C2CK 40 | /// 41 | /// The SiLabs programmer has a 10-pin ribbon cable, for which you will 42 | /// need to make an adapter. The User Guide, linked from the page here: 43 | /// 44 | /// http://www.silabs.com/products/mcu/Pages/USBDebug.aspx 45 | /// describes the pinout of the cable. 46 | /// 47 | /// Connect the SiLabs debug adapter to the RFD900 V1.2+ as follows: 48 | /// 49 | /// Debug Adapter Pin: RFD900A V1.2+ 9W header pin (J2) 50 | /// 51 | /// 2 <--------------------------> GND (Pin 2) 52 | /// 4 <--------------------------> C2D (Pin 4) 53 | /// 7 <--------------------------> C2CK (Pin 5) 54 | /// 10 <--------------------------> +5V (Pin 3) 55 | /// 56 | /// 57 | /// If you are making your own adapter board for the RFD900, note that 58 | /// whilst the stock firmware requires the ENABLE pin be tied low, 59 | /// it is a flow control input to the SiK radio firmware. 60 | 61 | 62 | #ifndef _BOARD_RFD900A 63 | #define _BOARD_RFD900A 64 | 65 | #include 66 | #include 67 | 68 | #define BOARD_ID 0x43 69 | #define BOARD_NAME "RFD900A" 70 | 71 | #define BOARD_MINTXPOWER 0 // Minimum transmit power level 72 | #define BOARD_MAXTXPOWER 30 // Maximum transmit power level 73 | 74 | // GPIO definitions (not exported) 75 | SBIT(LED_RED, SFR_P1, 6); 76 | SBIT(LED_GREEN, SFR_P1, 5); 77 | SBIT(PIN_CONFIG, SFR_P0, 2); 78 | SBIT(PIN_ENABLE, SFR_P0, 3); 79 | SBIT(PA_ENABLE, SFR_P2, 5); // Power Amplifier Enable 80 | 81 | 82 | // Signal polarity definitions 83 | #define LED_ON 1 // LED Sense inverted when compared to HM_TRP 84 | #define LED_OFF 0 85 | #define BUTTON_ACTIVE 0 86 | 87 | // UI definitions 88 | #define LED_BOOTLOADER LED_RED 89 | #define LED_RADIO LED_GREEN 90 | #define LED_ACTIVITY LED_RED 91 | #define BUTTON_BOOTLOAD PIN_CONFIG 92 | 93 | // Serial flow control 94 | #define SERIAL_RTS PIN_ENABLE // always an input 95 | #define SERIAL_CTS PIN_CONFIG // input in bootloader, output in app 96 | 97 | // board-specific hardware config 98 | #define HW_INIT \ 99 | do { \ 100 | /* GPIO config */ \ 101 | P0SKIP |= 0xCF; /* P0 UART avail on XBAR */ \ 102 | P1SKIP |= 0x78; /* P1 SPI1, CEX0 avail on XBAR */ \ 103 | P2SKIP |= 0xFF; /* P2 nothing avail on XBAR, All GPIO */ \ 104 | SFRPAGE = CONFIG_PAGE; \ 105 | P1MDOUT |= 0xF5; /* SCK1, MOSI1, MISO1 push-pull was 60 */ \ 106 | P1DRV |= 0xF5; /* SPI signals use high-current mode, LEDs and PAEN High current drive was 60 */ \ 107 | P2MDOUT |= 0x20; /* PA_ENABLE (P2.5) output */ \ 108 | P2DRV |= 0x20; /* PA_ENABLE (P2.5) high current drive*/ \ 109 | SFRPAGE = LEGACY_PAGE; \ 110 | /* INT0 is the radio interrupt, on P0.7 */ \ 111 | IT01CF = (IT01CF & 0xf) | 0x7; \ 112 | IT0 = 0; /* INT0 level triggered */ \ 113 | } while(0) 114 | 115 | // application/board-specific hardware config 116 | #define HW_INIT_APPLICATION \ 117 | do { \ 118 | SFRPAGE = CONFIG_PAGE; \ 119 | P0DRV |= 0x04; /* CTS */ \ 120 | SFRPAGE = LEGACY_PAGE; \ 121 | } while(0) 122 | 123 | // Radio Definitions 124 | 125 | #define EZRADIOPRO_OSC_CAP_VALUE 0xB6 // Measured on RFD900 V1.1 126 | #define ENABLE_RFD900_SWITCH 1 // Define RF switches on the module (V1.1 are V1.2 the same) 127 | #define RFD900_DIVERSITY 1 // Enable/Disable diversity on RFD900 (V1.1 are V1.2 the same) 128 | SBIT(IRQ, SFR_P0, 7); // Connection within RFD900 module, P0.7 is connected to nIRQ 129 | SBIT(NSS1, SFR_P1, 4); // SI100x Internal Connection 130 | 131 | #endif // _BOARD_RFD900A 132 | -------------------------------------------------------------------------------- /Firmware/include/cdt.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2011 Michael Smith, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file cdt.h 31 | /// 32 | /// Definitions to quiet the Eclipse CDT parser while working with 33 | /// SDCC code. 34 | /// 35 | 36 | #ifndef _CDT_H_ 37 | #define _CDT_H_ 38 | 39 | #ifdef __CDT_PARSER__ 40 | # define __data 41 | # define __xdata 42 | # define __pdata 43 | # define __idata 44 | # define __code 45 | # define __at(_x) 46 | # define __interrupt(_x) 47 | # define __using(_x) 48 | # define __reentrant 49 | # define __critical 50 | #endif 51 | 52 | #endif // _CDT_H_ 53 | -------------------------------------------------------------------------------- /Firmware/include/compiler_defs.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stronnag/SiK-MSP/5cd11ef83746e41a11ae22617424b5b4efcc4290/Firmware/include/compiler_defs.h -------------------------------------------------------------------------------- /Firmware/include/flash_layout.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2011 Michael Smith, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file flash_layout.h 31 | /// 32 | /// Layout definitions for the SiK bootloader and conforming applications. 33 | /// 34 | 35 | #ifndef _FLASH_LAYOUT_H 36 | #define _FLASH_LAYOUT_H 37 | 38 | #include 39 | 40 | // Flash memory map 41 | // It would be nice to derive all these numbers from some 42 | // simpler values, but life is easier if we just spell them all out. 43 | // 44 | #define FLASH_PAGE_SIZE 0x0400 // 1KiB 45 | #define FLASH_PAGE_SHIFT 10 46 | #define FLASH_APP_START 0x0400 // 1 page reserved for bootloader 47 | #define FLASH_INFO_PAGE 0xf800 // 1 page reserved for bootloader 48 | #define FLASH_LOCK_BYTE 0xfbff 49 | 50 | // Anticipated flash signature bytes 51 | // 52 | #define FLASH_SIG0 0x3d 53 | #define FLASH_SIG1 0xc2 54 | 55 | // Location of the flash signature 56 | // 57 | #define FLASH_SIGNATURE_BYTES (FLASH_INFO_PAGE - 2) 58 | 59 | // Bootloader patchbay for frequency code 60 | // 61 | #define FLASH_FREQUENCY_BYTE (FLASH_LOCK_BYTE - 1) 62 | 63 | #ifdef BOARD_rfd900a 64 | // locked and unlocked areas to store power calibration info 65 | #define FLASH_CALIBRATION_AREA_SIZE (31) 66 | #define FLASH_CALIBRATION_CRC_HIGH (FLASH_FREQUENCY_BYTE - 1) 67 | #define FLASH_CALIBRATION_AREA_HIGH (FLASH_CALIBRATION_CRC_HIGH - FLASH_CALIBRATION_AREA_SIZE) 68 | #define FLASH_CALIBRATION_CRC (FLASH_SIGNATURE_BYTES - 1) 69 | #define FLASH_CALIBRATION_AREA (FLASH_CALIBRATION_CRC - FLASH_CALIBRATION_AREA_SIZE) 70 | #endif 71 | 72 | #endif // _FLASH_LAYOUT_H 73 | -------------------------------------------------------------------------------- /Firmware/include/rules.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2011 Michael Smith, 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 6 | # are met: 7 | # 8 | # o Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # o Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in 12 | # the documentation and/or other materials provided with the distribution. 13 | # 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 17 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 18 | # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 19 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 23 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 25 | # OF THE POSSIBILITY OF SUCH DAMAGE. 26 | # 27 | # 28 | # Common rules and targets for the HopeRF radio apps 29 | # 30 | 31 | ifeq ($(BOARD),) 32 | $(error Must define BOARD before attempting to build) 33 | endif 34 | ifeq ($(SRCROOT),) 35 | $(error Must define SRCROOT before attempting to build) 36 | endif 37 | 38 | # 39 | # Get board-specific definitions 40 | # 41 | include $(SRCROOT)/include/rules_$(BOARD).mk 42 | 43 | # 44 | # Common build options. 45 | # 46 | CFLAGS += -DBOARD_$(BOARD) 47 | 48 | # 49 | # Paths. 50 | # 51 | OBJROOT ?= $(SRCROOT)/obj/$(BOARD)/$(PRODUCT) 52 | DSTROOT ?= $(SRCROOT)/dst 53 | 54 | # 55 | # Buildable and installable products 56 | # 57 | PRODUCT_HEX = $(OBJROOT)/$(PRODUCT).ihx 58 | PRODUCT_INSTALL ?= $(PRODUCT_HEX) 59 | 60 | # 61 | # Compiler and tools 62 | # 63 | ifeq ($(shell which sdcc),) 64 | $(error Could not find SDCC on your path - cannot build) 65 | endif 66 | CC = sdcc -mmcs51 67 | AS = sdas8051 -jloscp 68 | LD = sdcc 69 | INCLUDES = $(SRCROOT)/include 70 | CFLAGS += $(addprefix -I,$(INCLUDES)) 71 | DEPFLAGS = -MM $(CFLAGS) 72 | 73 | # 74 | # Assembly source/objects must come first to ensure startup files 75 | # can be in front. 76 | # 77 | ASRCS += $(sort $(wildcard $(PRODUCT_DIR)/*.asm)) 78 | OBJS += $(patsubst $(PRODUCT_DIR)/%.asm,$(OBJROOT)/%.rel,$(ASRCS)) 79 | 80 | CSRCS += $(wildcard $(PRODUCT_DIR)/*.c) 81 | OBJS += $(patsubst $(PRODUCT_DIR)/%.c,$(OBJROOT)/%.rel,$(CSRCS)) 82 | 83 | ifeq ($(VERBOSE),) 84 | v = @ 85 | else 86 | CFLAGS += -V 87 | endif 88 | 89 | # 90 | # Build rules 91 | # 92 | build: $(PRODUCT_HEX) 93 | 94 | $(PRODUCT_HEX): $(OBJS) 95 | @echo LD $@ 96 | @mkdir -p $(dir $@) 97 | $(v)$(LD) -o $@ $(LDFLAGS) $(OBJS) 98 | 99 | $(OBJROOT)/%.rel: $(PRODUCT_DIR)/%.c 100 | @echo CC $< 101 | @mkdir -p $(dir $@) 102 | $(v)(/bin/echo -n $(OBJROOT)/ && $(CC) $(DEPFLAGS) $<) > $(subst .rel,.dep,$@) 103 | $(v)$(CC) -c -o $@ $(CFLAGS) $< 104 | 105 | $(OBJROOT)/%.rel: $(PRODUCT_DIR)/%.asm 106 | @echo AS $< 107 | @mkdir -p $(dir $@) 108 | $(v)cp $< $(subst $(PRODUCT_DIR),$(OBJROOT),$<) 109 | $(v)$(AS) $(ASFLAGS) $(subst $(PRODUCT_DIR),$(OBJROOT),$<) 110 | 111 | clean: 112 | $(v)rm -rf $(OBJROOT) 113 | 114 | install: $(PRODUCT_INSTALL) 115 | @echo INSTALL $^ 116 | $(v)mkdir -p $(DSTROOT) 117 | $(v)cp $(PRODUCT_INSTALL) $(DSTROOT)/ 118 | 119 | # 120 | # Dependencies 121 | # 122 | GLOBAL_DEPS += $(MAKEFILE_LIST) 123 | $(OBJS): $(GLOBAL_DEPS) 124 | -include $(wildcard $(OBJROOT)/*.dep) 125 | -------------------------------------------------------------------------------- /Firmware/include/rules_hm_trp.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2011 Michael Smith, 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 6 | # are met: 7 | # 8 | # o Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # o Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in 12 | # the documentation and/or other materials provided with the distribution. 13 | # 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 17 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 18 | # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 19 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 23 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 25 | # OF THE POSSIBILITY OF SUCH DAMAGE. 26 | # 27 | 28 | # 29 | # Configuration options for the HM-TRP board. 30 | # 31 | FREQUENCIES = 433 470 868 915 32 | -------------------------------------------------------------------------------- /Firmware/include/rules_rf50.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2011 Michael Smith, 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 6 | # are met: 7 | # 8 | # o Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # o Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in 12 | # the documentation and/or other materials provided with the distribution. 13 | # 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 17 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 18 | # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 19 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 23 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 25 | # OF THE POSSIBILITY OF SUCH DAMAGE. 26 | # 27 | 28 | # 29 | # Configuration options for the RF50-DEMO board. 30 | # 31 | FREQUENCIES = 433 470 868 915 32 | -------------------------------------------------------------------------------- /Firmware/include/rules_rfd900.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2011 Michael Smith, 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 6 | # are met: 7 | # 8 | # o Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # o Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in 12 | # the documentation and/or other materials provided with the distribution. 13 | # 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 17 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 18 | # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 19 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 23 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 25 | # OF THE POSSIBILITY OF SUCH DAMAGE. 26 | # 27 | 28 | # 29 | # Configuration options for the HM-TRP board. 30 | # 31 | FREQUENCIES = 915 32 | -------------------------------------------------------------------------------- /Firmware/include/rules_rfd900a.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2011 Michael Smith, 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 6 | # are met: 7 | # 8 | # o Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # o Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in 12 | # the documentation and/or other materials provided with the distribution. 13 | # 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 17 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 18 | # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 19 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 23 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 25 | # OF THE POSSIBILITY OF SUCH DAMAGE. 26 | # 27 | 28 | # 29 | # Configuration options for the RFD900A board. 30 | # 31 | FREQUENCIES = 915 32 | -------------------------------------------------------------------------------- /Firmware/radio/at.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2011 Michael Smith, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file at.h 31 | /// 32 | /// Prototypes for the AT command parser 33 | /// 34 | 35 | #ifndef _AT_H_ 36 | #define _AT_H_ 37 | 38 | extern bool at_mode_active; ///< if true, the AT interpreter is in command mode 39 | extern bool at_cmd_ready; ///< if true, at_cmd / at_cmd_len contain valid data 40 | 41 | /// Timer tick handler for the AT command interpreter 42 | /// 43 | extern void at_timer(void); 44 | 45 | /// +++ detector. Handles the state machine for detecting the AT escape 46 | /// sequence. 47 | /// 48 | /// Call this at interrupt time for every incoming character when at_mode_active 49 | /// is false. 50 | /// 51 | /// @param c Received character. 52 | /// 53 | extern void at_plus_detector(register uint8_t c); 54 | 55 | /// AT command character input method. 56 | /// 57 | /// Call this at interrupt time for every incoming character when at_mode_active 58 | /// is true, and don't buffer those characters. 59 | /// 60 | /// @param c Received character. 61 | /// 62 | extern void at_input(register uint8_t c); 63 | 64 | /// Check for and execute AT commands 65 | /// 66 | /// Call this from non-interrupt context when it's safe for an AT command 67 | /// to be executed. It's cheap if at_mode_active is false. 68 | /// 69 | extern void at_command(void); 70 | 71 | /// AT_TEST_* test modes 72 | extern __pdata uint8_t at_testmode; ///< AT_TEST_* bits 73 | 74 | #define AT_TEST_RSSI 1 75 | #define AT_TEST_TDM 2 76 | 77 | // max size of an AT command 78 | #define AT_CMD_MAXLEN 16 79 | 80 | // AT command buffer 81 | extern __pdata char at_cmd[AT_CMD_MAXLEN + 1]; 82 | extern __pdata uint8_t at_cmd_len; 83 | 84 | #endif // _AT_H_ 85 | -------------------------------------------------------------------------------- /Firmware/radio/crc.c: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2012 Andrew Tridgell, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file crc.c 31 | /// 32 | /// crc 16 code 33 | /// see http://www.8052.com/users/bigblack/index.phtml 34 | /// 35 | 36 | #include 37 | #include "radio.h" 38 | #include "crc.h" 39 | 40 | // CRC tables 41 | static __code uint8_t crc_tab1[256] = 42 | { 43 | 0x00,0x00,0x10,0x21,0x20,0x42,0x30,0x63,0x40,0x84,0x50,0xA5,0x60,0xC6,0x70,0xE7, 44 | 0x81,0x08,0x91,0x29,0xA1,0x4A,0xB1,0x6B,0xC1,0x8C,0xD1,0xAD,0xE1,0xCE,0xF1,0xEF, 45 | 0x12,0x31,0x02,0x10,0x32,0x73,0x22,0x52,0x52,0xB5,0x42,0x94,0x72,0xF7,0x62,0xD6, 46 | 0x93,0x39,0x83,0x18,0xB3,0x7B,0xA3,0x5A,0xD3,0xBD,0xC3,0x9C,0xF3,0xFF,0xE3,0xDE, 47 | 0x24,0x62,0x34,0x43,0x04,0x20,0x14,0x01,0x64,0xE6,0x74,0xC7,0x44,0xA4,0x54,0x85, 48 | 0xA5,0x6A,0xB5,0x4B,0x85,0x28,0x95,0x09,0xE5,0xEE,0xF5,0xCF,0xC5,0xAC,0xD5,0x8D, 49 | 0x36,0x53,0x26,0x72,0x16,0x11,0x06,0x30,0x76,0xD7,0x66,0xF6,0x56,0x95,0x46,0xB4, 50 | 0xB7,0x5B,0xA7,0x7A,0x97,0x19,0x87,0x38,0xF7,0xDF,0xE7,0xFE,0xD7,0x9D,0xC7,0xBC, 51 | 0x48,0xC4,0x58,0xE5,0x68,0x86,0x78,0xA7,0x08,0x40,0x18,0x61,0x28,0x02,0x38,0x23, 52 | 0xC9,0xCC,0xD9,0xED,0xE9,0x8E,0xF9,0xAF,0x89,0x48,0x99,0x69,0xA9,0x0A,0xB9,0x2B, 53 | 0x5A,0xF5,0x4A,0xD4,0x7A,0xB7,0x6A,0x96,0x1A,0x71,0x0A,0x50,0x3A,0x33,0x2A,0x12, 54 | 0xDB,0xFD,0xCB,0xDC,0xFB,0xBF,0xEB,0x9E,0x9B,0x79,0x8B,0x58,0xBB,0x3B,0xAB,0x1A, 55 | 0x6C,0xA6,0x7C,0x87,0x4C,0xE4,0x5C,0xC5,0x2C,0x22,0x3C,0x03,0x0C,0x60,0x1C,0x41, 56 | 0xED,0xAE,0xFD,0x8F,0xCD,0xEC,0xDD,0xCD,0xAD,0x2A,0xBD,0x0B,0x8D,0x68,0x9D,0x49, 57 | 0x7E,0x97,0x6E,0xB6,0x5E,0xD5,0x4E,0xF4,0x3E,0x13,0x2E,0x32,0x1E,0x51,0x0E,0x70, 58 | 0xFF,0x9F,0xEF,0xBE,0xDF,0xDD,0xCF,0xFC,0xBF,0x1B,0xAF,0x3A,0x9F,0x59,0x8F,0x78 59 | }; 60 | 61 | static __code uint8_t crc_tab2[256] = 62 | { 63 | 0x91,0x88,0x81,0xA9,0xB1,0xCA,0xA1,0xEB,0xD1,0x0C,0xC1,0x2D,0xF1,0x4E,0xE1,0x6F, 64 | 0x10,0x80,0x00,0xA1,0x30,0xC2,0x20,0xE3,0x50,0x04,0x40,0x25,0x70,0x46,0x60,0x67, 65 | 0x83,0xB9,0x93,0x98,0xA3,0xFB,0xB3,0xDA,0xC3,0x3D,0xD3,0x1C,0xE3,0x7F,0xF3,0x5E, 66 | 0x02,0xB1,0x12,0x90,0x22,0xF3,0x32,0xD2,0x42,0x35,0x52,0x14,0x62,0x77,0x72,0x56, 67 | 0xB5,0xEA,0xA5,0xCB,0x95,0xA8,0x85,0x89,0xF5,0x6E,0xE5,0x4F,0xD5,0x2C,0xC5,0x0D, 68 | 0x34,0xE2,0x24,0xC3,0x14,0xA0,0x04,0x81,0x74,0x66,0x64,0x47,0x54,0x24,0x44,0x05, 69 | 0xA7,0xDB,0xB7,0xFA,0x87,0x99,0x97,0xB8,0xE7,0x5F,0xF7,0x7E,0xC7,0x1D,0xD7,0x3C, 70 | 0x26,0xD3,0x36,0xF2,0x06,0x91,0x16,0xB0,0x66,0x57,0x76,0x76,0x46,0x15,0x56,0x34, 71 | 0xD9,0x4C,0xC9,0x6D,0xF9,0x0E,0xE9,0x2F,0x99,0xC8,0x89,0xE9,0xB9,0x8A,0xA9,0xAB, 72 | 0x58,0x44,0x48,0x65,0x78,0x06,0x68,0x27,0x18,0xC0,0x08,0xE1,0x38,0x82,0x28,0xA3, 73 | 0xCB,0x7D,0xDB,0x5C,0xEB,0x3F,0xFB,0x1E,0x8B,0xF9,0x9B,0xD8,0xAB,0xBB,0xBB,0x9A, 74 | 0x4A,0x75,0x5A,0x54,0x6A,0x37,0x7A,0x16,0x0A,0xF1,0x1A,0xD0,0x2A,0xB3,0x3A,0x92, 75 | 0xFD,0x2E,0xED,0x0F,0xDD,0x6C,0xCD,0x4D,0xBD,0xAA,0xAD,0x8B,0x9D,0xE8,0x8D,0xC9, 76 | 0x7C,0x26,0x6C,0x07,0x5C,0x64,0x4C,0x45,0x3C,0xA2,0x2C,0x83,0x1C,0xE0,0x0C,0xC1, 77 | 0xEF,0x1F,0xFF,0x3E,0xCF,0x5D,0xDF,0x7C,0xAF,0x9B,0xBF,0xBA,0x8F,0xD9,0x9F,0xF8, 78 | 0x6E,0x17,0x7E,0x36,0x4E,0x55,0x5E,0x74,0x2E,0x93,0x3E,0xB2,0x0E,0xD1,0x1E,0xF0 79 | }; 80 | 81 | 82 | // calculate the CRC16 of a buffer 83 | // this costs about 2.2 microseconds per byte 84 | uint16_t 85 | crc16(__data uint8_t n, __xdata uint8_t * __data buf) 86 | { 87 | register uint8_t k; 88 | register uint8_t high, low; 89 | 90 | high = low = 0; 91 | 92 | while (n--) { 93 | register uint8_t b = *buf++; 94 | k = high << 1; 95 | if (high & 0x80) { 96 | high = low ^ crc_tab2[k++]; 97 | low = b ^ crc_tab2[k]; 98 | } else { 99 | high = low ^ crc_tab1[k++]; 100 | low = b ^ crc_tab1[k]; 101 | } 102 | } 103 | return (((uint16_t)high)<<8) | low; 104 | } 105 | -------------------------------------------------------------------------------- /Firmware/radio/crc.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2012 Andrew Tridgell, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// calculate a CRC16 on a buffer 30 | /// @param n number of bytes 31 | /// @param buf buffer 32 | /// 33 | /// @return CRC16 value 34 | /// 35 | extern uint16_t crc16(__data uint8_t n, __xdata uint8_t * __data buf); 36 | -------------------------------------------------------------------------------- /Firmware/radio/flash.c: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2011 Michael Smith, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file flash.c 31 | /// 32 | /// Flash-related data structures and functions, including the application 33 | /// signature for the bootloader. 34 | /// 35 | 36 | #include 37 | #include 38 | 39 | #include "radio.h" 40 | 41 | // The application signature block. 42 | // 43 | // The presence of this block, which is the first thing to be erased and the 44 | // last thing to be programmed during an update, tells the bootloader that 45 | // a valid application is installed. 46 | // 47 | __at(FLASH_SIGNATURE_BYTES) uint8_t __code app_signature[2] = { FLASH_SIG0, FLASH_SIG1 }; 48 | 49 | /// Load the write-enable keys into the hardware in order to enable 50 | /// one write or erase operation. 51 | /// 52 | static void 53 | flash_load_keys(void) 54 | { 55 | FLKEY = 0xa5; 56 | FLKEY = 0xf1; 57 | } 58 | 59 | void 60 | flash_erase_scratch(void) 61 | __critical { 62 | // erase the scratch page 63 | flash_load_keys(); // unlock flash for one operation 64 | PSCTL = 0x07; // enable flash erase of the scratch page 65 | *(uint8_t __xdata *)0 = 0xff; // trigger the erase 66 | PSCTL = 0x00; // disable flash write & scratch access 67 | } 68 | 69 | uint8_t 70 | flash_read_scratch(__pdata uint16_t address) 71 | __critical { 72 | uint8_t d; 73 | 74 | PSCTL = 0x04; 75 | d = *(uint8_t __code *)address; 76 | PSCTL = 0x00; 77 | return d; 78 | } 79 | 80 | void 81 | flash_write_scratch(__pdata uint16_t address, __pdata uint8_t c) 82 | __critical { 83 | flash_load_keys(); 84 | PSCTL = 0x05; 85 | *(uint8_t __xdata *)address = c; 86 | PSCTL = 0x00; 87 | } 88 | -------------------------------------------------------------------------------- /Firmware/radio/flash.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2011 Michael Smith, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file flash.h 31 | /// Prototypes for the flash interface. 32 | /// 33 | 34 | extern void flash_erase_scratch(void); 35 | extern uint8_t flash_read_scratch(__pdata uint16_t address); 36 | extern void flash_write_scratch(__pdata uint16_t address, __pdata uint8_t c); 37 | -------------------------------------------------------------------------------- /Firmware/radio/freq_hopping.c: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2012 Andrew Tridgell, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file freq_hopping.c 31 | /// 32 | /// Frequency hop managerment 33 | /// 34 | 35 | #include 36 | #include "radio.h" 37 | #include "freq_hopping.h" 38 | 39 | /// how many channels are we hopping over 40 | __pdata uint8_t num_fh_channels; 41 | 42 | /// whether we current have good lock with the other end 43 | static bool have_radio_lock; 44 | 45 | /// current transmit channel 46 | /// This changes every time the TDM transmit window opens or closes, 47 | /// regardless of our lock state 48 | __pdata static volatile uint8_t transmit_channel; 49 | 50 | /// current receive channel 51 | /// When we have good lock with the other radio the receive channel 52 | /// follows the transmit channel. When we don't have lock the receive 53 | /// channel only changes 54 | /// very slowly - it moves only when the transmit channel wraps 55 | __pdata static volatile uint8_t receive_channel; 56 | 57 | /// map between hopping channel numbers and physical channel numbers 58 | __xdata static uint8_t channel_map[MAX_FREQ_CHANNELS]; 59 | 60 | // a vary simple array shuffle 61 | // based on shuffle from 62 | // http://benpfaff.org/writings/clc/shuffle.html 63 | static inline void shuffle(__xdata uint8_t *array, uint8_t n) 64 | { 65 | uint8_t i; 66 | for (i = 0; i < n - 1; i++) { 67 | uint8_t j = ((uint8_t)rand()) % n; 68 | uint8_t t = array[j]; 69 | array[j] = array[i]; 70 | array[i] = t; 71 | } 72 | } 73 | 74 | // initialise frequency hopping logic 75 | void 76 | fhop_init(uint16_t netid) 77 | { 78 | uint8_t i; 79 | // create a random mapping between virtual and physical channel 80 | // numbers, seeded by the network ID 81 | for (i = 0; i < num_fh_channels; i++) { 82 | channel_map[i] = i; 83 | } 84 | srand(netid); 85 | shuffle(channel_map, num_fh_channels); 86 | } 87 | 88 | // tell the TDM code what channel to transmit on 89 | uint8_t 90 | fhop_transmit_channel(void) 91 | { 92 | return channel_map[transmit_channel]; 93 | } 94 | 95 | // tell the TDM code what channel to receive on 96 | uint8_t 97 | fhop_receive_channel(void) 98 | { 99 | return channel_map[receive_channel]; 100 | } 101 | 102 | // called when the transmit windows changes owner 103 | void 104 | fhop_window_change(void) 105 | { 106 | transmit_channel = (transmit_channel + 1) % num_fh_channels; 107 | if (have_radio_lock) { 108 | // when we have lock, the receive channel follows the 109 | // transmit channel 110 | receive_channel = transmit_channel; 111 | } else if (transmit_channel == 0) { 112 | // when we don't have lock, the receive channel only 113 | // changes when the transmit channel wraps 114 | receive_channel = (receive_channel + 1) % num_fh_channels; 115 | debug("Trying RCV on channel %d\n", (int)receive_channel); 116 | } 117 | } 118 | 119 | // called when we get or lose radio lock 120 | void 121 | fhop_set_locked(bool locked) 122 | { 123 | #if DEBUG 124 | if (locked && !have_radio_lock) { 125 | debug("FH lock\n"); 126 | } 127 | #endif 128 | have_radio_lock = locked; 129 | if (have_radio_lock) { 130 | // we have just received a packet, so we know the 131 | // other radios transmit channel must be our receive 132 | // channel 133 | transmit_channel = receive_channel; 134 | } else { 135 | // try the next receive channel 136 | receive_channel = (receive_channel+1) % num_fh_channels; 137 | } 138 | } 139 | 140 | -------------------------------------------------------------------------------- /Firmware/radio/freq_hopping.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2012 Andrew Tridgell, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | /// 29 | /// @file freq_hopping.h 30 | /// 31 | /// Prototypes for the frequency hopping manager 32 | /// 33 | 34 | #ifndef _FREQ_HOPPING_H_ 35 | #define _FREQ_HOPPING_H_ 36 | 37 | #define MAX_FREQ_CHANNELS 50 38 | 39 | /// initialise frequency hopping logic 40 | /// 41 | /// @param netid Our assigned network ID. 42 | extern void fhop_init(uint16_t netid); 43 | 44 | /// tell the TDM code what channel to transmit on 45 | /// 46 | /// @return The channel that we should be transmitting on. 47 | /// 48 | extern uint8_t fhop_transmit_channel(void); 49 | 50 | /// tell the TDM code what channel to receive on 51 | /// 52 | /// @return The channel that we should be receiving on. 53 | // 54 | extern uint8_t fhop_receive_channel(void); 55 | 56 | /// called when the transmit window flips 57 | /// 58 | extern void fhop_window_change(void); 59 | 60 | /// called when we get or lose radio lock 61 | /// 62 | /// @param locked True if we have gained lock, false if we have lost it. 63 | /// 64 | extern void fhop_set_locked(bool locked); 65 | 66 | /// how many channels are we hopping over 67 | extern __pdata uint8_t num_fh_channels; 68 | 69 | #endif // _FREQ_HOPPING_H_ 70 | -------------------------------------------------------------------------------- /Firmware/radio/golay.c: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2012 Andrew Tridgell, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file golay23.c 31 | /// 32 | /// golay 23/12 error correction encoding and decoding 33 | /// 34 | 35 | #include 36 | #include "radio.h" 37 | #include "golay23.h" 38 | 39 | // intermediate arrays for encodeing/decoding. Using these 40 | // saves some interal memory that would otherwise be needed 41 | // for pointers 42 | static __pdata uint8_t g3[3], g6[6]; 43 | 44 | // encode 3 bytes data into 6 bytes of coded data 45 | // input is in g3[], output in g6[] 46 | static void 47 | golay_encode24(void) 48 | { 49 | __pdata uint16_t v; 50 | __pdata uint16_t syn; 51 | 52 | v = g3[0] | ((uint16_t)g3[1] & 0x0F) << 8; 53 | syn = golay23_encode[v]; 54 | g6[0] = syn & 0xFF; 55 | g6[1] = (g3[0] & 0x1F) << 3 | syn >> 8; 56 | g6[2] = (g3[0] & 0xE0) >> 5 | (g3[1] & 0x0F) << 3; 57 | 58 | v = g3[2] | ((uint16_t)g3[1] & 0xF0) << 4; 59 | syn = golay23_encode[v]; 60 | g6[3] = syn & 0xFF; 61 | g6[4] = (g3[2] & 0x1F) << 3 | syn >> 8; 62 | g6[5] = (g3[2] & 0xE0) >> 5 | (g3[1] & 0xF0) >> 1; 63 | } 64 | 65 | // encode n bytes of data into 2n coded bytes. n must be a multiple 3 66 | // encoding takes about 6 microseconds per input byte 67 | void 68 | golay_encode(__pdata uint8_t n, __xdata uint8_t * __pdata in, __xdata uint8_t * __pdata out) 69 | { 70 | while (n >= 3) { 71 | g3[0] = in[0]; g3[1] = in[1]; g3[2] = in[2]; 72 | golay_encode24(); 73 | out[0] = g6[0]; out[1] = g6[1]; out[2] = g6[2]; 74 | out[3] = g6[3]; out[4] = g6[4]; out[5] = g6[5]; 75 | in += 3; 76 | out += 6; 77 | n -= 3; 78 | } 79 | } 80 | 81 | // decode 6 bytes of coded data into 3 bytes of original data 82 | // input is in g6[], output in g3[] 83 | // returns the number of words corrected (0, 1 or 2) 84 | static uint8_t 85 | golay_decode24(void) 86 | { 87 | __data uint16_t v; 88 | __data uint16_t syn; 89 | __data uint16_t e; 90 | __pdata uint8_t errcount = 0; 91 | 92 | v = (g6[2] & 0x7F) << 5 | (g6[1] & 0xF8) >> 3; 93 | syn = golay23_encode[v]; 94 | syn ^= g6[0] | (g6[1] & 0x07) << 8; 95 | e = golay23_decode[syn]; 96 | if (e) { 97 | errcount++; 98 | v ^= e; 99 | } 100 | g3[0] = v & 0xFF; 101 | g3[1] = v >> 8; 102 | 103 | v = (g6[5] & 0x7F) << 5 | (g6[4] & 0xF8) >> 3; 104 | syn = golay23_encode[v]; 105 | syn ^= g6[3] | (g6[4] & 0x07) << 8; 106 | e = golay23_decode[syn]; 107 | if (e) { 108 | errcount++; 109 | v ^= e; 110 | } 111 | g3[1] |= (v >> 4) & 0xF0; 112 | g3[2] = v & 0xFF; 113 | 114 | return errcount; 115 | } 116 | 117 | // decode n bytes of coded data into n/2 bytes of original data 118 | // n must be a multiple of 6 119 | // decoding takes about 4 microseconds per input byte 120 | // the number of 12 bit words that required correction is returned 121 | uint8_t 122 | golay_decode(__pdata uint8_t n, __xdata uint8_t * __pdata in, __xdata uint8_t * __pdata out) 123 | { 124 | __pdata uint8_t errcount = 0; 125 | while (n >= 6) { 126 | g6[0] = in[0]; g6[1] = in[1]; g6[2] = in[2]; 127 | g6[3] = in[3]; g6[4] = in[4]; g6[5] = in[5]; 128 | errcount += golay_decode24(); 129 | out[0] = g3[0]; out[1] = g3[1]; out[2] = g3[2]; 130 | in += 6; 131 | out += 3; 132 | n -= 6; 133 | } 134 | return errcount; 135 | } 136 | -------------------------------------------------------------------------------- /Firmware/radio/golay.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2012 Andrew Tridgell, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file golay23.h 31 | /// 32 | /// golay 23/12 error correction encoding and decoding 33 | /// 34 | 35 | 36 | /// encode n bytes of data into 2n coded bytes. n must be a multiple 3 37 | extern void golay_encode(__pdata uint8_t n, __xdata uint8_t * __pdata in, __xdata uint8_t * __pdata out); 38 | 39 | 40 | /// decode n bytes of coded data into n/2 bytes of original data 41 | /// n must be a multiple of 6 42 | extern uint8_t golay_decode(__pdata uint8_t n, __xdata uint8_t * __pdata in, __xdata uint8_t * __pdata out); 43 | -------------------------------------------------------------------------------- /Firmware/radio/mavlink.c: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2012 Andrew Tridgell, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file mavlink.c 31 | /// 32 | /// mavlink reporting code 33 | /// 34 | 35 | #include 36 | #include "radio.h" 37 | #include "packet.h" 38 | #include "timer.h" 39 | 40 | extern __xdata uint8_t pbuf[MAX_PACKET_LENGTH]; 41 | 42 | static uint8_t msp_calc_crc(uint8_t *buf, int len) 43 | { 44 | uint8_t crc=0; 45 | int n; 46 | 47 | for(n = 0; n < len; n++) 48 | { 49 | crc ^= buf[n]; 50 | } 51 | return crc; 52 | } 53 | 54 | /// send a MAVLink status report packet 55 | void MAVLink_report(void) 56 | { 57 | /*** 58 | public struct MSP_RADIO 59 | { 60 | public uint16 rxerrors; 61 | public uint16 fixed_errors; 62 | public uint8 localrssi; 63 | public uint8 remrssi; 64 | public uint8 txbuf; 65 | public uint8 noise; 66 | public uint8 remnoise; 67 | } 68 | **/ 69 | uint16_t rxerr = errors.rx_errors; 70 | uint16_t fixed = errors.corrected_packets; 71 | pbuf[0] = '$'; 72 | pbuf[1] = 'M'; 73 | pbuf[2] = '>'; 74 | pbuf[3] = 9; 75 | pbuf[4] = 199; 76 | pbuf[5] = (rxerr & 0xff); // rxerr 77 | pbuf[6] = (rxerr >> 8); // rxerr 78 | pbuf[7] = (fixed & 0xff); // fixederr 79 | pbuf[8] = (fixed >> 8); // fixederr 80 | pbuf[9] = statistics.average_rssi; 81 | pbuf[10] = remote_statistics.average_rssi; 82 | pbuf[11] = serial_read_space(); 83 | pbuf[12] = statistics.average_noise; 84 | pbuf[13] = remote_statistics.average_noise; 85 | pbuf[14] = msp_calc_crc(pbuf+3, 11); // CRC 86 | if (serial_write_space() > 14) 87 | serial_write_buf(pbuf, 15); 88 | } 89 | -------------------------------------------------------------------------------- /Firmware/radio/packet.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2012 Andrew Tridgell, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | 30 | /// return the next packet to be sent 31 | /// 32 | /// @param max_xmit maximum bytes that can be sent 33 | /// @param buf buffer to put bytes in 34 | /// 35 | /// @return number of bytes to send 36 | extern uint8_t packet_get_next(register uint8_t max_xmit, __xdata uint8_t * __pdata buf); 37 | 38 | /// return true if the last packet was a resend 39 | /// 40 | /// @return true is a resend 41 | extern bool packet_is_resend(void); 42 | 43 | /// return true if the last packet was a injected packet 44 | /// 45 | /// @return true is injected 46 | extern bool packet_is_injected(void); 47 | 48 | /// determine if a received packet is a duplicate 49 | /// 50 | /// @return true if this is a duplicate 51 | extern bool packet_is_duplicate(uint8_t len, __xdata uint8_t * __pdata buf, bool is_resend); 52 | 53 | /// force the last packet to be re-sent. Used when packet transmit has 54 | /// failed 55 | extern void packet_force_resend(void); 56 | 57 | /// set the maximum size of a packet 58 | /// 59 | extern void packet_set_max_xmit(uint8_t max); 60 | 61 | /// set the serial rate in bytes/s 62 | /// 63 | /// @param speed serial speed bytes/s 64 | /// 65 | extern void packet_set_serial_speed(uint16_t speed); 66 | 67 | /// inject a packet to be sent when possible 68 | /// @param buf buffer to send 69 | /// @param len number of bytes 70 | /// 71 | extern void packet_inject(__xdata uint8_t * __pdata buf, __pdata uint8_t len); 72 | 73 | // MSP marker 74 | #define MAVLINK10_STX '$' 75 | -------------------------------------------------------------------------------- /Firmware/radio/parameters.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2011 Michael Smith, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file parameters.h 31 | /// 32 | /// Definitions for program parameter storage. 33 | /// 34 | 35 | /// Parameter IDs. 36 | /// 37 | /// Parameter IDs here match AT S-register numbers, so change them with extreme 38 | /// care. Parameter zero cannot be written by AT commands. 39 | /// 40 | /// Note that this enumeration is used to initialise the parameter_names 41 | /// array, and parameters not listed in that array will not be visible by name. 42 | /// 43 | /// When adding or removing a parameter here, you must also update: 44 | /// 45 | /// parameters.c:parameter_names[] 46 | /// parameters.c:param_check() 47 | /// 48 | enum ParamID { 49 | PARAM_FORMAT = 0, // Must always be parameter 0 50 | PARAM_SERIAL_SPEED, // BAUD_RATE_* constant 51 | PARAM_AIR_SPEED, // over the air baud rate 52 | PARAM_NETID, // network ID 53 | PARAM_TXPOWER, // transmit power (dBm) 54 | PARAM_ECC, // ECC using golay encoding 55 | PARAM_MAVLINK, // MAVLink framing, 0=ignore, 1=use, 2=rc-override 56 | PARAM_OPPRESEND, // opportunistic resend 57 | PARAM_MIN_FREQ, // min frequency in MHz 58 | PARAM_MAX_FREQ, // max frequency in MHz 59 | PARAM_NUM_CHANNELS, // number of hopping channels 60 | PARAM_DUTY_CYCLE, // duty cycle (percentage) 61 | PARAM_LBT_RSSI, // listen before talk threshold 62 | PARAM_MANCHESTER, // enable manchester encoding 63 | PARAM_RTSCTS, // enable hardware flow control 64 | PARAM_MAX_WINDOW, // The maximum window size allowed 65 | PARAM_MAX // must be last 66 | }; 67 | 68 | #define PARAM_FORMAT_CURRENT 0x19UL ///< current parameter format ID 69 | 70 | /// Parameter type. 71 | /// 72 | /// All parameters have this type. 73 | /// 74 | typedef uint32_t param_t; 75 | 76 | /// Set a parameter 77 | /// 78 | /// @note Parameters are not saved until param_save is called. 79 | /// 80 | /// @param param The parameter to set. 81 | /// @param value The value to assign to the parameter. 82 | /// @return True if the parameter's value is valid. 83 | /// 84 | extern bool param_set(__data enum ParamID param, __pdata param_t value); 85 | 86 | /// Get a parameter 87 | /// 88 | /// @param param The parameter to get. 89 | /// @return The parameter value, or zero if the param 90 | /// argument is invalid. 91 | /// 92 | extern param_t param_get(__data enum ParamID param); 93 | 94 | /// Look up a parameter by name 95 | /// 96 | /// @param name The parameter name 97 | /// @return The parameter ID, or PARAM_MAX if the 98 | /// parameter is not known. 99 | /// 100 | extern enum ParamID param_id(__data char * __pdata name); 101 | 102 | /// Return the name of a parameter. 103 | /// 104 | /// @param param The parameter ID to look up. 105 | /// @return A pointer to the name of the parameter, 106 | /// or NULL if the parameter is not known. 107 | /// 108 | extern const char *__code param_name(__data enum ParamID param); 109 | 110 | /// Load parameters from the flash scratchpad. 111 | /// 112 | /// @return True if parameters were successfully loaded. 113 | /// 114 | extern bool param_load(void); 115 | 116 | /// Save parameters to the flash scratchpad. 117 | /// 118 | extern void param_save(void); 119 | 120 | /// Reset parameters to default. 121 | /// 122 | /// Note that this just resets - it does not save. 123 | /// 124 | extern void param_default(void); 125 | 126 | /// convenient routine to constrain parameter values 127 | uint32_t constrain(__pdata uint32_t v, __pdata uint32_t min, __pdata uint32_t max); 128 | 129 | #ifdef BOARD_rfd900a 130 | extern bool calibration_set(uint8_t idx, uint8_t value) __reentrant; 131 | extern uint8_t calibration_get(uint8_t level) __reentrant; 132 | extern bool calibration_lock() __reentrant; 133 | #endif // BOARD_rfd900a 134 | -------------------------------------------------------------------------------- /Firmware/radio/printfl.c: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------- 2 | printfl.c - source file for reduced version of printf 3 | 4 | Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net 5 | 2001060401: Improved by was@icb.snz.chel.su 6 | 7 | This library is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 2.1, or (at your option) any 10 | later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this library; see the file COPYING. If not, write to the 19 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 20 | MA 02110-1301, USA. 21 | 22 | As a special exception, if you link this library with other files, 23 | some of which are compiled with SDCC, to produce an executable, 24 | this library does not by itself cause the resulting executable to 25 | be covered by the GNU General Public License. This exception does 26 | not however invalidate any other reasons why the executable file 27 | might be covered by the GNU General Public License. 28 | -------------------------------------------------------------------------*/ 29 | 30 | /* following formats are supported :- 31 | format output type argument-type 32 | %d decimal int 33 | %ld decimal long 34 | %hd decimal char 35 | %u decimal unsigned int 36 | %lu decimal unsigned long 37 | %hu decimal unsigned char 38 | %x hexadecimal int 39 | %lx hexadecimal long 40 | %hx hexadecimal char 41 | %o octal int 42 | %lo octal long 43 | %ho octal char 44 | %c character char 45 | %s character generic pointer 46 | */ 47 | #include "radio.h" 48 | 49 | static __data char radix; 50 | static __bit long_flag = 0; 51 | static __bit string_flag = 0; 52 | static __bit char_flag = 0; 53 | static __bit unsigned_flag = 0; 54 | static char * __data str; 55 | static __data long val; 56 | 57 | // allow printf() output to be captured to a buffer 58 | // for remote AT command control 59 | static bool capture; 60 | static __xdata uint8_t *capture_buffer; 61 | static __pdata uint8_t capture_buffer_size; 62 | static __pdata uint8_t captured_size; 63 | 64 | static void 65 | output_char(register char c) 66 | { 67 | if (!capture) { 68 | putchar(c); 69 | return; 70 | } 71 | if (captured_size < capture_buffer_size) { 72 | capture_buffer[captured_size++] = c; 73 | } 74 | } 75 | 76 | // start capturing bytes from printf() 77 | void 78 | printf_start_capture(__xdata uint8_t *buf, uint8_t size) 79 | { 80 | capture_buffer = buf; 81 | captured_size = 0; 82 | capture_buffer_size = size; 83 | capture = true; 84 | } 85 | 86 | // end capture, returning number of bytes that have been captured 87 | uint8_t 88 | printf_end_capture(void) 89 | { 90 | capture = false; 91 | return captured_size; 92 | } 93 | 94 | void 95 | vprintfl(const char * fmt, va_list ap) __reentrant 96 | { 97 | 98 | for (; *fmt; fmt++) { 99 | if (*fmt == '%') { 100 | long_flag = string_flag = char_flag = unsigned_flag = 0; 101 | fmt++; 102 | switch (*fmt) { 103 | case 'l': 104 | long_flag = 1; 105 | fmt++; 106 | break; 107 | case 'h': 108 | char_flag = 1; 109 | fmt++; 110 | } 111 | 112 | switch (*fmt) { 113 | case 's': 114 | string_flag = 1; 115 | break; 116 | case 'd': 117 | radix = 10; 118 | break; 119 | case 'u': 120 | radix = 10; 121 | unsigned_flag = 1; 122 | break; 123 | case 'x': 124 | radix = 16; 125 | unsigned_flag = 1; 126 | break; 127 | case 'c': 128 | radix = 0; 129 | break; 130 | case 'o': 131 | radix = 8; 132 | unsigned_flag = 1; 133 | break; 134 | } 135 | 136 | if (string_flag) { 137 | str = va_arg(ap, char *); 138 | while (*str) 139 | output_char(*str++); 140 | continue; 141 | } 142 | 143 | if (unsigned_flag) { 144 | if (long_flag) { 145 | val = va_arg(ap,unsigned long); 146 | } else if (char_flag) { 147 | val = va_arg(ap,unsigned char); 148 | } else { 149 | val = va_arg(ap,unsigned int); 150 | } 151 | } else { 152 | if (long_flag) { 153 | val = va_arg(ap,long); 154 | } else if (char_flag) { 155 | val = va_arg(ap,char); 156 | } else { 157 | val = va_arg(ap,int); 158 | } 159 | } 160 | 161 | if (radix) { 162 | static char __idata buffer[12]; /* 37777777777(oct) */ 163 | char __idata * stri; 164 | 165 | if (unsigned_flag) { 166 | _ultoa(val, buffer, radix); 167 | } else { 168 | _ltoa(val, buffer, radix); 169 | } 170 | stri = buffer; 171 | while (*stri) { 172 | output_char(*stri); 173 | stri++; 174 | } 175 | } else { 176 | output_char((char) val); 177 | } 178 | 179 | } else { 180 | output_char(*fmt); 181 | } 182 | } 183 | } 184 | 185 | void 186 | printfl(const char *fmt, ...) __reentrant 187 | { 188 | va_list ap; 189 | 190 | va_start(ap,fmt); 191 | vprintfl(fmt, ap); 192 | } 193 | 194 | -------------------------------------------------------------------------------- /Firmware/radio/product.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2011 Michael Smith, 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 6 | # are met: 7 | # 8 | # o Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # o Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in 12 | # the documentation and/or other materials provided with the distribution. 13 | # 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 17 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 18 | # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 19 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 23 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 25 | # OF THE POSSIBILITY OF SUCH DAMAGE. 26 | # 27 | # Makefile for the Si1000 radio application 28 | # 29 | 30 | VERSION_MAJOR = 1 31 | VERSION_MINOR = 9 32 | 33 | PRODUCT = radio~$(BOARD) 34 | PRODUCT_DIR := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) 35 | 36 | CFLAGS += -DAPP_VERSION_HIGH=$(VERSION_MAJOR) -DAPP_VERSION_LOW=$(VERSION_MINOR) 37 | CFLAGS += --model-large --opt-code-speed --Werror --std-sdcc99 --fomit-frame-pointer 38 | #CFLAGS += --fverbose-asm 39 | 40 | LDFLAGS += --model-large --iram-size 256 --xram-size 4096 --code-loc 0x400 --code-size 0x00f400 --stack-size 64 41 | 42 | include $(SRCROOT)/include/rules.mk 43 | -------------------------------------------------------------------------------- /Firmware/radio/rtc.c: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2012 Michael Smith, All Rights Reserved 4 | // Copyright (c) 2012 Andrew Tridgell, All Rights Reserved 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // o Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // o Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in 14 | // the documentation and/or other materials provided with the distribution. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 19 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 20 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 27 | // OF THE POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | /// 31 | /// @file rtc.c 32 | /// 33 | /// Interface to the SmaRTClock 34 | /// 35 | 36 | #include "radio.h" 37 | 38 | #ifdef USE_RTC 39 | static uint8_t rtc_read_reg(uint8_t reg); 40 | static void rtc_write_reg(uint8_t reg, uint8_t val); 41 | 42 | #define CN_RUN (RTC_CN_EN | RTC_CN_TR) 43 | #define CN_CAPTURE (CN_RUN | RTC_CN_CAP) 44 | #define CN_LOAD (CN_RUN | RTC_CN_SET) 45 | 46 | #define EX0_SAVE_DISABLE __bit EX0_saved = EX0; EX0 = 0 47 | #define EX0_RESTORE EX0 = EX0_saved 48 | 49 | /// initialise the RTC subsystem 50 | void 51 | rtc_init(void) 52 | { 53 | // unlock the RTC 54 | RTC0KEY = 0xa5; 55 | RTC0KEY = 0xf1; 56 | 57 | // configure for self-oscillation 58 | rtc_write_reg(RTC_PIN, RTC_PIN_SELF_OSC); 59 | 60 | // double the clock rate 61 | rtc_write_reg(RTC_XCN, RTC_XCN_BIASX2); 62 | 63 | // start it running 64 | rtc_write_reg(RTC_CN, CN_RUN); 65 | } 66 | 67 | /// return the timer as a 32 bit value. 68 | /// 69 | /// @return The RTC clock in 25usec units 70 | /// 71 | uint32_t 72 | rtc_read_count(void) 73 | { 74 | union { 75 | uint8_t b[4]; 76 | uint32_t l; 77 | } mix; 78 | 79 | // start a capture 80 | rtc_write_reg(RTC_CN, CN_CAPTURE); 81 | 82 | // wait for capture to complete 83 | while (rtc_read_reg(RTC_CN) & RTC_CN_CAP) ; 84 | 85 | // capture the current counter value registers 86 | // using a auto-incrementing strobe read 87 | RTC0ADR = RTC0ADR_BUSY | RTC0ADR_AUTO | RTC0ADR_SHORT; 88 | __asm 89 | NOP 90 | NOP 91 | NOP 92 | __endasm; 93 | mix.b[0] = RTC0DAT; 94 | __asm 95 | NOP 96 | NOP 97 | NOP 98 | __endasm; 99 | mix.b[1] = RTC0DAT; 100 | __asm 101 | NOP 102 | NOP 103 | NOP 104 | __endasm; 105 | mix.b[2] = RTC0DAT; 106 | __asm 107 | NOP 108 | NOP 109 | NOP 110 | __endasm; 111 | mix.b[3] = RTC0DAT; 112 | 113 | return mix.l; 114 | } 115 | 116 | /// return the RTC timer as a 16 bit value. 117 | /// 118 | /// @return The RTC clock in 25usec units 119 | /// 120 | /// Note: this call takes about 50usec 121 | uint16_t 122 | rtc_read_count16(void) 123 | { 124 | uint16_t ret; 125 | 126 | EX0_SAVE_DISABLE; 127 | 128 | // start a capture 129 | rtc_write_reg(RTC_CN, CN_CAPTURE); 130 | 131 | // wait for capture to complete 132 | while (rtc_read_reg(RTC_CN) & RTC_CN_CAP) ; 133 | 134 | // capture the current counter value registers 135 | // using a auto-incrementing strobe read 136 | RTC0ADR = RTC0ADR_BUSY | RTC0ADR_AUTO | RTC0ADR_SHORT; 137 | __asm 138 | NOP 139 | NOP 140 | NOP 141 | __endasm; 142 | ret = RTC0DAT; 143 | __asm 144 | NOP 145 | NOP 146 | NOP 147 | __endasm; 148 | ret |= (RTC0DAT<<8); 149 | 150 | EX0_RESTORE; 151 | 152 | return ret; 153 | } 154 | 155 | /// return the timer as a 8 bit value. 156 | /// 157 | /// @return The RTC clock in 25usec units 158 | /// 159 | uint8_t 160 | rtc_read_low(void) 161 | { 162 | // capture the current counter value 163 | rtc_write_reg(RTC_CN, CN_CAPTURE); 164 | 165 | // wait for capture to complete 166 | while (rtc_read_reg(RTC_CN) & RTC_CN_CAP) ; 167 | 168 | // read the counter shadow 169 | return rtc_read_reg(RTC_CAPTURE0); 170 | } 171 | 172 | void 173 | rtc_write_count(uint32_t count) 174 | { 175 | union { 176 | uint8_t b[4]; 177 | uint32_t l; 178 | } mix; 179 | 180 | // write the counter shadow 181 | mix.l = count; 182 | rtc_write_reg(RTC_CAPTURE0, mix.b[0]); 183 | rtc_write_reg(RTC_CAPTURE1, mix.b[1]); 184 | rtc_write_reg(RTC_CAPTURE2, mix.b[2]); 185 | rtc_write_reg(RTC_CAPTURE3, mix.b[3]); 186 | 187 | // load the new value into the counter 188 | rtc_write_reg(RTC_CN, CN_LOAD); 189 | } 190 | 191 | static uint8_t 192 | rtc_read_reg(uint8_t reg) 193 | { 194 | while (RTC0ADR & RTC0ADR_BUSY) ; // wait for busy to clear 195 | RTC0ADR = RTC0ADR_BUSY | reg; 196 | while (RTC0ADR & RTC0ADR_BUSY) ; // wait for busy to clear 197 | return RTC0DAT; 198 | } 199 | 200 | static void 201 | rtc_write_reg(uint8_t reg, uint8_t val) 202 | { 203 | while (RTC0ADR & RTC0ADR_BUSY) ; // wait for busy to clear 204 | RTC0ADR = reg; 205 | RTC0DAT = val; 206 | } 207 | #endif 208 | -------------------------------------------------------------------------------- /Firmware/radio/rtc.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2012 Michael Smith, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file rtc.h 31 | /// 32 | /// Interface to the SmaRTClock 33 | /// 34 | 35 | // RTC internal registers 36 | #define RTC_CAPTURE0 0x00 37 | #define RTC_CAPTURE1 0x01 38 | #define RTC_CAPTURE2 0x02 39 | #define RTC_CAPTURE3 0x03 40 | #define RTC_CN 0x04 41 | #define RTC_XCN 0x05 42 | #define RTC_XCF 0x06 43 | #define RTC_PIN 0x07 44 | #define RTC_ALARM0 0x08 45 | #define RTC_ALARM1 0x09 46 | #define RTC_ALARM2 0x0a 47 | #define RTC_ALARM3 0x0b 48 | 49 | // RTC0ADR bits 50 | #define RTC0ADR_BUSY 0x80 51 | #define RTC0ADR_AUTO 0x40 52 | #define RTC0ADR_SHORT 0x10 53 | 54 | // RTC_CN 55 | #define RTC_CN_EN (1<<7) 56 | #define RTC_CN_MCLKEN (1<<6) 57 | #define RTC_CN_OSCFAIL (1<<5) 58 | #define RTC_CN_TR (1<<4) 59 | #define RTC_CN_AEN (1<<3) 60 | #define RTC_CN_ALRM (1<<2) 61 | #define RTC_CN_SET (1<<1) 62 | #define RTC_CN_CAP (1<<0) 63 | 64 | // RTC_XCN 65 | #define RTC_XCN_AGCEN (1<<7) 66 | #define RTC_XCN_XMODE (1<<6) 67 | #define RTC_XCN_BIASX2 (1<<5) 68 | #define RTC_XCN_CLKVLD (1<<4) 69 | 70 | // RTC_XCF 71 | #define RTC_XCF_AUTOSTP (1<<7) 72 | #define RTC_XCF_LOADRDY (1<<6) 73 | 74 | // RTC_PIN 75 | #define RTC_PIN_SELF_OSC 0xe7 76 | #define RTC_PIN_XTAL_OSC 0x67 77 | 78 | extern void rtc_init(void); 79 | extern uint32_t rtc_read_count(void); 80 | extern uint16_t rtc_read_count16(void); 81 | extern uint8_t rtc_read_low(void); 82 | extern void rtc_write_count(uint32_t count); 83 | -------------------------------------------------------------------------------- /Firmware/radio/serial.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2011 Michael Smith, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file serial.h 31 | /// 32 | /// Serial port driver with flow control and AT command 33 | /// parser integration. 34 | /// 35 | 36 | #ifndef _SERIAL_H_ 37 | #define _SERIAL_H_ 38 | 39 | #include 40 | #include "radio.h" 41 | 42 | /// Initialise the serial port. 43 | /// 44 | /// @param speed The serial speed to configure, passed 45 | /// to serial_device_set_speed at the appropriate 46 | /// point during initialisation. 47 | /// 48 | extern void serial_init(register uint8_t speed); 49 | 50 | /// check if a serial speed is valid 51 | /// 52 | /// @param speed The serial speed to configure 53 | /// 54 | extern bool serial_device_valid_speed(register uint8_t speed); 55 | 56 | /// Write a byte to the serial port. 57 | /// 58 | /// @param c The byte to write. 59 | /// @return True if the byte was written, false if the 60 | /// FIFO is full. 61 | /// 62 | extern bool serial_write(register uint8_t c); 63 | 64 | /// Write bytes to the serial port. 65 | /// 66 | /// @param buf Pointer to the data to write. 67 | /// @param count The number of bytes to write. 68 | /// 69 | extern void serial_write_buf(__xdata uint8_t * __data buf, __pdata uint8_t count); 70 | 71 | /// Check for space in the write FIFO 72 | /// 73 | /// @return The number of bytes that can be written. 74 | /// 75 | extern uint16_t serial_write_space(void); 76 | 77 | /// Check for space in the read FIFO. Used to allow for software flow 78 | /// control 79 | /// 80 | /// @return The percentage free space in the rx buffer 81 | /// 82 | extern uint8_t serial_read_space(void); 83 | 84 | /// Read a byte from the serial port. 85 | /// 86 | /// @return The next byte in the receive FIFO. 87 | /// If no bytes are available, returns zero. 88 | /// 89 | extern uint8_t serial_read(void); 90 | 91 | /// peek at a byte from the serial port, without removing it 92 | /// caller must ensure serial available is > 0 93 | /// 94 | /// @return The next byte in the receive FIFO. 95 | /// 96 | extern uint8_t serial_peek(void); 97 | 98 | /// peek at the byte after next from the serial port, without removing it 99 | /// caller must ensure serial available is > 1 100 | /// 101 | /// @return The byte after next in the receive FIFO. 102 | /// 103 | extern uint8_t serial_peek2(void); 104 | 105 | /// peek at the byte x bytes in from the serial port, without removing it 106 | /// caller must ensure serial available is > offset 107 | /// 108 | /// @return The byte after next in the receive FIFO. 109 | /// 110 | extern uint8_t serial_peekx(uint16_t offset); 111 | 112 | /// Read bytes from the serial port. 113 | /// 114 | /// @param buf Buffer for read data. 115 | /// @param count The number of bytes to read. 116 | /// @return True if @count bytes were read, false 117 | /// if there is not enough data in the buffer 118 | /// to satisfy the request (no bytes are read 119 | /// in this case). 120 | /// 121 | extern bool serial_read_buf(__xdata uint8_t * __data buf, __pdata uint8_t count); 122 | 123 | /// Check for bytes in the read FIFO 124 | /// 125 | /// @return The number of bytes available to be read 126 | /// from the FIFO. 127 | /// 128 | extern uint16_t serial_read_available(void); 129 | 130 | /// check if RTS allows us to send more data 131 | /// 132 | extern void serial_check_rts(void); 133 | 134 | #endif // _SERIAL_H_ 135 | -------------------------------------------------------------------------------- /Firmware/radio/tdm.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2012 Andrew Tridgell, All Rights Reserved 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // o Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // o Redistributions in binary form must reproduce the above copyright 12 | // notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 | // OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | 29 | /// 30 | /// @file tdm.h 31 | /// 32 | /// Interface to the time division multiplexing code 33 | /// 34 | 35 | #ifndef _TDM_H_ 36 | #define _TDM_H_ 37 | 38 | /// initialise tdm subsystem 39 | /// 40 | extern void tdm_init(void); 41 | 42 | // tdm main loop 43 | /// 44 | extern void tdm_serial_loop(void); 45 | 46 | /// report tdm timings 47 | /// 48 | extern void tdm_report_timing(void); 49 | 50 | /// dispatch a remote AT command 51 | extern void tdm_remote_at(void); 52 | 53 | /// change tdm phase (for testing recovery) 54 | extern void tdm_change_phase(void); 55 | 56 | /// show RSSI information 57 | extern void tdm_show_rssi(void); 58 | 59 | /// the long term duty cycle we are aiming for 60 | extern __pdata uint8_t duty_cycle; 61 | 62 | /// the LBT threshold 63 | extern __pdata uint8_t lbt_rssi; 64 | 65 | #endif // _TDM_H_ 66 | -------------------------------------------------------------------------------- /Firmware/radio/timer.c: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2011 Michael Smith, All Rights Reserved 4 | // Copyright (c) 2011 Andrew Tridgell, All Rights Reserved 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // o Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // o Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in 14 | // the documentation and/or other materials provided with the distribution. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 19 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 20 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 27 | // OF THE POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | #include "radio.h" 31 | #include "timer.h" 32 | 33 | /// Counter used by delay_msec 34 | /// 35 | static __data volatile uint8_t delay_counter; 36 | 37 | /// high 16 bits of timer2 SYSCLK/12 interrupt 38 | static __data volatile uint16_t timer2_high; 39 | 40 | 41 | INTERRUPT(T3_ISR, INTERRUPT_TIMER3) 42 | { 43 | // re-arm the interrupt by clearing TF3H 44 | TMR3CN = 0x04; 45 | 46 | // call the AT parser tick 47 | at_timer(); 48 | 49 | // update the delay counter 50 | if (delay_counter > 0) 51 | delay_counter--; 52 | } 53 | 54 | void 55 | delay_set(register uint16_t msec) 56 | { 57 | if (msec >= 2550) { 58 | delay_counter = 255; 59 | } else { 60 | delay_counter = (msec + 9) / 10; 61 | } 62 | } 63 | 64 | void 65 | delay_set_ticks(register uint8_t ticks) 66 | { 67 | delay_counter = ticks; 68 | } 69 | 70 | bool 71 | delay_expired(void) 72 | { 73 | return delay_counter == 0; 74 | } 75 | 76 | void 77 | delay_msec(register uint16_t msec) 78 | { 79 | delay_set(msec); 80 | while (!delay_expired()) 81 | ; 82 | } 83 | 84 | 85 | // timer2 interrupt called every 32768 microseconds 86 | INTERRUPT(T2_ISR, INTERRUPT_TIMER2) 87 | { 88 | // re-arm the interrupt by clearing TF2H 89 | TMR2CN = 0x04; 90 | 91 | // increment the high 16 bits 92 | timer2_high++; 93 | 94 | if (feature_rtscts) { 95 | serial_check_rts(); 96 | } 97 | } 98 | 99 | // return the 16 bit timer2 counter 100 | // this call costs about 2 microseconds 101 | uint16_t 102 | timer2_16(void) 103 | { 104 | register uint8_t low, high; 105 | do { 106 | // we need to make sure that the high byte hasn't changed 107 | // between reading the high and low parts of the 16 bit timer 108 | high = TMR2H; 109 | low = TMR2L; 110 | } while (high != TMR2H); 111 | return low | (((uint16_t)high)<<8); 112 | } 113 | 114 | #if 0 115 | // return microseconds since boot 116 | // this call costs about 5usec 117 | uint32_t 118 | micros(void) 119 | { 120 | uint16_t low, high; 121 | do { 122 | high = timer2_high; 123 | low = timer2_16(); 124 | } while (high != timer2_high); 125 | return ((((uint32_t)high)<<16) | low) >> 1; 126 | } 127 | #endif 128 | 129 | // return a 16 bit value that rolls over in approximately 130 | // one second intervals 131 | uint16_t 132 | timer2_tick(void) 133 | { 134 | register uint16_t low, high; 135 | do { 136 | high = timer2_high; 137 | low = timer2_16(); 138 | } while (high != timer2_high); 139 | // take 11 high bits from the 2MHz counter, and 5 low bits 140 | // from the rollover of that counter 141 | return (high<<11) | (low>>5); 142 | } 143 | 144 | // initialise timers 145 | void 146 | timer_init(void) 147 | { 148 | // 100Hz timer tick using timer3 149 | // Derive timer values from SYSCLK, just for laughs. 150 | TMR3RLL = (65536UL - ((SYSCLK / 12) / 100)) & 0xff; 151 | TMR3RLH = ((65536UL - ((SYSCLK / 12) / 100)) >> 8) & 0xff; 152 | TMR3CN = 0x04; // count at SYSCLK / 12 and start 153 | EIE1 |= 0x80; 154 | 155 | // setup TMR2 as a timer source at SYSCLK/12 156 | TMR2RLL = 0; 157 | TMR2RLH = 0; 158 | TMR2CN = 0x04; // start running, count at SYSCLK/12 159 | ET2 = 1; 160 | } 161 | 162 | // return some entropy 163 | uint8_t 164 | timer_entropy(void) 165 | { 166 | // use the SYSCLK/12 timer 167 | return TMR2L; 168 | } 169 | -------------------------------------------------------------------------------- /Firmware/radio/timer.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C; c-basic-offset: 8; -*- 2 | // 3 | // Copyright (c) 2011 Michael Smith, All Rights Reserved 4 | // Copyright (c) 2011 Andrew Tridgell, All Rights Reserved 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // o Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // o Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in 14 | // the documentation and/or other materials provided with the distribution. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 19 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 20 | // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 27 | // OF THE POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | 30 | /// return the 16 bit timer2 counter 31 | /// 32 | /// @return timer counter, in 0.5usec units 33 | /// 34 | extern uint16_t timer2_16(void); 35 | 36 | /// return microseconds since boot 37 | /// 38 | /// @return microseconds since boot 39 | extern uint32_t micros(void); 40 | 41 | /// return a 16 bit value that rolls over in approximately 42 | /// one second intervals 43 | /// 44 | /// @return 16 bit value in units of 16 microseconds 45 | /// 46 | extern uint16_t timer2_tick(void); 47 | 48 | 49 | /// initialise timers 50 | /// 51 | extern void timer_init(void); 52 | 53 | /// Set the delay timer 54 | /// 55 | /// @note Maximum delay is ~2.5sec in the current implementation. 56 | /// 57 | /// @param msec Minimum time before the timer expiers. The actual time 58 | /// may be greater. 59 | /// 60 | extern void delay_set(register uint16_t msec); 61 | 62 | /// Set the delay timer in 100Hz ticks 63 | /// 64 | /// @param ticks Number of ticks before the timer expires. 65 | /// 66 | extern void delay_set_ticks(register uint8_t ticks); 67 | 68 | /// Check the delay timer. 69 | /// 70 | /// @return True if the timer has expired. 71 | /// 72 | extern bool delay_expired(void); 73 | 74 | /// Wait for a period of time to expire. 75 | /// 76 | /// @note Maximum wait is ~2.5sec in the current implementation. 77 | /// 78 | /// @param msec Minimum time to wait. The actual time 79 | /// may be greater. 80 | /// 81 | extern void delay_msec(register uint16_t msec); 82 | 83 | /// return some entropy from timers 84 | /// 85 | extern uint8_t timer_entropy(void); 86 | -------------------------------------------------------------------------------- /Firmware/tools/check_code.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | ''' 3 | check the radio code for prototype consistency 4 | Andrew Tridgell, February 2012 5 | ''' 6 | 7 | import re, glob, sys 8 | 9 | header_protos = {} 10 | code_protos = {} 11 | 12 | hmatch = re.compile(r'^extern\s+.*\s+(\w+)\(.*\)'); 13 | cmatch = re.compile(r'^(\w+)\(.*\)'); 14 | 15 | def extract_header_functions(h, d): 16 | '''extract extern functions from a header''' 17 | f = open(h) 18 | for line in f: 19 | line = line.strip() 20 | line = line.replace('\t', ' ') 21 | line = line.replace(' ', ' ') 22 | if line.endswith(';'): 23 | line = line[:-1] 24 | m = hmatch.match(line) 25 | if m: 26 | d[m.group(1)] = line 27 | 28 | def extract_C_functions(c, d): 29 | '''extract extern functions from a header''' 30 | f = open(c) 31 | prevline = '' 32 | for line in f: 33 | line = line.rstrip() 34 | line = line.replace('\t', ' ') 35 | line = line.replace(' ', ' ') 36 | m = cmatch.match(line) 37 | if m and not prevline.startswith('static') and line.find('INTERRUPT') == -1: 38 | d[m.group(1)] = prevline + ' ' + line 39 | prevline = line 40 | 41 | error_count = 0 42 | 43 | def check_xiseg(): 44 | '''check that XISEG has not overflowed''' 45 | global error_count 46 | xmatch = re.compile(r'^XISEG\s*(\w+)\s*(\w+)'); 47 | for map in glob.glob("obj/*/radio*/*map"): 48 | f = open(map) 49 | for line in f: 50 | m = xmatch.match(line) 51 | if m: 52 | ofs1 = int(m.group(1),16) 53 | ofs2 = int(m.group(2),16) 54 | if ofs1 + ofs2 >= 4096: 55 | print('ERROR: XISEG overflow %u in %s' % (ofs1+ofs2, map)) 56 | error_count += 1 57 | else: 58 | print('XISEG %s - %u bytes available' % (map, 4096-(ofs1+ofs2))) 59 | 60 | 61 | # go through all the headers looking for extern declarations of functions 62 | for h in glob.glob('radio/*.h'): 63 | extract_header_functions(h, header_protos) 64 | 65 | for c in glob.glob('radio/*.c'): 66 | extract_C_functions(c, code_protos) 67 | 68 | for h in header_protos: 69 | if not h in code_protos: 70 | print("No code proto for %s: %s\n" % (h, header_protos[h])) 71 | error_count += 1 72 | continue 73 | if header_protos[h] != 'extern ' + code_protos[h]: 74 | print('Header: %s\nCode: %s\n' % (header_protos[h], code_protos[h])) 75 | error_count += 1 76 | 77 | 78 | for c in code_protos: 79 | if not c in header_protos and not c in ['main', 'putchar', '__at']: 80 | print("No header proto for %s: %s\n" % (c, code_protos[c])) 81 | error_count += 1 82 | continue 83 | 84 | check_xiseg() 85 | if error_count: 86 | print("ERROR: code checked failed with %u errors" % error_count) 87 | sys.exit(1) 88 | print("Code check OK") 89 | 90 | -------------------------------------------------------------------------------- /Firmware/tools/console.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # a trivial serial console 3 | 4 | import serial, sys, optparse, fdpexpect 5 | 6 | parser = optparse.OptionParser("console") 7 | parser.add_option("--baudrate", type='int', default=57600, help='baud rate') 8 | parser.add_option("--rtscts", action='store_true', default=False, help='enable rtscts') 9 | parser.add_option("--dsrdtr", action='store_true', default=False, help='enable dsrdtr') 10 | parser.add_option("--xonxoff", action='store_true', default=False, help='enable xonxoff') 11 | 12 | opts, args = parser.parse_args() 13 | 14 | if len(args) != 1: 15 | print("usage: console.py ") 16 | sys.exit(1) 17 | 18 | device = args[0] 19 | 20 | port = serial.Serial(device, opts.baudrate, timeout=0, 21 | dsrdtr=opts.dsrdtr, rtscts=opts.rtscts, xonxoff=opts.xonxoff) 22 | 23 | ser = fdpexpect.fdspawn(port.fileno(), maxread=1) 24 | ser.delaybeforesend = 0 25 | print("Connecting (use ^] to exit)") 26 | ser.interact() 27 | 28 | -------------------------------------------------------------------------------- /Firmware/tools/ec2upload: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Trivial uploader script, assumes that you have the EC2 tools somewhere on your path. 4 | # 5 | 6 | EWF=`which ec2writeflash` 7 | 8 | if [ -z $EWF ]; then 9 | echo "Could not find ec2writeflash on your path - did you install the EC2 tools?" 10 | exit 1 11 | fi 12 | if [ -z $1 ]; then 13 | echo "Missing firmware filename." 14 | exit 1 15 | fi 16 | if [ ! -r $1 ]; then 17 | echo "Input file '$1' not readable." 18 | exit 1 19 | fi 20 | 21 | ${EWF} --port=USB --mode=c2 --eraseall --run --hex $1 22 | -------------------------------------------------------------------------------- /Firmware/tools/hexpatch.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # IntelHex patcher. 4 | # 5 | # hexpatch --patch
:[,
:...] 6 | # 7 | # where
is the address at which the byte should be written. Results are 8 | # written to stdout. 9 | # 10 | 11 | import argparse, sys, binascii, struct 12 | 13 | class ihrange(object): 14 | '''Comprehend a line of IntelHex''' 15 | def __init__(self, line): 16 | # parse the header off the line 17 | self.line = line 18 | self.hexstr = line.rstrip()[1:-2] 19 | self.binstr = binascii.unhexlify(self.hexstr) 20 | self.count = ord(self.binstr[0]) 21 | self.address = (ord(self.binstr[1]) << 8) + ord(self.binstr[2]) 22 | self.command = ord(self.binstr[3]) 23 | 24 | # regular data line 25 | if (self.command == 0): 26 | self.bytes = list(self.binstr[4:]) 27 | 28 | def __str__(self): 29 | # only data lines can be patched 30 | if (self.command != 0): 31 | return self.line 32 | 33 | # reconstruct the line from the patched version 34 | hexstr = "" 35 | hexstr += chr(self.count) 36 | hexstr += chr(self.address >> 8) 37 | hexstr += chr(self.address & 0xff) 38 | hexstr += chr(self.command) 39 | hexstr += "".join(self.bytes) 40 | sum = 0 41 | for c in hexstr: 42 | sum += ord(c) 43 | sum = (256 - (sum % 256)) % 256 44 | hexstr += chr(sum) 45 | return ":" + binascii.hexlify(hexstr).upper() 46 | 47 | def patch(self, address, value): 48 | # only worth patching if command is zero 49 | if (self.command != 0): 50 | return 51 | if ((address >= self.address) and (address < (self.address + self.count))): 52 | self.bytes[address - self.address] = chr(value) 53 | 54 | 55 | # grab patches from the commandline 56 | parser = argparse.ArgumentParser(description="IntelHex patcher") 57 | parser.add_argument("--patch", action = "store", required = True, help = "comma-separated list of
: byte patches") 58 | parser.add_argument("inputfile", action = "store", help = "File to patch (results written to stdout)") 59 | args = parser.parse_args() 60 | 61 | patches = args.patch.split(",") 62 | f = open(args.inputfile, mode="r") 63 | 64 | # iterate the file 65 | for line in f: 66 | range = ihrange(line) 67 | for p in patches: 68 | address, value = tuple(p.split(":")) 69 | range.patch(int(address, 0), int(value, 0)) 70 | print(range) 71 | -------------------------------------------------------------------------------- /Firmware/tools/pattern.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # reflect input bytes to output, printing as it goes 3 | 4 | import serial, sys, optparse, time 5 | 6 | parser = optparse.OptionParser("pattern") 7 | parser.add_option("--baudrate", type='int', default=57600, help='baud rate') 8 | parser.add_option("--delay", type='float', default=0.0, help='delay between lines') 9 | parser.add_option("--pattern", type='str', default='0123456789', help='pattern to send') 10 | parser.add_option("--echo", action='store_true', default=False, help='echo any bytes received') 11 | parser.add_option("--crlf", action='store_true', default=False, help='add crlf') 12 | parser.add_option("--counter", action='store_true', default=False, help='add counter') 13 | parser.add_option("--rtscts", action='store_true', default=False, help='enable rtscts') 14 | parser.add_option("--dsrdtr", action='store_true', default=False, help='enable dsrdtr') 15 | parser.add_option("--xonxoff", action='store_true', default=False, help='enable xonxoff') 16 | 17 | opts, args = parser.parse_args() 18 | 19 | if len(args) != 1: 20 | print("usage: pattern.py ") 21 | sys.exit(1) 22 | 23 | device = args[0] 24 | 25 | port = serial.Serial(device, opts.baudrate, timeout=0, 26 | dsrdtr=opts.dsrdtr, rtscts=opts.rtscts, xonxoff=opts.xonxoff) 27 | counter = 0 28 | while True: 29 | try: 30 | buf = opts.pattern[:] 31 | if opts.counter: 32 | buf += "%02u" % (counter % 100) 33 | if opts.crlf: 34 | buf += '\r\n' 35 | port.write(buf) 36 | port.flush() 37 | if opts.echo: 38 | try: 39 | count = port.inWaiting() 40 | if count > 0: 41 | buf = port.read(count) 42 | if len(buf) > 0: 43 | sys.stdout.write(buf) 44 | sys.stdout.flush() 45 | except Exception: 46 | pass 47 | if opts.delay > 0.0: 48 | time.sleep(opts.delay) 49 | counter += 1 50 | except KeyboardInterrupt: 51 | sys.exit(0) 52 | -------------------------------------------------------------------------------- /Firmware/tools/reflector.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # reflect input bytes to output, printing as it goes 3 | 4 | import serial, sys, optparse 5 | 6 | parser = optparse.OptionParser("reflector") 7 | parser.add_option("--baudrate", type='int', default=57600, help='baud rate') 8 | parser.add_option("--echo", action='store_true', default=False, help='echo to stdout') 9 | parser.add_option("--rtscts", action='store_true', default=False, help='enable rtscts') 10 | parser.add_option("--dsrdtr", action='store_true', default=False, help='enable dsrdtr') 11 | parser.add_option("--xonxoff", action='store_true', default=False, help='enable xonxoff') 12 | 13 | opts, args = parser.parse_args() 14 | 15 | if len(args) != 1: 16 | print("usage: reflector.py ") 17 | sys.exit(1) 18 | 19 | device = args[0] 20 | 21 | port = serial.Serial(device, opts.baudrate, timeout=1, 22 | dsrdtr=opts.dsrdtr, rtscts=opts.rtscts, xonxoff=opts.xonxoff) 23 | 24 | while True: 25 | try: 26 | count = port.inWaiting() 27 | if count == 0: 28 | count = 1 29 | buf = port.read(count) 30 | if len(buf) == 0: 31 | continue 32 | if opts.echo: 33 | sys.stdout.write(buf) 34 | sys.stdout.flush() 35 | port.write(buf) 36 | port.flush() 37 | except KeyboardInterrupt: 38 | sys.exit(0) 39 | 40 | -------------------------------------------------------------------------------- /Firmware/tools/registers.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys 4 | 5 | for line in sys.stdin: 6 | line = line.strip() 7 | a = line.split('\t') 8 | sys.stdout.write('\t{') 9 | for i in range(len(a)-1): 10 | sys.stdout.write('0x%s,\t' % a[i]) 11 | sys.stdout.write('0x%s},\n' % a[-1]) 12 | -------------------------------------------------------------------------------- /Firmware/tools/sercat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # a trivial serial console 3 | 4 | import serial, sys, optparse 5 | 6 | parser = optparse.OptionParser("sercat") 7 | parser.add_option("--baudrate", type='int', default=57600, help='baud rate') 8 | parser.add_option("--rtscts", action='store_true', default=False, help='enable rtscts') 9 | parser.add_option("--dsrdtr", action='store_true', default=False, help='enable dsrdtr') 10 | parser.add_option("--xonxoff", action='store_true', default=False, help='enable xonxoff') 11 | 12 | opts, args = parser.parse_args() 13 | 14 | if len(args) != 1: 15 | print("usage: sercat.py ") 16 | sys.exit(1) 17 | 18 | device = args[0] 19 | 20 | port = serial.Serial(device, opts.baudrate, timeout=1, 21 | dsrdtr=opts.dsrdtr, rtscts=opts.rtscts, xonxoff=opts.xonxoff) 22 | while True: 23 | count = port.inWaiting() 24 | if count == 0: 25 | count = 1 26 | buf = port.read(count) 27 | sys.stdout.write(buf) 28 | sys.stdout.flush() 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Firmware/tools/set_speed.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # set air data rate 3 | 4 | import serial, sys, optparse, time, fdpexpect 5 | 6 | parser = optparse.OptionParser("set_speed") 7 | parser.add_option("--baudrate", type='int', default=57600, help='baud rate') 8 | parser.add_option("--speed", type='int', default=128, help='air speed') 9 | parser.add_option("--rtscts", action='store_true', default=False, help='enable rtscts') 10 | parser.add_option("--dsrdtr", action='store_true', default=False, help='enable dsrdtr') 11 | parser.add_option("--xonxoff", action='store_true', default=False, help='enable xonxoff') 12 | 13 | opts, args = parser.parse_args() 14 | 15 | if len(args) == 0: 16 | print("usage: set_speed.py ") 17 | sys.exit(1) 18 | 19 | 20 | def set_speed(device): 21 | '''set air speed''' 22 | 23 | port = serial.Serial(device, opts.baudrate, timeout=0, 24 | dsrdtr=opts.dsrdtr, rtscts=opts.rtscts, xonxoff=opts.xonxoff) 25 | 26 | ser = fdpexpect.fdspawn(port.fileno(), logfile=sys.stdout) 27 | ser.send('+++') 28 | time.sleep(1) 29 | ser.send('\r\nATI\r\n') 30 | try: 31 | ser.expect(['OK','SiK .* on HM-TRP'], timeout=2) 32 | except fdpexpect.TIMEOUT: 33 | print("timeout") 34 | return 35 | ser.send('ATS2=%u\r\n' % opts.speed) 36 | ser.expect('OK') 37 | ser.send('AT&W\r\n') 38 | ser.expect('OK') 39 | ser.send('ATI5\r\n') 40 | time.sleep(0.2) 41 | ser.read_nonblocking(100) 42 | ser.send('ATZ\r\n') 43 | time.sleep(1) 44 | port.close() 45 | 46 | for d in args: 47 | print("Setting speed %u on %s" % (opts.speed, d)) 48 | set_speed(d) 49 | 50 | -------------------------------------------------------------------------------- /Firmware/tools/set_sreg.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # set air data rate 3 | 4 | import serial, sys, optparse, time, fdpexpect 5 | 6 | parser = optparse.OptionParser("set_speed") 7 | parser.add_option("--baudrate", type='int', default=57600, help='baud rate') 8 | parser.add_option("--cmd", action='append', default=[], help='at command') 9 | parser.add_option("--reset", action='store_true', help='reset after set') 10 | parser.add_option("--write", action='store_true', help='write after set') 11 | parser.add_option("--rtscts", action='store_true', default=False, help='enable rtscts') 12 | parser.add_option("--dsrdtr", action='store_true', default=False, help='enable dsrdtr') 13 | parser.add_option("--xonxoff", action='store_true', default=False, help='enable xonxoff') 14 | 15 | opts, args = parser.parse_args() 16 | 17 | if len(args) == 0: 18 | print("usage: set_sreg.py ") 19 | sys.exit(1) 20 | 21 | 22 | def set_speed(device): 23 | '''set some registers''' 24 | port = serial.Serial(device, opts.baudrate, timeout=0, 25 | dsrdtr=opts.dsrdtr, rtscts=opts.rtscts, xonxoff=opts.xonxoff) 26 | ser = fdpexpect.fdspawn(port.fileno(), logfile=sys.stdout) 27 | ser.send('+++') 28 | time.sleep(1) 29 | ser.send('\r\nATI\r\n') 30 | try: 31 | ser.expect(['OK','SiK .* on HM-TRP'], timeout=2) 32 | except fdpexpect.TIMEOUT: 33 | print("timeout") 34 | return 35 | for cmd in opts.cmd: 36 | ser.send('%s\r\n' % cmd) 37 | ser.expect('OK') 38 | if opts.write: 39 | ser.send('AT&W\r\n') 40 | ser.expect('OK') 41 | if opts.reset: 42 | ser.send('ATZ\r\n') 43 | else: 44 | ser.send('ATO\r\n') 45 | ser.expect('OK') 46 | time.sleep(1) 47 | ser.read_nonblocking(300) 48 | port.close() 49 | 50 | for d in args: 51 | print("Setting %s on %s" % (opts.cmd, d)) 52 | set_speed(d) 53 | 54 | -------------------------------------------------------------------------------- /Firmware/tools/show_regs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # set air data rate 3 | 4 | import serial, sys, optparse, time, fdpexpect 5 | 6 | parser = optparse.OptionParser("show_regs") 7 | parser.add_option("--baudrate", type='int', default=57600, help='baud rate') 8 | parser.add_option("--rtscts", action='store_true', default=False, help='enable rtscts') 9 | parser.add_option("--dsrdtr", action='store_true', default=False, help='enable dsrdtr') 10 | parser.add_option("--xonxoff", action='store_true', default=False, help='enable xonxoff') 11 | 12 | opts, args = parser.parse_args() 13 | 14 | if len(args) == 0: 15 | print("usage: show_regs.py ") 16 | sys.exit(1) 17 | 18 | 19 | def show_regs(device): 20 | '''show S registers''' 21 | port = serial.Serial(device, opts.baudrate, timeout=0, 22 | dsrdtr=opts.dsrdtr, rtscts=opts.rtscts, xonxoff=opts.xonxoff) 23 | ser = fdpexpect.fdspawn(port.fileno(), logfile=sys.stdout) 24 | ser.send('+++') 25 | time.sleep(1) 26 | ser.send('\r\nATI\r\n') 27 | try: 28 | ser.expect(['OK','SiK .* on HM-TRP'], timeout=2) 29 | except fdpexpect.TIMEOUT: 30 | print("timeout") 31 | return 32 | ser.send('ATI5\r\n') 33 | time.sleep(0.2) 34 | ser.read_nonblocking(300) 35 | ser.send('ATI6\r\n') 36 | time.sleep(0.2) 37 | ser.read_nonblocking(300) 38 | ser.send('ATI7\r\n') 39 | time.sleep(0.2) 40 | ser.read_nonblocking(300) 41 | ser.send('ATO\r\n') 42 | print("") 43 | time.sleep(1) 44 | port.close() 45 | 46 | for d in args: 47 | print("showing registers on %s" % (d)) 48 | show_regs(d) 49 | 50 | -------------------------------------------------------------------------------- /Firmware/tools/show_rssi.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # set air data rate 3 | 4 | import serial, sys, optparse, time, fdpexpect 5 | 6 | parser = optparse.OptionParser("show_rssi") 7 | parser.add_option("--baudrate", type='int', default=57600, help='baud rate') 8 | parser.add_option("--rtscts", action='store_true', default=False, help='enable rtscts') 9 | parser.add_option("--dsrdtr", action='store_true', default=False, help='enable dsrdtr') 10 | parser.add_option("--xonxoff", action='store_true', default=False, help='enable xonxoff') 11 | 12 | opts, args = parser.parse_args() 13 | 14 | if len(args) == 0: 15 | print("usage: show_rssi.py ") 16 | sys.exit(1) 17 | 18 | 19 | def show_rssi(device): 20 | '''show RSSI''' 21 | port = serial.Serial(device, opts.baudrate, timeout=0, 22 | dsrdtr=opts.dsrdtr, rtscts=opts.rtscts, xonxoff=opts.xonxoff) 23 | ser = fdpexpect.fdspawn(port.fileno(), logfile=sys.stdout) 24 | ser.send('+++') 25 | time.sleep(1) 26 | ser.send('\r\nATI\r\n') 27 | try: 28 | ser.expect(['OK','SiK .* on HM-TRP'], timeout=2) 29 | except fdpexpect.TIMEOUT: 30 | print("timeout") 31 | return 32 | ser.send('AT&T=RSSI\r\n') 33 | time.sleep(1) 34 | ser.read_nonblocking(300) 35 | ser.send('AT&T\r\n') 36 | time.sleep(0.5) 37 | ser.send('ATO\r\n') 38 | ser.read_nonblocking(300) 39 | print("") 40 | time.sleep(1) 41 | port.close() 42 | 43 | for d in args: 44 | print("showing registers on %s" % (d)) 45 | show_rssi(d) 46 | 47 | -------------------------------------------------------------------------------- /Firmware/tools/update_mode.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # put a HopeRF into update mode 3 | 4 | import serial, sys, optparse, time, fdpexpect 5 | 6 | parser = optparse.OptionParser("update_mode") 7 | parser.add_option("--baudrate", type='int', default=57600, help='baud rate') 8 | parser.add_option("--rtscts", action='store_true', default=False, help='enable rtscts') 9 | parser.add_option("--dsrdtr", action='store_true', default=False, help='enable dsrdtr') 10 | parser.add_option("--xonxoff", action='store_true', default=False, help='enable xonxoff') 11 | 12 | opts, args = parser.parse_args() 13 | 14 | if len(args) == 0: 15 | print("usage: update_mode.py ") 16 | sys.exit(1) 17 | 18 | 19 | def update_mode(device): 20 | '''put a HM-TRP into update mode''' 21 | port = serial.Serial(device, opts.baudrate, timeout=0, 22 | dsrdtr=opts.dsrdtr, rtscts=opts.rtscts, xonxoff=opts.xonxoff) 23 | ser = fdpexpect.fdspawn(port.fileno(), logfile=sys.stdout) 24 | ser.send('+++') 25 | time.sleep(1) 26 | ser.send('\r\nATI\r\n') 27 | try: 28 | ser.expect(['OK','SiK .* on HM-TRP'], timeout=2) 29 | except fdpexpect.TIMEOUT: 30 | print("timeout") 31 | return 32 | ser.send('AT&UPDATE\r\n') 33 | try: 34 | buf = ser.read_nonblocking(100, timeout=1) 35 | except pexpect.TIMEOUT: 36 | pass 37 | port.close() 38 | 39 | 40 | for d in args: 41 | print("Putting %s into update mode" % d) 42 | update_mode(d) 43 | 44 | -------------------------------------------------------------------------------- /Firmware/upd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## SiK 1.9-MSP on HM-TRP 4 | 5 | python2 tools/uploader.py --port /dev/ttyUSB0 \ 6 | --baudrate 19200 \ 7 | obj/hm_trp/radio~hm_trp/radio~hm_trp.ihx 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SiK MSP - Firmware for SiLabs Si1000 ISM radios with Multiwii Serial Protocol optimisation 2 | 3 | 4 | This is fork of [Tridge's SiK project](http://github.com/tridge/SiK) 5 | to optimise the performance for MSP (Multiwii Serial Protocol). 6 | * Replaces MAVLink framing and radio RSSI reporting with MSP 7 | equivalents; 8 | * Is enabled by setting MAVLINK=1 (sic), i.e. by ATS6=1 / RTS6=1; 9 | * Sends radio RSSI as MSP_RADIO messages (as defined by EOSBandi for 10 | MW-NAV) when keyed; 11 | * Keying for MSP_RADIO is by the ground side polling the FC for MSP_ANALOG; 12 | * MSP_RADIO is MSP command 199; 13 | 14 | MSP_RADIO returns little endian data as: 15 | 16 | ``` 17 | struct __attribute__ ((__packed__)) _msp_radio 18 | { 19 | uint16_t rxerrors; 20 | uint16_t fixed_errors; 21 | uint8_t localrssi; 22 | uint8_t remrssi; 23 | uint8_t txbuf; 24 | uint8_t noise; 25 | uint8_t remnoise; 26 | }; 27 | typedef struct _msp_radio MSP_RADIO; 28 | ```` 29 | 30 | As a convenience to legacy opertaing system users, compiled firmware is provided in the Firmware/dst directory. 31 | 32 | # Original documenation: 33 | 34 | For user documentation please see this site: 35 | 36 | http://code.google.com/p/ardupilot-mega/wiki/3DRadio 37 | 38 | SiK is a collection of firmware and tools for radios based on the cheap, versatile SiLabs Si1000 SoC. 39 | 40 | Currently, it supports the following boards: 41 | 42 | - HopeRF HM-TRP 43 | - HopeRF RF50-DEMO 44 | 45 | Adding support for additional boards should not be difficult. 46 | 47 | Currently the firmware components include: 48 | 49 | - A bootloader with support for firmware upgrades over the serial interface. 50 | - Radio firmware with support for parsing AT commands, storing parameters and FHSS/TDM functionality 51 | 52 | See the user documentation above for a list of current firmware features 53 | 54 | ## What You Will Need 55 | 56 | - A Mac OS X or Linux system for building. Mac users will need the Developer Tools (Xcode) installed. 57 | - At least two Si1000-based radio devices (just one radio by itself is not very useful). 58 | - A [SiLabs USB debug adapter](http://www.silabs.com/products/mcu/Pages/USBDebug.aspx). 59 | - [SDCC](http://sdcc.sourceforge.net/), version 3.1.0 or later. 60 | - [EC2Tools](http://github.com/tridge/ec2) 61 | - [Mono](http://www.mono-project.com/) to build and run the GUI firmware updater. 62 | - Python to run the command-line firmware updater. 63 | 64 | Note that at this time, building on Windows systems is not supported. 65 | 66 | ## Building Things 67 | 68 | Type `make install` in the Firmware directory. If all is well, this will produce a folder called `dst` containing bootloader and firmware images. 69 | 70 | If you want to fine-tune the build process, `make help` will give you more details. 71 | 72 | Building the SiK firmware generates bootloaders and firmware for each of the supported boards. Many boards are available tuned to specific frequencies, but have no way for software on the Si1000 to detect which frequency the board is configured for. In this case, the build will produce different versions of the bootloader for each board. It's important to select the correct bootloader version for your board if this is the case. 73 | 74 | ## Flashing and Uploading 75 | 76 | The SiLabs debug adapter can be used to flash both the bootloader and the firmware. Alternatively, once the bootloader has been flashed the updater application can be used to update the firmware (it's faster than flashing, too). 77 | 78 | The `Firmware/tools/ec2upload` script can be used to flash either a bootloader or firmware to an attached board with the SiLabs USB debug adapter. Further details on the connections required to flash a specific board should be found in the `Firmware/include/board_*.h` header for the board in question. 79 | 80 | To use the updater application, open the `SiKUploader/SikUploader.sln` Mono solution file, build and run the application. Select the serial port connected to your radio and the appropriate firmware `.hex` file for the firmware you wish to uploader. You will need to get the board into the bootloader; how you do this varies from board to board, but it will normally involve either holding down a button or pulling a pin high or low when the board is reset or powered on. 81 | 82 | For the supported boards: 83 | 84 | - HM-TRP: hold the CONFIG pin low when applying power to the board. 85 | - RF50-DEMO: hold the ENTER button down and press RST. 86 | 87 | The uploader application contains a bidirectional serial console that can be used for interacting with the radio firmware. 88 | 89 | As an alternative to the Mono uploader, there is a Python-based command-line upload tool in `Firmware/tools/uploader.py`. 90 | 91 | ## Supporting New Boards 92 | 93 | Take a look at `Firmware/include/board_*.h` for the details of what board support entails. It will help to have a schematic for your board, and in the worst case, you may need to experiment a little to determine a suitable value for EZRADIOPRO_OSC_CAP_VALUE. To set the frequency codes for your board, edit the corresponding `Firmware/include/rules_*.mk` file. 94 | 95 | ## Resources 96 | 97 | SiLabs have an extensive collection of documentation, application notes and sample code available online. Start at the [Si1000 product page](http://www.silabs.com/products/wireless/wirelessmcu/Pages/Si1000.aspx) 98 | -------------------------------------------------------------------------------- /SiKUploader/SiKUploader.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiKUploader", "uploader\SiKUploader.csproj", "{9DD5CF39-E6F2-49E6-8B90-E51C72A5A09A}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|x86 = Debug|x86 9 | Release|x86 = Release|x86 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {9DD5CF39-E6F2-49E6-8B90-E51C72A5A09A}.Debug|x86.ActiveCfg = Debug|x86 13 | {9DD5CF39-E6F2-49E6-8B90-E51C72A5A09A}.Debug|x86.Build.0 = Debug|x86 14 | {9DD5CF39-E6F2-49E6-8B90-E51C72A5A09A}.Release|x86.ActiveCfg = Release|x86 15 | {9DD5CF39-E6F2-49E6-8B90-E51C72A5A09A}.Release|x86.Build.0 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(MonoDevelopProperties) = preSolution 18 | StartupItem = uploader\SiKUploader.csproj 19 | Policies = $0 20 | $0.VersionControlPolicy = $1 21 | $1.inheritsSet = Mono 22 | EndGlobalSection 23 | EndGlobal 24 | -------------------------------------------------------------------------------- /SiKUploader/SiKUploader.userprefs: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /SiKUploader/uploader.userprefs: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /SiKUploader/uploader/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle("SiKUploader")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("")] 12 | [assembly: AssemblyCopyright("msmith")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion("1.0.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | 28 | -------------------------------------------------------------------------------- /SiKUploader/uploader/IHex.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | 5 | namespace uploader 6 | { 7 | public class IHex : SortedList 8 | { 9 | public event LogEventHandler LogEvent; 10 | 11 | private SortedList merge_index; 12 | 13 | public IHex () 14 | { 15 | merge_index = new SortedList (); 16 | } 17 | 18 | public void load (string fromPath) 19 | { 20 | StreamReader sr = new StreamReader (fromPath); 21 | UInt32 loadedSize = 0; 22 | 23 | // discard anything we might previous have loaded 24 | Clear (); 25 | merge_index.Clear (); 26 | 27 | log (string.Format ("reading from {0}\n", fromPath)); 28 | 29 | while (!sr.EndOfStream) { 30 | string line = sr.ReadLine (); 31 | 32 | // every line must start with a : 33 | if (!line.StartsWith (":")) 34 | throw new Exception ("invalid IntelHex file"); 35 | 36 | // parse the record type and data length, assume ihex8 37 | // ignore the checksum 38 | byte length = Convert.ToByte (line.Substring (1, 2), 16); 39 | UInt32 address = Convert.ToUInt32 (line.Substring (3, 4), 16); 40 | byte rtype = Convert.ToByte (line.Substring (7, 2), 16); 41 | 42 | // handle type zero (data) records 43 | if (rtype == 0) { 44 | byte[] b = new byte[length]; 45 | string hexbytes = line.Substring (9, length * 2); 46 | 47 | // convert hex bytes 48 | for (int i = 0; i < length; i++) { 49 | b [i] = Convert.ToByte (hexbytes.Substring (i * 2, 2), 16); 50 | } 51 | 52 | log (string.Format ("ihex: 0x{0:X}: {1}\n", address, length), 1); 53 | loadedSize += length; 54 | 55 | // and add to the list of ranges 56 | insert (address, b); 57 | } 58 | } 59 | if (Count < 1) 60 | throw new Exception ("no data in IntelHex file"); 61 | log (string.Format ("read {0} bytes from {1}\n", loadedSize, fromPath)); 62 | } 63 | 64 | private void log (string message, int level = 0) 65 | { 66 | if (LogEvent != null) 67 | LogEvent (message, level); 68 | } 69 | 70 | private void idx_record (UInt32 start, byte[] data) 71 | { 72 | UInt32 len = (UInt32)data.GetLength (0); 73 | 74 | merge_index.Add (start + len, start); 75 | } 76 | 77 | private void idx_remove (UInt32 start, byte[] data) 78 | { 79 | UInt32 len = (UInt32)data.GetLength (0); 80 | 81 | merge_index.Remove (start + len); 82 | } 83 | 84 | private bool idx_find (UInt32 start, out UInt32 other) 85 | { 86 | return merge_index.TryGetValue (start, out other); 87 | } 88 | 89 | public void insert (UInt32 key, byte[] data) 90 | { 91 | UInt32 other; 92 | byte[] mergedata; 93 | 94 | // value of the key that would come after this one 95 | other = key; 96 | other += (UInt32)data.GetLength (0); 97 | 98 | // can we merge with the next block 99 | if (TryGetValue (other, out mergedata)) { 100 | int oldlen = data.GetLength (0); 101 | 102 | // remove the next entry, we are going to merge with it 103 | Remove (other); 104 | 105 | // remove its index entry as well 106 | idx_remove (other, mergedata); 107 | 108 | log (string.Format ("ihex: merging {0:X}/{1} with next {2:X}/{3}\n", 109 | key, data.GetLength (0), 110 | other, mergedata.GetLength (0)), 1); 111 | 112 | // resize the data array and append data from the next block 113 | Array.Resize (ref data, data.GetLength (0) + mergedata.GetLength (0)); 114 | Array.Copy (mergedata, 0, data, oldlen, mergedata.GetLength (0)); 115 | } 116 | 117 | // look up a possible adjacent preceding block in the merge index 118 | if (idx_find (key, out other)) { 119 | 120 | mergedata = this [other]; 121 | int oldlen = mergedata.GetLength (0); 122 | Remove (other); 123 | idx_remove (other, mergedata); 124 | 125 | log (string.Format ("ihex: merging {0:X}/{1} with prev {2:X}/{3}\n", 126 | key, data.GetLength (0), 127 | other, mergedata.GetLength (0)), 1); 128 | 129 | Array.Resize (ref mergedata, data.GetLength (0) + mergedata.GetLength (0)); 130 | Array.Copy (data, 0, mergedata, oldlen, data.GetLength (0)); 131 | key = other; 132 | data = mergedata; 133 | } 134 | 135 | // add the merged block 136 | Add (key, data); 137 | idx_record (key, data); 138 | log (string.Format ("ihex: adding {0:X}/{1}\n", key, data.GetLength (0)), 1); 139 | } 140 | } 141 | } 142 | 143 | -------------------------------------------------------------------------------- /SiKUploader/uploader/MainWindow.cs: -------------------------------------------------------------------------------- 1 | using Gtk; 2 | using System; 3 | using System.IO; 4 | using System.IO.Ports; 5 | 6 | namespace uploader 7 | { 8 | public partial class MainWindow: Gtk.Window 9 | { 10 | public event UploadEventHandler UploadEvent; 11 | public event MonitorEventHandler MonitorEvent; 12 | public event LogEventHandler LogEvent; 13 | public event QuitEventHandler QuitEvent; 14 | 15 | private string default_port_name; 16 | 17 | public MainWindow (): base (Gtk.WindowType.Toplevel) 18 | { 19 | // construct the UI 20 | Build (); 21 | 22 | // wire up the Upload button 23 | button_Upload.Clicked += new EventHandler (do_upload); 24 | 25 | // wire up the Console button 26 | button_Console.Clicked += new EventHandler (do_console); 27 | 28 | // configure the file chooser 29 | FileFilter filter = new FileFilter (); 30 | filter.Name = "IntelHex files (*.hex)"; 31 | filter.AddPattern ("*.hex"); 32 | chooser_Hex.AddFilter (filter); 33 | filter = new FileFilter (); 34 | filter.Name = "All Files (*.*)"; 35 | filter.AddPattern ("*.*"); 36 | chooser_Hex.AddFilter (filter); 37 | DeleteEvent += delete; 38 | 39 | // get serial port names and populate the combo box 40 | foreach (string port in SerialPort.GetPortNames ()) { 41 | if (port.StartsWith ("/dev/tty") && 42 | (!port.StartsWith ("/dev/tty.") || port.StartsWith ("/dev/tty.Bluetooth"))) 43 | continue; // ignore this, it's a pty or a Mac Bluetooth interface 44 | 45 | combo_Port.AppendText (port); 46 | } 47 | 48 | // start by defaulting to the first element in the combo box 49 | TreeIter iter; 50 | if (combo_Port.Model.GetIterFirst (out iter)) 51 | combo_Port.SetActiveIter (iter); 52 | 53 | // Set up the status bar 54 | status_Bar.Push (1, "Init..."); 55 | } 56 | 57 | /// 58 | /// Handles the window DeleteEvent by instigating the termination of the application. 59 | /// 60 | /// 61 | /// Sender. 62 | /// 63 | /// 64 | /// A. 65 | /// 66 | private void delete (object sender, DeleteEventArgs a) 67 | { 68 | Application.Quit (); 69 | a.RetVal = true; 70 | 71 | if (QuitEvent != null) 72 | QuitEvent (); 73 | } 74 | 75 | /// 76 | /// Flush any updates to the window to the display. 77 | /// 78 | private void flush () 79 | { 80 | while (Gtk.Application.EventsPending ()) 81 | Gtk.Application.RunIteration (); 82 | } 83 | 84 | /// 85 | /// Handle the button click event for the Console button. 86 | /// 87 | /// 88 | /// Object. 89 | /// 90 | /// 91 | /// Arguments. 92 | /// 93 | private void do_console (object obj, EventArgs args) 94 | { 95 | if (MonitorEvent != null) { 96 | MonitorEvent (PortName); 97 | } 98 | } 99 | 100 | /// 101 | /// Handle the button click for the Upload button. 102 | /// 103 | /// 104 | /// Object. 105 | /// 106 | /// 107 | /// Arguments. 108 | /// 109 | private void do_upload (object obj, EventArgs args) 110 | { 111 | if (UploadEvent != null) { 112 | UploadEvent (PortName, FileName); 113 | } 114 | } 115 | 116 | public string PortName { 117 | get { 118 | TreeIter iter; 119 | string port = ""; 120 | if (combo_Port.GetActiveIter (out iter)) 121 | port = (string)combo_Port.Model.GetValue (iter, 0); 122 | if (port.Equals ("")) { 123 | log ("Please select the serial port connected to your radio."); 124 | throw new Exception ("no port selected"); 125 | } 126 | return port; 127 | } 128 | set { 129 | default_port_name = value; 130 | combo_Port.Model.Foreach (default_port_compare); 131 | } 132 | } 133 | 134 | private bool default_port_compare (TreeModel model, TreePath path, TreeIter iter) 135 | { 136 | string port = model.GetValue (iter, 0) as string; 137 | 138 | if (port != null) { 139 | Console.WriteLine ("considering " + port + " while looking for " + default_port_name); 140 | if (port.Equals (default_port_name)) { 141 | combo_Port.SetActiveIter (iter); 142 | return true; 143 | } 144 | } 145 | return false; 146 | } 147 | 148 | public string FileName { 149 | get { 150 | string s = chooser_Hex.Filename; 151 | 152 | if (s == null) { 153 | log ("Please select an IntelHex (*.hex) file to flash."); 154 | throw new Exception ("no file selected to upload"); 155 | } 156 | return s; 157 | } 158 | set { 159 | if (File.Exists (value)) 160 | chooser_Hex.SetFilename (value); 161 | } 162 | } 163 | 164 | private void log (string message, int level = 0) 165 | { 166 | if (LogEvent != null) 167 | LogEvent (message, 0); 168 | } 169 | 170 | public void set_status (string msg) 171 | { 172 | status_Bar.Pop (1); 173 | status_Bar.Push (1, msg); 174 | flush (); 175 | } 176 | 177 | public void set_progress (double completed) 178 | { 179 | // silence an otherwise stupid Gtk warning in case we overflow slightly 180 | if (completed > 1.0) 181 | completed = 1.0; 182 | progress_Bar.Fraction = completed; 183 | flush (); 184 | } 185 | } 186 | } -------------------------------------------------------------------------------- /SiKUploader/uploader/Mon.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Author: 3 | // Michael Smith msmith@purgatory.org 4 | // 5 | // Copyright (c) 2011, Michael Smith 6 | // 7 | // All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 10 | // 11 | // * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | // the documentation and/or other materials provided with the distribution. 14 | // * Neither the name of the [ORGANIZATION] nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | using Gtk; 29 | using Gdk; 30 | using GLib; 31 | using Pango; 32 | using System; 33 | using System.IO.Ports; 34 | 35 | namespace uploader 36 | { 37 | public partial class Mon : Gtk.Window 38 | { 39 | public event LogEventHandler LogEvent; 40 | public event QuitEventHandler QuitEvent; 41 | 42 | private SerialPort port; 43 | private bool is_deleted; 44 | 45 | /// 46 | /// Maximum number of scrollback lines in the monitor window. 47 | /// 48 | private const int max_lines = 1000; 49 | 50 | public Mon (SerialPort on_port) : 51 | base(Gtk.WindowType.Toplevel) 52 | { 53 | this.Build (); 54 | 55 | // pick a font that works 56 | text_Monitor.ModifyFont (FontDescription.FromString ("Courier 12")); 57 | 58 | // add the port data poll timeout 59 | GLib.Timeout.Add (100, check_for_data); 60 | 61 | // default the statusbar 62 | status_Monitor.Push (1, "idle"); 63 | } 64 | 65 | private bool check_for_data () 66 | { 67 | try { 68 | if ((port != null) && 69 | port.IsOpen && 70 | (port.BytesToRead > 0)) 71 | addchars (port.ReadExisting ()); 72 | } catch { 73 | // harmless if this fails 74 | } 75 | if (is_deleted) 76 | return false; 77 | return true; 78 | } 79 | 80 | public void connect (SerialPort to_port) 81 | { 82 | port = to_port; 83 | status_Monitor.Pop (1); 84 | status_Monitor.Push (1, port.PortName); 85 | } 86 | 87 | public void disconnect () 88 | { 89 | port = null; 90 | status_Monitor.Pop (1); 91 | status_Monitor.Push (1, "not connected"); 92 | } 93 | 94 | /// 95 | /// Adds the string s to the textview at the cursor. 96 | /// 97 | /// 98 | /// String to add. 99 | /// 100 | private void addchars (string s) 101 | { 102 | 103 | // Add the text 104 | text_Monitor.Buffer.InsertAtCursor (s); 105 | 106 | // If there is too much text, remove some 107 | int linecount = text_Monitor.Buffer.LineCount; 108 | if (linecount > max_lines) { 109 | Gtk.TextIter startpoint = text_Monitor.Buffer.StartIter; 110 | Gtk.TextIter endpoint = text_Monitor.Buffer.GetIterAtLine (linecount - max_lines); 111 | text_Monitor.Buffer.Delete (ref startpoint, ref endpoint); 112 | } 113 | 114 | // And if we are autoscrolling, do the right thing and keep the cursor visible 115 | if (check_Autoscroll.Active) 116 | text_Monitor.ScrollMarkOnscreen (text_Monitor.Buffer.InsertMark); 117 | } 118 | 119 | /// 120 | /// Log the specified message with the given level. 121 | /// 122 | /// 123 | /// Message to log 124 | /// 125 | /// 126 | /// Level at which to log. 127 | /// 128 | private void log (string message, int level = 0) 129 | { 130 | if (LogEvent != null) 131 | LogEvent (message, level); 132 | } 133 | 134 | protected void clear_pressed (object sender, System.EventArgs e) 135 | { 136 | text_Monitor.Buffer.Clear (); 137 | } 138 | 139 | protected void delete_event (object o, Gtk.DeleteEventArgs args) 140 | { 141 | // stop the timer the next time it runs 142 | is_deleted = true; 143 | 144 | // close the port if it's open 145 | disconnect (); 146 | 147 | if (QuitEvent != null) 148 | QuitEvent (); 149 | } 150 | 151 | [GLib.ConnectBefore] 152 | protected void keypressed (object o, Gtk.KeyPressEventArgs args) 153 | { 154 | uint key = args.Event.KeyValue; 155 | byte[] sendbytes = new byte[1]; 156 | 157 | switch (args.Event.Key) { 158 | case Gdk.Key.Return: 159 | case Gdk.Key.KP_Enter: 160 | key = 13; 161 | break; 162 | case Gdk.Key.BackSpace: 163 | case Gdk.Key.Delete: 164 | key = 8; 165 | break; 166 | default: 167 | // don't handle anything that's not 7-bit ascii 168 | if (key > 128) { 169 | log (string.Format ("ignoring {0}\n", key), 2); 170 | return; 171 | } 172 | break; 173 | } 174 | 175 | sendbytes [0] = (byte)key; 176 | port.Write (sendbytes, 0, 1); 177 | log (string.Format ("sending {0}\n", key), 2); 178 | 179 | // we have handled the event - don't pass it any further 180 | args.RetVal = true; 181 | } 182 | } 183 | } -------------------------------------------------------------------------------- /SiKUploader/uploader/SiKUploader.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | x86 6 | 9.0.21022 7 | 2.0 8 | {9DD5CF39-E6F2-49E6-8B90-E51C72A5A09A} 9 | WinExe 10 | uploader 11 | uploader 12 | 13 | 14 | true 15 | full 16 | false 17 | bin\Debug 18 | DEBUG 19 | prompt 20 | 4 21 | x86 22 | false 23 | 24 | 25 | none 26 | false 27 | bin\Release 28 | prompt 29 | 4 30 | x86 31 | false 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | gui.stetic 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /SiKUploader/uploader/SiKUploader.pidb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stronnag/SiK-MSP/5cd11ef83746e41a11ae22617424b5b4efcc4290/SiKUploader/uploader/SiKUploader.pidb -------------------------------------------------------------------------------- /SiKUploader/uploader/gtk-gui/generated.cs: -------------------------------------------------------------------------------- 1 | 2 | // This file has been generated by the GUI designer. Do not modify. 3 | namespace Stetic 4 | { 5 | internal class Gui 6 | { 7 | private static bool initialized; 8 | 9 | internal static void Initialize (Gtk.Widget iconRenderer) 10 | { 11 | if ((Stetic.Gui.initialized == false)) { 12 | Stetic.Gui.initialized = true; 13 | } 14 | } 15 | } 16 | 17 | internal class IconLoader 18 | { 19 | public static Gdk.Pixbuf LoadIcon (Gtk.Widget widget, string name, Gtk.IconSize size) 20 | { 21 | Gdk.Pixbuf res = widget.RenderIcon (name, size, null); 22 | if ((res != null)) { 23 | return res; 24 | } else { 25 | int sz; 26 | int sy; 27 | global::Gtk.Icon.SizeLookup (size, out sz, out sy); 28 | try { 29 | return Gtk.IconTheme.Default.LoadIcon (name, sz, 0); 30 | } catch (System.Exception) { 31 | if ((name != "gtk-missing-image")) { 32 | return Stetic.IconLoader.LoadIcon (widget, "gtk-missing-image", size); 33 | } else { 34 | Gdk.Pixmap pmap = new Gdk.Pixmap (Gdk.Screen.Default.RootWindow, sz, sz); 35 | Gdk.GC gc = new Gdk.GC (pmap); 36 | gc.RgbFgColor = new Gdk.Color (255, 255, 255); 37 | pmap.DrawRectangle (gc, true, 0, 0, sz, sz); 38 | gc.RgbFgColor = new Gdk.Color (0, 0, 0); 39 | pmap.DrawRectangle (gc, false, 0, 0, (sz - 1), (sz - 1)); 40 | gc.SetLineAttributes (3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round); 41 | gc.RgbFgColor = new Gdk.Color (255, 0, 0); 42 | pmap.DrawLine (gc, (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)), ((sz - 1) - (sz / 4))); 43 | pmap.DrawLine (gc, ((sz - 1) - (sz / 4)), (sz / 4), (sz / 4), ((sz - 1) - (sz / 4))); 44 | return Gdk.Pixbuf.FromDrawable (pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz); 45 | } 46 | } 47 | } 48 | } 49 | } 50 | 51 | internal class ActionGroups 52 | { 53 | public static Gtk.ActionGroup GetActionGroup (System.Type type) 54 | { 55 | return Stetic.ActionGroups.GetActionGroup (type.FullName); 56 | } 57 | 58 | public static Gtk.ActionGroup GetActionGroup (string name) 59 | { 60 | return null; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /SiKUploader/uploader/gtk-gui/uploader.Mon.cs: -------------------------------------------------------------------------------- 1 | 2 | // This file has been generated by the GUI designer. Do not modify. 3 | namespace uploader 4 | { 5 | public partial class Mon 6 | { 7 | private global::Gtk.VBox vbox1; 8 | private global::Gtk.ScrolledWindow scrolledwindow1; 9 | private global::Gtk.TextView text_Monitor; 10 | private global::Gtk.Statusbar status_Monitor; 11 | private global::Gtk.CheckButton check_Autoscroll; 12 | private global::Gtk.Button button_Clear; 13 | 14 | protected virtual void Build () 15 | { 16 | global::Stetic.Gui.Initialize (this); 17 | // Widget uploader.Mon 18 | this.Name = "uploader.Mon"; 19 | this.Title = global::Mono.Unix.Catalog.GetString ("SiK Serial Monitor"); 20 | this.WindowPosition = ((global::Gtk.WindowPosition)(4)); 21 | // Container child uploader.Mon.Gtk.Container+ContainerChild 22 | this.vbox1 = new global::Gtk.VBox (); 23 | this.vbox1.Name = "vbox1"; 24 | this.vbox1.Spacing = 6; 25 | // Container child vbox1.Gtk.Box+BoxChild 26 | this.scrolledwindow1 = new global::Gtk.ScrolledWindow (); 27 | this.scrolledwindow1.CanFocus = true; 28 | this.scrolledwindow1.Name = "scrolledwindow1"; 29 | this.scrolledwindow1.ShadowType = ((global::Gtk.ShadowType)(1)); 30 | // Container child scrolledwindow1.Gtk.Container+ContainerChild 31 | this.text_Monitor = new global::Gtk.TextView (); 32 | this.text_Monitor.Sensitive = false; 33 | this.text_Monitor.CanFocus = true; 34 | this.text_Monitor.Events = ((global::Gdk.EventMask)(1024)); 35 | this.text_Monitor.Name = "text_Monitor"; 36 | this.text_Monitor.Editable = false; 37 | this.text_Monitor.AcceptsTab = false; 38 | this.text_Monitor.WrapMode = ((global::Gtk.WrapMode)(1)); 39 | this.scrolledwindow1.Add (this.text_Monitor); 40 | this.vbox1.Add (this.scrolledwindow1); 41 | global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.scrolledwindow1])); 42 | w2.Position = 0; 43 | // Container child vbox1.Gtk.Box+BoxChild 44 | this.status_Monitor = new global::Gtk.Statusbar (); 45 | this.status_Monitor.Name = "status_Monitor"; 46 | this.status_Monitor.Spacing = 6; 47 | // Container child status_Monitor.Gtk.Box+BoxChild 48 | this.check_Autoscroll = new global::Gtk.CheckButton (); 49 | this.check_Autoscroll.Name = "check_Autoscroll"; 50 | this.check_Autoscroll.Label = global::Mono.Unix.Catalog.GetString ("autoscroll"); 51 | this.check_Autoscroll.Active = true; 52 | this.check_Autoscroll.DrawIndicator = true; 53 | this.check_Autoscroll.UseUnderline = true; 54 | this.check_Autoscroll.FocusOnClick = false; 55 | this.status_Monitor.Add (this.check_Autoscroll); 56 | global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.status_Monitor [this.check_Autoscroll])); 57 | w3.Position = 1; 58 | w3.Expand = false; 59 | w3.Padding = ((uint)(2)); 60 | // Container child status_Monitor.Gtk.Box+BoxChild 61 | this.button_Clear = new global::Gtk.Button (); 62 | this.button_Clear.Name = "button_Clear"; 63 | this.button_Clear.UseUnderline = true; 64 | this.button_Clear.Label = global::Mono.Unix.Catalog.GetString (" Clear "); 65 | this.status_Monitor.Add (this.button_Clear); 66 | global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.status_Monitor [this.button_Clear])); 67 | w4.Position = 2; 68 | w4.Expand = false; 69 | w4.Fill = false; 70 | this.vbox1.Add (this.status_Monitor); 71 | global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.status_Monitor])); 72 | w5.Position = 1; 73 | w5.Expand = false; 74 | w5.Fill = false; 75 | this.Add (this.vbox1); 76 | if ((this.Child != null)) { 77 | this.Child.ShowAll (); 78 | } 79 | this.DefaultWidth = 570; 80 | this.DefaultHeight = 252; 81 | this.Show (); 82 | this.DeleteEvent += new global::Gtk.DeleteEventHandler (this.delete_event); 83 | this.vbox1.KeyPressEvent += new global::Gtk.KeyPressEventHandler (this.keypressed); 84 | this.button_Clear.Clicked += new global::System.EventHandler (this.clear_pressed); 85 | } 86 | } 87 | } 88 | --------------------------------------------------------------------------------