|
| 1 | +/* |
| 2 | +BSD 3-Clause License |
| 3 | +
|
| 4 | +Copyright (c) 2021, NewTec GmbH |
| 5 | +All rights reserved. |
| 6 | +
|
| 7 | +Redistribution and use in source and binary forms, with or without |
| 8 | +modification, are permitted provided that the following conditions are met: |
| 9 | +
|
| 10 | +1. Redistributions of source code must retain the above copyright notice, this |
| 11 | + list of conditions and the following disclaimer. |
| 12 | +
|
| 13 | +2. Redistributions in binary form must reproduce the above copyright notice, |
| 14 | + this list of conditions and the following disclaimer in the documentation |
| 15 | + and/or other materials provided with the distribution. |
| 16 | +
|
| 17 | +3. Neither the name of the copyright holder nor the names of its |
| 18 | + contributors may be used to endorse or promote products derived from |
| 19 | + this software without specific prior written permission. |
| 20 | +
|
| 21 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 22 | +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 23 | +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 24 | +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| 25 | +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 26 | +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 27 | +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 28 | +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 29 | +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 30 | +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | +*/ |
| 32 | + |
| 33 | + |
| 34 | +/** |
| 35 | + * @file Zumo32U4Specification.h |
| 36 | + * @author Luis Moser |
| 37 | + * @brief Zumo32U4Specification header |
| 38 | + * @date 08/23/2021 |
| 39 | + * @addtogroup Zumo |
| 40 | + * @{ |
| 41 | + */ |
| 42 | + |
| 43 | +#ifndef __ZUMO32U4Specification_H__ |
| 44 | +#define __ZUMO32U4Specification_H__ |
| 45 | + |
| 46 | +#include <Arduino.h> |
| 47 | + |
| 48 | + /** Simple struct for specifying Zumo commands */ |
| 49 | +template <int size> |
| 50 | +struct ZumoCommand |
| 51 | +{ |
| 52 | + /** The binary buffer for the command data */ |
| 53 | + uint8_t commandData[size]; |
| 54 | + |
| 55 | + /** Size of command data buffer in bytes */ |
| 56 | + uint8_t commandSize; |
| 57 | +}; |
| 58 | + |
| 59 | +/** Simple struct for specifying Zumo data */ |
| 60 | +template <int size> |
| 61 | +struct ZumoData |
| 62 | +{ |
| 63 | + /** The binary buffer for the response Zumo data */ |
| 64 | + uint8_t data[size]; |
| 65 | + |
| 66 | + /** Size of the response data in bytes */ |
| 67 | + uint8_t dataSize; |
| 68 | +}; |
| 69 | + |
| 70 | +/** Namespace for specifying all used Zumo32U4 commands, return codes and expected return values */ |
| 71 | +namespace Zumo32U4Specification |
| 72 | +{ |
| 73 | + /** Command for reading the software ID */ |
| 74 | + static const uint8_t READ_SW_ID_COMMAND[] = {0x53}; |
| 75 | + |
| 76 | + /** Command for reading the software version */ |
| 77 | + static const uint8_t READ_SW_VERSION[] = {0x56}; |
| 78 | + |
| 79 | + /** Command for reading the hardware version */ |
| 80 | + static const uint8_t READ_HW_VERSION[] = {0x76}; |
| 81 | + |
| 82 | + /** Command for getting the programmer type */ |
| 83 | + static const uint8_t READ_PROGRAMMER_TYPE[] = {0x70}; |
| 84 | + |
| 85 | + /** Command for getting the supported bootlaoder device codes */ |
| 86 | + static const uint8_t READ_SUPPORTED_DEVICE_CODE[] = {0x74}; |
| 87 | + |
| 88 | + /** Command for reading the signature */ |
| 89 | + static const uint8_t READ_SIGNATURE[] = {0x73}; |
| 90 | + |
| 91 | + /** Command for reading the low byte AVR fuse */ |
| 92 | + static const uint8_t READ_LSB_FUSE[] = {0x46}; |
| 93 | + |
| 94 | + /** Command for reading the high byte AVR fuse */ |
| 95 | + static const uint8_t READ_MSB_FUSE[] = {0x4E}; |
| 96 | + |
| 97 | + /** Command for reading the extended byte AVR fuse */ |
| 98 | + static const uint8_t READ_EXTENDED_FUSE[] = {0x51}; |
| 99 | + |
| 100 | + /** Command for checking if the bootloader supports block/page flashing */ |
| 101 | + static const uint8_t CHECK_BLOCK_FLASH_SUPPORT[] = {0x62}; |
| 102 | + |
| 103 | + /** Command for setting the current R/W flash memory/page address */ |
| 104 | + static const uint8_t SET_MEMORY_ADDR[] = {0x41}; |
| 105 | + |
| 106 | + /** Command for checking if the bootloader supports automatically incrementing byte addresses when flashing a page */ |
| 107 | + static const uint8_t CHECK_AUTO_MEM_ADDR_INC_SUPPORT[] = {0x61}; |
| 108 | + |
| 109 | + /** Command for setting the device type for flashing */ |
| 110 | + static const uint8_t SET_DEVICE_TYPE[] = {0x54}; |
| 111 | + |
| 112 | + /** Command for switching the bootloader into the programmer mode */ |
| 113 | + static const uint8_t ENTER_PROGRAMMING_MODE[] = {0x50}; |
| 114 | + |
| 115 | + /** Command for leaving the bootloader from the programmer mode */ |
| 116 | + static const uint8_t EXIT_PROGRAMMING_MODE[] = {0x4C}; |
| 117 | + |
| 118 | + /** Command for exiting the bootloader */ |
| 119 | + static const uint8_t EXIT_BOOTLOADER_MODE[] = {0x45}; |
| 120 | + |
| 121 | + /** Command for writing a memory page with 128 bytes into the flash/program memory */ |
| 122 | + static const uint8_t WRITE_MEMORY_PAGE[] = {0x42, 0x00, 0x80, 0x46}; |
| 123 | + |
| 124 | + /** Command for reading a memory page with 128 bytes from the flash/program memory */ |
| 125 | + static const uint8_t READ_MEMORY_PAGE[] = {0x67, 0x00, 0x80, 0x46}; |
| 126 | + |
| 127 | + /** Carriage return for successful return code */ |
| 128 | + static const uint8_t RET_OK [] = {0x0D}; |
| 129 | + |
| 130 | + /** The expected bootloader ID string */ |
| 131 | + static const uint8_t EXPECTED_SOFTWARE_ID[] = {'C', 'A', 'T', 'E', 'R', 'I', 'N', '\0'}; |
| 132 | + |
| 133 | + /** The expected bootloader version */ |
| 134 | + |
| 135 | + static const uint8_t EXPECTED_SW_VERSION[] = {0x31, 0x30}; |
| 136 | + |
| 137 | + /** The expected hardware version */ |
| 138 | + static const uint8_t EXPECTED_HW_VERSION [] = {0x3F}; |
| 139 | + |
| 140 | + /** The expected programmer type */ |
| 141 | + static const uint8_t EXPECTED_PROGRAMMER_TYPE[] = {0x53}; |
| 142 | + |
| 143 | + /** The expected supported device code */ |
| 144 | + static const uint8_t EXPECTED_DEVICE_CODE[] = {0x44}; |
| 145 | + |
| 146 | + /** The expected result when checking if bootloader supports auto incrementing page byte addresses */ |
| 147 | + static const uint8_t EXPECTED_SUPPORTS_AUTO_MEM_ADDR_INC[] = {0x59}; |
| 148 | + |
| 149 | + /** The expected block size result in bytes when checking if bootloader supports page/block flashing */ |
| 150 | + static const uint8_t EXPECTED_BLOCK_BUFFER_SIZE[] = {0x59}; |
| 151 | + |
| 152 | + /** The expected AVR low byte fuse value */ |
| 153 | + static const uint8_t EXPECTED_LSB_FUSE_VALUE [] = {0xFF}; |
| 154 | + |
| 155 | + /** The expected AVR high byte fuse value */ |
| 156 | + static const uint8_t EXPECTED_MSB_FUSE_VALUE[] = {0xD0}; |
| 157 | + |
| 158 | + /** The expected AVR extended byte fuse value */ |
| 159 | + static const uint8_t EXPECTED_EXTENDED_FUSE_VALUE[] = {0xC8}; |
| 160 | + |
| 161 | + /** The expected signature value */ |
| 162 | + static const uint8_t EXPECTED_SIGNATURE[] = {0x87, 0x95, 0x1E}; |
| 163 | +}; |
| 164 | + |
| 165 | +#endif /** __ZUMO32U4Specification_H__ */ |
| 166 | +/** @} */ |
0 commit comments