Main Page | Data Structures | File List | Data Fields | Globals

MSP430.h

Go to the documentation of this file.
00001 /* 00002 * MSP430.h 00003 * 00004 * API for accessing MSP430 devices via JTAG. 00005 * 00006 * Copyright (C) 2004 - 2011 Texas Instruments Incorporated - http://www.ti.com/ 00007 * 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 00013 * Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * 00016 * Redistributions in binary form must reproduce the above copyright 00017 * notice, this list of conditions and the following disclaimer in the 00018 * documentation and/or other materials provided with the 00019 * distribution. 00020 * 00021 * Neither the name of Texas Instruments Incorporated nor the names of 00022 * its contributors may be used to endorse or promote products derived 00023 * from this software without specific prior written permission. 00024 * 00025 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00026 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00027 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00028 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00029 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00030 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00031 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00032 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00033 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00034 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00035 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 */ 00037 00124 #ifndef MSP430_H 00125 #define MSP430_H 00126 00127 #include <stdint.h> 00128 #include <DLL430_SYMBOL.h> 00129 00130 #if defined(_WIN32) || defined(_WIN64) 00131 #include <windows.h> 00132 #include <stddef.h> 00133 #else 00134 #include "wtypes.h" 00135 #endif 00136 00137 #if defined(__cplusplus) 00138 extern "C" { 00139 #endif 00140 00141 #ifndef MSP430_TYPES 00142 #define MSP430_TYPES 00143 00145 typedef LONG STATUS_T; 00146 00150 typedef enum STATUS_CODE { 00151 STATUS_ERROR = -1, 00152 STATUS_OK = 0, 00153 } STATUS_CODE_t; 00154 00158 #pragma pack(1) 00159 typedef union DEVICE_T { 00162 CHAR buffer[112]; 00163 struct { // actually 108 Bytes 00165 WORD endian; 00167 WORD id; 00169 BYTE string[32]; 00171 WORD mainStart; 00173 WORD infoStart; 00175 WORD ramEnd; 00177 WORD nBreakpoints; 00179 WORD emulation; 00181 WORD clockControl; 00183 WORD lcdStart; 00185 WORD lcdEnd; 00187 WORD vccMinOp; 00189 WORD vccMaxOp; 00191 WORD hasTestVpp; 00193 WORD ramStart; 00195 WORD ram2Start; 00197 WORD ram2End; 00199 WORD infoEnd; 00201 ULONG mainEnd; 00203 WORD bslStart; 00205 WORD bslEnd; 00207 WORD nRegTrigger; 00209 WORD nCombinations; 00211 BYTE cpuArch; 00213 BYTE jtagId; 00215 WORD coreIpId; 00217 ULONG deviceIdPtr; 00219 WORD eemVersion; 00221 WORD nBreakpointsOptions; 00222 WORD nBreakpointsReadWrite; 00223 WORD nBreakpointsDma; 00225 WORD TrigerMask; 00227 WORD nRegTriggerOperations; 00229 WORD nStateStorage; 00231 WORD nCycleCounter; 00233 WORD nCycleCounterOperations; 00235 WORD nSequencer; 00237 WORD HasFramMemroy; 00238 }; 00239 } DEVICE_T_t; 00240 #pragma pack() 00241 00242 00244 #define DEVICE_UNKNOWN 0 00245 00246 typedef enum CPU_ARCH_TYPE 00247 { 00248 CPU_ARCH_ORIGINAL, 00249 CPU_ARCH_X, 00250 CPU_ARCH_XV2, 00251 } CPU_ARCH_TYPE_t; 00252 00253 typedef enum READ_WRITE { 00254 WRITE = 0, 00255 READ = 1, 00256 } READ_WRITE_t; 00257 00258 typedef enum ENABLE_DISABLE { 00259 DISABLE = 0, 00260 ENABLE = 1, 00261 } ENABLE_DISABLE_t; 00262 00264 typedef enum RESET_METHOD { 00265 PUC_RESET = (1 << 0), 00266 RST_RESET = (1 << 1), 00267 VCC_RESET = (1 << 2), 00268 FORCE_RESET = (1 << 3), 00269 00271 ALL_RESETS = (PUC_RESET | RST_RESET | VCC_RESET), 00273 FORCE_PUC_RESET = (FORCE_RESET | PUC_RESET), 00276 FORCE_RST_RESET = (FORCE_RESET | RST_RESET), 00279 FORCE_VCC_RESET = (FORCE_RESET | VCC_RESET), 00280 } RESET_METHOD_t; 00281 00282 00284 typedef enum ERASE_TYPE { 00285 ERASE_SEGMENT = 0, 00286 ERASE_MAIN = 1, 00287 ERASE_ALL = 2, 00288 ERASE_TOTAL = 3, 00289 } ERASE_TYPE_t; 00290 00292 typedef enum CONFIG_MODE { 00293 VERIFICATION_MODE = 0, 00294 EMULATION_MODE = 1, 00295 LOCKED_FLASH_ACCESS = 5, 00296 EDT_TRACE_MODE = 7, 00297 INTERFACE_MODE = 8, 00299 00300 00301 00302 SET_MDB_BEFORE_RUN = 9, 00303 00314 RAM_PRESERVE_MODE = 10, 00317 UNLOCK_BSL_MODE =11, 00318 // just used internal for the device code of L092 and C092 00319 DEVICE_CODE = 12, 00320 // set true to write the external SPI image of the L092 00321 WRITE_EXTERNAL_MEMORY = 13, 00322 // set DEBUG_LPM_X true to start debugging of LPMx.5 00323 // this will start polling for LPMX.5 events if a system notify callback was 00324 // previously set using MSP430_SET_SYSTEM_NOTIFY_CALLBACK() 00325 DEBUG_LPM_X = 14, 00326 // Configure JTAG speed 00327 JTAG_SPEED = 15, 00328 // total device erase including IP protection 00329 TOTAL_ERASE_DEVICE = 16 00330 00331 } CONFIG_MODE_t; 00332 00334 typedef enum INTERFACE_TYPE { 00335 JTAG_IF = 0, 00336 SPYBIWIRE_IF = 1, 00337 SPYBIWIREJTAG_IF = 2, 00338 AUTOMATIC_IF = 3 00339 } INTERFACE_TYPE_t; 00340 00341 00343 typedef enum FILE_TYPE { 00344 FILETYPE_AUTO, 00345 FILETYPE_TI_TXT, 00346 FILETYPE_INTEL_HEX, 00347 } FILE_TYPE_t; 00348 00349 #define ERROR_DEFINITIONS \ 00350 ERROR_DEF(NO_ERR, "No error") \ 00351 ERROR_DEF(INITIALIZE_ERR, "Could not initialize device interface") \ 00352 ERROR_DEF(CLOSE_ERR, "Could not close device interface") \ 00353 ERROR_DEF(PARAMETER_ERR, "Invalid parameter(s)") \ 00354 ERROR_DEF(NO_DEVICE_ERR, "Could not find device (or device not supported)") \ 00355 ERROR_DEF(DEVICE_UNKNOWN_ERR, "Unknown device") \ 00356 ERROR_DEF(READ_MEMORY_ERR, "Could not read device memory") \ 00357 ERROR_DEF(WRITE_MEMORY_ERR, "Could not write device memory") \ 00358 ERROR_DEF(READ_FUSES_ERR, "Could not read device configuration fuses") \ 00359 ERROR_DEF(CONFIGURATION_ERR, "Incorrectly configured device; device derivative not supported") \ 00360 ERROR_DEF(VCC_ERR, "Could not set device Vcc") \ 00361 ERROR_DEF(RESET_ERR, "Could not reset device") \ 00362 ERROR_DEF(PRESERVE_RESTORE_ERR, "Could not preserve/restore device memory") \ 00363 ERROR_DEF(FREQUENCY_ERR, "Could not set device operating frequency") \ 00364 ERROR_DEF(ERASE_ERR, "Could not erase device memory") \ 00365 ERROR_DEF(BREAKPOINT_ERR, "Could not set device breakpoint") \ 00366 ERROR_DEF(STEP_ERR, "Could not single step device") \ 00367 ERROR_DEF(RUN_ERR, "Could not run device (to breakpoint)") \ 00368 ERROR_DEF(STATE_ERR, "Could not determine device state") \ 00369 ERROR_DEF(EEM_OPEN_ERR, "Could not open Enhanced Emulation Module") \ 00370 ERROR_DEF(EEM_READ_ERR, "Could not read Enhanced Emulation Module register") \ 00371 ERROR_DEF(EEM_WRITE_ERR, "Could not write Enhanced Emulation Module register") \ 00372 ERROR_DEF(EEM_CLOSE_ERR, "Could not close Enhanced Emulation Module") \ 00373 ERROR_DEF(FILE_OPEN_ERR, "File open error") \ 00374 ERROR_DEF(FILE_DETECT_ERR, "File type could not be identified") \ 00375 ERROR_DEF(FILE_END_ERR, "File end error") \ 00376 ERROR_DEF(FILE_IO_ERR, "File input/output error") \ 00377 ERROR_DEF(FILE_DATA_ERR, "File data error") \ 00378 ERROR_DEF(VERIFY_ERR, "Verification error") \ 00379 ERROR_DEF(BLOW_FUSE_ERR, "Could not blow device security fuse") \ 00380 ERROR_DEF(FUSE_BLOWN_ERR, "Security Fuse has been blown") \ 00381 ERROR_DEF(INTEL_HEX_CODE_ERR, "Error within Intel Hex file") \ 00382 ERROR_DEF(WRITE_REGISTER_ERR, "Could not write device Register") \ 00383 ERROR_DEF(READ_REGISTER_ERR, "Could not read device Register") \ 00384 ERROR_DEF(INTERFACE_SUPPORT_ERR, "Not supported by selected Interface or Interface is not initialized") \ 00385 ERROR_DEF(COMM_ERR, "Interface Communication error") \ 00386 ERROR_DEF(NO_EX_POWER, "No external power supply detected") \ 00387 ERROR_DEF(LOW_EX_POWER, "External power too low") \ 00388 ERROR_DEF(EX_POWER_OK, "External power detected") \ 00389 ERROR_DEF(HIGH_EX_POWER, "External power too high") \ 00390 ERROR_DEF(SELFTEST_ERR, "Hardware Self Test Error") \ 00391 ERROR_DEF(FLASH_TIMEOUT_ERR, "Fast Flash Routine experienced a timeout") \ 00392 ERROR_DEF(THREAD_ERR, "Could not create thread for polling") \ 00393 ERROR_DEF(EEM_INIT_ERR, "Could not initialize Enhanced Emulation Module") \ 00394 ERROR_DEF(RESOURCE_ERR, "Insufficent resources") \ 00395 ERROR_DEF(CLK_CTRL_ERR, "No clock control emulation on connected device") \ 00396 ERROR_DEF(STATE_STOR_ERR, "No state storage buffer implemented on connected device") \ 00397 ERROR_DEF(READ_TRACE_ERR, "Could not read trace buffer") \ 00398 ERROR_DEF(VAR_WATCH_EN_ERR, "Enable the variable watch function") \ 00399 ERROR_DEF(SEQUENCER_ERR, "No trigger sequencer implemented on connected device") \ 00400 ERROR_DEF(SEQ_ENABLE_ERR, "Could not read sequencer state - Sequencer is disabled") \ 00401 ERROR_DEF(CLR_SEQ_TRIGGER, "Could not remove trigger - Used in sequencer") \ 00402 ERROR_DEF(SET_SEQ_TRIGGER, "Could not set combination - Trigger is used in sequencer") \ 00403 ERROR_DEF(SPMA_ACTIVE_ERR, "System Protection Module A is enabled - Device locked") \ 00404 ERROR_DEF(SPMA_INVALID_KEY_ERR, "Invalid SPMA key was passed to the target device - Device locked") \ 00405 ERROR_DEF(SPMA_MAX_TRIALS, "Device does not accept any further SPMA keys - Device locked") \ 00406 ERROR_DEF(USB_FET_BSL_ACTIVE_ERR, "MSP-FET430UIF Firmware erased - Bootloader active") \ 00407 ERROR_DEF(USB_FET_NOT_FOUND_ERR, "Could not find MSP-FET430UIF on specified COM port") \ 00408 ERROR_DEF(USB_FET_BUSY_ERR, "MSP-FET430UIF is already in use") \ 00409 ERROR_DEF(THREAD_ACTIVE_ERR, "EEM polling thread is already active") \ 00410 ERROR_DEF(THREAD_TERMINATE_ERR, "Could not terminate EEM polling thread") \ 00411 ERROR_DEF(UNLOCK_BSL_ERR, "Could not unlock BSL memory segments") \ 00412 ERROR_DEF(BSL_MEMORY_LOCKED_ERR, "Could not perform access, BSL memory segments are protected") \ 00413 ERROR_DEF(FOUND_OTHER_DEVICE, "Another device as selected was found") \ 00414 ERROR_DEF(WRONG_PASSWORD, "Could not enable JTAG wrong password") \ 00415 ERROR_DEF(UPDATE_MULTIPLE_UIF_ERR, "Only one UIF must be connected during update to v3") \ 00416 ERROR_DEF(CDC_UIF_ERR, "CDC-USB-FET-Driver was not installed. Please install the driver") \ 00417 ERROR_DEF(UIF_MANUAL_POWERCYCLE_NEEDED, "Manual reboot of USB-FET needed ! PLEASE unplug and reconnect your USB-FET!!") \ 00418 ERROR_DEF(INTERNAL_ERR, "Internal error") \ 00419 ERROR_DEF(INVALID_ERR, "Invalid error number") 00420 00422 #define ERROR_DEF(errorEnum, errorString) errorEnum, 00423 typedef enum ERROR_CODE { ERROR_DEFINITIONS } ERROR_CODE_t; 00424 #undef ERROR_DEF 00425 00426 // System events 00427 typedef enum SYSTEM_EVENT_MSP 00428 { 00430 FET_CONNECTION_LOST, 00432 DEVICE_CONNECTION_LOST, 00434 FET_RESTART_NEEDED, 00436 DEVICE_IN_LPM5_MODE, 00438 DEVICE_WAKEUP_LPM5_MODE, 00439 } SYSTEM_EVENT_MSP_t; 00440 00441 typedef void (* SYSTEM_NOTIFY_CALLBACK) (SYSTEM_EVENT_MSP_t MySystemEvent); 00442 00443 #endif /* MSP430_TYPES */ 00444 00445 // Functions. ----------------------------------------------------------------- 00462 STATUS_T WINAPI MSP430_SET_SYSTEM_NOTIFY_CALLBACK(SYSTEM_NOTIFY_CALLBACK parSystemNotifyCallback); 00463 00464 00513 DLL430_SYMBOL STATUS_T WINAPI MSP430_Initialize(CHAR* port, LONG* version); 00514 00531 DLL430_SYMBOL STATUS_T WINAPI MSP430_Close(LONG vccOff); 00532 00533 00548 DLL430_SYMBOL STATUS_T WINAPI MSP430_GetJtagID(LONG* JtagId); 00549 00567 STATUS_T WINAPI MSP430_GetFoundDevice(CHAR* FoundDevice, LONG count); 00568 00602 STATUS_T WINAPI MSP430_OpenDevice(CHAR* Device,CHAR* Password, LONG PwLength,LONG DeviceCode, LONG setId); 00603 00604 00623 DLL430_SYMBOL STATUS_T WINAPI MSP430_Device(LONG localDeviceId, CHAR* buffer, LONG count); 00624 00673 DLL430_SYMBOL STATUS_T WINAPI MSP430_Configure(LONG mode, LONG value); 00674 00698 DLL430_SYMBOL STATUS_T WINAPI MSP430_VCC(LONG voltage); 00699 00700 00718 DLL430_SYMBOL STATUS_T WINAPI MSP430_GetCurVCCT(LONG* voltage); 00719 00744 DLL430_SYMBOL STATUS_T WINAPI MSP430_GetExtVoltage(LONG* voltage, LONG* state); 00745 00746 00777 DLL430_SYMBOL STATUS_T WINAPI MSP430_Reset(LONG method, LONG execute, LONG releaseJTAG); 00778 00818 DLL430_SYMBOL STATUS_T WINAPI MSP430_Erase(LONG type, LONG address, LONG length); 00819 00849 DLL430_SYMBOL STATUS_T WINAPI MSP430_Memory(LONG address, CHAR* buffer, LONG count, LONG rw); 00850 00851 #define MSP430_Read_Memory(ADDRESS, BUFFER, COUNT) MSP430_Memory(ADDRESS, BUFFER, COUNT, READ) 00852 #define MSP430_Write_Memory(ADDRESS, BUFFER, COUNT) MSP430_Memory(ADDRESS, BUFFER, COUNT, WRITE) 00853 00874 DLL430_SYMBOL STATUS_T WINAPI MSP430_Secure(void); 00875 00899 #if ! defined(uController) 00900 DLL430_SYMBOL STATUS_T WINAPI MSP430_ReadOutFile(LONG wStart, LONG wLength, CHAR* lpszFileName, LONG iFileType); 00901 #endif 00902 00944 #if ! defined(uController) 00945 DLL430_SYMBOL STATUS_T WINAPI MSP430_ProgramFile(CHAR* File, LONG eraseType, LONG verifyMem); 00946 #endif 00947 00975 #if ! defined(uController) 00976 DLL430_SYMBOL STATUS_T WINAPI MSP430_VerifyFile(CHAR* File); 00977 #endif 00978 01001 DLL430_SYMBOL STATUS_T WINAPI MSP430_VerifyMem(LONG StartAddr, LONG Length, CHAR* DataArray); 01002 01024 DLL430_SYMBOL STATUS_T WINAPI MSP430_EraseCheck(LONG StartAddr, LONG Length); 01025 01036 DLL430_SYMBOL LONG WINAPI MSP430_Error_Number(void); 01037 01048 #if ! defined(uController) 01049 DLL430_SYMBOL const CHAR* WINAPI MSP430_Error_String(LONG errorNumber); 01050 #endif 01051 01066 #if ! defined(uController) 01067 DLL430_SYMBOL STATUS_T WINAPI MSP430_GetNumberOfUsbIfs(LONG* Number); 01068 #endif 01069 01096 #if ! defined(uController) 01097 DLL430_SYMBOL STATUS_T WINAPI MSP430_GetNameOfUsbIf(LONG Idx, CHAR** Name, LONG* Status); 01098 #endif 01099 01100 #if defined(__cplusplus) 01101 } 01102 #endif 01103 01104 #endif // MSP430_H