Part Number:MSP430F5529
参考https://github.com/rafaellcoellho/bsl-msp430来进行MSP430F5529开发板的固件升级,在进行到Testing步骤时,结果如下图
1、MSAA_ERASE,PC端下发80 01 00 15 64 A3指令给MSP430开发板,开发板其实是收到了,校验checksum通过并回了ACK(上图的<00>)。接下来跑到BSL430_massErase()函数时,程序就异常了。
2、RX_PASSWORD,PC端下发80 21 00 11 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 9E E6,开发板也是收到了,并回了checksum OK的ACK(上图的<00>)。接下来跑到BSL430_unlock_BSL()函数,校验密码不对,再跑到BSL430_massErase()时,程序又异常了。
感觉哪里的配置没配置对,导致密码校验和擦除出问题。CCS我用的6.1.0版本,
Ben Qin:
你好,我需要时间查看下代码,我会尽快回复您。
,
Ben Qin:
你好,检查一下两边波特率是否相同。如果方便能够提供源代码?
jing zhang 说:接下来跑到BSL430_unlock_BSL()函数,校验密码不对
可以确认接受的密码是正确的吗?
,
jing zhang:
波特率是相同的,后面又增加了打印,把接收的数据打印出来,是32个FF的,接收的数据也是没错的。
,
jing zhang:
源码怎样提供呢?
,
Ben Qin:
可以将工程打包成压缩文件夹发送到论坛上,如果你不愿意公开,也可以通过好友私信发给我。
,
jing zhang:
这论坛在哪可以带压缩文件的,在插入——》文件,只能带文件类型的东西,压缩文件不让上传的。方便给个邮箱吗,我直接邮件你。
,
Ben Qin:
直接使用鼠标拖拽就可以了。
,
jing zhang:
BSL_Device_File.hBSL430_API.c
/* --COPYRIGHT--,TI*MSP430 Tools Source and Object Code Software License Agreement***IMPORTANT PLEASE READ THE FOLLOWING LICENSE AGREEMENT CAREFULLY.THIS IS A LEGALLY BINDING AGREEMENT.AFTER YOU READ THIS LICENSE AGREEMENT, YOU WILL BE ASKED WHETHER YOU ACCEPT AND AGREE TO THE TERMS OF THIS LICENSE AGREEMENT.DO NOT CLICK "I HAVE READ AND AGREE" UNLESS: (1) YOU ARE AUTHORIZED TO ACCEPT AND AGREE TO THE TERMS OF THIS LICENSE AGREEMENT ON BEHALF OF YOURSELF AND YOUR COMPANY; AND (2) YOU INTEND TO ENTER INTO AND TO BE BOUND BY THE TERMS OF THIS LEGALLY BINDING AGREEMENT ON BEHALF OF YOURSELF AND YOUR COMPANY.***Important Read carefully: This MSP430 Tools source and object code software license agreement ("Agreement") is a legal agreement between you (either an individual or entity) and Texas Instruments Incorporated ("TI").The "Licensed Materials" subject to this Agreement include the software programs (in whole or in part) that accompany this Agreement and which you access "on-line" and/or electronic documentation (in whole or in part) associated and provided with these programs, as well as any updates or upgrades to such software programs and documentation, if any, provided to you at TI's sole discretion.The Licensed Materials are specifically designed and licensed for use solely and exclusively with MSP430 microcontroller devices manufactured by or for TI ("TI Devices").By installing, copying or otherwise using the Licensed Materials you agree to abide by the provisions set forth herein.This Agreement is displayed for you to read prior to using the Licensed Materials.If you choose not to accept or agree with these provisions, do not download or install the Licensed Materials.***1. License Grant and Use Restrictions.**a. Licensed Materials License Grant.**i. Limited Source Code License.Subject to the terms of this Agreement, TI hereby grants to you a limited, non-transferable, non-exclusive, non-assignable, non-sublicensable, fully paid-up and royalty-free license to make copies, prepare derivative works, display internally and use internally the Licensed Materials provided to you in source code for the sole purpose of developing object and executable versions of such Licensed Materials, or any derivative thereof, that execute solely and exclusively on TI Devices, for end use in Licensee Products, and maintaining and supporting such Licensed Materials, or any derivative thereof, and Licensee Products.For purposes of this Agreement, "Licensee Product" means a product that consists of both hardware, including one or more TI Devices, and software components, including only executable versions of the Licensed Materials that execute solely and exclusively on such TI Devices and not on devices manufactured by or for an entity other than TI.**ii. Object Code Evaluation, Testing and Use License.Subject to the terms of this Agreement, TI hereby grants to you a limited, non-transferable, non-exclusive, non-assignable, non-sublicensable, fully paid-up and royalty free license under all TI intellectual property embodied in the Licensed Materials provided to you in object code to make copies, display internally, distribute internally and use internally the Licensed Materials provided to you for the sole purposes of evaluating and testing the Licensed Materials and designing and developing Licensee Products, and maintaining and supporting the Licensee Products.**iii. Demonstration License.Subject to the terms of this Agreement, TI hereby grants to you a limited, non-transferable, non-exclusive, non-assignable, non-sublicensable, fully paid-up and royalty free license under all TI intellectual property embodied in the Licensed Materials to demonstrate to third parties the Licensed Materials, or any derivatives thereof, executing solely and exclusively on TI Devices as they are used in Licensee Products, provided that such Licensed Materials, or any derivatives thereof, are demonstrated in object or executable versions only.**iv. Production and Distribution License.Subject to the terms of this Agreement, TI hereby grants to you a non-transferable, non-exclusive, non-assignable, non-sublicensable, fully paid-up and royalty free license under all TI intellectual property embodied in the Licensed Materials to make, use, sell, offer to sell, import, export and otherwise distribute the Licensed Materials, or any derivatives thereof, as part of a Licensee Product, provided that such Licensee Products include only embedded executable copies of such Licensed Materials, or any derivatives thereof, that execute solely and exclusively on TI Devices in such Licensee Products.**b. Contractors and Suppliers.The licenses granted to you hereunder shall include your on-site and off-site suppliers and independent contractors, while such suppliers and independent contractors are performing work for or providing services to you, provided that such suppliers and independent contractors have executed work-for-hire agreements with you containing applicable terms and conditions consistent with the terms and conditions set forth in this Agreement and provided further that you shall be liable to TI for any breach by your suppliers or independent contractors of this Agreement to the same extent as you would be if you had breached the Agreement yourself.**c. Limited License to TI and Covenant not to Sue.Continuing for the term of this Agreement, you hereby grant to TI and TI's licensees of the Licensed Materials, under any of your patents embodied in the Licensed Materials, a non-transferable, non-exclusive, non-assignable, worldwide, fully paid-up, royalty-free license to make, use, sell, offer to sell, import, export and otherwise distribute such Licensed Materials.You covenant not to sue or otherwise assert Derived Patents against TI and TI's affiliates and their licensees of the Licensed Materials.In the event you assign a Derived Patent, you shall require as a condition of any such assignment that the assignee agree to be bound by the provisions in this Section 1(c) with respect to such Derived Patent.Any attempted assignment or transfer in violation of this Section 1(c) shall be null and void.For purposes of this Agreement, "Derived Patents" means any of your patents issuing from a patent application that discloses and claims an invention conceived of by you after delivery of the Licensed Materials, and derived by you from your access to the Licensed Materials.**d. No Other License.Notwithstanding anything to the contrary, nothing in this Agreement shall be construed as a license to any intellectual property rights of TI other than those rights embodied in the Licensed Materials provided to you by TI.EXCEPT AS PROVIDED HEREIN, NO OTHER LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY OTHER TI INTELLECTUAL PROPERTY RIGHTS IS GRANTED HEREIN.**e. Restrictions.You shall maintain the source code versions of the Licensed Materials, or any derivatives thereof, under password control protection and shall not disclose such source code versions of the Licensed Materials, or any derivatives thereof, to any person other than your employees and contractors whose job performance requires access.You shall not use the Licensed Materials, or any derivatives thereof, with a processing device manufactured by or for an entity other than TI, and you agree that any such unauthorized use of the Licensed Materials, or any derivatives thereof, is a material breach of this Agreement.Except as expressly provided in this Agreement, you shall not copy, publish, disclose, display, provide, transfer or make available the Licensed Materials, or any derivatives thereof, to any third party and you shall not sublicense, transfer, or assign the Licensed Materials, or any derivatives thereof, or your rights under this Agreement to any third party.You shall not mortgage, pledge or encumber the Licensed Materials, or any derivatives thereof, in any way.You may use the Licensed Materials, or any derivatives thereof, with Open Source Software or with software developed using Open Source Software tools provided you do not incorporate, combine or distribute the Licensed Materials, or any derivatives thereof, in a manner that subjects the Licensed Materials, or any derivatives thereof, to any license obligations or any other intellectual property related terms of any license governing such Open Source Software."Open Source Software" means any software licensed under terms requiring that (A) other software ("Proprietary Software") incorporated, combined or distributed with such software or developed using such software: (i) be disclosed or distributed in source code form; or (ii) otherwise be licensed on terms inconsistent with the terms of this Agreement, including but not limited to permitting use of the Proprietary Software on or with devices other than TI Devices, or (B) require the owner of Proprietary Software to license any of its patents to users of the Open Source Software and/or Proprietary Software incorporated, combined or distributed with such Open Source Software or developed using such Open Source Software.**f. Termination.This Agreement is effective until terminated.You may terminate this Agreement at any time by written notice to TI.Without prejudice to any other rights, if you fail to comply with the terms of this Agreement, TI may terminate your right to use the Licensed Materials, or any derivatives thereof, upon written notice to you.Upon termination of this Agreement, you will destroy any and all copies of the Licensed Materials, or any derivatives thereof, in your possession, custody or control and provide to TI a written statement signed by your authorized representative certifying such destruction. Except for Sections 1(a) and 1(b) and the limited license to TI in Section 1(c), all provisions of this Agreement shall survive termination of this Agreement.**2. Licensed Materials Ownership.The Licensed Materials are licensed, not sold to you, and can only be used in accordance with the terms of this Agreement.Subject to the licenses granted to you pursuant to this Agreement, TI and its licensors own and shall continue to own all right, title, and interest in and to the Licensed Materials, including all copies thereof.The parties agree that all fixes, modifications and improvements to the Licensed Materials conceived of or made by TI that are based, either in whole or in part, on your feedback, suggestions or recommendations are the exclusive property of TI and all right, title and interest in and to such fixes, modifications or improvements to the Licensed Materials will vest solely in TI.Moreover, you acknowledge and agree that when your independently developed software or hardware components are combined, in whole or in part, with the Licensed Materials, your right to use the combined work that includes the Licensed Materials remains subject to the terms and conditions of this Agreement.**3. Intellectual Property Rights.**a. The Licensed Materials contain copyrighted material, trade secrets and other proprietary information of TI and its licensors and are protected by copyright laws, international copyright treaties, and trade secret laws, as well as other intellectual property laws.To protect TI's and its licensors' rights in the Licensed Materials, you agree, except as specifically permitted by statute by a provision that cannot be waived by contract, not to "unlock", decompile, reverse engineer, disassemble or otherwise translate to a human-perceivable form any portions of the Licensed Materials provided to you in object code format only, nor permit any person or entity to do so.You shall not remove, alter, cover, or obscure any confidentiality, trade secret, trade mark, patent, copyright or other proprietary notice or other identifying marks or designs from any component of the Licensed Materials and you shall reproduce and include in all copies of the Licensed Materials, or any derivatives thereof, the copyright notice(s) and proprietary legend(s) of TI and its licensors as they appear in the Licensed Materials.TI reserves all rights not specifically granted under this Agreement.**b. Certain Licensed Materials may be based on industry recognized standards or software programs published by industry recognized standards bodies and certain third parties may claim to own patents, copyrights, and other intellectual property rights that cover implementation of those standards.You acknowledge and agree that this Agreement does not convey a license to any such third party patents, copyrights, and other intellectual property rights and that you are solely responsible for any patent, copyright, or other intellectual property right claim that relates to your use or distribution of the Licensed Materials, or any derivatives thereof,, or your use or distribution of your products that include or incorporate the Licensed Materials, or any derivatives thereof,.Moreover, you acknowledge that you are responsible for any fees or royalties that may be payable to any third party based on such third party's interests in the Licensed Materials or any intellectual property rights that cover implementation of any industry recognized standard, any software program published by any industry recognized standards bodies or any other proprietary technology.**4. Audit Right.At TI's request, and within thirty (30) days after receiving written notice, you shall permit an independent auditor selected by TI to have access, no more than twice each calendar year (unless the immediately preceding audit revealed a discrepancy) and during your regular business hours, to all of your equipment, records, and documents as may contain information bearing upon the use of the Licensed Materials, or any derivatives thereof.You shall keep full, complete, clear and accurate records with respect to product sales and distributions for a period beginning with the then-current calendar year and going back three (3) years.**5. Confidential Information.You acknowledge and agree that the Licensed Materials contain trade secrets and other confidential information of TI its licensors.You agree to use the Licensed Materials, or any derivatives thereof, solely within the scope of the licenses set forth herein, to maintain the Licensed Materials, or any derivatives thereof, in strict confidence, to use at least the same procedures and degree of care that you use to prevent disclosure of your own confidential information of like importance but in no instance less than reasonable care, and to prevent disclosure of the Licensed Materials, or any derivatives thereof, to any third party, except as may be necessary and required in connection with your rights and obligations hereunder.You agree to obtain executed confidentiality agreements with your employees and contractors having access to the Licensed Materials, or any derivatives thereof, and to diligently take steps to enforce such agreements in this respect.TI agrees that industry standard employment agreements used in the normal course of your business shall satisfy the requirements of this section. TI may disclose your contact information to TI's licensors.**6. Warranties and Limitations.THE LICENSED MATERIALS ARE PROVIDED "AS IS".FURTHERMORE, YOU ACKNOWLEDGE AND AGREE THAT THE LICENSED MATERIALS HAVE NOT BEEN TESTED OR CERTIFIED BY ANY GOVERNMENT AGENCY OR INDUSTRY REGULATORY ORGANIZATION OR ANY OTHER THIRD PARTY ORGANIZATION.YOU AGREE THAT PRIOR TO USING, INCORPORATING OR DISTRIBUTING THE LICENSED MATERIALS, OR ANY DERIVATIVES THEREOF, IN OR WITH ANY COMMERCIAL PRODUCT THAT YOU WILL THOROUGHLY TEST THE PRODUCT AND THE FUNCTIONALITY OF THE LICENSED MATERIALS, OR ANY DERIVATIVES THEREOF, IN OR WITH THAT PRODUCT AND BE SOLELY RESPONSIBLE FOR ANY PROBLEMS OR FAILURES.**TI AND ITS LICENSORS MAKE NO WARRANTY OR REPRESENTATION, EITHER EXPRESS, IMPLIED OR STATUTORY, REGARDING THE LICENSED MATERIALS, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT OF ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADE SECRETS OR OTHER INTELLECTUAL PROPERTY RIGHTS.YOU AGREE TO USE YOUR INDEPENDENT JUDGMENT IN DEVELOPING YOUR PRODUCTS.NOTHING CONTAINED IN THIS AGREEMENT WILL BE CONSTRUED AS A WARRANTY OR REPRESENTATION BY TI TO MAINTAIN PRODUCTION OF ANY TI SEMICONDUCTOR DEVICE OR OTHER HARDWARE OR SOFTWARE WITH WHICH THE LICENSED MATERIALS, OR ANY DERIVATIVES THEREOF, MAY BE USED.**IN NO EVENT SHALL TI OR ITS LICENSORS, BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED, ON ANY THEORY OF LIABILITY, IN CONNECTION WITH OR ARISING OUT OF THIS AGREEMENT OR THE USE OF THE LICENSED MATERIALS, OR ANY DERIVATIVES THEREOF, REGARDLESS OF WHETHER TI HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF REMOVAL OR REINSTALLATION, OUTSIDE COMPUTER TIME, LABOR COSTS, LOSS OF DATA, LOSS OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF USE OR INTERRUPTION OF BUSINESS.IN NO EVENT WILL TI'S OR ITS LICENSORS' AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF YOUR USE OF THE LICENSED MATERIALS, OR ANY DERIVATIVES THEREOF, EXCEED THE GREATER OF FIVE HUNDRED U.S. DOLLARS (US$500) OR THE FEES PAID TO TI BY YOU FOR THE LICENSED MATERIALS UNDER THIS AGREEMENT.**Because some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages or limitation on how long an implied warranty lasts, the above limitations or exclusions may not apply to you.**7. Indemnification Disclaimer.YOU ACKNOWLEDGE AND AGREE THAT TI SHALL NOT BE LIABLE FOR AND SHALL NOT DEFEND OR INDEMNIFY YOU AGAINST ANY THIRD PARTY INFRINGEMENT CLAIM THAT RELATES TO OR IS BASED ON YOUR MANUFACTURE, USE, OR DISTRIBUTION OF THE LICENSED MATERIALS, OR ANY DERIVATIVES THEREOF, OR YOUR MANUFACTURE, USE, OFFER FOR SALE, SALE, IMPORTATION OR DISTRIBUTION OF YOUR PRODUCTS THAT INCLUDE OR INCORPORATE THE LICENSED MATERIALS, OR ANY DERIVATIVES THEREOF,.**8. No Technical Support.TI and its licensors are under no obligation to install, maintain or support the Licensed Materials, or any derivatives thereof.**9. Notices.All notices to TI hereunder shall be delivered to Texas Instruments Incorporated, 12500 TI Boulevard, Mail Station 8638, Dallas, Texas 75243, Attention: Contracts Manager, with a copy to Texas Instruments Incorporated, 13588 North Central Expressway, MS 3999, Dallas, TX 75243,Attention: Law Department - ASP.All notices shall be deemed served when received by TI.**10. Export Control.You hereby acknowledge that the Licensed Materials are subject to export control under the U.S. Commerce Department's Export Administration Regulations ("EAR").You further hereby acknowledge and agree that unless prior authorization is obtained from the U.S. Commerce Department, neither you nor your customers will export, re-export, or release, directly or indirectly, any technology, software, or software source code (as defined in Part 772 of the EAR), received from TI, or export, directly or indirectly, any direct product of such technology, software, or software source code (as defined in Part 734 of the EAR), to any destination or country to which the export, re-export, or release of the technology, software, or software source code, or direct product is prohibited by the EAR.You agree that none of the Licensed Materials may be downloaded or otherwise exported or reexported (i) into (or to a national or resident of) Cuba, Iran, North Korea, Sudan and Syria or any other country the U.S. has embargoed goods; or (ii) to anyone on the U.S. Treasury Department's List of Specially Designated Nationals or the U.S. Commerce Department's Denied Persons List or Entity List.You represent and warrant that you are not located in, under the control of, or a national or resident of any such country or on any such list and you will not use or transfer the Licensed Materials, or any derivatives thereof, for use in any sensitive nuclear, chemical or biological weapons, or missile technology end-uses unless authorized by the U.S. Government by regulation or specific license or for a military end-use in, or by any military entity of Albania, Armenia, Azerbaijan, Belarus, Cambodia, China, Georgia, Iraq, Kazakhstan, Kyrgyzstan, Laos, Libya, Macau, Moldova, Mongolia, Russia, Tajikistan, Turkmenistan, Ukraine, Uzbekistan, and Vietnam. Any software export classification made by TI shall be for TI's internal use only and shall not be construed as a representation or warranty regarding the proper export classification for such software or whether an export license or other documentation is required for the exportation of such software.**11. Governing Law and Severability; Waiver.This Agreement will be governed by and interpreted in accordance with the laws of the State of Texas, without reference to conflict of laws principles.If for any reason a court of competent jurisdiction finds any provision of the Agreement to be unenforceable, that provision will be enforced to the maximum extent possible to effectuate the intent of the parties, and the remainder of the Agreement shall continue in full force and effect.This Agreement shall not be governed by the United Nations Convention on Contracts for the International Sale of Goods, or by the Uniform Computer Information Transactions Act (UCITA).The parties agree that non-exclusive jurisdiction for any dispute arising out of or relating to this Agreement lies within the courts located in the State of Texas.Notwithstanding the foregoing, any judgment may be enforced in any United States or foreign court, and either party may seek injunctive relief in any United States or foreign court.Failure by TI to enforce any provision of this Agreement shall not be deemed a waiver of future enforcement of that or any other provision in this Agreement or any other agreement that may be in place between the parties.**12. PRC Provisions.If you are located in the People's Republic of China ("PRC") or if the Licensed Materials, or any derivatives thereof, will be sent to the PRC, the following provisions shall apply and shall supersede any other provisions in this Agreement concerning the same subject matter:**a. Registration Requirements.You shall be solely responsible for performing all acts and obtaining all approvals that may be required in connection with this Agreement by the government of the PRC, including but not limited to registering pursuant to, and otherwise complying with, the PRC Measures on the Administration of Software Products, Management Regulations on Technology Import-Export, and Technology Import and Export Contract Registration Management Rules.Upon receipt of such approvals from the government authorities, you shall forward evidence of all such approvals to TI for its records.In the event that you fail to obtain any such approval or registration, you shall be solely responsible for any and all losses, damages or costs resulting therefrom, and shall indemnify TI for all such losses, damages or costs.**b. Governing Language.This Agreement is written and executed in the English language.If a translation of this Agreement is required for any purpose, including but not limited to registration of the Agreement pursuant to any governmental laws, regulations or rules, you shall be solely responsible for creating such translation.Any translation of this Agreement into a language other than English is intended solely in order to comply with such laws or for reference purposes, and the English language version shall be authoritative and controlling.**c. Export Control.**i. Diversions of Technology.You hereby agree that unless prior authorization is obtained from the U.S. Department of Commerce, neither you nor your subsidiaries or affiliates shall knowingly export, re-export, or release, directly or indirectly, any technology, software, or software source code (as defined in Part 772 of the Export Administration Regulations of the U.S. Department of Commerce ("EAR")), received from TI or any of its affiliated companies, or export, directly or indirectly, any direct product of such technology, software, or software source code (as defined in Part 734 of the EAR), to any destination or country to which the export, re-export, or release of the technology, software, software source code, or direct product is prohibited by the EAR.**ii. Assurance of Compliance.You understand and acknowledge that products, technology (regardless of the form in which it is provided), software or software source code, received from TI or any of its affiliates under this Agreement may be under export control of the United States or other countries.You shall comply with the United States and other applicable non-U.S. laws and regulations governing the export, re-export and release of any products, technology, software, or software source code received under this Agreement from TI or its affiliates.You shall not undertake any action that is prohibited by the EAR.Without limiting the generality of the foregoing, you specifically agree that you shall not transfer or release products, technology, software, or software source code of TI or its affiliates to, or for use by, military end users or for use in military, missile, nuclear, biological, or chemical weapons end uses.**iii.Licenses.Each party shall secure at its own expense, such licenses and export and import documents as are necessary for each respective party to fulfill its obligations under this Agreement.If such licenses or government approvals cannot be obtained, TI may terminate this Agreement, or shall otherwise be excused from the performance of any obligations it may have under this Agreement for which the licenses or government approvals are required.**13. Entire Agreement.This is the entire Agreement between you and TI and this Agreement supersedes any prior agreement between the parties related to the subject matter of this Agreement.Notwithstanding the foregoing, any signed and effective software license agreement relating to the subject matter hereof and stating expressly that such agreement shall control regardless of any subsequent click-wrap, shrink-wrap or web-wrap, shall supersede the terms of this Agreement.No amendment or modification of this Agreement will be effective unless in writing and signed by a duly authorized representative of TI.You hereby warrant and represent that you have obtained all authorizations and other applicable consents required empowering you to enter into this Agreement.** --/COPYRIGHT--*/ #include "BSL_Device_File.h" #include "BSL430_API.h" #include "BSL430_Command_Definitions.h"/******************************************************************************* *Change Log: *2.2.09LCWremoved RAM erase *Changed mass erase and info segments *2.2.09LCWworked on RAM Loader function *Changed Password to XOR *Changed Password addr to 0xFFE0 *-------------------------------------------------------------------------------- *Version 3 work begins *07.08.09 LCWRemoved info erase *11.08.09 LCWbugfix in CRC algorithm *-------------------------------------------------------------------------------- *Version 4 work begins *21.12.09 LCWRemoved VPE check *15.03.10 LCWMisc comment cleanup for source release *-------------------------------------------------------------------------------- *Version 4.1 (no output change, source/comment modified) *15.04.10 LCWChanged Version defines to remove warning *-------------------------------------------------------------------------------- *Version 5 work begins *18.02.11 LCWAdded USB BSL Buffering for block write *disabled GIE at startup *uncrustified *VPE check removed from word write *13.04.11 LCWMade length varibles unsigned *-------------------------------------------------------------------------------- *Version 6 work begins *30.10.12 LCWCleared Lock IO on startup *-------------------------------------------------------------------------------- *Version 6.1 (update to align with previous releases) *11.03.13 ELAdded definition for LOCKIO *-------------------------------------------------------------------------------- *Version 7*08.05.13 ELreduced zArea Size to make room for USB Bugfix *-------------------------------------------------------------------------------- *Version 8 *Aug29.13 BEPMoved __low_level_init to __program_start to free up code space. *BEPMoved RAM clean up to BSL430_API_init since it does not fit in *__program_start. *******************************************************************************/ #ifdef RAM_BASED_BSL #ifdef RAM_WRITE_ONLY_BSL #error Can NOT have RAM write and RAM based BSL #endif #define DEFAULT_STATE (UNLOCKED) #else #define DEFAULT_STATE (LOCKED) #endif#ifdef RAM_BASED_BSL char flushBuffer(void);// buffer flush routine, internal for USB only#pragma data_alignment=2 __no_init unsigned char BlockBuffer[128]; __no_init unsigned long int BlockBufferStart; __no_init unsigned long int BlockBufferNext; __no_init unsigned int BlockBufferPtr; #endif#pragma NOINIT(LockedStatus); volatile unsigned int LockedStatus; #pragma NOINIT(FwRamKey); int FwRamKey;/******************************************************************************* * *Function:__low_level_init * *Description: function used to erase the RAM in device and stop WDT *******************************************************************************/ #ifndef EXCLUDE_LOW_LEVEL_INIT #if __VER__ <= 420 void #else int #endif _system_pre_init(void) {WDTCTL = WDTPW + WDTHOLD;// Stop watchdog timer__disable_interrupt();// disable interrupts #if __VER__ > 420return 0;// do not initialize #endif } #endif/******************************************************************************* * *Function:BSL430_RAM_Clear * *Description: Clears the contents of RAM *******************************************************************************/void BSL430_API_RAM_Clear() { #ifndef RAM_BASED_BSLunsigned int *size = (unsigned int *)(__get_SP_register() - SECURE_RAM_START);do {size[(SECURE_RAM_START >> 1) - 1] = 0;// Clear RAM contentssize--;} while ((unsigned int)size); #endif }/******************************************************************************* * *Function:BSL430_API_init * *Description: sets the key for writing to flash,sets device state *******************************************************************************/void BSL430_API_init() {LockedStatus = DEFAULT_STATE;FwRamKey = FWKEY; #ifdef CLEAR_LOCKIOPMMCTL0_H = PMMPW_H;// open PMM registersPM5CTL0 &= ~LOCKLPM5;// clear lock IOPMMCTL0_H = 0x00;// close PMM registers #endif#ifdef RAM_BASED_BSLBlockBufferNext = 0;BlockBufferStart = 0;BlockBufferPtr = 0; #endif }/******************************************************************************* * *Function:BSL430_lock_BSL * *Description: Locks the BSL * *Returns: *SUCCESSFUL_OPERATIONBSL Locked *******************************************************************************/char BSL430_lock_BSL() {LockedStatus = LOCKED;return SUCCESSFUL_OPERATION; }/******************************************************************************* * *Function:BSL430_unlock_BSL * *Description: Causes the BSL to compare the data buffer against the BSL password *BSL state will be UNLOCKED if successful * *Parameters: *char* dataA pointer to an array containing the password * *Returns: *SUCCESSFUL_OPERATIONAll data placed into data array successfully *BSL_PASSWORD_ERRORCorrect Password was not given *******************************************************************************/char BSL430_unlock_BSL(char* data) {int i;int retValue = 0;char *interrupts = (char*)INTERRUPT_VECTOR_START;for (i = 0; i <= (INTERRUPT_VECTOR_END - INTERRUPT_VECTOR_START); i++, interrupts++){retValue |=*interrupts ^ data[i];}if (retValue == 0){ #ifndef RAM_WRITE_ONLY_BSLvolatile int i;for (i = MASS_ERASE_DELAY - 1; i > 0; i--) ; #endifLockedStatus = UNLOCKED;return SUCCESSFUL_OPERATION;}else{BSL430_massErase();return BSL_PASSWORD_ERROR;} }/******************************************************************************* * *Function:BSL430_toggleInfoLock * *Description: Toggles the LOCKA bit for writing/erasing info A segment * *Returns: *SUCCESSFUL_OPERATIONInfo A is now open for writing or erasing. *BSL_LOCKEDCorrect Password has not yet been given *******************************************************************************/char BSL430_toggleInfoLock() {char exceptions;if (LockedStatus == UNLOCKED){exceptions = SUCCESSFUL_OPERATION;FCTL3 = FwRamKey + LOCKA + (FCTL3 & LOCK); // toggle LOCKA bit}else{exceptions = BSL_LOCKED;}return exceptions; }/******************************************************************************* * *Function:BSL430_openMemory * *Description: Unlocks the Flash for writing * *Returns: *SUCCESSFUL_OPERATIONFlash is now open for writing. *BSL_LOCKEDCorrect Password has not yet been given *******************************************************************************/char BSL430_openMemory() {char exceptions = BSL_LOCKED;if (LockedStatus == UNLOCKED){exceptions = SUCCESSFUL_OPERATION; #ifndef RAM_BASED_BSLFCTL3 = FwRamKey;// Clear Lock bitFCTL1 = FwRamKey + WRT;// Set write bit #endif}return exceptions; }/******************************************************************************* * *Function:BSL430_closeMemory * *Description: Locks the Flash against writing * *Returns: *SUCCESSFUL_OPERATIONFlash is now locked. *******************************************************************************/char BSL430_closeMemory(void) {FCTL1 = FwRamKey;// Clear WRT bitFCTL3 = FwRamKey + LOCK;// Set LOCK bitreturn SUCCESSFUL_OPERATION; }/******************************************************************************* * *Function:BSL430_readMemory * *Description: Reads an array of bytes from memory into a supplied array * *Parameters: *unsigned long addrThe address from which the read should begin *char lengthThe amount of bytes to read *char* dataThe array into which the data will be saved * *Returns: *SUCCESSFUL_OPERATIONAll Data placed into data array successfully *BSL_LOCKEDCorrect Password has not yet been given *******************************************************************************/char BSL430_readMemory(unsigned long addr, unsigned int length, char* data) {unsigned long i;#ifdef RAM_BASED_BSLflushBuffer(); #endifchar exceptions = SUCCESSFUL_OPERATION;for (i = addr + length - 1; i >= addr; i--){if (LockedStatus == UNLOCKED){data[i - addr] = __data20_read_char(i);}else{return BSL_LOCKED;}}return exceptions; }/******************************************************************************* * *Function:BSL430_crcCheck * *Description: return a CRC check on the memory specified * *Parameters: *unsigned long addrThe address from which to start the check *int lengthThe length of the data area to check *int* returnvariable in which to put the return value * *Returns: *SUCCESSFUL_OPERATIONCRC check done correctly *BSL_LOCKEDCorrect Password has not yet been given *******************************************************************************/int BSL430_crcCheck(unsigned long addr, unsigned int length, int* result) {unsigned long i;#ifdef RAM_BASED_BSLflushBuffer(); #endifCRCINIRES = 0xFFFF;for (i = addr; i < addr + length; i++){if (LockedStatus == UNLOCKED){CRCDIRB_L = __data20_read_char(i);}else{return BSL_LOCKED;}}*result = CRCINIRES;return SUCCESSFUL_OPERATION;}/******************************************************************************* * *Function:BSL430_callAddress * *Description: Loads the Program Counter with the supplied address * *Parameters: *unsigned long addrThe address to which the function call should go * *Returns: *SUCCESSFUL_OPERATIONCalled location has returned *BSL_LOCKEDCorrect Password has not yet been given * *Note: *If successful, this function does not return. *******************************************************************************/char BSL430_callAddress(unsigned long addr) {if (LockedStatus == UNLOCKED){ #ifdef RAM_BASED_BSLflushBuffer(); #endif((void (*)())addr)();// type cast addr to// function ptr, callreturn SUCCESSFUL_OPERATION;}return BSL_LOCKED;// can only be reached if// BSL is locked}/******************************************************************************* * *Function:flushBuffer * *Description: Flushes any remaining data in the buffer * *Returns: *SUCCESSFUL_OPERATIONFlash is now locked. *******************************************************************************/ #ifdef RAM_BASED_BSL char flushBuffer(void) {unsigned long i;char exceptions = SUCCESSFUL_OPERATION;unsigned char* data = &BlockBuffer[0];if (LockedStatus == UNLOCKED){if (((BlockBufferStart & 0x7F) == 0) && (BlockBufferPtr == 128)) //Buffer is full and// aligned{while (FCTL3 & BUSY) ;FCTL3 = FWKEY;// Clear Lock bitFCTL1 = FWKEY + BLKWRT + WRT;// Set write/block bitfor (i = BlockBufferStart; i < BlockBufferStart + 128; i += 4){__data20_write_long(i, *((long*)data));data += 4;while ((FCTL3 & WAIT) == 0) ;} // forFCTL1 = FwRamKey;while (FCTL3 & BUSY) ;FCTL3 = FwRamKey + LOCK;} // ifelse{FCTL3 = FwRamKey;// Clear Lock bitFCTL1 = FwRamKey + WRT;// Set write bitfor (i = BlockBufferStart; i < BlockBufferStart + BlockBufferPtr; i++){if ((BlockBufferStart & 0x01) || i == BlockBufferStart + BlockBufferPtr - 1){exceptions = BSL430_writeByte(i, *data);data += 1;}else{exceptions = BSL430_writeWord(i, *(int *)data);data += 2;i++;}if (exceptions != SUCCESSFUL_OPERATION){return exceptions;} // if}// for}// elseBlockBufferStart = 0;BlockBufferNext = 0;BlockBufferPtr = 0;}else{exceptions = BSL_LOCKED;}return exceptions; }#endif/******************************************************************************* * *Function:BSL430_writeMemory * *Description: Writes a byte array starting at a given address. *Note: the function will write in word mode if possible *(when start address is even) * *Parameters: *unsigned long startAddrThe address to which the write should begin *int sizeThe number of bytes to write *char* dataThe array of bytes to write (must be even aligned) * *Returns: *SUCCESSFUL_OPERATIONBytes written successfully *MEMORY_WRITE_CHECK_FAILEDA byte in data location post-write does not match data * *parameter *Note: write stops immediatly after a byte check fails *BSL_LOCKEDCorrect Password has not yet been given *VOLTAGE_CHANGE_DURING_PROGRAMVoltage changed during write (of a single byte/word) *******************************************************************************/char BSL430_writeMemory(unsigned long startAddr, unsigned int size,char* data) {unsigned long i;char exceptions = SUCCESSFUL_OPERATION;// Note: this function compiles quite differently based on whether the// BSL is based out of RAM, or not.RAM based BSLs can use buffering// and perform a block long word write.This is primarily used for// USB BSLs for performance increase.// Flash based BSLs will use the second second of code, below#ifdef RAM_BASED_BSLif (LockedStatus == UNLOCKED){if ((BlockBufferStart == 0) || BlockBufferNext == startAddr){// if we are starting, or continuing a block...if (BlockBufferStart == 0){BlockBufferStart = startAddr;// if starting a new block, reset// start addr}BlockBufferNext =startAddr + size;// always update the next addr for// streamingfor (i = 0; i < size;){BlockBuffer[BlockBufferPtr++] = *data;// add the incoming data to the bufferdata++;startAddr++;i++;// i incrimented here for check belowif (((startAddr) & 0x7F) == 0x00)// we've crossed a 128 byte block// boundary{flushBuffer();// flush out old buffer, writing...// begin write on block boundaryreturn BSL430_writeMemory(startAddr, (size - i), data);} // if} // for} // if buffer startelse{// for when data exists in the buffer, but we are jumping to a new place to write...flushBuffer();// flush out old buffer, writing..return BSL430_writeMemory(startAddr, size, data); // begin buffering new data}} // if unlockedelse{exceptions = BSL_LOCKED;}// Below is the writeMemory function compiled with Flash based BSLs. #elsefor (i = startAddr; i < startAddr + size; i++){ #ifndef RAM_WRITE_ONLY_BSL// if the start address is odd, or we're 1 byte from end...if ((startAddr & 0x01) || i == startAddr + size - 1) #endif{exceptions = BSL430_writeByte(i, *data);data += 1;} #ifndef RAM_WRITE_ONLY_BSL// else, we're on an even addr, and have at least 1 word left..else{exceptions = BSL430_writeWord(i, *(int *)data);data += 2;i++;}if (exceptions != SUCCESSFUL_OPERATION){return exceptions;} // if #endif}// for #endifreturn exceptions; }/******************************************************************************* * *Function:BSL430_writeByte * *Description: Writes a byte at a given address * *Parameters: *unsigned long addrThe address to which the byte should be written *char dataThe byte to write * *Returns: *SUCCESSFUL_OPERATIONByte written successfully *MEMORY_WRITE_CHECK_FAILEDByte in data location post-write does not match data * *parameter *VOLTAGE_CHANGE_DURING_PROGRAMVoltage changed during write *BSL_LOCKEDCorrect Password has not yet been given *******************************************************************************/char BSL430_writeByte(unsigned long addr, char data) {char exceptions;if (LockedStatus == UNLOCKED){exceptions = SUCCESSFUL_OPERATION; #ifdef RAM_BASED_BSLwhile (FCTL3 & BUSY) ; #endif__data20_write_char(addr, data); #ifdef RAM_BASED_BSLwhile (FCTL3 & BUSY) ; #endifif (data != __data20_read_char(addr)){exceptions = MEMORY_WRITE_CHECK_FAILED;} #ifndef RAM_WRITE_ONLY_BSL #ifndef DO_NOT_CHECK_VPEif (FCTL4 & VPE){exceptions = VOLTAGE_CHANGE_DURING_PROGRAM;} #endif #endif}else{exceptions = BSL_LOCKED;}return exceptions; }/******************************************************************************* * *Function:BSL430_writeWord * *Description: Writes a word at a given address * *Parameters: *unsigned long addrThe address to which the word should be written *int dataThe byte to write * *Returns: *SUCCESSFUL_OPERATIONWord written successfully *MEMORY_WRITE_CHECK_FAILEDWord in data location post-write does not match data * *parameter *VOLTAGE_CHANGE_DURING_PROGRAMVoltage changed during write *BSL_LOCKEDCorrect Password has not yet been given *******************************************************************************/char BSL430_writeWord(unsigned long addr, int data) {char exceptions;if (LockedStatus == UNLOCKED){exceptions = SUCCESSFUL_OPERATION; #ifdef RAM_BASED_BSLwhile (FCTL3 & BUSY) ; #endif__data20_write_short(addr, data); #ifdef RAM_BASED_BSLwhile (FCTL3 & BUSY) ; #endifif (data != __data20_read_short(addr)){exceptions = MEMORY_WRITE_CHECK_FAILED;} #ifndef DO_NOT_CHECK_VPEif (FCTL4 & VPE){exceptions = VOLTAGE_CHANGE_DURING_PROGRAM;} #endif}else{exceptions = BSL_LOCKED;}return exceptions; }/******************************************************************************* * *Function:BSL430_eraseLocation * *Description: Erases a memory segment which contains a given address * *Parameters: *char block_erasecurrently unused 1: erase block 0: erase segment *unsigned long addrAn address which is within the segment to be erased * *Returns: *SUCCESSFUL_OPERATIONSegment erased *BSL_LOCKEDCorrect Password has not yet been given *******************************************************************************/char BSL430_eraseLocation(char block_erase, unsigned long addr) {char exceptions;if (LockedStatus == UNLOCKED){exceptions = SUCCESSFUL_OPERATION; #ifdef RAM_BASED_BSLwhile (FCTL3 & BUSY) ; #endifFCTL3 = FwRamKey;// Clear Lock bitFCTL1 = FwRamKey + ERASE;// Set Erase bit__data20_write_char(addr, 0);// Dummy write to erase Flash seg #ifdef RAM_BASED_BSLwhile (FCTL3 & BUSY) ; #endifFCTL3 = FwRamKey + LOCK;// Set LOCK bit}else{exceptions = BSL_LOCKED;}return exceptions; }/******************************************************************************* * *Function:BSL430_massErase * *Description: Mass erases the entire MSP430 device * *Returns: *SUCCESSFUL_OPERATIONFlash erased *BSL_LOCKEDCorrect Password has not yet been given *******************************************************************************/char BSL430_massErase() {char exceptions = SUCCESSFUL_OPERATION;volatile char *Flash_ptr;// Flash pointer#ifdef RAM_BASED_BSLwhile (FCTL3 & BUSY) ; #endifFCTL3 = FwRamKey; #ifdef RAM_BASED_BSLwhile (FCTL3 & BUSY) ; #endifFlash_ptr = (char *)INTERRUPT_VECTOR_START; // Initialize Flash pointerFCTL1 = FwRamKey + MERAS + ERASE;// Set Mass Erase bit*Flash_ptr = 0;// Dummy write to erase main flash #ifdef RAM_BASED_BSLwhile (FCTL3 & BUSY) ; #endifFCTL3 = FwRamKey + LOCK;// Set LOCK bitreturn exceptions; }BSL430_API.hBSL430_Command_Definitions.hBSL430_Command_Interpreter.c
/* --COPYRIGHT--,TI*MSP430 Tools Source and Object Code Software License Agreement***IMPORTANT PLEASE READ THE FOLLOWING LICENSE AGREEMENT CAREFULLY.THIS IS A LEGALLY BINDING AGREEMENT.AFTER YOU READ THIS LICENSE AGREEMENT, YOU WILL BE ASKED WHETHER YOU ACCEPT AND AGREE TO THE TERMS OF THIS LICENSE AGREEMENT.DO NOT CLICK "I HAVE READ AND AGREE" UNLESS: (1) YOU ARE AUTHORIZED TO ACCEPT AND AGREE TO THE TERMS OF THIS LICENSE AGREEMENT ON BEHALF OF YOURSELF AND YOUR COMPANY; AND (2) YOU INTEND TO ENTER INTO AND TO BE BOUND BY THE TERMS OF THIS LEGALLY BINDING AGREEMENT ON BEHALF OF YOURSELF AND YOUR COMPANY.***Important Read carefully: This MSP430 Tools source and object code software license agreement ("Agreement") is a legal agreement between you (either an individual or entity) and Texas Instruments Incorporated ("TI").The "Licensed Materials" subject to this Agreement include the software programs (in whole or in part) that accompany this Agreement and which you access "on-line" and/or electronic documentation (in whole or in part) associated and provided with these programs, as well as any updates or upgrades to such software programs and documentation, if any, provided to you at TI's sole discretion.The Licensed Materials are specifically designed and licensed for use solely and exclusively with MSP430 microcontroller devices manufactured by or for TI ("TI Devices").By installing, copying or otherwise using the Licensed Materials you agree to abide by the provisions set forth herein.This Agreement is displayed for you to read prior to using the Licensed Materials.If you choose not to accept or agree with these provisions, do not download or install the Licensed Materials.***1. License Grant and Use Restrictions.**a. Licensed Materials License Grant.**i. Limited Source Code License.Subject to the terms of this Agreement, TI hereby grants to you a limited, non-transferable, non-exclusive, non-assignable, non-sublicensable, fully paid-up and royalty-free license to make copies, prepare derivative works, display internally and use internally the Licensed Materials provided to you in source code for the sole purpose of developing object and executable versions of such Licensed Materials, or any derivative thereof, that execute solely and exclusively on TI Devices, for end use in Licensee Products, and maintaining and supporting such Licensed Materials, or any derivative thereof, and Licensee Products.For purposes of this Agreement, "Licensee Product" means a product that consists of both hardware, including one or more TI Devices, and software components, including only executable versions of the Licensed Materials that execute solely and exclusively on such TI Devices and not on devices manufactured by or for an entity other than TI.**ii. Object Code Evaluation, Testing and Use License.Subject to the terms of this Agreement, TI hereby grants to you a limited, non-transferable, non-exclusive, non-assignable, non-sublicensable, fully paid-up and royalty free license under all TI intellectual property embodied in the Licensed Materials provided to you in object code to make copies, display internally, distribute internally and use internally the Licensed Materials provided to you for the sole purposes of evaluating and testing the Licensed Materials and designing and developing Licensee Products, and maintaining and supporting the Licensee Products.**iii. Demonstration License.Subject to the terms of this Agreement, TI hereby grants to you a limited, non-transferable, non-exclusive, non-assignable, non-sublicensable, fully paid-up and royalty free license under all TI intellectual property embodied in the Licensed Materials to demonstrate to third parties the Licensed Materials, or any derivatives thereof, executing solely and exclusively on TI Devices as they are used in Licensee Products, provided that such Licensed Materials, or any derivatives thereof, are demonstrated in object or executable versions only.**iv. Production and Distribution License.Subject to the terms of this Agreement, TI hereby grants to you a non-transferable, non-exclusive, non-assignable, non-sublicensable, fully paid-up and royalty free license under all TI intellectual property embodied in the Licensed Materials to make, use, sell, offer to sell, import, export and otherwise distribute the Licensed Materials, or any derivatives thereof, as part of a Licensee Product, provided that such Licensee Products include only embedded executable copies of such Licensed Materials, or any derivatives thereof, that execute solely and exclusively on TI Devices in such Licensee Products.**b. Contractors and Suppliers.The licenses granted to you hereunder shall include your on-site and off-site suppliers and independent contractors, while such suppliers and independent contractors are performing work for or providing services to you, provided that such suppliers and independent contractors have executed work-for-hire agreements with you containing applicable terms and conditions consistent with the terms and conditions set forth in this Agreement and provided further that you shall be liable to TI for any breach by your suppliers or independent contractors of this Agreement to the same extent as you would be if you had breached the Agreement yourself.**c. Limited License to TI and Covenant not to Sue.Continuing for the term of this Agreement, you hereby grant to TI and TI's licensees of the Licensed Materials, under any of your patents embodied in the Licensed Materials, a non-transferable, non-exclusive, non-assignable, worldwide, fully paid-up, royalty-free license to make, use, sell, offer to sell, import, export and otherwise distribute such Licensed Materials.You covenant not to sue or otherwise assert Derived Patents against TI and TI's affiliates and their licensees of the Licensed Materials.In the event you assign a Derived Patent, you shall require as a condition of any such assignment that the assignee agree to be bound by the provisions in this Section 1(c) with respect to such Derived Patent.Any attempted assignment or transfer in violation of this Section 1(c) shall be null and void.For purposes of this Agreement, "Derived Patents" means any of your patents issuing from a patent application that discloses and claims an invention conceived of by you after delivery of the Licensed Materials, and derived by you from your access to the Licensed Materials.**d. No Other License.Notwithstanding anything to the contrary, nothing in this Agreement shall be construed as a license to any intellectual property rights of TI other than those rights embodied in the Licensed Materials provided to you by TI.EXCEPT AS PROVIDED HEREIN, NO OTHER LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY OTHER TI INTELLECTUAL PROPERTY RIGHTS IS GRANTED HEREIN.**e. Restrictions.You shall maintain the source code versions of the Licensed Materials, or any derivatives thereof, under password control protection and shall not disclose such source code versions of the Licensed Materials, or any derivatives thereof, to any person other than your employees and contractors whose job performance requires access.You shall not use the Licensed Materials, or any derivatives thereof, with a processing device manufactured by or for an entity other than TI, and you agree that any such unauthorized use of the Licensed Materials, or any derivatives thereof, is a material breach of this Agreement.Except as expressly provided in this Agreement, you shall not copy, publish, disclose, display, provide, transfer or make available the Licensed Materials, or any derivatives thereof, to any third party and you shall not sublicense, transfer, or assign the Licensed Materials, or any derivatives thereof, or your rights under this Agreement to any third party.You shall not mortgage, pledge or encumber the Licensed Materials, or any derivatives thereof, in any way.You may use the Licensed Materials, or any derivatives thereof, with Open Source Software or with software developed using Open Source Software tools provided you do not incorporate, combine or distribute the Licensed Materials, or any derivatives thereof, in a manner that subjects the Licensed Materials, or any derivatives thereof, to any license obligations or any other intellectual property related terms of any license governing such Open Source Software."Open Source Software" means any software licensed under terms requiring that (A) other software ("Proprietary Software") incorporated, combined or distributed with such software or developed using such software: (i) be disclosed or distributed in source code form; or (ii) otherwise be licensed on terms inconsistent with the terms of this Agreement, including but not limited to permitting use of the Proprietary Software on or with devices other than TI Devices, or (B) require the owner of Proprietary Software to license any of its patents to users of the Open Source Software and/or Proprietary Software incorporated, combined or distributed with such Open Source Software or developed using such Open Source Software.**f. Termination.This Agreement is effective until terminated.You may terminate this Agreement at any time by written notice to TI.Without prejudice to any other rights, if you fail to comply with the terms of this Agreement, TI may terminate your right to use the Licensed Materials, or any derivatives thereof, upon written notice to you.Upon termination of this Agreement, you will destroy any and all copies of the Licensed Materials, or any derivatives thereof, in your possession, custody or control and provide to TI a written statement signed by your authorized representative certifying such destruction. Except for Sections 1(a) and 1(b) and the limited license to TI in Section 1(c), all provisions of this Agreement shall survive termination of this Agreement.**2. Licensed Materials Ownership.The Licensed Materials are licensed, not sold to you, and can only be used in accordance with the terms of this Agreement.Subject to the licenses granted to you pursuant to this Agreement, TI and its licensors own and shall continue to own all right, title, and interest in and to the Licensed Materials, including all copies thereof.The parties agree that all fixes, modifications and improvements to the Licensed Materials conceived of or made by TI that are based, either in whole or in part, on your feedback, suggestions or recommendations are the exclusive property of TI and all right, title and interest in and to such fixes, modifications or improvements to the Licensed Materials will vest solely in TI.Moreover, you acknowledge and agree that when your independently developed software or hardware components are combined, in whole or in part, with the Licensed Materials, your right to use the combined work that includes the Licensed Materials remains subject to the terms and conditions of this Agreement.**3. Intellectual Property Rights.**a. The Licensed Materials contain copyrighted material, trade secrets and other proprietary information of TI and its licensors and are protected by copyright laws, international copyright treaties, and trade secret laws, as well as other intellectual property laws.To protect TI's and its licensors' rights in the Licensed Materials, you agree, except as specifically permitted by statute by a provision that cannot be waived by contract, not to "unlock", decompile, reverse engineer, disassemble or otherwise translate to a human-perceivable form any portions of the Licensed Materials provided to you in object code format only, nor permit any person or entity to do so.You shall not remove, alter, cover, or obscure any confidentiality, trade secret, trade mark, patent, copyright or other proprietary notice or other identifying marks or designs from any component of the Licensed Materials and you shall reproduce and include in all copies of the Licensed Materials, or any derivatives thereof, the copyright notice(s) and proprietary legend(s) of TI and its licensors as they appear in the Licensed Materials.TI reserves all rights not specifically granted under this Agreement.**b. Certain Licensed Materials may be based on industry recognized standards or software programs published by industry recognized standards bodies and certain third parties may claim to own patents, copyrights, and other intellectual property rights that cover implementation of those standards.You acknowledge and agree that this Agreement does not convey a license to any such third party patents, copyrights, and other intellectual property rights and that you are solely responsible for any patent, copyright, or other intellectual property right claim that relates to your use or distribution of the Licensed Materials, or any derivatives thereof,, or your use or distribution of your products that include or incorporate the Licensed Materials, or any derivatives thereof,.Moreover, you acknowledge that you are responsible for any fees or royalties that may be payable to any third party based on such third party's interests in the Licensed Materials or any intellectual property rights that cover implementation of any industry recognized standard, any software program published by any industry recognized standards bodies or any other proprietary technology.**4. Audit Right.At TI's request, and within thirty (30) days after receiving written notice, you shall permit an independent auditor selected by TI to have access, no more than twice each calendar year (unless the immediately preceding audit revealed a discrepancy) and during your regular business hours, to all of your equipment, records, and documents as may contain information bearing upon the use of the Licensed Materials, or any derivatives thereof.You shall keep full, complete, clear and accurate records with respect to product sales and distributions for a period beginning with the then-current calendar year and going back three (3) years.**5. Confidential Information.You acknowledge and agree that the Licensed Materials contain trade secrets and other confidential information of TI its licensors.You agree to use the Licensed Materials, or any derivatives thereof, solely within the scope of the licenses set forth herein, to maintain the Licensed Materials, or any derivatives thereof, in strict confidence, to use at least the same procedures and degree of care that you use to prevent disclosure of your own confidential information of like importance but in no instance less than reasonable care, and to prevent disclosure of the Licensed Materials, or any derivatives thereof, to any third party, except as may be necessary and required in connection with your rights and obligations hereunder.You agree to obtain executed confidentiality agreements with your employees and contractors having access to the Licensed Materials, or any derivatives thereof, and to diligently take steps to enforce such agreements in this respect.TI agrees that industry standard employment agreements used in the normal course of your business shall satisfy the requirements of this section. TI may disclose your contact information to TI's licensors.**6. Warranties and Limitations.THE LICENSED MATERIALS ARE PROVIDED "AS IS".FURTHERMORE, YOU ACKNOWLEDGE AND AGREE THAT THE LICENSED MATERIALS HAVE NOT BEEN TESTED OR CERTIFIED BY ANY GOVERNMENT AGENCY OR INDUSTRY REGULATORY ORGANIZATION OR ANY OTHER THIRD PARTY ORGANIZATION.YOU AGREE THAT PRIOR TO USING, INCORPORATING OR DISTRIBUTING THE LICENSED MATERIALS, OR ANY DERIVATIVES THEREOF, IN OR WITH ANY COMMERCIAL PRODUCT THAT YOU WILL THOROUGHLY TEST THE PRODUCT AND THE FUNCTIONALITY OF THE LICENSED MATERIALS, OR ANY DERIVATIVES THEREOF, IN OR WITH THAT PRODUCT AND BE SOLELY RESPONSIBLE FOR ANY PROBLEMS OR FAILURES.**TI AND ITS LICENSORS MAKE NO WARRANTY OR REPRESENTATION, EITHER EXPRESS, IMPLIED OR STATUTORY, REGARDING THE LICENSED MATERIALS, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT OF ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADE SECRETS OR OTHER INTELLECTUAL PROPERTY RIGHTS.YOU AGREE TO USE YOUR INDEPENDENT JUDGMENT IN DEVELOPING YOUR PRODUCTS.NOTHING CONTAINED IN THIS AGREEMENT WILL BE CONSTRUED AS A WARRANTY OR REPRESENTATION BY TI TO MAINTAIN PRODUCTION OF ANY TI SEMICONDUCTOR DEVICE OR OTHER HARDWARE OR SOFTWARE WITH WHICH THE LICENSED MATERIALS, OR ANY DERIVATIVES THEREOF, MAY BE USED.**IN NO EVENT SHALL TI OR ITS LICENSORS, BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED, ON ANY THEORY OF LIABILITY, IN CONNECTION WITH OR ARISING OUT OF THIS AGREEMENT OR THE USE OF THE LICENSED MATERIALS, OR ANY DERIVATIVES THEREOF, REGARDLESS OF WHETHER TI HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF REMOVAL OR REINSTALLATION, OUTSIDE COMPUTER TIME, LABOR COSTS, LOSS OF DATA, LOSS OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF USE OR INTERRUPTION OF BUSINESS.IN NO EVENT WILL TI'S OR ITS LICENSORS' AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF YOUR USE OF THE LICENSED MATERIALS, OR ANY DERIVATIVES THEREOF, EXCEED THE GREATER OF FIVE HUNDRED U.S. DOLLARS (US$500) OR THE FEES PAID TO TI BY YOU FOR THE LICENSED MATERIALS UNDER THIS AGREEMENT.**Because some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages or limitation on how long an implied warranty lasts, the above limitations or exclusions may not apply to you.**7. Indemnification Disclaimer.YOU ACKNOWLEDGE AND AGREE THAT TI SHALL NOT BE LIABLE FOR AND SHALL NOT DEFEND OR INDEMNIFY YOU AGAINST ANY THIRD PARTY INFRINGEMENT CLAIM THAT RELATES TO OR IS BASED ON YOUR MANUFACTURE, USE, OR DISTRIBUTION OF THE LICENSED MATERIALS, OR ANY DERIVATIVES THEREOF, OR YOUR MANUFACTURE, USE, OFFER FOR SALE, SALE, IMPORTATION OR DISTRIBUTION OF YOUR PRODUCTS THAT INCLUDE OR INCORPORATE THE LICENSED MATERIALS, OR ANY DERIVATIVES THEREOF,.**8. No Technical Support.TI and its licensors are under no obligation to install, maintain or support the Licensed Materials, or any derivatives thereof.**9. Notices.All notices to TI hereunder shall be delivered to Texas Instruments Incorporated, 12500 TI Boulevard, Mail Station 8638, Dallas, Texas 75243, Attention: Contracts Manager, with a copy to Texas Instruments Incorporated, 13588 North Central Expressway, MS 3999, Dallas, TX 75243,Attention: Law Department - ASP.All notices shall be deemed served when received by TI.**10. Export Control.You hereby acknowledge that the Licensed Materials are subject to export control under the U.S. Commerce Department's Export Administration Regulations ("EAR").You further hereby acknowledge and agree that unless prior authorization is obtained from the U.S. Commerce Department, neither you nor your customers will export, re-export, or release, directly or indirectly, any technology, software, or software source code (as defined in Part 772 of the EAR), received from TI, or export, directly or indirectly, any direct product of such technology, software, or software source code (as defined in Part 734 of the EAR), to any destination or country to which the export, re-export, or release of the technology, software, or software source code, or direct product is prohibited by the EAR.You agree that none of the Licensed Materials may be downloaded or otherwise exported or reexported (i) into (or to a national or resident of) Cuba, Iran, North Korea, Sudan and Syria or any other country the U.S. has embargoed goods; or (ii) to anyone on the U.S. Treasury Department's List of Specially Designated Nationals or the U.S. Commerce Department's Denied Persons List or Entity List.You represent and warrant that you are not located in, under the control of, or a national or resident of any such country or on any such list and you will not use or transfer the Licensed Materials, or any derivatives thereof, for use in any sensitive nuclear, chemical or biological weapons, or missile technology end-uses unless authorized by the U.S. Government by regulation or specific license or for a military end-use in, or by any military entity of Albania, Armenia, Azerbaijan, Belarus, Cambodia, China, Georgia, Iraq, Kazakhstan, Kyrgyzstan, Laos, Libya, Macau, Moldova, Mongolia, Russia, Tajikistan, Turkmenistan, Ukraine, Uzbekistan, and Vietnam. Any software export classification made by TI shall be for TI's internal use only and shall not be construed as a representation or warranty regarding the proper export classification for such software or whether an export license or other documentation is required for the exportation of such software.**11. Governing Law and Severability; Waiver.This Agreement will be governed by and interpreted in accordance with the laws of the State of Texas, without reference to conflict of laws principles.If for any reason a court of competent jurisdiction finds any provision of the Agreement to be unenforceable, that provision will be enforced to the maximum extent possible to effectuate the intent of the parties, and the remainder of the Agreement shall continue in full force and effect.This Agreement shall not be governed by the United Nations Convention on Contracts for the International Sale of Goods, or by the Uniform Computer Information Transactions Act (UCITA).The parties agree that non-exclusive jurisdiction for any dispute arising out of or relating to this Agreement lies within the courts located in the State of Texas.Notwithstanding the foregoing, any judgment may be enforced in any United States or foreign court, and either party may seek injunctive relief in any United States or foreign court.Failure by TI to enforce any provision of this Agreement shall not be deemed a waiver of future enforcement of that or any other provision in this Agreement or any other agreement that may be in place between the parties.**12. PRC Provisions.If you are located in the People's Republic of China ("PRC") or if the Licensed Materials, or any derivatives thereof, will be sent to the PRC, the following provisions shall apply and shall supersede any other provisions in this Agreement concerning the same subject matter:**a. Registration Requirements.You shall be solely responsible for performing all acts and obtaining all approvals that may be required in connection with this Agreement by the government of the PRC, including but not limited to registering pursuant to, and otherwise complying with, the PRC Measures on the Administration of Software Products, Management Regulations on Technology Import-Export, and Technology Import and Export Contract Registration Management Rules.Upon receipt of such approvals from the government authorities, you shall forward evidence of all such approvals to TI for its records.In the event that you fail to obtain any such approval or registration, you shall be solely responsible for any and all losses, damages or costs resulting therefrom, and shall indemnify TI for all such losses, damages or costs.**b. Governing Language.This Agreement is written and executed in the English language.If a translation of this Agreement is required for any purpose, including but not limited to registration of the Agreement pursuant to any governmental laws, regulations or rules, you shall be solely responsible for creating such translation.Any translation of this Agreement into a language other than English is intended solely in order to comply with such laws or for reference purposes, and the English language version shall be authoritative and controlling.**c. Export Control.**i. Diversions of Technology.You hereby agree that unless prior authorization is obtained from the U.S. Department of Commerce, neither you nor your subsidiaries or affiliates shall knowingly export, re-export, or release, directly or indirectly, any technology, software, or software source code (as defined in Part 772 of the Export Administration Regulations of the U.S. Department of Commerce ("EAR")), received from TI or any of its affiliated companies, or export, directly or indirectly, any direct product of such technology, software, or software source code (as defined in Part 734 of the EAR), to any destination or country to which the export, re-export, or release of the technology, software, software source code, or direct product is prohibited by the EAR.**ii. Assurance of Compliance.You understand and acknowledge that products, technology (regardless of the form in which it is provided), software or software source code, received from TI or any of its affiliates under this Agreement may be under export control of the United States or other countries.You shall comply with the United States and other applicable non-U.S. laws and regulations governing the export, re-export and release of any products, technology, software, or software source code received under this Agreement from TI or its affiliates.You shall not undertake any action that is prohibited by the EAR.Without limiting the generality of the foregoing, you specifically agree that you shall not transfer or release products, technology, software, or software source code of TI or its affiliates to, or for use by, military end users or for use in military, missile, nuclear, biological, or chemical weapons end uses.**iii.Licenses.Each party shall secure at its own expense, such licenses and export and import documents as are necessary for each respective party to fulfill its obligations under this Agreement.If such licenses or government approvals cannot be obtained, TI may terminate this Agreement, or shall otherwise be excused from the performance of any obligations it may have under this Agreement for which the licenses or government approvals are required.**13. Entire Agreement.This is the entire Agreement between you and TI and this Agreement supersedes any prior agreement between the parties related to the subject matter of this Agreement.Notwithstanding the foregoing, any signed and effective software license agreement relating to the subject matter hereof and stating expressly that such agreement shall control regardless of any subsequent click-wrap, shrink-wrap or web-wrap, shall supersede the terms of this Agreement.No amendment or modification of this Agreement will be effective unless in writing and signed by a duly authorized representative of TI.You hereby warrant and represent that you have obtained all authorizations and other applicable consents required empowering you to enter into this Agreement.** --/COPYRIGHT--*/ #include "BSL430_Command_Interpreter.h" #include "BSL430_Command_Definitions.h" #include "BSL_Device_File.h" #include "BSL430_API.h" #include "BSL430_PI.h"/******************************************************************************* *Change Log: *2.2.09LCWworked on RAM Loader function *-------------------------------------------------------------------------------- *Version 3 work begins *07.08.09 LCWRemoved parameter from mass erase *-------------------------------------------------------------------------------- *Version 4 work begins *23.11.09 LCWChanged to more generic API function calls *-------------------------------------------------------------------------------- *Version 5 work begins *10.03.10 LCW'Off by one' error with sending Data fixed *15.03.10 LCWMisc comment cleanup for source release *-------------------------------------------------------------------------------- *Version 5.1 (no output change, source/comment modified) *15.04.10 LCW Changed receiveDataBlock to remove warning *-------------------------------------------------------------------------------- *Version 6.0 *15.04.10 LCW Made Buffer_Size an unsigned int *-------------------------------------------------------------------------------- *Version 6.1 (no output change, source/comment modified) *28.02.11 LCW Ran Uncrustify *-------------------------------------------------------------------------------- *Version 7.0 *13.04.11 LCW Made read length variables an unsigned int, several others as well *-------------------------------------------------------------------------------- *Version 7.1 *Aug29.13 BEP Added function to clear RAM contents at the start of main *-------------------------------------------------------------------------------- *Version 8 *09/23/13 MGVersion number incremented to track possible P1.0-goes-high bug *in BSL430_Low_Level_Init.s43. No other changes than that. *******************************************************************************/void interpretCommand(); void receiveDataBlock(unsigned long addr, char* data, char fastWrite); void receivePassword(); void eraseLocation(char block_erase, unsigned long addr); void CRC_Check(unsigned long addr, unsigned int length); void sendDataBlock(unsigned long addr, unsigned int length); void sendMessage(char message);extern char* BSL430_ReceiveBuffer; extern char* BSL430_SendBuffer; extern unsigned int BSL430_BufferSize;// DEBUG extern void sendByte(char data);/******************************************************************************* * *Function:main * *Description: Initializes the BSL Command Interpreter and begins listening for *incoming packets *******************************************************************************/ void main(void) {unsigned char eventFlags = 0;volatile int i, ii;BSL430_API_RAM_Clear(); // Moved from BSL430_API_init() into independent functionBSL430_API_init();PI_init();// DEBUGsendByte('M');sendByte('S');sendByte('P');sendByte('4');sendByte('3');sendByte('0');sendByte('B');sendByte('S');sendByte('L');sendByte('\r');sendByte('\n');while (1){eventFlags = PI_receivePacket();if (eventFlags &DATA_RECEIVED){interpretCommand();}} }/******************************************************************************* * *Function:interpretCommand * *Description: Interprets the command contained in the data buffer and *calls the appropriate BSL api function *******************************************************************************/void interpretCommand() {unsigned char command = BSL430_ReceiveBuffer[0];unsigned long addr = BSL430_ReceiveBuffer[1];addr |= ((unsigned long)BSL430_ReceiveBuffer[2]) << 8;addr |= ((unsigned long)BSL430_ReceiveBuffer[3]) << 16;switch (command){ #ifdef SUPPORTS_RX_DATA_BLOCK_FASTcase RX_DATA_BLOCK_FAST:receiveDataBlock(addr, &BSL430_ReceiveBuffer[4], 1);break; #endif/*----------------------------------------------------------------------------*/ #ifdef SUPPORTS_RX_PASSWORDcase RX_PASSWORD:// Receive passwordreceivePassword();break; #endif/*----------------------------------------------------------------------------*/ #ifdef SUPPORTS_LOAD_PCcase LOAD_PC:// Load PCsendMessage(BSL430_callAddress(addr));break; #endif/*----------------------------------------------------------------------------*/ #ifdef SUPPORTS_RX_DATA_BLOCKcase RX_DATA_BLOCK:// Receive data blockreceiveDataBlock(addr, &BSL430_ReceiveBuffer[4], 0);break; #endif/*----------------------------------------------------------------------------*/ #ifdef SUPPORTS_MASS_ERASEcase MASS_ERASE:// Mass Erase//sendMessage(BSL430_massErase());sendMessage(SUCCESSFUL_OPERATION);break; #endif/*----------------------------------------------------------------------------*/ #ifdef SUPPORTS_ERASE_SEGMENTcase ERASE_SEGMENT:// Erase segmenteraseLocation(0, addr);break; #endif/*----------------------------------------------------------------------------*/ #ifdef SUPPORTS_TOGGLE_INFOcase TOGGLE_INFO:// Toggle Info locksendMessage(BSL430_toggleInfoLock());break; #endif/*----------------------------------------------------------------------------*/ #ifdef SUPPORTS_ERASE_BLOCKcase ERASE_BLOCK:// Erase BlockeraseLocation(1, addr);break; #endif/*----------------------------------------------------------------------------*/ #ifdef SUPPORTS_CRC_CHECKcase CRC_CHECK:// CRC Check{unsigned int length;length = BSL430_ReceiveBuffer[4];length |= ((unsigned long)BSL430_ReceiveBuffer[5]) << 8;CRC_Check(addr, length);}break; #endif/*----------------------------------------------------------------------------*/ #ifdef SUPPORTS_TX_DATA_BLOCKcase TX_DATA_BLOCK:// Transmit Data Block{unsigned int length;length = BSL430_ReceiveBuffer[4];length |= BSL430_ReceiveBuffer[5] << 8;sendDataBlock(addr, length);}break; #endif/*----------------------------------------------------------------------------*/ #ifdef SUPPORTS_TX_BSL_VERSIONcase TX_BSL_VERSION:// Transmit BSL Version arraysendDataBlock((unsigned long)(&BSL430_Vendor_Version), 4);break; #endif/*----------------------------------------------------------------------------*/default:// unknown commandsendMessage(UNKNOWN_COMMAND);} }/******************************************************************************* * *Function:receiveDataBlock * *Description: Calls the API to write a data block to a given memory location * *Parameters: *unsigned long addrAddress to which the data should be written *char* dataPointer to an array of data to write *charFastWriteIf 1, do not send a reply message *******************************************************************************/void receiveDataBlock(unsigned long addr, char* data, char fastWrite) { #ifndef RAM_WRITE_ONLY_BSLchar returnValue;returnValue = BSL430_openMemory();if ((returnValue == SUCCESSFUL_OPERATION) & (BSL430_BufferSize > 4)) #endif{ #ifndef RAM_WRITE_ONLY_BSLreturnValue = BSL430_writeMemory(addr, BSL430_BufferSize - 4, data); #elseBSL430_writeMemory(addr, BSL430_BufferSize - 4, data); #endif} #ifndef RAM_WRITE_ONLY_BSLif (!fastWrite){sendMessage(returnValue);}BSL430_closeMemory(); #endif }/******************************************************************************* * *Function:receivePassword * *Description: Calls the API to unlock the BSL *******************************************************************************/void receivePassword() {if (BSL430_unlock_BSL(&BSL430_ReceiveBuffer[1]) == SUCCESSFUL_OPERATION){sendMessage(ACK);}else{sendMessage(BSL_PASSWORD_ERROR);} }/******************************************************************************* * *Function:eraseSegment * *Description: Calls the API to erase a segment containing the given address * *Parameters: *char block_eraseIf 1, the entire block should be erased *unsigned long addrAddress in the segment to be erased. *******************************************************************************/void eraseLocation(char block_erase, unsigned long addr) {sendMessage(BSL430_eraseLocation(block_erase, addr)); }/******************************************************************************* * *Function:CRC_Check * *Description: Calls the API to perform a CRC check over a given addr+length of data * *Parameters: *unsigned long addrStart Addr of CRC *unsigned int lengthnumber of bytes in the CRC *******************************************************************************/void CRC_Check(unsigned long addr, unsigned int length) {int crcResult;int crcStatus;crcStatus = BSL430_crcCheck(addr, length, &crcResult);if (crcStatus == BSL_LOCKED){sendMessage(BSL_LOCKED);}else{BSL430_SendBuffer[0] = BSL_DATA_REPLY;BSL430_SendBuffer[1] = (char)(crcResult & 0xFF);BSL430_SendBuffer[2] = (char)((crcResult >> 8) & 0xFF);PI_sendData(3);} }/******************************************************************************* * *Function:sendDataBlock * *Description: Fills the SendBuffer array with bytes from the given parameters *Sends the data by calling the PI, or sends an error * *Parameters: *unsigned long addrThe address from which to begin reading the block *int lengthThe number of bytes to read *******************************************************************************/void sendDataBlock(unsigned long addr, unsigned int length) {unsigned long endAddr = addr + length;unsigned int bytes;char returnValue = SUCCESSFUL_OPERATION;while ((addr < endAddr) & (returnValue == SUCCESSFUL_OPERATION)){if ((endAddr - addr) > PI_getBufferSize() - 1){bytes = PI_getBufferSize() - 1;}else{bytes = (endAddr - addr);}returnValue = BSL430_readMemory(addr, bytes, &BSL430_SendBuffer[1]);if (returnValue == SUCCESSFUL_OPERATION){BSL430_SendBuffer[0] = BSL_DATA_REPLY;PI_sendData(bytes + 1);}else{sendMessage(returnValue);}addr += bytes;} }/******************************************************************************* * *Function:sendMessage * *Description: Sends a Reply message with attached information * *Parameters: *char messagethe message to send *******************************************************************************/void sendMessage(char message) {BSL430_SendBuffer[0] = BSL_MESSAGE_REPLY;BSL430_SendBuffer[1] = message;PI_sendData(2); }BSL430_Command_Interpreter.hBSL430_Low_Level_Init.asmBSL430_PI.hBSL430_PI_USCIA.c
/* --COPYRIGHT--,TI*MSP430 Tools Source and Object Code Software License Agreement***IMPORTANT PLEASE READ THE FOLLOWING LICENSE AGREEMENT CAREFULLY.THIS IS A LEGALLY BINDING AGREEMENT.AFTER YOU READ THIS LICENSE AGREEMENT, YOU WILL BE ASKED WHETHER YOU ACCEPT AND AGREE TO THE TERMS OF THIS LICENSE AGREEMENT.DO NOT CLICK "I HAVE READ AND AGREE" UNLESS: (1) YOU ARE AUTHORIZED TO ACCEPT AND AGREE TO THE TERMS OF THIS LICENSE AGREEMENT ON BEHALF OF YOURSELF AND YOUR COMPANY; AND (2) YOU INTEND TO ENTER INTO AND TO BE BOUND BY THE TERMS OF THIS LEGALLY BINDING AGREEMENT ON BEHALF OF YOURSELF AND YOUR COMPANY.***Important Read carefully: This MSP430 Tools source and object code software license agreement ("Agreement") is a legal agreement between you (either an individual or entity) and Texas Instruments Incorporated ("TI").The "Licensed Materials" subject to this Agreement include the software programs (in whole or in part) that accompany this Agreement and which you access "on-line" and/or electronic documentation (in whole or in part) associated and provided with these programs, as well as any updates or upgrades to such software programs and documentation, if any, provided to you at TI's sole discretion.The Licensed Materials are specifically designed and licensed for use solely and exclusively with MSP430 microcontroller devices manufactured by or for TI ("TI Devices").By installing, copying or otherwise using the Licensed Materials you agree to abide by the provisions set forth herein.This Agreement is displayed for you to read prior to using the Licensed Materials.If you choose not to accept or agree with these provisions, do not download or install the Licensed Materials.***1. License Grant and Use Restrictions.**a. Licensed Materials License Grant.**i. Limited Source Code License.Subject to the terms of this Agreement, TI hereby grants to you a limited, non-transferable, non-exclusive, non-assignable, non-sublicensable, fully paid-up and royalty-free license to make copies, prepare derivative works, display internally and use internally the Licensed Materials provided to you in source code for the sole purpose of developing object and executable versions of such Licensed Materials, or any derivative thereof, that execute solely and exclusively on TI Devices, for end use in Licensee Products, and maintaining and supporting such Licensed Materials, or any derivative thereof, and Licensee Products.For purposes of this Agreement, "Licensee Product" means a product that consists of both hardware, including one or more TI Devices, and software components, including only executable versions of the Licensed Materials that execute solely and exclusively on such TI Devices and not on devices manufactured by or for an entity other than TI.**ii. Object Code Evaluation, Testing and Use License.Subject to the terms of this Agreement, TI hereby grants to you a limited, non-transferable, non-exclusive, non-assignable, non-sublicensable, fully paid-up and royalty free license under all TI intellectual property embodied in the Licensed Materials provided to you in object code to make copies, display internally, distribute internally and use internally the Licensed Materials provided to you for the sole purposes of evaluating and testing the Licensed Materials and designing and developing Licensee Products, and maintaining and supporting the Licensee Products.**iii. Demonstration License.Subject to the terms of this Agreement, TI hereby grants to you a limited, non-transferable, non-exclusive, non-assignable, non-sublicensable, fully paid-up and royalty free license under all TI intellectual property embodied in the Licensed Materials to demonstrate to third parties the Licensed Materials, or any derivatives thereof, executing solely and exclusively on TI Devices as they are used in Licensee Products, provided that such Licensed Materials, or any derivatives thereof, are demonstrated in object or executable versions only.**iv. Production and Distribution License.Subject to the terms of this Agreement, TI hereby grants to you a non-transferable, non-exclusive, non-assignable, non-sublicensable, fully paid-up and royalty free license under all TI intellectual property embodied in the Licensed Materials to make, use, sell, offer to sell, import, export and otherwise distribute the Licensed Materials, or any derivatives thereof, as part of a Licensee Product, provided that such Licensee Products include only embedded executable copies of such Licensed Materials, or any derivatives thereof, that execute solely and exclusively on TI Devices in such Licensee Products.**b. Contractors and Suppliers.The licenses granted to you hereunder shall include your on-site and off-site suppliers and independent contractors, while such suppliers and independent contractors are performing work for or providing services to you, provided that such suppliers and independent contractors have executed work-for-hire agreements with you containing applicable terms and conditions consistent with the terms and conditions set forth in this Agreement and provided further that you shall be liable to TI for any breach by your suppliers or independent contractors of this Agreement to the same extent as you would be if you had breached the Agreement yourself.**c. Limited License to TI and Covenant not to Sue.Continuing for the term of this Agreement, you hereby grant to TI and TI's licensees of the Licensed Materials, under any of your patents embodied in the Licensed Materials, a non-transferable, non-exclusive, non-assignable, worldwide, fully paid-up, royalty-free license to make, use, sell, offer to sell, import, export and otherwise distribute such Licensed Materials.You covenant not to sue or otherwise assert Derived Patents against TI and TI's affiliates and their licensees of the Licensed Materials.In the event you assign a Derived Patent, you shall require as a condition of any such assignment that the assignee agree to be bound by the provisions in this Section 1(c) with respect to such Derived Patent.Any attempted assignment or transfer in violation of this Section 1(c) shall be null and void.For purposes of this Agreement, "Derived Patents" means any of your patents issuing from a patent application that discloses and claims an invention conceived of by you after delivery of the Licensed Materials, and derived by you from your access to the Licensed Materials.**d. No Other License.Notwithstanding anything to the contrary, nothing in this Agreement shall be construed as a license to any intellectual property rights of TI other than those rights embodied in the Licensed Materials provided to you by TI.EXCEPT AS PROVIDED HEREIN, NO OTHER LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY OTHER TI INTELLECTUAL PROPERTY RIGHTS IS GRANTED HEREIN.**e. Restrictions.You shall maintain the source code versions of the Licensed Materials, or any derivatives thereof, under password control protection and shall not disclose such source code versions of the Licensed Materials, or any derivatives thereof, to any person other than your employees and contractors whose job performance requires access.You shall not use the Licensed Materials, or any derivatives thereof, with a processing device manufactured by or for an entity other than TI, and you agree that any such unauthorized use of the Licensed Materials, or any derivatives thereof, is a material breach of this Agreement.Except as expressly provided in this Agreement, you shall not copy, publish, disclose, display, provide, transfer or make available the Licensed Materials, or any derivatives thereof, to any third party and you shall not sublicense, transfer, or assign the Licensed Materials, or any derivatives thereof, or your rights under this Agreement to any third party.You shall not mortgage, pledge or encumber the Licensed Materials, or any derivatives thereof, in any way.You may use the Licensed Materials, or any derivatives thereof, with Open Source Software or with software developed using Open Source Software tools provided you do not incorporate, combine or distribute the Licensed Materials, or any derivatives thereof, in a manner that subjects the Licensed Materials, or any derivatives thereof, to any license obligations or any other intellectual property related terms of any license governing such Open Source Software."Open Source Software" means any software licensed under terms requiring that (A) other software ("Proprietary Software") incorporated, combined or distributed with such software or developed using such software: (i) be disclosed or distributed in source code form; or (ii) otherwise be licensed on terms inconsistent with the terms of this Agreement, including but not limited to permitting use of the Proprietary Software on or with devices other than TI Devices, or (B) require the owner of Proprietary Software to license any of its patents to users of the Open Source Software and/or Proprietary Software incorporated, combined or distributed with such Open Source Software or developed using such Open Source Software.**f. Termination.This Agreement is effective until terminated.You may terminate this Agreement at any time by written notice to TI.Without prejudice to any other rights, if you fail to comply with the terms of this Agreement, TI may terminate your right to use the Licensed Materials, or any derivatives thereof, upon written notice to you.Upon termination of this Agreement, you will destroy any and all copies of the Licensed Materials, or any derivatives thereof, in your possession, custody or control and provide to TI a written statement signed by your authorized representative certifying such destruction. Except for Sections 1(a) and 1(b) and the limited license to TI in Section 1(c), all provisions of this Agreement shall survive termination of this Agreement.**2. Licensed Materials Ownership.The Licensed Materials are licensed, not sold to you, and can only be used in accordance with the terms of this Agreement.Subject to the licenses granted to you pursuant to this Agreement, TI and its licensors own and shall continue to own all right, title, and interest in and to the Licensed Materials, including all copies thereof.The parties agree that all fixes, modifications and improvements to the Licensed Materials conceived of or made by TI that are based, either in whole or in part, on your feedback, suggestions or recommendations are the exclusive property of TI and all right, title and interest in and to such fixes, modifications or improvements to the Licensed Materials will vest solely in TI.Moreover, you acknowledge and agree that when your independently developed software or hardware components are combined, in whole or in part, with the Licensed Materials, your right to use the combined work that includes the Licensed Materials remains subject to the terms and conditions of this Agreement.**3. Intellectual Property Rights.**a. The Licensed Materials contain copyrighted material, trade secrets and other proprietary information of TI and its licensors and are protected by copyright laws, international copyright treaties, and trade secret laws, as well as other intellectual property laws.To protect TI's and its licensors' rights in the Licensed Materials, you agree, except as specifically permitted by statute by a provision that cannot be waived by contract, not to "unlock", decompile, reverse engineer, disassemble or otherwise translate to a human-perceivable form any portions of the Licensed Materials provided to you in object code format only, nor permit any person or entity to do so.You shall not remove, alter, cover, or obscure any confidentiality, trade secret, trade mark, patent, copyright or other proprietary notice or other identifying marks or designs from any component of the Licensed Materials and you shall reproduce and include in all copies of the Licensed Materials, or any derivatives thereof, the copyright notice(s) and proprietary legend(s) of TI and its licensors as they appear in the Licensed Materials.TI reserves all rights not specifically granted under this Agreement.**b. Certain Licensed Materials may be based on industry recognized standards or software programs published by industry recognized standards bodies and certain third parties may claim to own patents, copyrights, and other intellectual property rights that cover implementation of those standards.You acknowledge and agree that this Agreement does not convey a license to any such third party patents, copyrights, and other intellectual property rights and that you are solely responsible for any patent, copyright, or other intellectual property right claim that relates to your use or distribution of the Licensed Materials, or any derivatives thereof,, or your use or distribution of your products that include or incorporate the Licensed Materials, or any derivatives thereof,.Moreover, you acknowledge that you are responsible for any fees or royalties that may be payable to any third party based on such third party's interests in the Licensed Materials or any intellectual property rights that cover implementation of any industry recognized standard, any software program published by any industry recognized standards bodies or any other proprietary technology.**4. Audit Right.At TI's request, and within thirty (30) days after receiving written notice, you shall permit an independent auditor selected by TI to have access, no more than twice each calendar year (unless the immediately preceding audit revealed a discrepancy) and during your regular business hours, to all of your equipment, records, and documents as may contain information bearing upon the use of the Licensed Materials, or any derivatives thereof.You shall keep full, complete, clear and accurate records with respect to product sales and distributions for a period beginning with the then-current calendar year and going back three (3) years.**5. Confidential Information.You acknowledge and agree that the Licensed Materials contain trade secrets and other confidential information of TI its licensors.You agree to use the Licensed Materials, or any derivatives thereof, solely within the scope of the licenses set forth herein, to maintain the Licensed Materials, or any derivatives thereof, in strict confidence, to use at least the same procedures and degree of care that you use to prevent disclosure of your own confidential information of like importance but in no instance less than reasonable care, and to prevent disclosure of the Licensed Materials, or any derivatives thereof, to any third party, except as may be necessary and required in connection with your rights and obligations hereunder.You agree to obtain executed confidentiality agreements with your employees and contractors having access to the Licensed Materials, or any derivatives thereof, and to diligently take steps to enforce such agreements in this respect.TI agrees that industry standard employment agreements used in the normal course of your business shall satisfy the requirements of this section. TI may disclose your contact information to TI's licensors.**6. Warranties and Limitations.THE LICENSED MATERIALS ARE PROVIDED "AS IS".FURTHERMORE, YOU ACKNOWLEDGE AND AGREE THAT THE LICENSED MATERIALS HAVE NOT BEEN TESTED OR CERTIFIED BY ANY GOVERNMENT AGENCY OR INDUSTRY REGULATORY ORGANIZATION OR ANY OTHER THIRD PARTY ORGANIZATION.YOU AGREE THAT PRIOR TO USING, INCORPORATING OR DISTRIBUTING THE LICENSED MATERIALS, OR ANY DERIVATIVES THEREOF, IN OR WITH ANY COMMERCIAL PRODUCT THAT YOU WILL THOROUGHLY TEST THE PRODUCT AND THE FUNCTIONALITY OF THE LICENSED MATERIALS, OR ANY DERIVATIVES THEREOF, IN OR WITH THAT PRODUCT AND BE SOLELY RESPONSIBLE FOR ANY PROBLEMS OR FAILURES.**TI AND ITS LICENSORS MAKE NO WARRANTY OR REPRESENTATION, EITHER EXPRESS, IMPLIED OR STATUTORY, REGARDING THE LICENSED MATERIALS, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT OF ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADE SECRETS OR OTHER INTELLECTUAL PROPERTY RIGHTS.YOU AGREE TO USE YOUR INDEPENDENT JUDGMENT IN DEVELOPING YOUR PRODUCTS.NOTHING CONTAINED IN THIS AGREEMENT WILL BE CONSTRUED AS A WARRANTY OR REPRESENTATION BY TI TO MAINTAIN PRODUCTION OF ANY TI SEMICONDUCTOR DEVICE OR OTHER HARDWARE OR SOFTWARE WITH WHICH THE LICENSED MATERIALS, OR ANY DERIVATIVES THEREOF, MAY BE USED.**IN NO EVENT SHALL TI OR ITS LICENSORS, BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED, ON ANY THEORY OF LIABILITY, IN CONNECTION WITH OR ARISING OUT OF THIS AGREEMENT OR THE USE OF THE LICENSED MATERIALS, OR ANY DERIVATIVES THEREOF, REGARDLESS OF WHETHER TI HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF REMOVAL OR REINSTALLATION, OUTSIDE COMPUTER TIME, LABOR COSTS, LOSS OF DATA, LOSS OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF USE OR INTERRUPTION OF BUSINESS.IN NO EVENT WILL TI'S OR ITS LICENSORS' AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF YOUR USE OF THE LICENSED MATERIALS, OR ANY DERIVATIVES THEREOF, EXCEED THE GREATER OF FIVE HUNDRED U.S. DOLLARS (US$500) OR THE FEES PAID TO TI BY YOU FOR THE LICENSED MATERIALS UNDER THIS AGREEMENT.**Because some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages or limitation on how long an implied warranty lasts, the above limitations or exclusions may not apply to you.**7. Indemnification Disclaimer.YOU ACKNOWLEDGE AND AGREE THAT TI SHALL NOT BE LIABLE FOR AND SHALL NOT DEFEND OR INDEMNIFY YOU AGAINST ANY THIRD PARTY INFRINGEMENT CLAIM THAT RELATES TO OR IS BASED ON YOUR MANUFACTURE, USE, OR DISTRIBUTION OF THE LICENSED MATERIALS, OR ANY DERIVATIVES THEREOF, OR YOUR MANUFACTURE, USE, OFFER FOR SALE, SALE, IMPORTATION OR DISTRIBUTION OF YOUR PRODUCTS THAT INCLUDE OR INCORPORATE THE LICENSED MATERIALS, OR ANY DERIVATIVES THEREOF,.**8. No Technical Support.TI and its licensors are under no obligation to install, maintain or support the Licensed Materials, or any derivatives thereof.**9. Notices.All notices to TI hereunder shall be delivered to Texas Instruments Incorporated, 12500 TI Boulevard, Mail Station 8638, Dallas, Texas 75243, Attention: Contracts Manager, with a copy to Texas Instruments Incorporated, 13588 North Central Expressway, MS 3999, Dallas, TX 75243,Attention: Law Department - ASP.All notices shall be deemed served when received by TI.**10. Export Control.You hereby acknowledge that the Licensed Materials are subject to export control under the U.S. Commerce Department's Export Administration Regulations ("EAR").You further hereby acknowledge and agree that unless prior authorization is obtained from the U.S. Commerce Department, neither you nor your customers will export, re-export, or release, directly or indirectly, any technology, software, or software source code (as defined in Part 772 of the EAR), received from TI, or export, directly or indirectly, any direct product of such technology, software, or software source code (as defined in Part 734 of the EAR), to any destination or country to which the export, re-export, or release of the technology, software, or software source code, or direct product is prohibited by the EAR.You agree that none of the Licensed Materials may be downloaded or otherwise exported or reexported (i) into (or to a national or resident of) Cuba, Iran, North Korea, Sudan and Syria or any other country the U.S. has embargoed goods; or (ii) to anyone on the U.S. Treasury Department's List of Specially Designated Nationals or the U.S. Commerce Department's Denied Persons List or Entity List.You represent and warrant that you are not located in, under the control of, or a national or resident of any such country or on any such list and you will not use or transfer the Licensed Materials, or any derivatives thereof, for use in any sensitive nuclear, chemical or biological weapons, or missile technology end-uses unless authorized by the U.S. Government by regulation or specific license or for a military end-use in, or by any military entity of Albania, Armenia, Azerbaijan, Belarus, Cambodia, China, Georgia, Iraq, Kazakhstan, Kyrgyzstan, Laos, Libya, Macau, Moldova, Mongolia, Russia, Tajikistan, Turkmenistan, Ukraine, Uzbekistan, and Vietnam. Any software export classification made by TI shall be for TI's internal use only and shall not be construed as a representation or warranty regarding the proper export classification for such software or whether an export license or other documentation is required for the exportation of such software.**11. Governing Law and Severability; Waiver.This Agreement will be governed by and interpreted in accordance with the laws of the State of Texas, without reference to conflict of laws principles.If for any reason a court of competent jurisdiction finds any provision of the Agreement to be unenforceable, that provision will be enforced to the maximum extent possible to effectuate the intent of the parties, and the remainder of the Agreement shall continue in full force and effect.This Agreement shall not be governed by the United Nations Convention on Contracts for the International Sale of Goods, or by the Uniform Computer Information Transactions Act (UCITA).The parties agree that non-exclusive jurisdiction for any dispute arising out of or relating to this Agreement lies within the courts located in the State of Texas.Notwithstanding the foregoing, any judgment may be enforced in any United States or foreign court, and either party may seek injunctive relief in any United States or foreign court.Failure by TI to enforce any provision of this Agreement shall not be deemed a waiver of future enforcement of that or any other provision in this Agreement or any other agreement that may be in place between the parties.**12. PRC Provisions.If you are located in the People's Republic of China ("PRC") or if the Licensed Materials, or any derivatives thereof, will be sent to the PRC, the following provisions shall apply and shall supersede any other provisions in this Agreement concerning the same subject matter:**a. Registration Requirements.You shall be solely responsible for performing all acts and obtaining all approvals that may be required in connection with this Agreement by the government of the PRC, including but not limited to registering pursuant to, and otherwise complying with, the PRC Measures on the Administration of Software Products, Management Regulations on Technology Import-Export, and Technology Import and Export Contract Registration Management Rules.Upon receipt of such approvals from the government authorities, you shall forward evidence of all such approvals to TI for its records.In the event that you fail to obtain any such approval or registration, you shall be solely responsible for any and all losses, damages or costs resulting therefrom, and shall indemnify TI for all such losses, damages or costs.**b. Governing Language.This Agreement is written and executed in the English language.If a translation of this Agreement is required for any purpose, including but not limited to registration of the Agreement pursuant to any governmental laws, regulations or rules, you shall be solely responsible for creating such translation.Any translation of this Agreement into a language other than English is intended solely in order to comply with such laws or for reference purposes, and the English language version shall be authoritative and controlling.**c. Export Control.**i. Diversions of Technology.You hereby agree that unless prior authorization is obtained from the U.S. Department of Commerce, neither you nor your subsidiaries or affiliates shall knowingly export, re-export, or release, directly or indirectly, any technology, software, or software source code (as defined in Part 772 of the Export Administration Regulations of the U.S. Department of Commerce ("EAR")), received from TI or any of its affiliated companies, or export, directly or indirectly, any direct product of such technology, software, or software source code (as defined in Part 734 of the EAR), to any destination or country to which the export, re-export, or release of the technology, software, software source code, or direct product is prohibited by the EAR.**ii. Assurance of Compliance.You understand and acknowledge that products, technology (regardless of the form in which it is provided), software or software source code, received from TI or any of its affiliates under this Agreement may be under export control of the United States or other countries.You shall comply with the United States and other applicable non-U.S. laws and regulations governing the export, re-export and release of any products, technology, software, or software source code received under this Agreement from TI or its affiliates.You shall not undertake any action that is prohibited by the EAR.Without limiting the generality of the foregoing, you specifically agree that you shall not transfer or release products, technology, software, or software source code of TI or its affiliates to, or for use by, military end users or for use in military, missile, nuclear, biological, or chemical weapons end uses.**iii.Licenses.Each party shall secure at its own expense, such licenses and export and import documents as are necessary for each respective party to fulfill its obligations under this Agreement.If such licenses or government approvals cannot be obtained, TI may terminate this Agreement, or shall otherwise be excused from the performance of any obligations it may have under this Agreement for which the licenses or government approvals are required.**13. Entire Agreement.This is the entire Agreement between you and TI and this Agreement supersedes any prior agreement between the parties related to the subject matter of this Agreement.Notwithstanding the foregoing, any signed and effective software license agreement relating to the subject matter hereof and stating expressly that such agreement shall control regardless of any subsequent click-wrap, shrink-wrap or web-wrap, shall supersede the terms of this Agreement.No amendment or modification of this Agreement will be effective unless in writing and signed by a duly authorized representative of TI.You hereby warrant and represent that you have obtained all authorizations and other applicable consents required empowering you to enter into this Agreement.** --/COPYRIGHT--*/ #include "BSL_Device_File.h" #include "BSL430_PI.h" #include "BSL430_Command_Interpreter.h" #include "BSL430_Command_Definitions.h" /******************************************************************************* Change Log: -------------------------------------------------------------------------------- Version 0x523.15.10LCWchanged to DCORSEL_4 -------------------------------------------------------------------------------- Version 0x535.18.10LCWmade buffer size unsized to align with Interface -------------------------------------------------------------------------------- *******************************************************************************/ //errors #define HEADER_INCORRECT (PI_COMMAND_UPPER+0x01) #define CHECKSUM_INCORRECT (PI_COMMAND_UPPER+0x02)#define PACKET_SIZE_ZERO (PI_COMMAND_UPPER+0x03) #define PACKET_SIZE_TOO_BIG (PI_COMMAND_UPPER+0x04) #define UNKNOWN_ERROR (PI_COMMAND_UPPER+0x05) // errors for PI commands #define UNKNOWN_BAUD_RATE (PI_COMMAND_UPPER+0x06)// TA PI Commands #define CHANGE_BAUD_RATE (PI_COMMAND_UPPER + 0x02)// 4800 (unused) #define BAUD_48000x01 #define BAUD_96000x02 #define BAUD_192000x03 #define BAUD_384000x04 #define BAUD_576000x05 #define BAUD_115200 0x06#define MAX_BUFFER_SIZE 260char verifyData( int checksum ); char receiveByte(); void sendByte( char data ); void interpretPI_Command(); void init_USCI( char baud_rate );#pragma NOINIT(BSL430_ReceiveBuffer); char *BSL430_ReceiveBuffer; #pragma NOINIT(BSL430_SendBuffer); char *BSL430_SendBuffer; #pragma NOINIT(BSL430_BufferSize); unsigned int BSL430_BufferSize; #pragma DATA_ALIGN(RAM_Buf, 2); char RAM_Buf[MAX_BUFFER_SIZE];/******************************************************************************* *Function:init *Description: Initialize the USCI and Ports *Parameters:*******************************************************************************/ void PI_init() {volatile int i;BSL430_ReceiveBuffer = RAM_Buf;BSL430_SendBuffer = RAM_Buf;// turn off XT1 and XT2UCSCTL6 |= XT1OFF + XT2OFF;UCSCTL3 |= SELREF_2;// Set DCO FLL reference = REFOUCSCTL4 |= SELA_2;// Set ACLK = REFO__bis_SR_register(SCG0);// Disable the FLL control loopUCSCTL0 = 0x0000;// Set lowest possible DCOx, MODxUCSCTL1 = DCORSEL_5;// Select DCO range 16MHz operationUCSCTL2 = FLLD_1 + 249;// Set DCO Multiplier for 8MHz// (N + 1) * FLLRef = Fdco// (249 + 1) * 32768 = 8MHz// Set FLL Div = fDCOCLK/2__bic_SR_register(SCG0);// Enable the FLL control loop// Worst-case settling time for the DCO when the DCO range bits have been// changed is n x 32 x 32 x f_MCLK / f_FLL_reference. See UCS chapter in 5xx// UG for optimization.// 32 x 32 x 8 MHz / 32,768 Hz = 250000 = MCLK cycles for DCO to settle__delay_cycles(250000);// Loop until XT1,XT2 & DCO fault flag is cleareddo{UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);// Clear XT2,XT1,DCO fault flagsSFRIFG1 &= ~OFIFG;// Clear fault flags}while (SFRIFG1 & OFIFG);// Test oscillator fault flaginit_USCI( BAUD_115200 );}//init/******************************************************************************* *Function:receivePacket *Description: Reads an entire packet, verifies it, and sends it to the core to be interpreted *******************************************************************************/ char PI_receivePacket() {char RX_StatusFlags = RX_PACKET_ONGOING;char dataByte = 0;int dataPointer = 0;volatile int checksum = 0;while( RX_StatusFlags == RX_PACKET_ONGOING ){dataByte = receiveByte();// get another byte from hostif( dataPointer == 0 )// first byte is the size of the Core packet{if ( dataByte != 0x80 )// first byte in packet should be 0x80{sendByte( HEADER_INCORRECT );RX_StatusFlags = RX_ERROR_RECOVERABLE;}else{dataPointer++;}}else if( dataPointer == 1 )// first byte is the size of the Core packet{BSL430_BufferSize = dataByte;dataPointer++;}else if( dataPointer == 2 ){BSL430_BufferSize |= (int)dataByte<<8;if( BSL430_BufferSize == 0 ){sendByte( PACKET_SIZE_ZERO );RX_StatusFlags = RX_ERROR_RECOVERABLE;}if( BSL430_BufferSize > MAX_BUFFER_SIZE )// For future devices that might need smaller packets{sendByte( PACKET_SIZE_TOO_BIG );RX_StatusFlags = RX_ERROR_RECOVERABLE;}dataPointer++;}else if( dataPointer == (BSL430_BufferSize + 3 ) ){// if the pointer is pointing to the Checksum low data byte which resides// after 0x80, rSize, Core Command.checksum = dataByte;dataPointer++;}else if( dataPointer == (BSL430_BufferSize+4) ){// if the pointer is pointing to the Checksum low data byte which resides// after 0x80, rSize, Core Command, CKL.checksum = checksum | dataByte<<8;if( verifyData(checksum) ){if( (RAM_Buf[0] & 0xF0) == PI_COMMAND_UPPER){interpretPI_Command();RX_StatusFlags = RX_PACKET_ONGOING;dataByte = 0;dataPointer = 0;checksum = 0;}else{//sendByte( ACK );RX_StatusFlags = DATA_RECEIVED;}}else{sendByte( CHECKSUM_INCORRECT );RX_StatusFlags = RX_ERROR_RECOVERABLE;}}else{RAM_Buf[dataPointer-3] = dataByte;dataPointer++;}}return RX_StatusFlags; } /******************************************************************************* *Function:sendData *Description: Sends the data in the data buffer *******************************************************************************/ void PI_sendData(int size) {int i;sendByte( 0x80 );sendByte( size & 0xFF );sendByte( size>>8 & 0xFF );CRCINIRES = 0xFFFF;for( i = 0; i < size; i++){CRCDIRB_L = RAM_Buf[i];sendByte( RAM_Buf[i] );}i = CRCINIRES;sendByte( i & 0xFF );sendByte( i>>8 & 0xFF ); }/******************************************************************************* *Function:sendByte *Description: Sends a byte *******************************************************************************/ void sendByte(char data) {while (!(UCA1IFG&UCTXIFG));// USCI_A0 TX buffer ready?UCA1TXBUF = data; } /******************************************************************************* *Function:receiveByte *Description: receives a byte *******************************************************************************/ char receiveByte() {while( !(UCA1IFG & UCRXIFG));// wait for RX flagreturn UCA1RXBUF; } /******************************************************************************* *Function:verifyData *Description: verifies the data in the data buffer against a checksum *Parameters:*int checksumthe checksum to check against *Returns: *1 checksum parameter is correct for data in the data buffer *0 checksum parameter is not correct for the data in the buffer *******************************************************************************/ char verifyData( int checksum ) {int i;CRCINIRES = 0xFFFF;for( i = 0; i < BSL430_BufferSize; i++){CRCDIRB_L = RAM_Buf[i];}return (CRCINIRES == checksum ); }/******************************************************************************* *Function:getBufferSize *Description: Returns the max Data Buffer Size for this PI *Returns:max buffer size *******************************************************************************/ int PI_getBufferSize() {return MAX_BUFFER_SIZE; }/******************************************************************************* *Function:interpretPI_Command *Description: processes a PI command *******************************************************************************/ void interpretPI_Command() {char command = RAM_Buf[0];if( command == CHANGE_BAUD_RATE ){volatile int i;char rate = RAM_Buf[1];if( (rate < BAUD_9600 )||(rate > BAUD_115200) ){sendByte(UNKNOWN_BAUD_RATE);}else{sendByte(ACK);while(UCA0STAT&UCBUSY);init_USCI( rate );}} }/******************************************************************************* *Function:init_USCI *Description: internal code size saving function used by init and change baud rate *******************************************************************************/ void init_USCI( char baud_rate ) {/*UCA0CTL1 |= UCSWRST;// **Put state machine in reset**UCA0CTL0 |= UCPEN+UCPAR;// even parityUCA0CTL1 |= UCSSEL__SMCLK;// SMCLKswitch ( baud_rate ){case BAUD_9600:UCA0BRW = 833 ;// 8MHz 9600 (see User's Guide)UCA0MCTL = UCBRS_2 + UCBRF_0;// Modulationbreak;case BAUD_19200:UCA0BRW = 416;// 8MHz 19200 (see User's Guide)UCA0MCTL = UCBRS_6 + UCBRF_0;// Modulationbreak;case BAUD_38400:UCA0BRW = 208;// 8MHz 38400 (see User's Guide)UCA0MCTL = UCBRS_3 + UCBRF_0;// Modulationbreak;case BAUD_57600:UCA0BRW = 138;// 8MHz 57600 (see User's Guide)UCA0MCTL = UCBRS_7 + UCBRF_0;// Modulationbreak;case BAUD_115200:UCA0BRW = 69;// 8MHz 115200 (see User's Guide)UCA0MCTL = UCBRS_4 + UCBRF_0;// Modulationbreak;}USCI_PORT_SEL = RXD + TXD;// P1.5.6 = USCI_A0 TXD/RXDUCA0CTL1 &= ~UCSWRST;// **Initialize USCI state machine***/UCA1CTL1 |= UCSWRST;// **Put state machine in reset**UCA1CTL0 |= UCPEN+UCPAR;// even parityUCA1CTL1 |= UCSSEL__SMCLK;// SMCLKswitch ( baud_rate ){case BAUD_9600:UCA1BRW = 833 ;// 8MHz 9600 (see User's Guide)UCA1MCTL = UCBRS_2 + UCBRF_0;// Modulationbreak;case BAUD_19200:UCA1BRW = 416;// 8MHz 19200 (see User's Guide)UCA1MCTL = UCBRS_6 + UCBRF_0;// Modulationbreak;case BAUD_38400:UCA1BRW = 208;// 8MHz 38400 (see User's Guide)UCA1MCTL = UCBRS_3 + UCBRF_0;// Modulationbreak;case BAUD_57600:UCA1BRW = 138;// 8MHz 57600 (see User's Guide)UCA1MCTL = UCBRS_7 + UCBRF_0;// Modulationbreak;case BAUD_115200:UCA1BRW = 69;// 8MHz 115200 (see User's Guide)UCA1MCTL = UCBRS_4 + UCBRF_0;// Modulationbreak;}//USCI_PORT_SEL = RXD + TXD;// P1.5.6 = USCI_A0 TXD/RXDP4SEL = BIT4+BIT5;// P3.4,5 = USCI_A0 TXD/RXDUCA1CTL1 &= ~UCSWRST;// **Initialize USCI state machine** }直接用鼠标拖拽文件夹,我这边也是拖拽不了的,只能是文件
,
Ben Qin:
好的,我需要一些时间来查看代码,一旦有结果会立刻回复您。
,
Ben Qin:
你好,抱歉回复晚了。
你是如何将板子和电脑连接的?
,
Andrew Su:
FW_upgrade_5.zip
,
Andrew Su:
附件是工程包压缩文件,请帮忙看看
,
Ben Qin:
好的,我这边会尝试调试一下。
,
Ben Qin:
你好,试过用和文章https://github.com/rafaellcoellho/bsl-msp430作者一样版本的编译器吗?
,
Ben Qin:
你好,该程序是可以成功运行的:
你的配置没有问题。
调试过程中发现该程序只能使用一次,也就是说,只有第一次可以成功。每调试一次需要重新烧录BSL。
,
jing zhang:
比如编了3个版本分别是A,B,C。从A版升级到B版是OK,这时想再从B版升级到C版,就一直升级不了(失败了),这时该如何处理?
,
Ben Qin:
这个程序原作者设计的应该是只能使用一次,也就是说只能升级一次。
你需要根据自己的需要来修改程序。